frozen_record 0.3.0 → 0.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ddd2c7d5a3193c955747df36c966af51301a635f
4
- data.tar.gz: 1d8ca8bd18703b5e6a0ab7d6009b3c4c942cf0d9
3
+ metadata.gz: adb5e89145c00c13f76483285346371896a49c1f
4
+ data.tar.gz: dbaa591c9cd948b6d4a63a41b742af908dbf0f9f
5
5
  SHA512:
6
- metadata.gz: 6087f508fd4dff8578a36f9d79a7cf04aa714d1a44df723be848863f5ac492e8e291dede1249802b5b18ab4e158c6baf7ec7e1ebc8986aa547a3e0315a13c71c
7
- data.tar.gz: 790171c1c06b52001c53e2e7a2447acb8ad44cfb4f95f5cc4dcb8fcf4d2b26fed286afe9090847f46c06f959a6d7cf2007635fd314fb6d093490a748d41a56d2
6
+ metadata.gz: baacf19c3123b119826cf461249f880c55816c21125565e819f065d4b854bffd492f726ae5abf1a799f4de581e412266f207fce25cef30df784c164685f88518
7
+ data.tar.gz: 5f4cc8959474d1fc41674537d09c786ec96c4098545a4e8a603fa4b9f04b4f8b215c8ab0775d04cceb3ed830b4e1e8197dee7501c5b14b34e88132f6cf259014
data/README.md CHANGED
@@ -103,8 +103,9 @@ Country.republics.part_of_nato.order(id: :desc)
103
103
 
104
104
  - count
105
105
  - pluck
106
+ - ids
106
107
  - minimum
107
- - minimum
108
+ - maximum
108
109
  - sum
109
110
  - average
110
111
 
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ['Jean Boussier']
10
10
  spec.email = ['jean.boussier@gmail.com']
11
11
  spec.summary = %q{ActiveRecord like interface to read only access and query static YAML files}
12
- spec.homepage = ''
12
+ spec.homepage = 'https://github.com/byroot/frozen_record'
13
13
  spec.license = 'MIT'
14
14
 
15
15
  spec.files = `git ls-files`.split($/)
@@ -47,7 +47,7 @@ module FrozenRecord
47
47
  store[:scope] = scope
48
48
  end
49
49
 
50
- delegate :find, :find_by_id, :find_by, :find_by!, :where, :first, :first!, :last, :last!, :pluck, :order, :limit, :offset,
50
+ delegate :find, :find_by_id, :find_by, :find_by!, :where, :first, :first!, :last, :last!, :pluck, :ids, :order, :limit, :offset,
51
51
  :minimum, :maximum, :average, :sum, to: :current_scope
52
52
 
53
53
  def file_path
@@ -68,6 +68,10 @@ module FrozenRecord
68
68
  end
69
69
  end
70
70
 
71
+ def ids
72
+ pluck(primary_key)
73
+ end
74
+
71
75
  def sum(attribute)
72
76
  pluck(attribute).sum
73
77
  end
@@ -1,3 +1,3 @@
1
1
  module FrozenRecord
2
- VERSION = '0.3.0'
2
+ VERSION = '0.4.0'
3
3
  end
data/spec/scope_spec.rb CHANGED
@@ -282,15 +282,6 @@ describe 'querying' do
282
282
 
283
283
  end
284
284
 
285
- context 'when called with multiple arguments' do
286
-
287
- it 'returns an array of arrays' do
288
- names = Country.pluck(:id, :name)
289
- expect(names).to be == [[1, 'Canada'], [2, 'France'], [3, 'Austria']]
290
- end
291
-
292
- end
293
-
294
285
  context 'when called without arguments' do
295
286
 
296
287
  pending 'returns an array of arrays containing all attributes in order'
@@ -308,6 +299,28 @@ describe 'querying' do
308
299
 
309
300
  end
310
301
 
302
+ describe '.ids' do
303
+
304
+ context 'when called with no arguments' do
305
+
306
+ it 'returns an array of ids' do
307
+ ids = Country.ids
308
+ expect(ids).to be == [1, 2, 3]
309
+ end
310
+
311
+ end
312
+
313
+ context 'when called on a scope' do
314
+
315
+ it 'returns only the ids of matching records' do
316
+ ids = Country.where(capital: "Ottawa").ids
317
+ expect(ids).to be == [1]
318
+ end
319
+
320
+ end
321
+
322
+ end
323
+
311
324
  describe '.exists?' do
312
325
 
313
326
  it 'returns true if query match at least one record' do
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.3.0
4
+ version: 0.4.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: 2014-09-09 00:00:00.000000000 Z
11
+ date: 2015-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -120,7 +120,7 @@ files:
120
120
  - spec/spec_helper.rb
121
121
  - spec/support/car.rb
122
122
  - spec/support/country.rb
123
- homepage: ''
123
+ homepage: https://github.com/byroot/frozen_record
124
124
  licenses:
125
125
  - MIT
126
126
  metadata: {}
@@ -140,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
140
  version: '0'
141
141
  requirements: []
142
142
  rubyforge_project:
143
- rubygems_version: 2.2.2
143
+ rubygems_version: 2.4.6
144
144
  signing_key:
145
145
  specification_version: 4
146
146
  summary: ActiveRecord like interface to read only access and query static YAML files
@@ -152,3 +152,4 @@ test_files:
152
152
  - spec/spec_helper.rb
153
153
  - spec/support/car.rb
154
154
  - spec/support/country.rb
155
+ has_rdoc: