ur-product 0.9.1 → 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -32,3 +32,4 @@ API wrapper for the [Utbildningsradion](http://ur.se) product services.
32
32
  * [RSolr](http://github.com/mwmitchell/rsolr)
33
33
  * [RSolr-ext](http://github.com/mwmitchell/rsolr-ext)
34
34
  * [RestClient](http://github.com/archiloque/rest-client)
35
+ * [YAJL](http://github.com/lloyd/yajl)
@@ -24,8 +24,4 @@ Feature: UR Product
24
24
  Scenario: Check if a product has an image
25
25
  Given I want the product 100001
26
26
  When I get the product
27
- Then it should have image
28
-
29
- # Scenario: Boolean search for sab:H* should return 3 or more hits
30
- # Given I search for "sab:H*"
31
- # Then I should get 3 or more hits
27
+ Then it should have image
@@ -22,22 +22,6 @@ Given /^I want the products (.+)$/ do |ids|
22
22
  @ids = ids.split(' and ')
23
23
  end
24
24
 
25
- Given /^I search for "([^\"]*)"$/ do |query|
26
- @search = UR::Product.search({
27
- :per_page => 10,
28
- :qt => 'internalfacets',
29
- :defType => 'lucene',
30
- :q => query
31
- })
32
-
33
- puts @search.inspect
34
-
35
- end
36
-
37
- Then /^I should get (\d+) or more hits$/ do |num_hits|
38
- @search.num_hits.should >= num_hits
39
- end
40
-
41
25
  # When
42
26
 
43
27
  When /^I get the product$/ do
@@ -8,8 +8,7 @@ FakeWeb.allow_net_connect = false
8
8
  faked_urls = [
9
9
  'http://metadata.ur.se/products/100001.json',
10
10
  'http://metadata.ur.se/products.json?ur_product_ids=100001,150423',
11
- 'http://assets.ur.se/id/100001/images/1.jpg',
12
- 'http://services.ur.se/search/select?qt=internalfacets&wt=ruby&defType=lucene&q=sab%3AH%2A&rows=10'
11
+ 'http://assets.ur.se/id/100001/images/1.jpg'
13
12
  ]
14
13
 
15
14
  faked_urls.each do |url|
@@ -0,0 +1,30 @@
1
+ require 'yajl/http_stream'
2
+
3
+ # Module for Utbildningsradion AB (http://ur.se/)
4
+ module UR
5
+ # Streaming information for mp4/mp3 files
6
+ class Streaming
7
+ # Setup
8
+ if !defined?(STREAMING_URL)
9
+ STREAMING_URL = 'http://metadata.ur.se/streaming'
10
+ end
11
+
12
+ def initialize(data)
13
+ @data = data
14
+ end
15
+
16
+ def [](product)
17
+ if product.respond_to? :ur_product_id
18
+ @data[product.ur_product_id.to_s]
19
+ else
20
+ @data[product.to_s]
21
+ end
22
+ end
23
+
24
+ def self.search(ids)
25
+ return [] if ids.empty?
26
+ url = STREAMING_URL + '.json?ur_product_ids=' + ids.join(',')
27
+ Streaming.new(Yajl::HttpStream.get(url))
28
+ end
29
+ end
30
+ end
data/lib/ur-product.rb CHANGED
@@ -4,6 +4,7 @@ require File.dirname(__FILE__) + '/ur/product/distribution_event.rb'
4
4
  require File.dirname(__FILE__) + '/ur/product/related_product_id.rb'
5
5
  require File.dirname(__FILE__) + '/ur/product/storage.rb'
6
6
  require File.dirname(__FILE__) + '/ur/search'
7
+ require File.dirname(__FILE__) + '/ur/streaming'
7
8
 
8
9
  module UR
9
10
  class InvalidProductID < Exception
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ur-product
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 63
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 9
8
- - 1
9
- version: 0.9.1
9
+ - 2
10
+ version: 0.9.2
10
11
  platform: ruby
11
12
  authors:
12
13
  - Peter Hellberg
@@ -14,16 +15,18 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-05-25 00:00:00 +02:00
18
+ date: 2010-06-08 00:00:00 +02:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: yajl-ruby
22
23
  prerelease: false
23
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
24
26
  requirements:
25
27
  - - ">="
26
28
  - !ruby/object:Gem::Version
29
+ hash: 15
27
30
  segments:
28
31
  - 0
29
32
  - 7
@@ -35,9 +38,11 @@ dependencies:
35
38
  name: rsolr
36
39
  prerelease: false
37
40
  requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
38
42
  requirements:
39
43
  - - ">="
40
44
  - !ruby/object:Gem::Version
45
+ hash: 45
41
46
  segments:
42
47
  - 0
43
48
  - 12
@@ -49,9 +54,11 @@ dependencies:
49
54
  name: rsolr-ext
50
55
  prerelease: false
51
56
  requirement: &id003 !ruby/object:Gem::Requirement
57
+ none: false
52
58
  requirements:
53
59
  - - ">="
54
60
  - !ruby/object:Gem::Version
61
+ hash: 47
55
62
  segments:
56
63
  - 0
57
64
  - 12
@@ -63,9 +70,11 @@ dependencies:
63
70
  name: rest-client
64
71
  prerelease: false
65
72
  requirement: &id004 !ruby/object:Gem::Requirement
73
+ none: false
66
74
  requirements:
67
75
  - - ">="
68
76
  - !ruby/object:Gem::Version
77
+ hash: 3
69
78
  segments:
70
79
  - 1
71
80
  - 4
@@ -92,6 +101,7 @@ files:
92
101
  - lib/ur/product/related_product_id.rb
93
102
  - lib/ur/product/storage.rb
94
103
  - lib/ur/search.rb
104
+ - lib/ur/streaming.rb
95
105
  - features/product.feature
96
106
  - features/support/env.rb
97
107
  - features/step_definitions/product_steps.rb
@@ -105,23 +115,27 @@ rdoc_options: []
105
115
  require_paths:
106
116
  - lib
107
117
  required_ruby_version: !ruby/object:Gem::Requirement
118
+ none: false
108
119
  requirements:
109
120
  - - ">="
110
121
  - !ruby/object:Gem::Version
122
+ hash: 3
111
123
  segments:
112
124
  - 0
113
125
  version: "0"
114
126
  required_rubygems_version: !ruby/object:Gem::Requirement
127
+ none: false
115
128
  requirements:
116
129
  - - ">="
117
130
  - !ruby/object:Gem::Version
131
+ hash: 3
118
132
  segments:
119
133
  - 0
120
134
  version: "0"
121
135
  requirements: []
122
136
 
123
137
  rubyforge_project: ur-product
124
- rubygems_version: 1.3.6
138
+ rubygems_version: 1.3.7
125
139
  signing_key:
126
140
  specification_version: 3
127
141
  summary: API wrapper for the Utbildningsradion product services