yaml_exporter 0.1.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 11669d9671c43a7dced493565d65af864c3e0b61ba583c40b678f547dc952796
4
- data.tar.gz: 2f235b07235119bffc293e3030bbeaedfb8f4eca263ef921d0076a83bf658e0c
3
+ metadata.gz: 6c15fc079f4444a43a53ea849f8ff86162074ace88cc884ed28bef127a59afc0
4
+ data.tar.gz: 6b51f04b4712e71f1840c61fb323be7127b133e561afaaafcd81f9e382f7919b
5
5
  SHA512:
6
- metadata.gz: 29676b99c64faa28c7e70fddd67fb1376fe9d0ff1bf1657318197367021313164048eb8e75d8ff7e6cbb90b0eba48bbc71ee7aa3fe8ab32bc23e431adc6a8d0b
7
- data.tar.gz: 618c63aa98999137b72d3dfc030cb9d861f29a60c333671d58fa21e71974ced9041dd10a6d2c49176669c627d9edca92a19965743945682225e807bffe8f41ef
6
+ metadata.gz: 4beae00561aeb8d7da659b6b3b578cb9e9aa95bfcd2d266a63bc9fb0e98a6a6f1310cd73801edc03125fb3c831b6a730458165b56549067a0b5a5eb276a114a8
7
+ data.tar.gz: 19dfc281188c17041c1d822422b1eb07f11aea06525ba042b261f016945e664ae40ac272e10246f280fbe5c70d1b0f3633a809ec4cb9ea4363eb6563ddf2dc8e
@@ -1,36 +1,27 @@
1
- name: Ruby Gem
1
+ name: Push gem
2
2
 
3
+ # Publishes to RubyGems when you publish a GitHub Release (tag `vX.Y.Z`).
4
+ # Uses RubyGems Trusted Publishing (OIDC) — no API key stored as a secret.
5
+ # One-time setup: on rubygems.org -> the gem -> Trusted Publishers -> add a
6
+ # GitHub Actions publisher for this repo with workflow `gem-push.yml`.
7
+ # See RELEASING.md.
3
8
  on:
4
- push:
5
- branches: [ "main" ]
6
- pull_request:
7
- branches: [ "main" ]
9
+ release:
10
+ types: [published]
8
11
 
9
12
  jobs:
10
- build:
11
- name: Build + Publish
13
+ push:
12
14
  runs-on: ubuntu-latest
13
15
  permissions:
14
- contents: read
15
- packages: write
16
-
16
+ contents: write # let the action attach a build-provenance attestation to the release
17
+ id-token: write # required for Trusted Publishing (OIDC)
17
18
  steps:
