carddb 0.2.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f38ee7d9b3b04bbbc3cfa0c3b4954cb0a65ee7f61f64f87a7bc07c228cdec60d
4
+ data.tar.gz: 80759ca9be30df5ef9c3b122caccde5c669d7828d3fbd097d5ad431b2c2885b3
5
+ SHA512:
6
+ metadata.gz: 8d1f7de2a44deaa670f63f3de0879edb50b271e154d31d788464f457537a91c99e56a8db7a1717ff047456eee7f1f02d1745305f92e3fa9488945386941af6c6
7
+ data.tar.gz: db96a54832d649c3bb683a01ec1c19a287062ba4ec82b08c201c628e15b407a788d587562f124447d943652d299ccd1b4b8287fd8bedd70e2c2675257022c2ef
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rspec_status ADDED
@@ -0,0 +1,96 @@
1
+ example_id | status | run_time |
2
+ ------------------------------------------------- | ------ | --------------- |
3
+ ./spec/carddb/client_spec.rb[1:1:1] | passed | 0.00029 seconds |
4
+ ./spec/carddb/client_spec.rb[1:1:2] | passed | 0.00004 seconds |
5
+ ./spec/carddb/client_spec.rb[1:1:3] | passed | 0.00003 seconds |
6
+ ./spec/carddb/client_spec.rb[1:2:1] | passed | 0.00016 seconds |
7
+ ./spec/carddb/client_spec.rb[1:2:2] | passed | 0.00019 seconds |
8
+ ./spec/carddb/client_spec.rb[1:3:1] | passed | 0.00003 seconds |
9
+ ./spec/carddb/client_spec.rb[1:4:1] | passed | 0.00003 seconds |
10
+ ./spec/carddb/client_spec.rb[1:5:1] | passed | 0.00004 seconds |
11
+ ./spec/carddb/client_spec.rb[1:6:1] | passed | 0.00003 seconds |
12
+ ./spec/carddb/client_spec.rb[1:7:1] | passed | 0.00032 seconds |
13
+ ./spec/carddb/client_spec.rb[1:7:2] | passed | 0.01201 seconds |
14
+ ./spec/carddb/collection_spec.rb[1:1:1] | passed | 0.00006 seconds |
15
+ ./spec/carddb/collection_spec.rb[2:1:1] | passed | 0.00245 seconds |
16
+ ./spec/carddb/collection_spec.rb[2:1:2] | passed | 0.00015 seconds |
17
+ ./spec/carddb/collection_spec.rb[2:1:3] | passed | 0.0004 seconds |
18
+ ./spec/carddb/collection_spec.rb[2:1:4] | passed | 0.00038 seconds |
19
+ ./spec/carddb/collection_spec.rb[2:1:5] | passed | 0.00005 seconds |
20
+ ./spec/carddb/collection_spec.rb[3:1:1] | passed | 0.00018 seconds |
21
+ ./spec/carddb/collection_spec.rb[3:1:2] | passed | 0.0003 seconds |
22
+ ./spec/carddb/collection_spec.rb[3:1:3] | passed | 0.00015 seconds |
23
+ ./spec/carddb/collection_spec.rb[3:1:4] | passed | 0.00004 seconds |
24
+ ./spec/carddb/configuration_spec.rb[1:1:1] | passed | 0.00004 seconds |
25
+ ./spec/carddb/configuration_spec.rb[1:1:2] | passed | 0.0001 seconds |
26
+ ./spec/carddb/configuration_spec.rb[1:1:3] | passed | 0.00004 seconds |
27
+ ./spec/carddb/configuration_spec.rb[1:1:4] | passed | 0.00003 seconds |
28
+ ./spec/carddb/configuration_spec.rb[1:1:5] | passed | 0.00003 seconds |
29
+ ./spec/carddb/configuration_spec.rb[1:1:6] | passed | 0.00003 seconds |
30
+ ./spec/carddb/configuration_spec.rb[1:2:1:1] | passed | 0.00004 seconds |
31
+ ./spec/carddb/configuration_spec.rb[1:2:2:1] | passed | 0.00003 seconds |
32
+ ./spec/carddb/configuration_spec.rb[1:2:2:2] | passed | 0.0001 seconds |
33
+ ./spec/carddb/configuration_spec.rb[1:3:1:1] | passed | 0.00003 seconds |
34
+ ./spec/carddb/configuration_spec.rb[1:3:2:1] | passed | 0.00003 seconds |
35
+ ./spec/carddb/configuration_spec.rb[1:3:2:2] | passed | 0.00003 seconds |
36
+ ./spec/carddb/configuration_spec.rb[1:3:2:3] | passed | 0.00002 seconds |
37
+ ./spec/carddb/configuration_spec.rb[1:4:1] | passed | 0.00004 seconds |
38
+ ./spec/carddb/configuration_spec.rb[1:4:2] | passed | 0.00003 seconds |
39
+ ./spec/carddb/configuration_spec.rb[1:5:1] | passed | 0.00003 seconds |
40
+ ./spec/carddb/filter_builder_spec.rb[1:1:1] | passed | 0.00004 seconds |
41
+ ./spec/carddb/filter_builder_spec.rb[1:1:2] | passed | 0.00003 seconds |
42
+ ./spec/carddb/filter_builder_spec.rb[1:1:3] | passed | 0.00003 seconds |
43
+ ./spec/carddb/filter_builder_spec.rb[1:1:4] | passed | 0.00002 seconds |
44
+ ./spec/carddb/filter_builder_spec.rb[1:1:5] | passed | 0.00002 seconds |
45
+ ./spec/carddb/filter_builder_spec.rb[1:1:6] | passed | 0.00003 seconds |
46
+ ./spec/carddb/filter_builder_spec.rb[1:1:7] | passed | 0.00003 seconds |
47
+ ./spec/carddb/filter_builder_spec.rb[1:1:8] | passed | 0.00002 seconds |
48
+ ./spec/carddb/filter_builder_spec.rb[1:2:1] | passed | 0.00003 seconds |
49
+ ./spec/carddb/filter_builder_spec.rb[1:2:2] | passed | 0.00002 seconds |
50
+ ./spec/carddb/filter_builder_spec.rb[1:2:3] | passed | 0.00002 seconds |
51
+ ./spec/carddb/filter_builder_spec.rb[1:2:4] | passed | 0.00002 seconds |
52
+ ./spec/carddb/filter_builder_spec.rb[1:2:5] | passed | 0.00002 seconds |
53
+ ./spec/carddb/filter_builder_spec.rb[1:2:6] | passed | 0.00002 seconds |
54
+ ./spec/carddb/filter_builder_spec.rb[1:2:7] | passed | 0.00002 seconds |
55
+ ./spec/carddb/filter_builder_spec.rb[1:2:8] | passed | 0.00002 seconds |
56
+ ./spec/carddb/filter_builder_spec.rb[1:2:9] | passed | 0.00002 seconds |
57
+ ./spec/carddb/filter_builder_spec.rb[1:2:10] | passed | 0.00002 seconds |
58
+ ./spec/carddb/filter_builder_spec.rb[1:2:11] | passed | 0.00002 seconds |
59
+ ./spec/carddb/filter_builder_spec.rb[1:2:12] | passed | 0.00002 seconds |
60
+ ./spec/carddb/filter_builder_spec.rb[1:2:13] | passed | 0.00003 seconds |
61
+ ./spec/carddb/resources/datasets_spec.rb[1:1:1] | passed | 0.00387 seconds |
62
+ ./spec/carddb/resources/datasets_spec.rb[1:1:2] | passed | 0.00363 seconds |
63
+ ./spec/carddb/resources/datasets_spec.rb[1:2:1] | passed | 0.00444 seconds |
64
+ ./spec/carddb/resources/decks_spec.rb[1:1:1] | passed | 0.00427 seconds |
65
+ ./spec/carddb/resources/decks_spec.rb[1:2:1] | passed | 0.00438 seconds |
66
+ ./spec/carddb/resources/decks_spec.rb[1:3:1] | passed | 0.00442 seconds |
67
+ ./spec/carddb/resources/decks_spec.rb[1:4:1] | passed | 0.0043 seconds |
68
+ ./spec/carddb/resources/decks_spec.rb[1:5:1] | passed | 0.00403 seconds |
69
+ ./spec/carddb/resources/decks_spec.rb[1:6:1] | passed | 0.00384 seconds |
70
+ ./spec/carddb/resources/decks_spec.rb[1:7:1] | passed | 0.00416 seconds |
71
+ ./spec/carddb/resources/games_spec.rb[1:1:1] | passed | 0.00463 seconds |
72
+ ./spec/carddb/resources/games_spec.rb[1:1:2] | passed | 0.00008 seconds |
73
+ ./spec/carddb/resources/games_spec.rb[1:2:1] | passed | 0.00426 seconds |
74
+ ./spec/carddb/resources/games_spec.rb[1:2:2] | passed | 0.00444 seconds |
75
+ ./spec/carddb/resources/publishers_spec.rb[1:1:1] | passed | 0.00383 seconds |
76
+ ./spec/carddb/resources/publishers_spec.rb[1:2:1] | passed | 0.00447 seconds |
77
+ ./spec/carddb/resources/records_spec.rb[1:1:1] | passed | 0.00428 seconds |
78
+ ./spec/carddb/resources/records_spec.rb[1:1:2] | passed | 0.00416 seconds |
79
+ ./spec/carddb/resources/records_spec.rb[1:1:3] | passed | 0.00012 seconds |
80
+ ./spec/carddb/resources/records_spec.rb[1:1:4] | passed | 0.00004 seconds |
81
+ ./spec/carddb/resources/records_spec.rb[1:2:1] | passed | 0.00412 seconds |
82
+ ./spec/carddb/resources/records_spec.rb[1:2:2] | passed | 0.00414 seconds |
83
+ ./spec/carddb/resources/records_spec.rb[1:3:1] | passed | 0.00444 seconds |
84
+ ./spec/carddb/resources/records_spec.rb[1:3:2] | passed | 0.00011 seconds |
85
+ ./spec/carddb/resources/records_spec.rb[1:4:1] | passed | 0.00365 seconds |
86
+ ./spec/carddb/resources/records_spec.rb[1:4:2] | passed | 0.00004 seconds |
87
+ ./spec/carddb/resources/records_spec.rb[1:4:3] | passed | 0.00009 seconds |
88
+ ./spec/carddb/resources/rules_spec.rb[1:1:1] | passed | 0.00403 seconds |
89
+ ./spec/carddb/resources/rules_spec.rb[1:2:1] | passed | 0.00419 seconds |
90
+ ./spec/carddb_spec.rb[1:1] | passed | 0.00004 seconds |
91
+ ./spec/carddb_spec.rb[1:2:1] | passed | 0.00003 seconds |
92
+ ./spec/carddb_spec.rb[1:3:1] | passed | 0.00003 seconds |
93
+ ./spec/carddb_spec.rb[1:4:1] | passed | 0.00004 seconds |
94
+ ./spec/carddb_spec.rb[1:5:1] | passed | 0.00003 seconds |
95
+ ./spec/carddb_spec.rb[1:6:1] | passed | 0.00003 seconds |
96
+ ./spec/carddb_spec.rb[1:7:1] | passed | 0.00003 seconds |
data/.rubocop.yml ADDED
@@ -0,0 +1,72 @@
1
+ plugins:
2
+ - rubocop-rspec
3
+
4
+ AllCops:
5
+ TargetRubyVersion: 3.0
6
+ NewCops: enable
7
+ SuggestExtensions: false
8
+ Exclude:
9
+ - "vendor/**/*"
10
+ - "spec/fixtures/**/*"
11
+
12
+ Style/Documentation:
13
+ Enabled: false
14
+
15
+ Style/FrozenStringLiteralComment:
16
+ Enabled: true
17
+
18
+ Metrics/BlockLength:
19
+ Exclude:
20
+ - "spec/**/*"
21
+ - "*.gemspec"
22
+
23
+ Metrics/MethodLength:
24
+ Max: 35
25
+
26
+ Metrics/AbcSize:
27
+ Max: 40
28
+
29
+ Metrics/ClassLength:
30
+ Max: 450
31
+
32
+ Metrics/ModuleLength:
33
+ Max: 450
34
+
35
+ Metrics/ParameterLists:
36
+ Max: 10
37
+
38
+ Metrics/CyclomaticComplexity:
39
+ Max: 10
40
+
41
+ Layout/LineLength:
42
+ Max: 250
43
+
44
+ Naming/MethodParameterName:
45
+ MinNameLength: 2
46
+
47
+ Naming/PredicatePrefix:
48
+ Enabled: false
49
+
50
+ Style/ComparableClamp:
51
+ Enabled: false
52
+
53
+ Style/SafeNavigationChainLength:
54
+ Enabled: false
55
+
56
+ RSpec/ExampleLength:
57
+ Max: 40
58
+
59
+ RSpec/MultipleExpectations:
60
+ Max: 5
61
+
62
+ RSpec/NestedGroups:
63
+ Max: 4
64
+
65
+ RSpec/SpecFilePathFormat:
66
+ Enabled: false
67
+
68
+ RSpec/MultipleDescribes:
69
+ Enabled: false
70
+
71
+ RSpec/IdenticalEqualityAssertion:
72
+ Enabled: false
data/AGENTS.md ADDED
@@ -0,0 +1,27 @@
1
+ # AGENTS.md
2
+
3
+ ## Commands
4
+ - `bundle exec rspec` - run all tests
5
+ - `bundle exec rspec spec/carddb/client_spec.rb` - run single test file
6
+ - `bundle exec rspec spec/carddb/client_spec.rb:42` - run test at line
7
+ - `bundle exec rubocop` - run linter
8
+ - `bundle exec rake` - run tests + linter (default)
9
+
10
+ ## Code Style
11
+ - Add `# frozen_string_literal: true` at top of all files
12
+ - Use `require_relative` for internal requires, not `require`
13
+ - Prefer single-quoted strings unless interpolation needed
14
+ - Module name is `CardDB` (capital D and B)
15
+ - Classes: PascalCase, methods/variables: snake_case, constants: SCREAMING_SNAKE_CASE
16
+ - Use keyword arguments for optional parameters
17
+ - Document public methods with YARD (`@param`, `@return`, `@raise`)
18
+
19
+ ## Error Handling
20
+ - Raise `ArgumentError` for invalid arguments
21
+ - Use custom errors from `CardDB::Error` hierarchy for API issues
22
+
23
+ ## Testing
24
+ - Use `described_class` instead of repeating class name
25
+ - Use `let` for test data, `subject(:name)` for named subjects
26
+ - Stub API calls with `stub_graphql_response(data)` helper
27
+ - Group tests by method: `describe "#method_name"`
data/CHANGELOG.md ADDED
@@ -0,0 +1,127 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [0.2.0] - 2026-04-29
11
+
12
+ ### Added
13
+
14
+ - **Publishers Resource**: New `CardDB.publishers` resource for searching and fetching publishers
15
+ - `search(search:, first:, after:)` - Search publishers by name
16
+ - `fetch(id:)` or `fetch(slug:)` - Fetch a single publisher by ID or slug
17
+ - `fetch_many(slugs)` - Fetch multiple publishers by slugs
18
+ - `Publisher#games` - Navigate from publisher to games
19
+
20
+ - **Records.get Method**: Fetch records by identifier value using the dataset's identifier field
21
+ ```ruby
22
+ record = CardDB.records.get(
23
+ identifier: "xy1-1",
24
+ dataset_key: "cards"
25
+ )
26
+ ```
27
+
28
+ - **Batch Query Support**: Combine multiple queries into a single API request
29
+ ```ruby
30
+ results = CardDB.batch do |b|
31
+ b.games.fetch("uuid-1")
32
+ b.publishers.fetch(slug: "pokemon-company")
33
+ end
34
+ ```
35
+
36
+ - **Configurable Logging**: Debug API interactions with configurable logging
37
+ ```ruby
38
+ CardDB.configure do |config|
39
+ config.logger = Logger.new(STDOUT)
40
+ config.log_level = :debug # :debug, :info, :warn, :error
41
+ end
42
+ ```
43
+
44
+ - **Auto-Retry on Rate Limit**: Automatically retry requests when rate limited
45
+ ```ruby
46
+ CardDB.configure do |config|
47
+ config.retry_on_rate_limit = true
48
+ config.max_retries = 3
49
+ end
50
+ ```
51
+
52
+ - **Configurable Caching**: Cache fetch/get results to reduce API calls
53
+ ```ruby
54
+ CardDB.configure do |config|
55
+ config.cache = CardDB::MemoryCache.new # or Rails.cache
56
+ config.cache_ttl = 300 # Default: 5 minutes
57
+
58
+ # Per-resource TTLs (override the default)
59
+ config.cache_ttls = {
60
+ publishers: 3600, # 1 hour
61
+ games: 3600, # 1 hour
62
+ datasets: 1800, # 30 minutes
63
+ records: 300 # 5 minutes
64
+ }
65
+ end
66
+
67
+ # Per-request control
68
+ game = CardDB.games.fetch("uuid", cache: true)
69
+ game = CardDB.games.fetch("uuid", cache: false)
70
+ ```
71
+
72
+ - **Batch Iteration Methods**: Rails-style `find_each` and `find_in_batches` on Collection
73
+ ```ruby
74
+ collection.find_each { |record| process(record) }
75
+ collection.find_in_batches(batch_size: 50) { |batch| ... }
76
+ ```
77
+
78
+ - **Schema-Aware Dataset Helpers**: Convenient methods for working with dataset schemas
79
+ - `dataset.field_keys` - All field keys
80
+ - `dataset.filterable_fields` - Filterable field keys
81
+ - `dataset.searchable_fields` - Searchable field keys
82
+ - `dataset.identifier_field` - The identifier field key
83
+ - `dataset.filterable?(:field)` - Check if field is filterable
84
+ - `dataset.searchable?(:field)` - Check if field is searchable
85
+ - `dataset.field(:key)` - Get field info by key
86
+
87
+ - **Dynamic Field Access on Record**: Access record data via method calls
88
+ ```ruby
89
+ record.name # equivalent to record['name']
90
+ record.hp # equivalent to record['hp']
91
+ ```
92
+
93
+ - **MemoryCache**: Thread-safe in-memory cache with TTL support
94
+ ```ruby
95
+ cache = CardDB::MemoryCache.new
96
+ cache.write("key", "value", expires_in: 60)
97
+ cache.read("key") # => "value"
98
+ ```
99
+
100
+ ### Changed
101
+
102
+ - **Games.get Method**: Now uses unified `fetchGame` query with optional parameters
103
+ - **Datasets.get Method**: Now uses unified `fetchDataset` query with optional parameters
104
+
105
+ ### Fixed
106
+
107
+ - Fixed duplicate return statement in `Batch#build_publisher_query`
108
+
109
+ ## [0.1.0] - 2024-12-16
110
+
111
+ ### Added
112
+
113
+ - Initial release
114
+ - Client configuration (API key, endpoint, timeouts, defaults, restrictions)
115
+ - Games resource (search, fetch)
116
+ - Datasets resource (search, fetch, get, schema)
117
+ - Records resource (search, fetch, fetch_many)
118
+ - Expressive filter DSL with operators (eq, neq, gt, gte, lt, lte, within, not_within, contains, like, ilike, is_null, is_not_null)
119
+ - Boolean logic in filters (AND, OR via `any` blocks)
120
+ - Nested field filtering
121
+ - Link filtering (`where_link`)
122
+ - Link resolution in search results
123
+ - Pagination support (manual, auto_paginate)
124
+ - Collection class with Enumerable support
125
+ - Resource wrapper classes (Game, Dataset, Record, DatasetSchema, FieldInfo)
126
+ - Comprehensive error handling (AuthenticationError, RateLimitError, RestrictedError, NotFoundError, ValidationError, GraphQLError, ConnectionError, TimeoutError)
127
+ - Rate limit info access
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2024 CardDB Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.