ur-product 0.5 → 0.6
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/lib/ur/product/related_product_id.rb +14 -0
- data/lib/ur/product/storage.rb +1 -1
- data/lib/ur/product.rb +43 -9
- data/lib/ur-product.rb +1 -0
- metadata +4 -3
data/lib/ur/product/storage.rb
CHANGED
data/lib/ur/product.rb
CHANGED
|
@@ -15,7 +15,8 @@ module UR
|
|
|
15
15
|
:main_title, :remainder_of_title, :producing_company,
|
|
16
16
|
:created_at, :modified_at, :format, :duration, :aspect_ratio,
|
|
17
17
|
:product_type, :product_sub_type, :typical_age_ranges,
|
|
18
|
-
:publication_date, :storages, :distribution_events, :
|
|
18
|
+
:publication_date, :storages, :distribution_events, :difficulty,
|
|
19
|
+
:sli, :sli_sub, :sab, :sao, :related_product_ids
|
|
19
20
|
|
|
20
21
|
def initialize(data)
|
|
21
22
|
product_data = data.include?('product') ? data['product'] : data
|
|
@@ -24,10 +25,14 @@ module UR
|
|
|
24
25
|
|
|
25
26
|
self.class.define_boolean_methods([
|
|
26
27
|
'distribution_events', 'storages', 'typical_age_ranges', 'languages',
|
|
27
|
-
'duration', 'difficulty', 'producing_company', '
|
|
28
|
-
'sab', 'sao'
|
|
28
|
+
'duration', 'difficulty', 'producing_company', 'production_year',
|
|
29
|
+
'obsolete_order_id', 'sli', 'sli_sub', 'sab', 'sao'
|
|
30
|
+
])
|
|
31
|
+
self.class.define_relation_boolean_methods([
|
|
32
|
+
'siblings', 'packageseries', 'packageusageseries', 'website',
|
|
33
|
+
'packagedvd', 'packagecd', 'programtv', 'programradio',
|
|
34
|
+
'trailertrailer'
|
|
29
35
|
])
|
|
30
|
-
self.class.define_relation_boolean_methods(['siblings'])
|
|
31
36
|
end
|
|
32
37
|
|
|
33
38
|
def self.find(id)
|
|
@@ -45,7 +50,7 @@ module UR
|
|
|
45
50
|
names.each do |name|
|
|
46
51
|
define_method("has_#{name}?") do
|
|
47
52
|
instance_variable = instance_variable_get("@#{name}")
|
|
48
|
-
!(instance_variable.nil? || instance_variable.empty?)
|
|
53
|
+
!(instance_variable.nil? || instance_variable.to_s.empty?)
|
|
49
54
|
end
|
|
50
55
|
end
|
|
51
56
|
end
|
|
@@ -76,7 +81,8 @@ module UR
|
|
|
76
81
|
'created', 'modified', 'pubdate',
|
|
77
82
|
'format', 'duration', 'aspect_ratio',
|
|
78
83
|
'product_type', 'product_sub_type',
|
|
79
|
-
'typicalagerange', '
|
|
84
|
+
'typicalagerange', 'difficulty',
|
|
85
|
+
'sli', 'sli_sub', 'sab', 'sao'
|
|
80
86
|
]
|
|
81
87
|
|
|
82
88
|
field_names = lambda do |name|
|
|
@@ -115,8 +121,9 @@ module UR
|
|
|
115
121
|
|
|
116
122
|
# Handle the data structures
|
|
117
123
|
[
|
|
118
|
-
['distributionevent', 'distribution_events', DistributionEvent],
|
|
119
|
-
['storage', 'storages', Storage]
|
|
124
|
+
['distributionevent', 'distribution_events', UR::Product::DistributionEvent],
|
|
125
|
+
['storage', 'storages', UR::Product::Storage],
|
|
126
|
+
['relation_haspart', 'related_product_ids', UR::Product::RelatedProductId],
|
|
120
127
|
].each do |name, variable, structure_class|
|
|
121
128
|
data = product_data[name]
|
|
122
129
|
instance_variable_set("@#{variable}", (!data.nil? && data.size > 0) ?
|
|
@@ -165,7 +172,7 @@ module UR
|
|
|
165
172
|
if matched = duration.match(/^(\d\d):(\d\d):(\d\d)/)
|
|
166
173
|
(full,h,m,s) = matched.to_a
|
|
167
174
|
if h == '00'
|
|
168
|
-
"#{m} minuter"
|
|
175
|
+
"#{m.to_i} minuter"
|
|
169
176
|
elsif h == '00' && m == '00'
|
|
170
177
|
'Under en minut'
|
|
171
178
|
else
|
|
@@ -201,5 +208,32 @@ module UR
|
|
|
201
208
|
def has_relations?
|
|
202
209
|
(!@related_products.nil? && @related_products.size > 0)
|
|
203
210
|
end
|
|
211
|
+
|
|
212
|
+
def get_storage_location(format)
|
|
213
|
+
storage = storages.map { |s| s if s.storage_format == format }.compact
|
|
214
|
+
storage.empty? ? false : storage.first.location
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
def url
|
|
218
|
+
return @url unless @url.nil?
|
|
219
|
+
|
|
220
|
+
if product_type == 'website'
|
|
221
|
+
@url = get_storage_location('url')
|
|
222
|
+
elsif respond_to?(:website)
|
|
223
|
+
if website.first.nil?
|
|
224
|
+
@url = false
|
|
225
|
+
else
|
|
226
|
+
@url = website.first.get_storage_location('url')
|
|
227
|
+
end
|
|
228
|
+
else
|
|
229
|
+
@url = false
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
@url
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
def has_url?
|
|
236
|
+
(url)
|
|
237
|
+
end
|
|
204
238
|
end
|
|
205
239
|
end
|
data/lib/ur-product.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
require File.dirname(__FILE__) + '/ur/metadata_cache'
|
|
2
2
|
require File.dirname(__FILE__) + '/ur/product'
|
|
3
3
|
require File.dirname(__FILE__) + '/ur/product/distribution_event.rb'
|
|
4
|
+
require File.dirname(__FILE__) + '/ur/product/related_product_id.rb'
|
|
4
5
|
require File.dirname(__FILE__) + '/ur/product/storage.rb'
|
|
5
6
|
require File.dirname(__FILE__) + '/ur/search'
|
|
6
7
|
|
metadata
CHANGED
|
@@ -4,8 +4,8 @@ version: !ruby/object:Gem::Version
|
|
|
4
4
|
prerelease: false
|
|
5
5
|
segments:
|
|
6
6
|
- 0
|
|
7
|
-
-
|
|
8
|
-
version: "0.
|
|
7
|
+
- 6
|
|
8
|
+
version: "0.6"
|
|
9
9
|
platform: ruby
|
|
10
10
|
authors:
|
|
11
11
|
- Peter Hellberg
|
|
@@ -13,7 +13,7 @@ autorequire:
|
|
|
13
13
|
bindir: bin
|
|
14
14
|
cert_chain: []
|
|
15
15
|
|
|
16
|
-
date: 2010-05-
|
|
16
|
+
date: 2010-05-17 00:00:00 +02:00
|
|
17
17
|
default_executable:
|
|
18
18
|
dependencies:
|
|
19
19
|
- !ruby/object:Gem::Dependency
|
|
@@ -88,6 +88,7 @@ files:
|
|
|
88
88
|
- lib/ur/metadata_cache.rb
|
|
89
89
|
- lib/ur/product.rb
|
|
90
90
|
- lib/ur/product/distribution_event.rb
|
|
91
|
+
- lib/ur/product/related_product_id.rb
|
|
91
92
|
- lib/ur/product/storage.rb
|
|
92
93
|
- lib/ur/search.rb
|
|
93
94
|
- features/product.feature
|