embark-journey 0.0.9 → 0.0.10

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: 9fa7f4099b371cb91581b51ad9ddd78938dd6283
4
- data.tar.gz: 1f96fd382c67828f29a632c51ba8764c7c6ba6be
3
+ metadata.gz: a0cd32ef332691e7a68b65df539b921203ce7e5f
4
+ data.tar.gz: fcde00c27970d0dc628ff000cd0dddaabed6c4da
5
5
  SHA512:
6
- metadata.gz: 82cbbdab31d16755611fbf429e642eac1df94ddc7a7ce0cac1ba4296ebbff64ee476d250abfa72edd3415588df58a44c9e596086e96efd96c95ba05a48fdca42
7
- data.tar.gz: e8b672cff0b27d786cbed452db6c6c9e34030f1d6863c3f334657cf5a23610d4a638c326f59df982ca89331d9ea34b3ee1fd82834430cb94ca2840867b36ecf1
6
+ metadata.gz: 72b022961f5a7b672d6d7cf71c78efc098d88bec20c85e331a83986ea76996b766bfc532959796d8bfecad55b19e1c672061e6e1e5e1082f90ed067d5dd2f7b2
7
+ data.tar.gz: 8b040479c36abdf8ce548026d75f2fbcd20db632fe3db52a4841a13a33ee19a31742e4816913080f4b90252c8e7f2d47d8323f420fd8090b09271912863ace64
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
1
  v0.0.9
2
2
  - Rescues from ActiveResource::ResourceNotFound when association_id is set but object doesn't exist
3
3
  - Fixes embeds for associations with names different from their class
4
+
5
+ v0.0.10
6
+ - Adds Journey::Resource.count
data/README.md CHANGED
@@ -57,6 +57,13 @@ Often you'll want to load associated resources without needing to make additiona
57
57
  end
58
58
 
59
59
 
60
+ ### Counting objects
61
+
62
+ Receive an object count for a given query:
63
+
64
+ User.count(query: { 'friends_count.lt' => 4 })
65
+
66
+
60
67
  ## Contributing
61
68
 
62
69
  1. Fork it
@@ -20,6 +20,7 @@ require 'journey/resource/enums'
20
20
  require 'journey/resource/queries'
21
21
  require 'journey/resource/search'
22
22
  require 'journey/resource/embed'
23
+ require 'journey/resource/count'
23
24
 
24
25
  class Journey::Resource
25
26
  include API
@@ -28,6 +29,7 @@ class Journey::Resource
28
29
  include AttributeLoading
29
30
  include Search
30
31
  include Embed
32
+ include Count
31
33
  end
32
34
 
33
35
 
@@ -0,0 +1,12 @@
1
+ require 'active_support/concern'
2
+
3
+ module Journey::Resource::Count
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ def self.count(constraints)
8
+ get(:count, constraints)["count"]
9
+ end
10
+ end
11
+
12
+ end
@@ -2,7 +2,7 @@ module Journey
2
2
  module VERSION
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- TINY = 9
5
+ TINY = 10
6
6
  PRE = nil
7
7
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
8
8
  end
@@ -127,4 +127,25 @@ describe Journey::Resource do
127
127
  expect(job.reported_fault).to eq fault
128
128
  end
129
129
  end
130
+
131
+
132
+ describe '::Count' do
133
+ it 'returns a count of objects when some are matched' do
134
+ uuid = SecureRandom.uuid
135
+
136
+ matched_objects = [
137
+ klass.create(name: uuid),
138
+ klass.create(name: uuid)
139
+ ]
140
+ expect(matched_objects.all?(&:persisted?)).to be true
141
+
142
+ count = klass.count(query: { name: uuid })
143
+ expect(count).to eq(matched_objects.count)
144
+ end
145
+
146
+ it 'returns 0 for no matching objects' do
147
+ count = klass.count(query: { name: SecureRandom.uuid })
148
+ expect(count).to eq(0)
149
+ end
150
+ end
130
151
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embark-journey
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Davey
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-06 00:00:00.000000000 Z
11
+ date: 2014-05-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_attr
@@ -149,6 +149,7 @@ files:
149
149
  - lib/journey/resource.rb
150
150
  - lib/journey/resource/api.rb
151
151
  - lib/journey/resource/attribute_loading.rb
152
+ - lib/journey/resource/count.rb
152
153
  - lib/journey/resource/embed.rb
153
154
  - lib/journey/resource/enums.rb
154
155
  - lib/journey/resource/queries.rb