Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
94ae17e
rubocop -A auto-corrections
Esity Mar 13, 2026
3c555be
update rspec for end-to-end coverage of legion-json
Esity Mar 13, 2026
42e0f45
rubocop -A auto-corrections and config updates
Esity Mar 13, 2026
3236f6d
reindex documentation to reflect current codebase
Esity Mar 13, 2026
4c7cdbe
resolve rubocop offenses with auto-correct
Esity Mar 13, 2026
2ad231b
switch to org-level reusable ci workflow
Esity Mar 13, 2026
9928cc0
reindex documentation to reflect current codebase state
Esity Mar 14, 2026
8b90c2b
trigger ci with updated shared workflow
Esity Mar 15, 2026
357162b
add release job to ci workflow
Esity Mar 15, 2026
10a8470
reindex documentation to reflect current codebase state
Esity Mar 19, 2026
bd19296
add Legion::JSON::Helper mixin for LEX extensions (v1.2.1)
Esity Mar 23, 2026
e2faf1e
add repo governance files (CODEOWNERS, dependabot, CI)
Esity Mar 25, 2026
b4a8a16
add parse, generate, pretty_generate, fast_generate methods (#2)
Esity Mar 26, 2026
4f34111
avoid api-json-dump-kwargs lint false positive in helper (#2)
Esity Mar 26, 2026
d7819a2
apply copilot review suggestions (#2)
Esity Mar 26, 2026
b20d830
Merge pull request #3 from LegionIO/feature/issue-2
Esity Mar 26, 2026
51fbcee
accept **kwargs in dump for ergonomic keyword serialization
Esity Mar 27, 2026
683648d
update project documentation
Esity Mar 29, 2026
af003e4
clean up dev dependencies: add rubocop-legion
Esity Mar 31, 2026
a15333b
add logging helper and structured exception handling to json parse/load
Esity Apr 8, 2026
6891262
fix broken require of legion-logging and restore simplecov coverage
Esity Apr 8, 2026
a00b2a4
apply copilot review suggestions (#5)
Esity Apr 8, 2026
94422b1
Merge pull request #5 from LegionIO/add-logging-helper-exception-hand…
Esity Apr 8, 2026
ef9d258
fix: dump with pretty: false produces compact output when Oj adapter …
Esity Apr 14, 2026
52ea3fa
Merge pull request #6 from LegionIO/fix/dump-pretty-false-oj
Esity Apr 14, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Auto-generated from team-config.yml
# Team: core
#
# To apply: scripts/apply-codeowners.sh legion-json

* @LegionIO/maintainers
* @LegionIO/core
18 changes: 18 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: 2
updates:
- package-ecosystem: bundler
directory: /
schedule:
interval: weekly
day: monday
open-pull-requests-limit: 5
labels:
- "type:dependencies"
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
day: monday
open-pull-requests-limit: 5
labels:
- "type:dependencies"
34 changes: 34 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: CI
on:
push:
branches: [main]
pull_request:
schedule:
- cron: '0 9 * * 1'

jobs:
ci:
uses: LegionIO/.github/.github/workflows/ci.yml@main

lint:
uses: LegionIO/.github/.github/workflows/lint-patterns.yml@main

security:
uses: LegionIO/.github/.github/workflows/security-scan.yml@main

version-changelog:
uses: LegionIO/.github/.github/workflows/version-changelog.yml@main

dependency-review:
uses: LegionIO/.github/.github/workflows/dependency-review.yml@main

stale:
if: github.event_name == 'schedule'
uses: LegionIO/.github/.github/workflows/stale.yml@main

release:
needs: [ci, lint]
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: LegionIO/.github/.github/workflows/release.yml@main
secrets:
rubygems-api-key: ${{ secrets.RUBYGEMS_API_KEY }}
50 changes: 0 additions & 50 deletions .github/workflows/rubocop-analysis.yml

This file was deleted.

20 changes: 0 additions & 20 deletions .github/workflows/sourcehawk-scan.yml

This file was deleted.

55 changes: 42 additions & 13 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,51 @@
AllCops:
TargetRubyVersion: 3.4
NewCops: enable
SuggestExtensions: false

Layout/LineLength:
Max: 120
Exclude:
- '*.gemspec'
Max: 160

Layout/SpaceAroundEqualsInParameterDefault:
EnforcedStyle: space

Layout/HashAlignment:
EnforcedHashRocketStyle: table
EnforcedColonStyle: table

Metrics/MethodLength:
Max: 30
Max: 50

Metrics/ClassLength:
Max: 1500

Metrics/ModuleLength:
Max: 1500

Metrics/BlockLength:
Max: 50
Style/OptionalBooleanParameter:
Enabled: false
Max: 40
AllowedPatterns: ['describe', 'context', 'it', 'shared_examples']
Exclude:
- 'spec/**/*'

Metrics/AbcSize:
Max: 60

Metrics/CyclomaticComplexity:
Max: 15

Metrics/PerceivedComplexity:
Max: 17

Style/Documentation:
Enabled: false
AllCops:
TargetRubyVersion: 2.5
NewCops: enable
SuggestExtensions: false

Style/SymbolArray:
Enabled: true

Style/FrozenStringLiteralComment:
Enabled: true
EnforcedStyle: always

Naming/FileName:
Enabled: false
Gemspec/RequiredRubyVersion:
Enabled: false
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.4.8
33 changes: 32 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,35 @@
# Legion::JSON

## [1.3.3] - 2026-04-14

### Fixed
- `Legion::JSON.dump` with `pretty: false` (the default) produced pretty-printed output when Oj adapter was active. Oj/MultiJson treats any explicit `pretty:` keyword (even `false`) as truthy. Fix: only pass `pretty: true` when requested; omit the keyword entirely otherwise.

## [1.3.2] - 2026-04-08

### Fixed
- Removed `require 'legion/logging'` and `Legion::Logging::Helper` dependency that broke standalone usage (legion-logging is not a gemspec dependency)
- Fixed SimpleCov profile not being activated in spec_helper, restoring 100% coverage enforcement

## [1.3.1] - 2026-03-27

### Changed
- `.dump` now accepts `**kwargs` — callers can pass `Legion::JSON.dump(key: val)` without wrapping in `{}`
- `pretty:` keyword option preserved; all other kwargs become the serialized object

## [1.3.0] - 2026-03-26

### Added
- `.parse(string, symbolize_names: true)` — wraps `::JSON.parse` with `ParseError` error handling and symbol keys by default
- `.generate(object)` — wraps `::JSON.generate` for compact output
- `.pretty_generate(object)` — wraps `::JSON.pretty_generate` for formatted output
- `.fast_generate(object)` — wraps `::JSON.fast_generate` for unchecked fast output
- Helper methods: `json_parse`, `json_generate`, `json_pretty_generate` in `Legion::JSON::Helper`

## [1.2.1] - 2026-03-22

### Added
- `Legion::JSON::Helper` mixin module with `json_load` and `json_dump` convenience methods for LEX extensions

## v1.2.0
Moving from BitBucket to GitHub inside the Optum org. All git history is reset from this point on
Moving from BitBucket to GitHub. All git history is reset from this point on
72 changes: 72 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# legion-json: JSON Wrapper for LegionIO

**Repository Level 3 Documentation**
- **Parent**: `/Users/miverso2/rubymine/legion/CLAUDE.md`

## Purpose

JSON wrapper module for the LegionIO framework. Wraps `multi_json` and `json_pure` to provide a consistent JSON interface across all Legion gems and extensions. Automatically uses faster C-extension JSON gems (like `oj`) when available.

**GitHub**: https://github.com/LegionIO/legion-json
**Version**: 1.3.2
**License**: Apache-2.0

## Architecture

```
Legion::JSON
├── .load(string, symbolize_keys: true) # Deserialize JSON -> Hash (via MultiJson)
├── .dump(object = nil, pretty: false, **kwargs) # Serialize Hash -> JSON (via MultiJson); nil object uses kwargs
├── .parse(string, symbolize_names: true) # ::JSON.parse with symbolize_names (stdlib)
├── .generate(object) # ::JSON.generate (stdlib)
├── .pretty_generate(object) # ::JSON.pretty_generate (stdlib)
├── .fast_generate(object) # ::JSON.fast_generate (stdlib)
├── InvalidJson # Custom error class
└── ParseError # JSON parse error class
```

### Key Design Patterns

- **Dual API**: `.load`/`.dump` route through MultiJson (adapter abstraction). `.parse`/`.generate`/`.pretty_generate`/`.fast_generate` route through Ruby stdlib `::JSON` directly.
- **Symbolized Keys by Default**: `symbolize_keys: true` is the default for `.load`; `symbolize_names: true` for `.parse`
- **Auto C-Extension**: If `oj` gem is installed, `multi_json` automatically uses it for performance
- **Keyword Form for dump**: `.dump(pretty: true, foo: 'bar')` — when `object` is nil, `**kwargs` become the data
- **Namespace note**: Inside `module Legion`, bare `JSON` resolves to `Legion::JSON`. Use `::JSON` to access stdlib.

## Dependencies

| Gem | Purpose |
|-----|---------|
| `multi_json` | JSON adapter abstraction |
| `json_pure` | Pure-Ruby JSON fallback |

## File Map

| Path | Purpose |
|------|---------|
| `lib/legion/json.rb` | Module entry with `load`/`dump` methods |
| `lib/legion/json/invalid_json.rb` | InvalidJson error class |
| `lib/legion/json/parse_error.rb` | ParseError class |
| `lib/legion/json/version.rb` | VERSION constant |

## Role in LegionIO

**Foundation gem** - used by nearly every other Legion gem. `legion-settings` depends on it directly for config file parsing. All message serialization flows through this module.

Note: Inside the `Legion::` namespace, `JSON` refers to `Legion::JSON` — callers outside this gem must use `::JSON` to access the stdlib.

```
legion-json
^
|-- legion-settings
| ^
| |-- legion-cache
| |-- legion-data
| |-- legion-transport
| └-- LegionIO
└-- legion-transport (direct dependency)
```

---

**Maintained By**: Matthew Iverson (@Esity)
75 changes: 0 additions & 75 deletions CODE_OF_CONDUCT.md

This file was deleted.

Loading
Loading