mongory 2.0.1-x86_64-linux → 2.1.0-x86_64-linux

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: 38b0a037f33288ffb095a7461cb9409e4f9411a586fbbbf850abebaf86361ff6
4
- data.tar.gz: 261250a90f30d4a2167eda54fa0ce5c5c7fa3b4bf643bb072f804edb249ba156
3
+ metadata.gz: b2f42ef3e29de6eddae44a1f6a89f4131080d6caaabe91feac496c66b65793f4
4
+ data.tar.gz: 635eb9ae306c9ed61ec67afc12d7ecdb123d5ed621ba8ff61435fc05388b156f
5
5
  SHA512:
6
- metadata.gz: df5258cd5e555e487e34dcc4b85e72ef266d6e4d40baec391bd0eaf39b9115c0c67f2cd5edc4b53f15b934a46deb86951710dc555e049b52b95095ddb541f14e
7
- data.tar.gz: 765e7a8b488c5d050facd1d78a5c300c44705f7fd4c1fc137480c56c208556c3263a4e0a41c0dc13c7635cab5280318b7b5634314dd7bf6ca273f8507b25b0a7
6
+ metadata.gz: 97e169a3eefa07d0910458382dd3c41711e33a77a4b28e5285b0cb65c676b0d971fa3b3bfbe5aeab568942ee247747ed081c6e506f4c1ed7a1c82359a61dcecb
7
+ data.tar.gz: 6691a6abad840bd78933d985d9e4d317626ec205e0ea2b35a49146ae133044750963f460b600acb3db698cb450a0fad2b5a5ea61b968012603ba7a42e8fa937a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.1.0] - 2026-11-23
4
+
5
+ ### Added
6
+ - **`Mongory.compile` & `Mongory.query`**: Added `Mongory.compile(condition)` (alias `build_matcher`) and `Mongory.query(records)` (alias `build_query`) as primary entry points aligned across the Mongory ecosystem.
7
+
8
+ ### Fixes
9
+ - **C Extension Load Verification & Source-Gem Fallback (`lib/mongory.rb`)**: Fall back to `require 'mongory_ext'` when precompiled `core/<abi>/mongory_ext` is absent (supporting source-gem installs), and verify that `Mongory::Matcher#match?` is defined before reopening `Mongory::Matcher` so stale or incompatible C extensions fail fast with a clear `LoadError`.
10
+
3
11
  ## [2.0.1] - 2026-11-22
4
12
 
5
13
  Aligns with `mongory-core` `v0.3.0` and finishes v2.0.0 cleanup.
data/README.md CHANGED
@@ -59,6 +59,11 @@ matched = records.mongory
59
59
  rule = JSON.parse('{"age": {"$gte": 18}, "$or": [{"name": {"$regex": "^J"}}, {"name": "Bob"}]}')
60
60
  records.mongory.where(rule).pluck('name')
61
61
  # => ["Jack", "Bob"]
62
+
63
+ # 3. Compile once as a reusable, thread-safe Matcher (ideal for constants)
64
+ ADULT_RULE = Mongory.compile(:age.gte => 18, :active => true)
65
+ ADULT_RULE.match?(records.first)
66
+ # => true
62
67
  ```
63
68
 
64
69
  ### Query Builder Methods
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Mongory
4
- VERSION = '2.0.1'
4
+ VERSION = '2.1.0'
5
5
  end
data/lib/mongory.rb CHANGED
@@ -74,22 +74,33 @@ module Mongory
74
74
  @condition_converter ||= Converters::ConditionConverter.instance
75
75
  end
76
76
 
77
- # Builds a new query over the given record set.
77
+ # Builds a new query builder over the given record set.
78
+ #
79
+ # @example
80
+ # Mongory.query(records).where(:age.gte => 18).pluck(:name)
78
81
  #
79
82
  # @param records [Enumerable] any enumerable object (Array, AR::Relation, etc.)
80
83
  # @return [QueryBuilder] a new query builder
81
- def self.build_query(records)
84
+ def self.query(records)
82
85
  QueryBuilder.new(records)
83
86
  end
84
87
 
85
- # Builds a new matcher for the given condition.
88
+ singleton_class.alias_method :build_query, :query
89
+
90
+ # Compiles a reusable matcher for the given condition.
91
+ #
92
+ # @example
93
+ # ADULT = Mongory.compile(:age.gte => 18)
94
+ # ADULT.match?(age: 20) #=> true
86
95
  #
87
96
  # @param condition [Hash] the query condition
88
- # @return [Matcher] a new matcher
89
- def self.build_matcher(condition)
97
+ # @return [Matcher] a new compiled matcher
98
+ def self.compile(condition)
90
99
  Matcher.new(condition)
91
100
  end
92
101
 
102
+ singleton_class.alias_method :build_matcher, :compile
103
+
93
104
  # Registers a class to support `.mongory` query DSL.
94
105
  # This injects a `#mongory` method into the given class.
95
106
  #
@@ -123,6 +134,17 @@ module Mongory
123
134
  end
124
135
 
125
136
  abi = RUBY_VERSION.split('.').first(2).join('.')
126
- require_relative "core/#{abi}/mongory_ext"
137
+ begin
138
+ require_relative "core/#{abi}/mongory_ext"
139
+ rescue LoadError
140
+ require 'mongory_ext'
141
+ end
142
+
143
+ unless defined?(Mongory::Matcher) && Mongory::Matcher.method_defined?(:match?)
144
+ raise LoadError,
145
+ "Incompatible or outdated mongory_ext loaded for Ruby #{abi} (Mongory::Matcher not defined). " \
146
+ 'Please recompile the C extension (e.g. `bundle exec rake compile`).'
147
+ end
148
+
127
149
  require_relative 'mongory/matcher'
128
150
  require_relative 'mongory/query_builder'
data/renovate.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3
+ "extends": [
4
+ "github>mongoryhq/.github"
5
+ ]
6
+ }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongory
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.1.0
5
5
  platform: x86_64-linux
6
6
  authors:
7
7
  - koten0224
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-11-22 00:00:00.000000000 Z
11
+ date: 2026-11-23 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A Mongo-like in-memory query DSL for Ruby
14
14
  email:
@@ -116,6 +116,7 @@ files:
116
116
  - lib/mongory/utils/tree_renderer.rb
117
117
  - lib/mongory/version.rb
118
118
  - mongory.gemspec
119
+ - renovate.json
119
120
  - script/bench.rb
120
121
  - scripts/build_with_core.sh
121
122
  - sig/mongory.rbs