18
- - uses: actions/checkout@v4
19
- - name: Set up Ruby 3.3.x
20
- # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
21
- # change this to (see https://github.com/ruby/setup-ruby#versioning):
22
- # uses: ruby/setup-ruby@v1
23
- uses: ruby/setup-ruby@v1
24
- with:
25
- ruby-version: 3.3.4
26
-
27
- - name: Publish to RubyGems
28
- run: |
29
- mkdir -p $HOME/.gem
30
- touch $HOME/.gem/credentials
31
- chmod 0600 $HOME/.gem/credentials
32
- printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
33
- gem build *.gemspec
34
- gem push *.gem
35
- env:
36
- GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
19
+ - uses: actions/checkout@v4
20
+ - uses: ruby/setup-ruby@v1
21
+ with:
22
+ ruby-version: '3.4'
23
+ bundler-cache: true
24
+ - run: bundle exec rake test
25
+ # Verifies the tag matches lib/yaml_exporter/version.rb, builds, attests,
26
+ # and pushes via trusted publishing.
27
+ - uses: rubygems/release-gem@v1
@@ -0,0 +1,27 @@
1
+ name: Test
2
+
3
+ on:
4
+ push:
5
+ branches: [main, find_by]
6
+ # No branch filter — run on every PR, including ones targeting `find_by`,
7
+ # so a change is tested before it is merged onto its base branch.
8
+ pull_request:
9
+
10
+ jobs:
11
+ test:
12
+ runs-on: ubuntu-latest
13
+ name: Ruby ${{ matrix.ruby }}
14
+ strategy:
15
+ fail-fast: false
16
+ matrix:
17
+ ruby: ['3.2', '3.3', '3.4', '4.0']
18
+
19
+ steps:
20
+ - uses: actions/checkout@v4
21
+ # Resolve a fresh lockfile so each Ruby gets a compatible dependency set.
22
+ - run: rm -f Gemfile.lock
23
+ - uses: ruby/setup-ruby@v1
24
+ with:
25
+ ruby-version: ${{ matrix.ruby }}
26
+ bundler-cache: true
27
+ - run: bundle exec rake test
data/AGENTS.md ADDED
@@ -0,0 +1,34 @@
1
+ # AGENTS.md
2
+
3
+ ## Cursor Cloud specific instructions
4
+
5
+ ### Project overview
6
+
7
+ `yaml_exporter` is a Ruby gem that provides YAML serialization/deserialization for ActiveRecord models with JSON schema generation. It is a library (not a runnable application) — there are no servers, databases, or background services to run.
8
+
9
+ ### Ruby version management
10
+
11
+ Ruby is managed via **rbenv** (installed at `~/.rbenv`). The project targets the latest stable Ruby — currently **4.0.2**.
12
+
13
+ If a future Ruby version is needed and `rbenv install <version>` fails with "definition not found", update ruby-build first:
14
+
15
+ ```bash
16
+ cd ~/.rbenv/plugins/ruby-build && git pull
17
+ rbenv install <version>
18
+ rbenv global <version>
19
+ ```
20
+
21
+ Then re-run `bundle install` in the workspace.
22
+
23
+ ### Key commands
24
+
25
+ | Task | Command |
26
+ | -------------------- | ----------------------------------------------------------- |
27
+ | Install dependencies | `bundle install` |
28
+ | Build the gem | `gem build yaml_exporter.gemspec` |
29
+ | Verify the gem loads | `ruby -e 'require_relative "lib/yaml_exporter"; puts "OK"'` |
30
+
31
+ ### Notes
32
+
33
+ - The gem depends on `activerecord`, `activesupport`, and `json-schema` at runtime. For manual testing, `sqlite3` is also needed (`gem install sqlite3`).
34
+ - The gemspec uses `git ls-files` to determine included files — new files must be tracked by git to be included in builds.
data/CHANGELOG.md ADDED
@@ -0,0 +1,56 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented here.
4
+ This project follows [semantic versioning](https://semver.org).
5
+
6
+ ## Unreleased
7
+
8
+ ## v0.2.1
9
+
10
+ ### Added
11
+
12
+ - `of:` on `many` reference lists. Both `many :assoc, find_by: :col, of: :nested`
13
+ and the `through:` flavor `many :assoc, through: :join, find_by: :col, of: :nested`
14
+ now identify each target indirectly via a 1:[0,1] association on the target
15
+ (`of:`), mirroring the existing `one … find_by: of:` semantics. The YAML stays
16
+ a flat list of the related model's `find_by` values (e.g. user slugs) instead
17
+ of requiring a nested block of hashes.
18
+
19
+ ## v0.2.0
20
+
21
+ A ground-up rewrite of the export/import engine and its DSL. **Breaking: nothing
22
+ from 0.1.0 carries over** — the module, the entry points, and the mapping API are
23
+ all new. See the README for the full DSL.
24
+
25
+ ### Changed (breaking)
26
+
27
+ - **New mixin API.** `include YamlExporter` in the model and declare the mapping
28
+ in a `yaml_structure do … end` block; round-trip with the instance methods
29
+ `#yaml_export` / `#yaml_import`. This replaces 0.1.0's
30
+ `YamlSerializable::YamlExporter.export(object, structure)` / `.import` class
31
+ methods that took an externally built structure — the `YamlSerializable`
32
+ module no longer exists.
33
+ - **Ownership-driven DSL.** The mapping is three methods — `attributes`, `one`,
34
+ `many` — where shape decides ownership: a **block** owns the record
35
+ (YamlExporter creates, updates, and destroys records to match the YAML), while
36
+ **`find_by:` without a block** only resolves a reference and never creates or
37
+ destroys the target.
38
+
39
+ ### Added
40
+
41
+ - `one` associations in three forms: owned (`one :x do … end`), a plain
42
+ reference (`one :x, find_by:`), and `one_reference_of` to reach a relation's
43
+ single record.
44
+ - `many` associations: owned lists, `find_by:` reference lists, positional
45
+ lists, `positioned_by:` ordering, and `many … through:` (with or without a
46
+ block).
47
+ - Export omits `nil` attributes by default (`yaml_export(omit_nil:)`).
48
+ - Text columns export as YAML multiline block scalars, with surrounding
49
+ whitespace stripped and emojis preserved.
50
+ - Column-based type inference and a JSON-schema-style description of a structure
51
+ via `.yaml_schema`.
52
+
53
+ ### Docs
54
+
55
+ - Rewritten README covering the mental model (cardinality × ownership) and every
56
+ DSL form.
data/Gemfile.lock ADDED
@@ -0,0 +1,106 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ yaml_exporter (0.2.1)
5
+ activerecord (>= 5.2)
6
+ activesupport (>= 5.2)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ activemodel (8.1.3)
12
+ activesupport (= 8.1.3)
13
+ activerecord (8.1.3)
14
+ activemodel (= 8.1.3)
15
+ activesupport (= 8.1.3)
16
+ timeout (>= 0.4.0)
17
+ activesupport (8.1.3)
18
+ base64
19
+ bigdecimal
20
+ concurrent-ruby (~> 1.0, >= 1.3.1)
21
+ connection_pool (>= 2.2.5)
22
+ drb
23
+ i18n (>= 1.6, < 2)
24
+ json
25
+ logger (>= 1.4.2)
26
+ minitest (>= 5.1)
27
+ securerandom (>= 0.3)
28
+ tzinfo (~> 2.0, >= 2.0.5)
29
+ uri (>= 0.13.1)
30
+ base64 (0.3.0)
31
+ bigdecimal (4.1.2)
32
+ concurrent-ruby (1.3.7)
33
+ connection_pool (3.0.2)
34
+ drb (2.2.3)
35
+ i18n (1.15.2)
36
+ concurrent-ruby (~> 1.0)
37
+ json (2.21.1)
38
+ logger (1.7.0)
39
+ minitest (5.27.0)
40
+ rake (13.4.2)
41
+ securerandom (0.4.1)
42
+ sqlite3 (2.9.5-aarch64-linux-gnu)
43
+ sqlite3 (2.9.5-aarch64-linux-musl)
44
+ sqlite3 (2.9.5-arm-linux-gnu)
45
+ sqlite3 (2.9.5-arm-linux-musl)
46
+ sqlite3 (2.9.5-arm64-darwin)
47
+ sqlite3 (2.9.5-x86-linux-gnu)
48
+ sqlite3 (2.9.5-x86-linux-musl)
49
+ sqlite3 (2.9.5-x86_64-darwin)
50
+ sqlite3 (2.9.5-x86_64-linux-gnu)
51
+ sqlite3 (2.9.5-x86_64-linux-musl)
52
+ timeout (0.6.1)
53
+ tzinfo (2.0.6)
54
+ concurrent-ruby (~> 1.0)
55
+ uri (1.1.1)
56
+
57
+ PLATFORMS
58
+ aarch64-linux-gnu
59
+ aarch64-linux-musl
60
+ arm-linux-gnu
61
+ arm-linux-musl
62
+ arm64-darwin
63
+ x86-linux-gnu
64
+ x86-linux-musl
65
+ x86_64-darwin
66
+ x86_64-linux-gnu
67
+ x86_64-linux-musl
68
+
69
+ DEPENDENCIES
70
+ minitest (~> 5.0)
71
+ rake (~> 13.0)
72
+ sqlite3 (>= 1.4)
73
+ yaml_exporter!
74
+
75
+ CHECKSUMS
76
+ activemodel (8.1.3) sha256=90c05cbe4cef3649b8f79f13016191ea94c4525ce4a5c0fb7ef909c4b91c8219
77
+ activerecord (8.1.3) sha256=8003be7b2466ba0a2a670e603eeb0a61dd66058fccecfc49901e775260ac70ab
78
+ activesupport (8.1.3) sha256=21a5e0dfbd4c3ddd9e1317ec6a4d782fa226e7867dc70b0743acda81a1dca20e
79
+ base64 (0.3.0) sha256=27337aeabad6ffae05c265c450490628ef3ebd4b67be58257393227588f5a97b
80
+ bigdecimal (4.1.2) sha256=53d217666027eab4280346fba98e7d5b66baaae1b9c3c1c0ffe89d48188a3fbd
81
+ concurrent-ruby (1.3.7) sha256=4412caec3a5ea2e5fdc52076724c071a81f2c0593d83b2ac8cbb8ca63b3151b0
82
+ connection_pool (3.0.2) sha256=33fff5ba71a12d2aa26cb72b1db8bba2a1a01823559fb01d29eb74c286e62e0a
83
+ drb (2.2.3) sha256=0b00d6fdb50995fe4a45dea13663493c841112e4068656854646f418fda13373
84
+ i18n (1.15.2) sha256=00f9eb62412fe593b2a65a97daa75300d37abb8f7202ec748e94b6d46a9dd1b5
85
+ json (2.21.1) sha256=13a43df75d95641443f5702dff350f237164a9d811ff0f2c2800d4d980220583
86
+ logger (1.7.0) sha256=196edec7cc44b66cfb40f9755ce11b392f21f7967696af15d274dde7edff0203
87
+ minitest (5.27.0) sha256=2d3b17f8a36fe7801c1adcffdbc38233b938eb0b4966e97a6739055a45fa77d5
88
+ rake (13.4.2) sha256=cb825b2bd5f1f8e91ca37bddb4b9aaf345551b4731da62949be002fa89283701
89
+ securerandom (0.4.1) sha256=cc5193d414a4341b6e225f0cb4446aceca8e50d5e1888743fac16987638ea0b1
90
+ sqlite3 (2.9.5-aarch64-linux-gnu) sha256=78075b6337d3d182c6d2b4691049ed45cd220826160c9ea18946bf6a1de200dc
91
+ sqlite3 (2.9.5-aarch64-linux-musl) sha256=18c801185deb4adc01ddb281e8f672a39e3d1729979ca91e39439cd3eac0402d
92
+ sqlite3 (2.9.5-arm-linux-gnu) sha256=1bdfca0c7d63998c60b0f4a8e3c8df2d33800ccc4abd2d612eddbbbc92a4c48b
93
+ sqlite3 (2.9.5-arm-linux-musl) sha256=bae1109d12b2e9f588455967729b008e1ff4feb7761749df695019c9079913c6
94
+ sqlite3 (2.9.5-arm64-darwin) sha256=d0cf444a70fc9395d513cfbcc1e6719e224aa645314e3824cb0474c721425aa2
95
+ sqlite3 (2.9.5-x86-linux-gnu) sha256=c94b96b16f17796be6fa099d15218b52e396f55690c4760faaaefa21ebab9dd5
96
+ sqlite3 (2.9.5-x86-linux-musl) sha256=063a8c13cbadfe7f29453b1706cbdf91fca4a78d244f816ff20bac4fb259f1e4
97
+ sqlite3 (2.9.5-x86_64-darwin) sha256=8e9caae38bd7ebb29cbeee3e7ab1d12dc2327d9a1b92c7fcf0dda05589627a81
98
+ sqlite3 (2.9.5-x86_64-linux-gnu) sha256=233dbcb6714148dd23bc5aeb33e8efd6eac974969564ddd5794c23d5f52b231e
99
+ sqlite3 (2.9.5-x86_64-linux-musl) sha256=e7d3a7474e8af0f96150c21abc203fbab5437206bfcdf11deab7741c0ca516f2
100
+ timeout (0.6.1) sha256=78f57368a7e7bbadec56971f78a3f5ecbcfb59b7fcbb0a3ed6ddc08a5094accb
101
+ tzinfo (2.0.6) sha256=8daf828cc77bcf7d63b0e3bdb6caa47e2272dcfaf4fbfe46f8c3a9df087a829b
102
+ uri (1.1.1) sha256=379fa58d27ffb1387eaada68c749d1426738bd0f654d812fcc07e7568f5c57c6
103
+ yaml_exporter (0.2.1)
104
+
105
+ BUNDLED WITH
106
+ 4.0.6