active_hash 3.1.0 → 3.2.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: b300c0554a72d04ab10205af37b7f3e89dbbedca23b9c5185cc4ad0aac4e761b
4
- data.tar.gz: 3aca6e2f970fa2362a127cafd0b88eb5df716daace9281355b5f5966981f9d1d
3
+ metadata.gz: 11f2e4807b50cf0708d0a9ca9bea56e9a26bc9b7ca7eb2e81e0a93f88c333c7e
4
+ data.tar.gz: ba9dee0fea4fa0e02b8ebc2eae74839e72f1e2ea1fd262606561e42aac10ecf1
5
5
  SHA512:
6
- metadata.gz: 02ab457c893ee5388d9668221b84725a1b83b1f2057a17cba98962973b3c2ab902cc9b17ad62b4fb1d4367d9fb40c13fe9d9b70caa76bdb76bf59f287f3b4b5f
7
- data.tar.gz: d7176902700dbb797afac5ea08978b774df1428cfaab593e8895a70897cf9d9eaa39f468cc0829e0dc6aa8a687d209106e4ce6c0dd0b0df505aa3a54971f0fb8
6
+ metadata.gz: 1f7d4c59c9087aaddd26c05295507850f9720ba14b60cdfeb4c77bfbcefd43d982fb052212dc89e6fd5c0d753de047d512d1ce7d5ce3644dc9dd89efa166066d
7
+ data.tar.gz: ec31d53f5622c6b2a8958656b9ac035d00c2484b7d7ee8cd6b486ad6a9c1351ad1d55fbda487025b268ee708688ba832b0513189b91db773956eaea5ba2c2737
data/CHANGELOG.md ADDED
@@ -0,0 +1,353 @@
1
+ # active_hash Changelog
2
+
3
+ ## Version [3.2.0] - <sub><sup>2022-07-14</sup></sub>
4
+
5
+ - Add Ruby 3.2 to the CI matrix [#275](https://github.com/active-hash/active_hash/pull/275) @petergoldstein
6
+ - Handle default value of `false` [#274](https://github.com/active-hash/active_hash/pull/274) @ihollander
7
+ - Run CI only one time per commit [#273](https://github.com/active-hash/active_hash/pull/273) @flavorjones
8
+ - Rails 7 support [#272](https://github.com/active-hash/active_hash/pull/272) @flavorjones
9
+ - Avoid interfere with AR's belongs_to arguments. [#270](https://github.com/active-hash/active_hash/pull/270) @koyo-miyamura
10
+ - Fix broken #pluck method with 3+ attrs specified [#269](https://github.com/active-hash/active_hash/pull/269) @h6ah4i
11
+ - Fix relations for Rails 7 support, and not modifying conditions [#268](https://github.com/active-hash/active_hash/pull/268) @pfeiffer
12
+ - docs: Remove the string 'F' [#264](https://github.com/active-hash/active_hash/pull/264) @tbotaq
13
+ - Show example using regex in where query [#263](https://github.com/active-hash/active_hash/pull/263) @scottharvey
14
+ - Improve performance of exists? [#262](https://github.com/active-hash/active_hash/pull/262) @ise-tang
15
+ - Remove redundant ActiveRecord version check [#260](https://github.com/active-hash/active_hash/pull/260) @yujideveloper
16
+ - Fix deprecation warnings [#259](https://github.com/active-hash/active_hash/pull/259) @yujideveloper
17
+ - Fix rspec config when SKIP_ACTIVE_RECORD enabled [#258](https://github.com/active-hash/active_hash/pull/258) @yujideveloper
18
+ - isolate tests with temporary classes [#256](https://github.com/active-hash/active_hash/pull/256) @machisuke
19
+ - Avoid ActiveRecordExtensions affects AR's belongs_to method. [#255](https://github.com/active-hash/active_hash/pull/255) @machisuke
20
+ - add option to disable erb parsing [#202](https://github.com/active-hash/active_hash/pull/202) @reedlaw
21
+ - add collection singular ids for associations [#237](https://github.com/active-hash/active_hash/pull/237) @1160054
22
+ - Fix the thread-safe spec for the updated cities fixture @adampal
23
+ - Add thread-safety to ActiveFile [#229](https://github.com/active-hash/active_hash/pull/229) @dmitriy-kiriyenko
24
+
25
+ ## Version [3.1.1] - <sub><sup>2022-07-14</sup></sub>
26
+
27
+ - Make scopes chainable [#248](https://github.com/active-hash/active_hash/pull/248) @andreynering
28
+ - Set default key attributes [#251](https://github.com/active-hash/active_hash/pull/251/commits/68a0a121d110ac83f4bbf0024f027714fd24debf) @adampal
29
+ - Migrate from Travis to GitHub Actions for CI @kbrock
30
+ - Add primary_key support for has_one [#218](https://github.com/active-hash/active_hash/pull/218) @yujideveloper
31
+ - Return a chainable relation when using .not [#205](https://github.com/active-hash/active_hash/pull/205) @pfeiffer
32
+ - Correct fields with YAML aliases in array style [#226](https://github.com/active-hash/active_hash/pull/226) @stomk
33
+ - Add ActiveHash::Relation#size method for compatibily [#227](https://github.com/active-hash/active_hash/pull/227) @sluceno
34
+ - Implement ActiveRecord::RecordNotFound interface [#207](https://github.com/active-hash/active_hash/pull/207) @ChrisBr
35
+ - Fix find_by_id with filter chain [#210](https://github.com/active-hash/active_hash/pull/210) @ChrisBr
36
+ - Suppress Ruby 2.7 kwargs warnings [#206](https://github.com/active-hash/active_hash/pull/206) @yhirano55
37
+ - Call reload if @records is not defined [#208](https://github.com/active-hash/active_hash/pull/208) @jonmagic
38
+ - Switch to rspec3 (and update the Gemfile) [#209](https://github.com/active-hash/active_hash/pull/209) @djberg96
39
+ - Implement filter by RegEx [#211](https://github.com/active-hash/active_hash/pull/211) @ChrisBr
40
+ - Supports .pick method [#195](https://github.com/active-hash/active_hash/pull/195/files) @yhirano55
41
+ - Lots of other small performance improvements, documentation and testing. Thanks to everyone who contributed!
42
+
43
+ ## Version [3.1.0] - <sub><sup>2020-01-15</sup></sub>
44
+
45
+ - Add ActiveHash::Base.order method inspired by ActiveRecord [#177](https://github.com/active-hash/active_hash/pull/177)
46
+ - Add #to_ary to ActiveHash::Relation [#182](https://github.com/active-hash/active_hash/pull/182)
47
+ - Allow #find to behave like Enumerable#find if id is nil and a block is given [#183](https://github.com/active-hash/active_hash/pull/183)
48
+ - Delegate :sample to `records` [#189](https://github.com/active-hash/active_hash/pull/189)
49
+
50
+ ## Version [3.0.0] - <sub><sup>2019-09-28</sup></sub>
51
+
52
+ - Make #where chainable [#178](https://github.com/active-hash/active_hash/pull/178)
53
+
54
+ ## Version [2.3.0] - <sub><sup>2019-09-28</sup></sub>
55
+
56
+ - Add ::scope method (inspired by ActiveRecord) [#173](https://github.com/active-hash/active_hash/pull/173)
57
+ - Let `.find(nil)` raise ActiveHash::RecordNotFound (inspired by ActiveRecord) [#174](https://github.com/active-hash/active_hash/pull/174)
58
+ - `where` clause now works with range argument [#175](https://github.com/active-hash/active_hash/pull/175)
59
+
60
+ ## Version [2.2.1] - <sub><sup>2019-03-06</sup></sub>
61
+
62
+ - Allow empty YAML [#171](https://github.com/active-hash/active_hash/pull/171) Thanks, @ppworks
63
+
64
+ ## Version [2.2.0] - <sub><sup>2018-11-22</sup></sub>
65
+
66
+ - Support pluck method [#164](https://github.com/active-hash/active_hash/pull/164) Thanks, @ihatov08
67
+ - Support where.not method [#167](https://github.com/active-hash/active_hash/pull/167) Thanks, @DialBird
68
+
69
+ ## Version [2.1.0] - <sub><sup>2018-04-05</sup></sub>
70
+
71
+ - Allow to use ERB (embedded ruby) in yml files [#160](https://github.com/active-hash/active_hash/pull/160) Thanks, @UgoMare
72
+ - Add `ActiveHash::Base.polymorphic_name` [#162](https://github.com/active-hash/active_hash/pull/162)
73
+ - Fix to be able to use enum accessor constant with same name as top-level constant[#161](https://github.com/active-hash/active_hash/pull/161) Thanks, @yujideveloper
74
+
75
+ ## Version [2.0.0] - <sub><sup>2018-02-27</sup></sub>
76
+
77
+ - Drop old Ruby and Rails support [#157](https://github.com/active-hash/active_hash/pull/157)
78
+ - Don't generate instance accessors for class attributes [#136](https://github.com/active-hash/active_hash/pull/136) Thanks, @rainhead
79
+
80
+ ## Version [1.5.3] - <sub><sup>2017-06-14</sup></sub>
81
+
82
+ - Support symbol values in where and find_by [#156](https://github.com/active-hash/active_hash/pull/156) Thanks, @south37
83
+
84
+ ## Version [1.5.2] - <sub><sup>2017-06-14</sup></sub>
85
+
86
+ - Fix find_by when passed an invalid id [#152](https://github.com/active-hash/active_hash/pull/152) Thanks, @davidstosik
87
+
88
+ ## Version [1.5.1] - <sub><sup>2017-04-20</sup></sub>
89
+
90
+ - Fix a bug on `.where` [#147](https://github.com/active-hash/active_hash/pull/147)
91
+
92
+ ## Version [1.5.0] - <sub><sup>2017-03-24</sup></sub>
93
+
94
+ - add support for `.find_by!`(@syguer)
95
+
96
+ ## Version [1.4.1] - <sub><sup>2015-09-13</sup></sub>
97
+
98
+ - fix bug where `#attributes` didn't contain default values [#107](https://github.com/active-hash/active_hash/pull/107)
99
+ - add support for `.find_by` and `#_read_attribute`. Thanks, @andrewfader
100
+
101
+ ## Version [1.4.0] - <sub><sup>2014-09-03</sup></sub>
102
+
103
+ - support Rails 4.2 @agraves, @al2o3cr
104
+
105
+ ## Version [1.3.0] - <sub><sup>2014-02-18</sup></sub>
106
+
107
+ - fix bug where including ActiveHash associations would make `belongs_to :imageable, polymorphic: true` blow up
108
+ - fixed several bugs that prevented active hash from being used without active record / active model
109
+ - add support for splitting up data sources into multiple files @rheaton
110
+ - add support for storing data in json files @rheaton
111
+
112
+ ## Version [1.2.3] - <sub><sup>2013-11-29</sup></sub>
113
+
114
+ - fix bug where active hash would call `.all` on models when setting has_many @grosser
115
+
116
+ ## Version [1.2.2] - <sub><sup>2013-11-05</sup></sub>
117
+
118
+ - fix bug in gemspec that made it impossible to use w/ Rails 4
119
+
120
+ ## Version [1.2.1] - <sub><sup>2013-10-24</sup></sub>
121
+
122
+ - fixed nasty bug in belongs_to that would prevent users from passing procs @freebird0221
123
+ - fixed bug where passing in a separate class name to belongs_to_active_hash would raise an exception @mauriciopasquier
124
+
125
+ ## Version [1.2.0] - <sub><sup>2013-10-01</sup></sub>
126
+
127
+ - belongs_to is back!
128
+ - added support for primary key options for belongs_to @tomtaylor
129
+
130
+ ## Version [1.0.2] - <sub><sup>2013-09-09</sup></sub>
131
+
132
+ - `where(nil)` returns all results, like ActiveRecord @kugaevsky
133
+
134
+ ## Version [1.0.1] - <sub><sup>2013-07-15</sup></sub>
135
+
136
+ - Travis CI for ActiveHash + Ruby 2, 1.8.7, Rubinius and JRuby support @mattheworiordan
137
+ - no longer need to call .all before executing `find_by_*` or `where` methods @mattheworiordan
138
+
139
+ ## Version [1.0.0] - <sub><sup>2013-06-24</sup></sub>
140
+
141
+ - save is a no-op on existing records, instead of raising an error (issue #63)
142
+
143
+ ## Version [0.10.0] - <sub><sup>2013-06-24</sup></sub>
144
+
145
+ - added ActiveYaml::Aliases module so you can DRY up your repetitive yaml @brett-richardson
146
+
147
+ ## Version [0.9.14] - <sub><sup>2013-05-23</sup></sub>
148
+
149
+ - enum_accessor can now take multiple field names when generating the constant
150
+ - temporarily disabled rails edge specs since there's an appraisal issue with minitest
151
+
152
+ ## Version [0.9.13] <sub><sup>2013-01-22</sup></sub>
153
+ - Fix find_by_id and find method returning nil unless .all called in ActiveYaml @mattheworiordan
154
+
155
+ ## Version [0.9.12] <sub><sup>2012-07-25</sup></sub>
156
+ - Make find_by_id lookups faster by indexing records by id @desmondmonster
157
+
158
+ ## Version [0.9.11] <sub><sup>2012-07-16</sup></sub>
159
+ - Validate IDs are unique by caching them in a set @desmondmonster
160
+
161
+ ## Version [0.9.10] <sub><sup>2012-04-14</sup></sub>
162
+ - Support for has_one associations @kbrock
163
+
164
+ ## Version [0.9.9] <sub><sup>2012-04-05</sup></sub>
165
+
166
+ - Allow gems like simple_form to read metadata about belongs_to associations that point to active hash objects @kbrock
167
+ - Move specs to appraisal @flavorjones
168
+
169
+ ## Version [0.9.8] - <sub><sup>2012-01-18</sup></sub>
170
+
171
+ - Make ActiveHash.find with array raise an exception when record cannot be found @mocoso
172
+
173
+ ## Version [0.9.7] - <sub><sup>2011-09-18</sup></sub>
174
+
175
+ - Fixing the setting of a `belongs_to_active_hash` association by association (not id).
176
+
177
+ ## Version [0.9.6] - <sub><sup>2011-08-31</sup></sub>
178
+ - added a module which adds a .belongs_to_active_hash method to ActiveRecord, since it was broken for Rails 3.1 @felixclack
179
+
180
+ ## Version [0.9.5] - <sub><sup>2011-06-07</sup></sub>
181
+ - fixed bug where .find would not work if you defined your ids as strings
182
+
183
+ ## Version [0.9.4] - <sub><sup>2011-06-05</sup></sub>
184
+ - fixed deprecation warnings for class_inheritable_accessor @scudco
185
+ - added basic compatibility with the `where` method from Arel @rgarver
186
+
187
+ ## Version [0.9.3] - <sub><sup>2011-04-19</sup></sub>
188
+ - better dependency management and compatibility with ActiveSupport 2.x @vandrijevik
189
+
190
+ ## Version [0.9.2] - <sub><sup>2011-01-22</sup></sub>
191
+ - improved method_missing errors for dynamic finders
192
+ - prevent users from trying to overwrite :attributes [#33](https://github.com/active-hash/active_hash/issues/33)
193
+
194
+ ## Version [0.9.1] <sub><sup>2010-12-08</sup></sub>
195
+ - ruby 1.9.2 compatibility
196
+
197
+ ## Version [0.9.0] <sub><sup>2010-12-06</sup></sub>
198
+ - added dependency on ActiveModel
199
+ - add persisted? method to ActiveHash::Base
200
+ - ActiveHash::Base#save takes \*args to be compatible with ActiveModel
201
+ - ActiveHash::Base#to_param returns nil if the object hasn't been saved
202
+
203
+ ## Version [0.8.7] <sub><sup>2010-11-09</sup></sub>
204
+ - Use Ruby's definition of "word character" (numbers, underscores) when forming ActiveHash::Enum constants @tstuart
205
+
206
+ ## Version [0.8.6] <sub><sup>2010-11-07</sup></sub>
207
+ - Get ActiveHash::Associations to return a scope for has_many active record relationships @mocoso
208
+
209
+ ## Version [0.8.5] <sub><sup>2010-10-20</sup></sub>
210
+ - Allow find_by_* methods to accept an options hash, so rails associations don't blow up
211
+
212
+ ## Version [0.8.4] <sub><sup>2010-10-07</sup></sub>
213
+ - Add conditions to ActiveHash#all (Ryan Garver)
214
+ - Add #cache_key to ActiveHash::Base (Tom Stuart)
215
+ - Add banged dynamic finder support to ActiveHash::Base (Tom Stuart)
216
+
217
+ ## Version [0.8.3] <sub><sup>2010-09-16</sup></sub>
218
+ - Enum format now uses underscores instead of removing all characters
219
+ - Removed test dependency on acts_as_fu
220
+
221
+ ## Version [0.8.2] <sub><sup>2010-05-26</sup></sub>
222
+ - Silence metaclass deprecation warnings in active support 2.3.8
223
+
224
+ ## Version [0.8.1] <sub><sup>2010-05-04</sup></sub>
225
+ - When calling ActiveFile::Base.reload do not actually perform the reload if nothing has been modified unless you call reload(true) to force (Michael Schubert)
226
+
227
+ ## Version [0.8.0] <sub><sup>2010-04-25</sup></sub>
228
+ - When ActiveRecord model belongs_to an ActiveHash and the associated id is nil, returns nil instead of raising RecordNotFound (Jeremy Weiskotten)
229
+ - Merged Nakajima's "add" alias for "create" - gotta save those ASCII characters :)
230
+
231
+ ## Version [0.7.9] <sub><sup>2010-03-01</sup></sub>
232
+ - Removed "extend"-related deprecations - they didn't play well with rails class loading
233
+
234
+ ## Version [0.7.8] <sub><sup>2010-01-18</sup></sub>
235
+ - Added stub for #destroyed? method, since Rails associations now depend on it
236
+
237
+ ## Version [0.7.7] <sub><sup>2009-12-19</sup></sub>
238
+ - Deprecated include ActiveHash::Associations in favor of extend ActiveHash::Associations
239
+
240
+ ## Version [0.7.6] <sub><sup>2009-12-19</sup></sub>
241
+ - Added ActiveHash::Enum (John Pignata)
242
+ - Fixed bug where you can't set nil to an association
243
+ - Calling #belongs_to now creates the underlying field if it's not already there (belongs_to :city will create the :city_id field)
244
+
245
+ ## Version [0.7.5] <sub><sup>2009-12-10</sup></sub>
246
+ - Fixed a bug where belongs_to associations would raise an error instead of returning nil when the parent object didn't exist.
247
+ - Added #[] and #[]= accessors for more ActiveRecord-esque-ness. (Pat Nakajima & Dave Yeu)
248
+
249
+ ## Version [0.7.4] <sub><sup>2009-12-01</sup></sub>
250
+ - Add marked_for_destruction? to be compatible with nested attributes (Brandon Keene)
251
+ - Added second parameter to respond_to? and cleaned up specs (Brian Takita)
252
+ - Find with an id that does not exist now raises a RecordNotFound exception to mimic ActiveRecord (Pat Nakajima)
253
+
254
+ ## Version [0.7.3] <sub><sup>2009-10-22</sup></sub>
255
+ - added setters to ActiveHash::Base for all fields
256
+ - instantiating an ActiveHash object with a hash calls the setter methods on the object
257
+ - boolean default values now work
258
+
259
+ ## Version [0.7.2] <sub><sup>2009-10-21</sup></sub>
260
+ - Removed auto-reloading of files based on mtime - maybe it will come back later
261
+ - Made ActiveFile::Base.all a bit more sane
262
+
263
+ ## Version 0.7.1 <sub><sup>2009-10-13</sup></sub>
264
+ - added ActiveHash::Base.has_many, which works with ActiveRecord or ActiveHash classes @baldwindavid
265
+ - added ActiveHash::Base.belongs_to, which works with ActiveRecord or ActiveHash classes @baldwindavid
266
+ - added .delete_all method that clears the in-memory array
267
+ - added support for Hash-style yaml (think, Rails fixtures)
268
+ - added setter for parent object on belongs_to ( `city = City.new; city.state = State.first; city.state_id == State.first.id` )
269
+
270
+ ## Version [0.7.0] <sub><sup>2009-10-12</sup></sub>
271
+ - auto-assign fields after calling data= instead of after calling .all
272
+ - remove require 'rubygems', so folks with non-gem setups can still use AH
273
+ - added more specific activesupport dependency to ensure that metaclass is available
274
+ - AH no longer calls to_i on ids. If you pass in a string as an id, you'll get a string back
275
+ - Fancy finders, such as find_all_by_id_and_name, will compare the to_s values of the fields, so you can pass in strings
276
+ - You can now use ActiveHash models as the parents of polymorphic belongs_to associations
277
+ - save, save!, create and create! now add items to the in-memory collection, and naively adds autoincrementing id
278
+ - new_record? returns false if the record is part of the collection
279
+ - ActiveHash now works with Fixjour!
280
+
281
+ ## Version [0.6.1] <sub><sup>2009-08-19</sup></sub>
282
+ - Added custom finders for multiple fields, such as .find_all_by_name_and_age
283
+
284
+ ## Version 0.5.0 <sub><sup>2009-07-23</sup></sub>
285
+ - Added support for auto-defining methods based on hash keys in ActiveHash::Base
286
+ - Changed the :field and :fields API so that they don't overwrite existing methods (useful when ActiveHash auto-defines methods)
287
+ - Fixed a bug where ActiveFile incorrectly set the root_path to be the path in the gem directory, not the current working directory
288
+
289
+ ## Version 0.4.0 <sub><sup>2009-07-24</sup></sub>
290
+ - ActiveFile no longer reloads files by default
291
+ - Added ActiveFile.reload_active_file= so you can cause ActiveFile to reload
292
+ - Setting data to nil correctly causes .all to return an empty array
293
+ - Added reload(force) method, so that you can force a reload from files in ActiveFile, useful for tests
294
+
295
+ [HEAD]: https://github.com/active-hash/active_hash/compare/v4.3.0...HEAD
296
+ [4.3.0]: https://github.com/active-hash/active_hash/compare/v3.2.0...v4.3.0
297
+ [4.2.0]: https://github.com/active-hash/active_hash/compare/v3.1.1...v4.2.0
298
+ [3.1.1]: https://github.com/active-hash/active_hash/compare/v3.1.0...v3.1.1
299
+ [3.1.0]: https://github.com/active-hash/active_hash/compare/v3.0.0...v3.1.0
300
+ [3.0.0]: https://github.com/active-hash/active_hash/compare/v2.3.0...v3.0.0
301
+ [2.3.0]: https://github.com/active-hash/active_hash/compare/v2.2.1...v2.3.0
302
+ [2.2.1]: https://github.com/active-hash/active_hash/compare/v2.2.0...v2.2.1
303
+ [2.2.0]: https://github.com/active-hash/active_hash/compare/v2.1.0...v2.2.0
304
+ [2.1.0]: https://github.com/active-hash/active_hash/compare/v2.0.0...v2.1.0
305
+ [2.0.0]: https://github.com/active-hash/active_hash/compare/v1.5.3...v2.0.0
306
+ [1.5.3]: https://github.com/active-hash/active_hash/compare/v1.5.2...v1.5.3
307
+ [1.5.2]: https://github.com/active-hash/active_hash/compare/v1.5.1...v1.5.2
308
+ [1.5.1]: https://github.com/active-hash/active_hash/compare/v1.5.0...v1.5.1
309
+ [1.5.0]: https://github.com/active-hash/active_hash/compare/v1.4.1...v1.5.0
310
+ [1.4.1]: https://github.com/active-hash/active_hash/compare/v1.4.0...v1.4.1
311
+ [1.4.0]: https://github.com/active-hash/active_hash/compare/v1.3.0...v1.4.0
312
+ [1.3.0]: https://github.com/active-hash/active_hash/compare/v1.2.3...v1.3.0
313
+ [1.2.3]: https://github.com/active-hash/active_hash/compare/v1.2.2...v1.2.3
314
+ [1.2.2]: https://github.com/active-hash/active_hash/compare/v1.2.1...v1.2.2
315
+ [1.2.1]: https://github.com/active-hash/active_hash/compare/v1.2.0...v1.2.1
316
+ [1.2.0]: https://github.com/active-hash/active_hash/compare/v1.0.2...v1.2.0
317
+ [1.0.2]: https://github.com/active-hash/active_hash/compare/v1.0.1...v1.0.2
318
+ [1.0.1]: https://github.com/active-hash/active_hash/compare/v1.0.0...v1.0.1
319
+ [1.0.0]: https://github.com/active-hash/active_hash/compare/v0.10.0...v1.0.0
320
+ [0.10.0]: https://github.com/active-hash/active_hash/compare/v0.9.14...v0.10.0
321
+ [0.9.14]: https://github.com/active-hash/active_hash/compare/v0.9.13...v0.9.14
322
+ [0.9.13]: https://github.com/active-hash/active_hash/compare/v0.9.12...v0.9.13
323
+ [0.9.12]: https://github.com/active-hash/active_hash/compare/v0.9.11...v0.9.12
324
+ [0.9.11]: https://github.com/active-hash/active_hash/compare/v0.9.10...v0.9.11
325
+ [0.9.10]: https://github.com/active-hash/active_hash/compare/v0.9.9...v0.9.10
326
+ [0.9.9]: https://github.com/active-hash/active_hash/compare/v0.9.8...v0.9.9
327
+ [0.9.8]: https://github.com/active-hash/active_hash/compare/v0.9.7...v0.9.8
328
+ [0.9.7]: https://github.com/active-hash/active_hash/compare/v0.9.6...v0.9.7
329
+ [0.9.6]: https://github.com/active-hash/active_hash/compare/v0.9.5...v0.9.6
330
+ [0.9.5]: https://github.com/active-hash/active_hash/compare/v0.9.4...v0.9.5
331
+ [0.9.4]: https://github.com/active-hash/active_hash/compare/v0.9.3...v0.9.4
332
+ [0.9.3]: https://github.com/active-hash/active_hash/compare/v0.9.2...v0.9.3
333
+ [0.9.2]: https://github.com/active-hash/active_hash/compare/v0.9.1...v0.9.2
334
+ [0.9.1]: https://github.com/active-hash/active_hash/compare/v0.9.0...v0.9.1
335
+ [0.9.0]: https://github.com/active-hash/active_hash/compare/v0.8.7...v0.9.0
336
+ [0.8.7]: https://github.com/active-hash/active_hash/compare/v0.8.6...v0.8.7
337
+ [0.8.6]: https://github.com/active-hash/active_hash/compare/v0.8.5...v0.8.6
338
+ [0.8.5]: https://github.com/active-hash/active_hash/compare/v0.8.4...v0.8.5
339
+ [0.8.4]: https://github.com/active-hash/active_hash/compare/v0.8.3...v0.8.4
340
+ [0.8.3]: https://github.com/active-hash/active_hash/compare/v0.8.2...v0.8.3
341
+ [0.8.2]: https://github.com/active-hash/active_hash/compare/v0.8.1...v0.8.2
342
+ [0.8.1]: https://github.com/active-hash/active_hash/compare/v0.8.0...v0.8.1
343
+ [0.8.0]: https://github.com/active-hash/active_hash/compare/v0.7.9...v0.8.0
344
+ [0.7.9]: https://github.com/active-hash/active_hash/compare/v0.7.8...v0.7.9
345
+ [0.7.8]: https://github.com/active-hash/active_hash/compare/v0.7.7...v0.7.8
346
+ [0.7.7]: https://github.com/active-hash/active_hash/compare/v0.7.6...v0.7.7
347
+ [0.7.6]: https://github.com/active-hash/active_hash/compare/v0.7.5...v0.7.6
348
+ [0.7.5]: https://github.com/active-hash/active_hash/compare/v0.7.4...v0.7.5
349
+ [0.7.4]: https://github.com/active-hash/active_hash/compare/v0.7.3...v0.7.4
350
+ [0.7.3]: https://github.com/active-hash/active_hash/compare/v0.7.2...v0.7.3
351
+ [0.7.2]: https://github.com/active-hash/active_hash/compare/v0.7.0...v0.7.2
352
+ [0.7.0]: https://github.com/active-hash/active_hash/compare/v0.6.1...v0.7.0
353
+ [0.6.1]: https://github.com/active-hash/active_hash/compare/v0.6.0...v0.6.1
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # ActiveHash
2
2
 
3
- [![Build Status](https://travis-ci.org/zilkey/active_hash.png?branch=master)](https://travis-ci.org/zilkey/active_hash)
3
+ [![Build Status](https://github.com/active-hash/active_hash/actions/workflows/ruby.yml/badge.svg)](https://github.com/active-hash/active_hash/actions/workflows/ruby.yml)
4
4
 
5
5
  ActiveHash is a simple base class that allows you to use a ruby hash as a readonly datasource for an ActiveRecord-like model.
6
6
 
@@ -17,7 +17,7 @@ ActiveHash also ships with:
17
17
 
18
18
  ## !!! Important notice !!!
19
19
  We have changed returned value to chainable by v3.0.0. It's not just an `Array` instance anymore.
20
- If it breaks your application, please report us on [issues](https://github.com/zilkey/active_hash/issues), and use v2.x.x as following..
20
+ If it breaks your application, please report us on [issues](https://github.com/active-hash/active_hash/issues), and use v2.x.x as following..
21
21
 
22
22
  ```ruby
23
23
  gem 'active_hash', '~> 2.3.0'
@@ -169,6 +169,7 @@ Country.find_by_id 1 # => find the first object that matches the id
169
169
  Country.find_by(name: 'US') # => returns the first country object with specified argument
170
170
  Country.find_by!(name: 'US') # => same as find_by, but raise exception when not found
171
171
  Country.where(name: 'US') # => returns all records with name: 'US'
172
+ Country.where(name: /U/) # => returns all records where the name matches the regex /U/
172
173
  Country.where.not(name: 'US') # => returns all records without name: 'US'
173
174
  Country.order(name: :desc) # => returns all records ordered by name attribute in DESC order
174
175
  ```
@@ -211,11 +212,11 @@ Country#name= # => sets the name
211
212
  The ActiveHash::Base.all method functions like an in-memory data store. You can save your records as ActiveHash::Relation object by using standard ActiveRecord create and save methods:
212
213
  ```ruby
213
214
  Country.all
214
- => #<ActiveHash::Relation:0x00007f861e043bb0 @klass=Country, @all_records=[], @query_hash={}, @records_dirty=false>
215
+ => #<ActiveHash::Relation:0x00007f861e043bb0 @klass=Country, @all_records=[], @conditions=[..], @records_dirty=false>
215
216
  Country.create
216
217
  => #<Country:0x00007f861b7abce8 @attributes={:id=>1}>
217
218
  Country.all
218
- => #<ActiveHash::Relation:0x00007f861b7b3628 @klass=Country, @all_records=[#<Country:0x00007f861b7abce8 @attributes={:id=>1}>], @query_hash={}, @records_dirty=false>
219
+ => #<ActiveHash::Relation:0x00007f861b7b3628 @klass=Country, @all_records=[#<Country:0x00007f861b7abce8 @attributes={:id=>1}>], @conditions=[..], @records_dirty=false>
219
220
  country = Country.new
220
221
  => #<Country:0x00007f861e059938 @attributes={}>
221
222
  country.new_record?
@@ -225,7 +226,7 @@ country.save
225
226
  country.new_record?
226
227
  # => false
227
228
  Country.all
228
- => #<ActiveHash::Relation:0x00007f861e0ca610 @klass=Country, @all_records=[#<Country:0x00007f861b7abce8 @attributes={:id=>1}>, #<Country:0x00007f861e059938 @attributes={:id=>2}>], @query_hash={}, @records_dirty=false>
229
+ => #<ActiveHash::Relation:0x00007f861e0ca610 @klass=Country, @all_records=[#<Country:0x00007f861b7abce8 @attributes={:id=>1}>, #<Country:0x00007f861e059938 @attributes={:id=>2}>], @conditions=[..], @records_dirty=false>
229
230
  ```
230
231
  Notice that when adding records to the collection, it will auto-increment the id for you by default. If you use string ids, it will not auto-increment the id. Available methods are:
231
232
  ```
@@ -349,7 +350,7 @@ end
349
350
  The above example will look for the file "/u/data/sample.yml".
350
351
 
351
352
  Since ActiveYaml just creates a hash from the YAML file, you will have all fields specified in YAML auto-defined for you. You can format your YAML as an array, or as a hash:
352
- ```
353
+ ```yaml
353
354
  # array style
354
355
  - id: 1
355
356
  name: US
@@ -369,6 +370,35 @@ mexico:
369
370
  id: 3
370
371
  name: Mexico
371
372
  ```
373
+
374
+ ### Automatic Key Attribute
375
+
376
+ When using the hash format for your YAML file, ActiveYaml will automatically add a `key` attribute with the name of the object. You can overwrite this by setting the key attribute in the YAML file.
377
+ For example:
378
+ ```
379
+ au:
380
+ id: 1
381
+ name: Australia
382
+ ```
383
+
384
+ When you access the object you can do `Country.find(1).key => 'au'`. Or `Country.find_by_key('au')`
385
+
386
+ If you want a different key on only some objects you can mix and match:
387
+
388
+ ```
389
+ au:
390
+ id: 1
391
+ key: aus
392
+ name: Australia
393
+ nz:
394
+ id: 2
395
+ name: New Zealand
396
+ ```
397
+
398
+ `Country.find(1).key => 'aus'`
399
+
400
+ `Country.find(2).key => 'nz'`
401
+
372
402
  ### Multiple files per model
373
403
 
374
404
  You can use multiple files to store your data. You will have to choose between hash or array style as you cannot use both for one model.
@@ -382,7 +412,7 @@ end
382
412
 
383
413
  Aliases can be used in ActiveYaml using either array or hash style by including `ActiveYaml::Aliases`.
384
414
  With that module included, keys beginning with a '/' character can be safely added, and will be ignored, allowing you to add aliases anywhere in your code:
385
- ```
415
+ ```yaml
386
416
  # Array Style
387
417
  - /aliases:
388
418
  soda_flavor: &soda_flavor
@@ -408,7 +438,8 @@ coke:
408
438
  name: Coke
409
439
  flavor: *soda_flavor
410
440
  price: *soda_price
411
-
441
+ ```
442
+ ```ruby
412
443
  class Soda < ActiveYaml::Base
413
444
  include ActiveYaml::Aliases
414
445
  end
@@ -420,14 +451,20 @@ Soda.first.price # => 1.0
420
451
 
421
452
  ### Using ERB ruby in YAML
422
453
 
423
- Embedded ruby can bu used in ActiveYaml using erb brackets `<% %>` and `<%= %>` to set the result of a ruby operation as a value in the yaml file.
454
+ Embedded ruby can be used in ActiveYaml using erb brackets `<% %>` and `<%= %>` to set the result of a ruby operation as a value in the yaml file.
424
455
 
425
- ```
456
+ ```yaml
426
457
  - id: 1
427
458
  email: <%= "user#{rand(100)}@email.com" %>
428
459
  password: <%= ENV['USER_PASSWORD'] %>
429
460
  ```
430
461
 
462
+ This can be disabled in an initializer:
463
+ ```ruby
464
+ # config/initializers/active_yaml.rb
465
+ ActiveYaml::Base.process_erb = false
466
+ ```
467
+
431
468
  ## ActiveJSON
432
469
 
433
470
  If you want to store your data in JSON files, just inherit from ActiveJSON and specify your path information:
@@ -492,7 +529,7 @@ class Country < ActiveFile::Base
492
529
 
493
530
  class << self
494
531
  def extension
495
- ".super_secret"
532
+ "super_secret"
496
533
  end
497
534
 
498
535
  def load_file
@@ -587,10 +624,6 @@ To make users' lives easier, please maintain support for:
587
624
  * Ruby 2.4
588
625
  * ActiveRecord/ActiveSupport from 5.0 through edge
589
626
 
590
- To that end, run specs against all rubies before committing:
591
-
592
- wwtd
593
-
594
627
  Once appraisal passes in all supported rubies, follow these steps to release a new version of active_hash:
595
628
 
596
629
  * update the changelog with a brief summary of the changes that are included in the release
data/active_hash.gemspec CHANGED
@@ -33,11 +33,18 @@ Gem::Specification.new do |s|
33
33
  s.email = %q{jeff@zilkey.com}
34
34
  s.summary = %q{An ActiveRecord-like model that uses a hash or file as a datasource}
35
35
  s.description = %q{Includes the ability to specify data using hashes, yml files or JSON files}
36
- s.homepage = %q{http://github.com/zilkey/active_hash}
36
+ s.homepage = %q{http://github.com/active-hash/active_hash}
37
37
  s.license = "MIT"
38
38
 
39
+ s.metadata = {
40
+ "homepage_uri" => s.homepage,
41
+ "changelog_uri" => "https://github.com/active-hash/active_hash/blob/master/CHANGELOG.md",
42
+ "source_code_uri" => s.homepage,
43
+ "bug_tracker_uri" => "https://github.com/active-hash/active_hash/issues",
44
+ }
45
+
39
46
  s.files = [
40
- "CHANGELOG",
47
+ "CHANGELOG.md",
41
48
  "LICENSE",
42
49
  "README.md",
43
50
  "active_hash.gemspec",
@@ -2,6 +2,7 @@ module ActiveFile
2
2
 
3
3
  class Base < ActiveHash::Base
4
4
  extend ActiveFile::MultipleFiles
5
+ @@instance_lock = Mutex.new
5
6
 
6
7
  class_attribute :filename, :root_path, :data_loaded, instance_reader: false, instance_writer: false
7
8
 
@@ -13,10 +14,12 @@ module ActiveFile
13
14
  end
14
15
 
15
16
  def reload(force = false)
16
- return if !self.dirty && !force && self.data_loaded
17
- self.data_loaded = true
18
- self.data = load_file
19
- mark_clean
17
+ @@instance_lock.synchronize do
18
+ return if !self.dirty && !force && self.data_loaded
19
+ self.data = load_file
20
+ mark_clean
21
+ self.data_loaded = true
22
+ end
20
23
  end
21
24
 
22
25
  def set_filename(name)
@@ -47,12 +50,16 @@ module ActiveFile
47
50
  protected :actual_root_path
48
51
 
49
52
  [:find, :find_by_id, :all, :where, :method_missing].each do |method|
50
- define_method(method) do |*args|
53
+ define_method(method) do |*args, &block|
51
54
  reload unless data_loaded
52
- return super(*args)
55
+ return super(*args, &block)
53
56
  end
54
57
  end
55
58
 
59
+ def all_in_process
60
+ return super if data_loaded
61
+ @records || []
62
+ end
56
63
  end
57
64
  end
58
65
 
@@ -13,7 +13,7 @@ module ActiveFile
13
13
  loaded_files = full_paths.collect { |path| load_path(path) }
14
14
 
15
15
  if loaded_files.all?{ |file_data| file_data.is_a?(Array) }
16
- loaded_files.sum
16
+ loaded_files.sum([])
17
17
  elsif loaded_files.all?{ |file_data| file_data.is_a?(Hash) }
18
18
  loaded_files.inject({}) { |hash, file_data| hash.merge(file_data) }
19
19
  else