legato 0.5.2 → 0.6.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
  SHA1:
3
- metadata.gz: 980eb1079898deac8afc471a03804fda0cc3865a
4
- data.tar.gz: 90eb6e06d3ccfb0ebb5cb178c8e81ef9808beef6
3
+ metadata.gz: 304acd2f0f716bf682b425bea037c4445afc97fd
4
+ data.tar.gz: 4443a2410d7c782ae282bd4913ae5f5e6730cadd
5
5
  SHA512:
6
- metadata.gz: bdb333f5453cb364f28a431eb1b6b84cf3c8fedd1df39a05e3af0bf6784cda44e9279b2e81051d81158daa5717cc8ed7a6ce2786deed0b59e180266acb66ef0b
7
- data.tar.gz: 6596be013de3f10f9704e9ab11167316d475919038200770f34130b99dc555218905420c7cd36a000bba44db4926b054797ba3ef497ee7bda2f3b28a3d79bb1b
6
+ metadata.gz: d978c8ac87bcab86a9ac8003b7afb18735f8f7281203bb186f23d0cc773a33b2ac1cd5750f502ad1ed0490a47189c6311d63f5e09f005452614dc69a750ac501
7
+ data.tar.gz: c1d37f5c5b819ae0c14fc7a88b486165c5ad000d1762550ee8e12a15cbe63d36668c7fc69b743dcc22cda394a3cf76862ba651db1f522849a7e0e7749bb02b8c
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## Legato 0.6.0 ##
2
+
3
+ * Fix bug in `Query` where calling `results` after loading a collection would not load new data into the collection
4
+
5
+ *Tony Pitale*
6
+
1
7
  ## Legato 0.5.2 ##
2
8
 
3
9
  * Refactor `User.request` into a `Request` class
data/lib/legato/query.rb CHANGED
@@ -39,6 +39,10 @@ module Legato
39
39
  attr_accessor :filters, :segment_filters # combined, can be appended to
40
40
  attr_accessor :tracking_scope
41
41
 
42
+ def self.from_query(query)
43
+ new(query.parent_klass, query.tracking_scope)
44
+ end
45
+
42
46
  def initialize(klass, tracking_scope = "ga")
43
47
  @loaded = false
44
48
  @parent_klass = klass
@@ -164,11 +168,13 @@ module Legato
164
168
 
165
169
  # if no filters, we use results to add profile
166
170
  def results(profile=nil, options={})
167
- options, profile = profile, nil if profile.is_a?(Hash)
171
+ query = loaded? ? Query.from_query(self) : self
168
172
 
169
- self.profile = profile unless profile.nil?
170
- apply_options(options)
171
- self
173
+ options, profile = profile, self.profile if profile.is_a?(Hash)
174
+
175
+ query.profile = profile
176
+ query.apply_options(options)
177
+ query
172
178
  end
173
179
 
174
180
  # def total_results
@@ -1,3 +1,3 @@
1
1
  module Legato
2
- VERSION = "0.5.2"
2
+ VERSION = "0.6.0"
3
3
  end
@@ -123,15 +123,25 @@ describe Legato::Query do
123
123
  end
124
124
 
125
125
  it 'sets options and returns self' do
126
+ profile = @query.profile
126
127
  @query.stubs(:profile=)
127
128
  @query.stubs(:apply_options)
128
129
 
129
130
  @query.results({:sort => [:city]}).should == @query
130
131
 
131
- @query.should have_received(:profile=).never
132
+ @query.should have_received(:profile=).with(profile)
132
133
  @query.should have_received(:apply_options).with({:sort => [:city]})
133
134
  end
134
135
 
136
+ it 'creates a new query if collection has already been loaded' do
137
+ @query.stubs(:loaded?).returns(true)
138
+
139
+ new_query = @query.results({offset: 10_000})
140
+
141
+ expect(new_query).to_not eql(@query)
142
+ expect(new_query.offset).to eql(10_000)
143
+ end
144
+
135
145
  context "when modifying dimensions" do
136
146
  it 'changes the query dimensions' do
137
147
  @query.dimensions << :city
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: legato
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tony Pitale
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-24 00:00:00.000000000 Z
11
+ date: 2015-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake