frozen_record 0.25.3 → 0.26.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 55cfe5dc540e6f5aa6d4a188a45297e5daae39c67b6f79a029ed12a1333d2a17
4
- data.tar.gz: 68ec4931e6cd4c24dc95da423b4d32f61f789ebb38e8012ad16f12db9a0d389b
3
+ metadata.gz: 558032391d508fe0e51074f70abb81395189376a610c694cf6b43a64bbf2b91a
4
+ data.tar.gz: e8bd4b3bb7e2dafb6d3854176b7c98e6f87a3148790dd5d5f0de0ec55b95ef48
5
5
  SHA512:
6
- metadata.gz: a3bbf2f250846efd3679e39a7aea8628bfdea01c84a31cab342d5348e4a41bff3655a1f4e4158b461e2084866113c0a110b676664087ccb1b735c5d66e330cd3
7
- data.tar.gz: e3bb79694ba6bb4b430cc378bad2c787a41bf71ec2834eb218d10243e0cb24d6573ef19661a454c613ede947dd33eaccc75a61395259533e2aaedb6a3089f565
6
+ metadata.gz: 725c9abc9be65de3c1db5643e0df340c34b9b72f50e4a650d0f0a51a27160f6f7db6bcdbb33cab77d7fac3d9e7c6558fe22fd04081b43b8da4c6f7ba2887a3e4
7
+ data.tar.gz: a1f7e30104161efb60b5a6fbb89c1270f6656557c4f8bfb549a18ec012fdc87be73223e2d13d1efc73d18c3c8e2a0c905f9b9d0bb30907dcd465b659801f41fe
@@ -0,0 +1,6 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "github-actions"
4
+ directory: "/"
5
+ schedule:
6
+ interval: "weekly"
@@ -12,7 +12,7 @@ jobs:
12
12
  minimal: [ false, true ]
13
13
  name: Ruby ${{ matrix.ruby }} tests, minimal=${{ matrix.minimal }}
14
14
  steps:
15
- - uses: actions/checkout@v2
15
+ - uses: actions/checkout@v3
16
16
  - name: Set up Ruby
17
17
  uses: ruby/setup-ruby@v1
18
18
  with:
data/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Unreleased
2
2
 
3
+ # v0.26.0
4
+
5
+ - Drop dependency on `dedup` gem.
6
+
7
+ # v0.25.5
8
+
9
+ - `FrozenRecord::Base#==` now returns `false` if the primary key is `nil` (to match the `ActiveRecord::Base` implementation)
10
+
11
+ # v0.25.4
12
+
13
+ - Minor Ruby 3.2 compatiblity fix (regarding `ruby2_keywords`).
14
+
15
+ # v0.25.3
16
+
3
17
  - Also disable max_records_scan when loading `Compact` records.
4
18
 
5
19
  # v0.25.2
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  [![Build Status](https://secure.travis-ci.org/byroot/frozen_record.svg)](http://travis-ci.org/byroot/frozen_record)
4
4
  [![Gem Version](https://badge.fury.io/rb/frozen_record.svg)](http://badge.fury.io/rb/frozen_record)
5
5
 
6
- Activec Record-like interface for **read only** access to static data files of reasonable size.
6
+ Active Record-like interface for **read only** access to static data files of reasonable size.
7
7
 
8
8
  ## Installation
9
9
 
@@ -156,7 +156,7 @@ The primary key isn't indexed by default.
156
156
 
157
157
  ## Limitations
158
158
 
159
- Frozen Record is not meant to operate or large unindexed datasets.
159
+ Frozen Record is not meant to operate on large unindexed datasets.
160
160
 
161
161
  To ensure that it doesn't happen by accident, you can set `FrozenRecord::Base.max_records_scan = 500` (or whatever limit makes sense to you), in your development and test environments.
162
162
  This setting will cause Frozen Record to raise an error if it has to scan more than `max_records_scan` records. This property can also be set on a per model basis.
@@ -20,7 +20,6 @@ Gem::Specification.new do |spec|
20
20
  spec.required_ruby_version = '>= 2.5'
21
21
 
22
22
  spec.add_runtime_dependency 'activemodel'
23
- spec.add_runtime_dependency 'dedup'
24
23
 
25
24
  spec.add_development_dependency 'rake'
26
25
  spec.add_development_dependency 'rspec'
@@ -19,16 +19,16 @@ module FrozenRecord
19
19
 
20
20
  if supports_freeze
21
21
  def load(file_path)
22
- JSON.load_file(file_path, freeze: true) || Dedup::EMPTY_ARRAY
22
+ JSON.load_file(file_path, freeze: true) || [].freeze
23
23
  end
24
24
  else
25
25
  def load(file_path)
26
- Dedup.deep_intern!(JSON.load_file(file_path) || Dedup::EMPTY_ARRAY)
26
+ JSON.load_file(file_path) || [].freeze
27
27
  end
28
28
  end
29
29
  else
30
30
  def load(file_path)
31
- Dedup.deep_intern!(JSON.parse(File.read(file_path)) || Dedup::EMPTY_ARRAY)
31
+ JSON.parse(File.read(file_path)) || [].freeze
32
32
  end
33
33
  end
34
34
  end
@@ -56,27 +56,27 @@ module FrozenRecord
56
56
 
57
57
  if YAML.respond_to?(:unsafe_load_file)
58
58
  def load_file(path)
59
- YAML.unsafe_load_file(path, freeze: true) || Dedup::EMPTY_ARRAY
59
+ YAML.unsafe_load_file(path, freeze: true) || [].freeze
60
60
  end
61
61
 
62
62
  def load_string(yaml)
63
- YAML.unsafe_load(yaml, freeze: true) || Dedup::EMPTY_ARRAY
63
+ YAML.unsafe_load(yaml, freeze: true) || [].freeze
64
64
  end
65
65
  elsif supports_freeze
66
66
  def load_file(path)
67
- YAML.load_file(path, freeze: true) || Dedup::EMPTY_ARRAY
67
+ YAML.load_file(path, freeze: true) || [].freeze
68
68
  end
69
69
 
70
70
  def load_string(yaml)
71
- YAML.load(yaml, freeze: true) || Dedup::EMPTY_ARRAY
71
+ YAML.load(yaml, freeze: true) || [].freeze
72
72
  end
73
73
  else
74
74
  def load_file(path)
75
- Dedup.deep_intern!(YAML.load_file(path) || Dedup::EMPTY_ARRAY)
75
+ YAML.load_file(path) || [].freeze
76
76
  end
77
77
 
78
78
  def load_string(yaml)
79
- Dedup.deep_intern!(YAML.load(yaml) || Dedup::EMPTY_ARRAY)
79
+ YAML.load(yaml) || [].freeze
80
80
  end
81
81
  end
82
82
  end
@@ -69,7 +69,7 @@ module FrozenRecord
69
69
  alias_method :set_default_attributes, :default_attributes=
70
70
  private :set_default_attributes
71
71
  def default_attributes=(default_attributes)
72
- set_default_attributes(Dedup.deep_intern!(default_attributes.transform_keys(&:to_s)))
72
+ set_default_attributes(default_attributes.transform_keys(&:to_s))
73
73
  end
74
74
 
75
75
  alias_method :set_primary_key, :primary_key=
@@ -252,7 +252,7 @@ module FrozenRecord
252
252
  alias_method :attribute, :[]
253
253
 
254
254
  def ==(other)
255
- super || other.is_a?(self.class) && other.id == id
255
+ super || other.is_a?(self.class) && !id.nil? && other.id == id
256
256
  end
257
257
 
258
258
  def persisted?
@@ -62,7 +62,7 @@ module FrozenRecord
62
62
 
63
63
  def attributes=(attributes)
64
64
  self.class.attributes.each do |attr|
65
- instance_variable_set(self.class._attributes_cache[attr], Dedup.deep_intern!(attributes[attr]))
65
+ instance_variable_set(self.class._attributes_cache[attr], attributes[attr])
66
66
  end
67
67
  end
68
68
 
@@ -4,8 +4,6 @@ require 'yaml'
4
4
  require 'set'
5
5
  require 'active_model'
6
6
 
7
- require 'dedup'
8
-
9
7
  require 'frozen_record/version'
10
8
  require 'frozen_record/scope'
11
9
  require 'frozen_record/index'
@@ -242,17 +242,13 @@ module FrozenRecord
242
242
  if array_delegable?(method_name)
243
243
  to_a.public_send(method_name, *args, &block)
244
244
  elsif @klass.respond_to?(method_name)
245
- delegate_to_class(method_name, *args, &block)
245
+ scoping { @klass.public_send(method_name, *args, &block) }
246
246
  else
247
247
  super
248
248
  end
249
249
  end
250
250
  ruby2_keywords :method_missing if respond_to?(:ruby2_keywords, true)
251
251
 
252
- def delegate_to_class(*args, &block)
253
- scoping { @klass.public_send(*args, &block) }
254
- end
255
-
256
252
  def array_delegable?(method)
257
253
  Array.method_defined?(method) && !DISALLOWED_ARRAY_METHODS.include?(method)
258
254
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FrozenRecord
4
- VERSION = '0.25.3'
4
+ VERSION = '0.26.0'
5
5
  end
@@ -149,6 +149,13 @@ RSpec.shared_examples 'main' do
149
149
  expect(country).to be == second_country
150
150
  end
151
151
 
152
+ it 'returns false if both instances are from the same class and their ids are nil' do
153
+ country = country_model.new(id: nil)
154
+ second_country = country_model.new(id: nil)
155
+
156
+ expect(country).to_not be == second_country
157
+ end
158
+
152
159
  it 'returns false if both instances are not from the same class' do
153
160
  country = country_model.first
154
161
  car = car_model.new(id: country.id)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: frozen_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.25.3
4
+ version: 0.26.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean Boussier
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-13 00:00:00.000000000 Z
11
+ date: 2022-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: dedup
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: rake
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -73,6 +59,7 @@ executables: []
73
59
  extensions: []
74
60
  extra_rdoc_files: []
75
61
  files:
62
+ - ".github/dependabot.yml"
76
63
  - ".github/workflows/main.yml"
77
64
  - ".gitignore"
78
65
  - ".rspec"
@@ -137,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
137
124
  - !ruby/object:Gem::Version
138
125
  version: '0'
139
126
  requirements: []
140
- rubygems_version: 3.3.7
127
+ rubygems_version: 3.2.20
141
128
  signing_key:
142
129
  specification_version: 4
143
130
  summary: ActiveRecord like interface to read only access and query static YAML files