bbc_redux 0.4.5.pre → 0.4.6.pre

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.
data/Rakefile CHANGED
@@ -19,6 +19,11 @@ task :coverage do
19
19
  sh 'open coverage/index.html'
20
20
  end
21
21
 
22
+ desc 'Open IRB with library loaded'
23
+ task :console do
24
+ sh 'irb -Ilib -r bbc/redux'
25
+ end
26
+
22
27
  ################################################################################
23
28
  # Documentation Tasks
24
29
 
@@ -142,18 +142,25 @@ module BBC
142
142
 
143
143
  # Return all programmes for the schedule date, everything from 0600 for
144
144
  # 24 hours afterwards. May make multiple requests to backend to retreive
145
- # all the data
145
+ # all the data.
146
146
  #
147
147
  # @param [Date,DateTime,Time] date query this schedule date
148
148
  # @param [String,Array<String>,Channel,Array<Channel>,nil] channel
149
149
  # optionally limit schedule query to one or an array of channels
150
150
  # @return [Array<BBC::Redux::Asset>] the list of assets broadcast on date
151
151
  def schedule(date, channels = nil)
152
+
153
+ date = DateTime.parse date.strftime('%Y-%m-%dT06:00:00Z00:00')
154
+
152
155
  query = {
153
- :date => date,
154
- :channels => channels,
155
- :offset => 0,
156
- :limit => 100,
156
+ :after => date.strftime('%Y-%m-%dT%H:%M:%S'),
157
+ :before => ( date + 1 ).strftime('%Y-%m-%dT05:59:59'),
158
+ :channel => channels,
159
+ :offset => 0,
160
+ :limit => 100,
161
+ :sort_by =>'time',
162
+ :sort_order => 'ascending',
163
+ :repeats => true,
157
164
  }
158
165
 
159
166
  results = search(query)
@@ -175,7 +182,7 @@ module BBC
175
182
  end
176
183
  end
177
184
 
178
- assets.sort { |a,b| b.start - a.start }
185
+ assets
179
186
  end
180
187
 
181
188
  # Perform a search of Redux Archive
@@ -188,9 +195,9 @@ module BBC
188
195
  # multiple channels.
189
196
  # @option params [Integer] :limit number of results to return. Default 10
190
197
  # @option params [Integer] :offset offset of the start of results
191
- # @option params [Date,DateTime,Time] :before only return braodcasts
198
+ # @option params [Date,DateTime,Time] :before only return broadcasts
192
199
  # before date
193
- # @option params [Date,DateTime,Time] :after only return braodcasts after
200
+ # @option params [Date,DateTime,Time] :after only return broadcasts after
194
201
  # date
195
202
  # @option params [Date,DateTime,Time] :date everything from 0600 on given
196
203
  # date for 24hrs
@@ -198,6 +205,9 @@ module BBC
198
205
  # @option params [Integer] :shorter constraint on the duration, in seconds
199
206
  # @option params [String] :programme_crid TV Anytime CRID
200
207
  # @option params [String] :series_crid TV Anytime CRID
208
+ # @option params [TrueClass,FalseClass] :repeats include repeats
209
+ # @option params [String] :sort_by 'time' or nil
210
+ # @option params [String] :sort_order 'ascending' or 'descending'
201
211
  # @see BBC::Redux::SearchResults
202
212
  # @return [BBC::Redux::SearchResults] search results
203
213
  def search(params = {})
@@ -207,6 +217,10 @@ module BBC
207
217
  val.strftime('%Y-%m-%dT%H:%M:%S')
208
218
  elsif val.class == Channel
209
219
  val.name
220
+ elsif val.class == TrueClass
221
+ '1'
222
+ elsif val.class == FalseClass
223
+ '0'
210
224
  else
211
225
  val.to_s
212
226
  end
@@ -269,7 +283,7 @@ module BBC
269
283
  def url_for(action)
270
284
  case action
271
285
  when :asset
272
- host + '/asset/details/extended'
286
+ host + '/asset/details'
273
287
  when :channels
274
288
  host + '/asset/channel/available'
275
289
  when :channel_categories
@@ -2,7 +2,7 @@ module BBC
2
2
  module Redux
3
3
 
4
4
  # Library version
5
- VERSION = '0.4.5.pre'
5
+ VERSION = '0.4.6.pre'
6
6
 
7
7
  end
8
8
  end
@@ -111,7 +111,7 @@ describe BBC::Redux::Client do
111
111
 
112
112
  it 'takes json from the backend HTTP API and generates an asset object' do
113
113
  expect(http_client).to \
114
- receive(:post).with('https://i.bbcredux.com/asset/details/extended', {
114
+ receive(:post).with('https://i.bbcredux.com/asset/details', {
115
115
  :body => { :reference => reference, :token => token },
116
116
  :followlocation => true,
117
117
  }).and_return(resp)
@@ -123,7 +123,7 @@ describe BBC::Redux::Client do
123
123
 
124
124
  it 'works when given a UUID rather than a disk reference' do
125
125
  expect(http_client).to \
126
- receive(:post).with('https://i.bbcredux.com/asset/details/extended', {
126
+ receive(:post).with('https://i.bbcredux.com/asset/details', {
127
127
  :body => { :uuid => uuid, :token => token },
128
128
  :followlocation => true,
129
129
  }).and_return(resp)
@@ -212,14 +212,22 @@ describe BBC::Redux::Client do
212
212
  it 'passes params to backend HTTP API and generates results object' do
213
213
  expect(http_client).to \
214
214
  receive(:post).with('https://i.bbcredux.com/asset/search', {
215
- :body => { :q => 'foo', :longer => '200', :token => token },
215
+ :body => {
216
+ :q => 'foo',
217
+ :longer => '200',
218
+ :token => token,
219
+ :true => '1',
220
+ :false => '0',
221
+ },
216
222
  :followlocation => true,
217
223
  }).and_return(resp)
218
224
 
219
- results = instance.search(:q => 'foo', :longer => 200)
225
+ query = { :q => 'foo', :longer => 200, :true => true, :false => false }
226
+
227
+ results = instance.search( query )
220
228
 
221
229
  expect(results.class).to be(BBC::Redux::SearchResults)
222
- expect(results.query).to eq(:q => 'foo', :longer => 200)
230
+ expect(results.query).to eq( query )
223
231
  end
224
232
 
225
233
  context 'channel object based parameters' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bbc_redux
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.5.pre
4
+ version: 0.4.6.pre
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2015-02-19 00:00:00.000000000 Z
14
+ date: 2015-03-03 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rspec
@@ -200,7 +200,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
200
200
  version: '0'
201
201
  segments:
202
202
  - 0
203
- hash: -2431091401732504293
203
+ hash: 1338354639053621810
204
204
  required_rubygems_version: !ruby/object:Gem::Requirement
205
205
  none: false
206
206
  requirements: