opera-mobile-store-sdk 0.1.1 → 0.1.2

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: 74b3499c0b6013c04854c3bf42825ffa4193c701
4
- data.tar.gz: 6698b91cbf6ad11d45cea44ac0461579d00e3c3e
3
+ metadata.gz: 7580c98f69eaa74be9332b97b6c508f6189b5e0e
4
+ data.tar.gz: 0aa75ee6c1c38dcf970acd47116ec627bec85549
5
5
  SHA512:
6
- metadata.gz: 70b6f179a33e1f413b1dc95d0a3aca5337f0877ed5221c1d0ac364c4e0b32a80694e25dab4b9b9f3214330bba1139ff41f3536c89db35bf69f06d20c5d51ad62
7
- data.tar.gz: 81f2d3db5b3890fcae6f4f698fd5b0cccd820963e60f7e1eeb093ee18a798d7a9a51a2a16b685d20b852da82af3e620e840dc3a74244ef39cfbc85bf5a77f5a9
6
+ metadata.gz: 9565ba3b577af06ec4a9532d1982ebb90c42152dd7f8f6ef66a977934b5d593a183534dd0420900c27cfb42409aceaca2d174fae3a0d62f021a6ee281f87f3e2
7
+ data.tar.gz: bfed336b46f33cf1aabf435807b77fafdcd54229c2d078c3465fb81a55438a4e486ccb86e5d98a537a4e6f6f0ff3a8cddaedb5c1d3baf722cc5fdaa4260f84e3
@@ -9,11 +9,12 @@ module Opera
9
9
  autoload :ProductLocalization
10
10
  autoload :ProductImage
11
11
  autoload :Category
12
- autoload :Author
13
12
  autoload :Build
14
13
  autoload :BuildFile
15
14
  autoload :Developer
16
15
  autoload :PaymentInfo
16
+
17
+ autoload :InspectableAttributes
17
18
  end
18
19
 
19
20
  module MobileStoreSDK
@@ -1,5 +1,5 @@
1
1
  module Opera
2
2
  module MobileStoreSDK
3
- VERSION = "0.1.1" #
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
@@ -1,129 +1,125 @@
1
- module Opera
2
- module MobileStore
3
- class Build
4
-
5
- include ActiveModel::Model
6
- include ActiveModel::Serialization
7
-
8
- # include Opera::MobileStoreSDK::IdentityMapable
9
-
10
- # All attributes are Read-Only...
11
- attr_accessor :id,
12
- :name,
13
- :platform,
14
- :type,
15
- :installer_type,
16
- :package_name,
17
- :version_name,
18
- :version_code,
19
- :build_update_date,
20
- :files,
21
- :billing,
22
- :languages
23
-
24
- def files
25
- @files ||= []
26
- end
1
+ require "active_model"
2
+
3
+ module Opera::MobileStore
4
+ class Build
5
+
6
+ include ActiveModel::Model
7
+ include ActiveModel::Serialization
8
+
9
+ include Opera::MobileStore::InspectableAttributes
10
+
11
+ # All attributes are Read-Only...
12
+ attr_accessor :id,
13
+ :name,
14
+ :platform,
15
+ :type,
16
+ :installer_type,
17
+ :package_name,
18
+ :version_name,
19
+ :version_code,
20
+ :build_update_date,
21
+ :files,
22
+ :billing,
23
+ :languages
24
+
25
+ def files
26
+ @files ||= []
27
+ end
27
28
 
28
- def languages
29
- @languages ||= []
30
- end
29
+ def languages
30
+ @languages ||= []
31
+ end
31
32
 
32
- def billing
33
- @billing ||= false
34
- end
33
+ def billing
34
+ @billing ||= false
35
+ end
35
36
 
36
- def attributes
37
- [
38
- :id, :name, :platform, :type, :installer_type, :package_name,
39
- :version_name, :version_code, :build_update_date, :files, :billing,
40
- :languages
41
- ].inject({}) do |hash, field_name|
42
- field_value = self.public_send field_name
43
- hash[field_name.to_s] = field_value if field_value.present?
44
- hash
45
- end
37
+ def attributes
38
+ [
39
+ :id, :name, :platform, :type, :installer_type, :package_name,
40
+ :version_name, :version_code, :build_update_date, :files, :billing,
41
+ :languages
42
+ ].inject({}) do |hash, field_name|
43
+ field_value = self.public_send field_name
44
+ hash[field_name.to_s] = field_value if field_value.present?
45
+ hash
46
46
  end
47
+ end
47
48
 
48
- # Override of serializable_hash:
49
- #
50
- # This override will prevent dumping special objects to the hash:
51
- def serializable_hash(options = nil)
52
- attributes.inject({}) do |shsh, keyval|
53
- field_name, field_value = keyval
49
+ # Override of serializable_hash:
50
+ #
51
+ # This override will prevent dumping special objects to the hash:
52
+ def serializable_hash(options = nil)
53
+ attributes.inject({}) do |shsh, keyval|
54
+ field_name, field_value = keyval
54
55
 
55
- if field_name == 'files' # Array of special objects
56
- field_value = field_value.map(&:serializable_hash)
57
- end
58
-
59
- shsh[field_name] = field_value
60
- shsh
56
+ if field_name == 'files' # Array of special objects
57
+ field_value = field_value.map(&:serializable_hash)
61
58
  end
62
- end
63
59
 
64
- def self.build_from_nokogiri_node(node)
60
+ shsh[field_name] = field_value
61
+ shsh
62
+ end
63
+ end
65
64
 
66
- version_code = node.xpath("string(version_code)")
65
+ def self.build_from_nokogiri_node(node)
67
66
 
68
- data = {
69
- id: node.xpath("string(@id)").to_i,
70
- name: node.xpath("string(name)").strip,
71
- platform: node.xpath("string(platform)").strip,
72
- type: node.xpath("string(type)").strip,
73
- installer_type: node.xpath("string(installer_type)").strip,
74
- package_name: node.xpath("string(package_name)").strip,
75
- version_name: node.xpath("string(version_name)").strip,
76
- version_code: version_code.present? ? version_code.to_i : nil,
77
- build_update_date: Time.parse(node.xpath "string(build_update_date)"),
78
- }.select { |key, val| val.present? }
67
+ version_code = node.xpath("string(version_code)")
79
68
 
80
- data[:files] = node.xpath("files/file").map do |f|
81
- BuildFile.build_from_nokogiri_node f
82
- end
69
+ data = {
70
+ id: node.xpath("string(@id)").to_i,
71
+ name: node.xpath("string(name)").strip,
72
+ platform: node.xpath("string(platform)").strip,
73
+ type: node.xpath("string(type)").strip,
74
+ installer_type: node.xpath("string(installer_type)").strip,
75
+ package_name: node.xpath("string(package_name)").strip,
76
+ version_name: node.xpath("string(version_name)").strip,
77
+ version_code: version_code.present? ? version_code.to_i : nil,
78
+ build_update_date: Time.parse(node.xpath "string(build_update_date)"),
79
+ }.select { |key, val| val.present? }
83
80
 
84
- data[:billing] = node.xpath("string(billing)").to_i > 0
81
+ data[:files] = node.xpath("files/file").map do |f|
82
+ BuildFile.build_from_nokogiri_node f
83
+ end
85
84
 
86
- data[:languages] = node.xpath("languages/language").map do |language|
87
- language.attributes["code"].to_s.strip
88
- end
85
+ data[:billing] = node.xpath("string(billing)").to_i > 0
89
86
 
90
- self.new data
87
+ data[:languages] = node.xpath("languages/language").map do |language|
88
+ language.attributes["code"].to_s.strip
91
89
  end
92
90
 
93
- def attributes
94
- [
95
- :id, :name, :platform, :type, :installer_type, :package_name,
96
- :version_name, :version_code, :build_update_date, :files, :billing,
97
- :languages
98
- ].inject({}) do |hash, field_name|
99
- field_value = self.public_send field_name
100
- hash[field_name.to_s] = field_value if field_value.present?
101
- hash
102
- end
103
- end
91
+ self.new data
92
+ end
104
93
 
105
- def inspect
106
- "<#{self.class.name} #{attributes.inspect}>"
94
+ def attributes
95
+ [
96
+ :id, :name, :platform, :type, :installer_type, :package_name,
97
+ :version_name, :version_code, :build_update_date, :files, :billing,
98
+ :languages
99
+ ].inject({}) do |hash, field_name|
100
+ field_value = self.public_send field_name
101
+ hash[field_name.to_s] = field_value if field_value.present?
102
+ hash
107
103
  end
104
+ end
108
105
 
109
- def self.deserialize(serializable_hash)
110
- attributes_hash = serializable_hash.inject({}) do |hsh, keyval|
111
- field_name, field_value = keyval
106
+ def self.deserialize(serializable_hash)
107
+ attributes_hash = serializable_hash.inject({}) do |hsh, keyval|
108
+ field_name, field_value = keyval
112
109
 
113
- case field_name
114
- when 'files'
115
- field_value = field_value.map do |item_serializable_hash|
116
- BuildFile.deserialize item_serializable_hash
117
- end
110
+ case field_name
111
+ when 'files'
112
+ field_value = field_value.map do |item_serializable_hash|
113
+ BuildFile.deserialize item_serializable_hash
118
114
  end
119
-
120
- hsh[field_name] = field_value
121
- hsh
122
115
  end
123
116
 
124
- self.new attributes_hash
117
+ hsh[field_name] = field_value
118
+ hsh
125
119
  end
126
120
 
121
+ self.new attributes_hash
127
122
  end
123
+
128
124
  end
129
125
  end
@@ -1,38 +1,35 @@
1
- module Opera
2
- module MobileStore
3
- class BuildFile
4
-
5
- include ActiveModel::Model
6
- include ActiveModel::Serialization
7
-
8
- # All attributes are Read-Only...
9
- attr_accessor :size, :url
10
-
11
- def attributes
12
- [:size, :url].inject({}) do |hash, field_name|
13
- field_value = self.public_send field_name
14
- hash[field_name.to_s] = field_value if field_value.present?
15
- hash
16
- end
17
- end
1
+ require "active_model"
18
2
 
19
- def self.build_from_nokogiri_node(node)
3
+ module Opera::MobileStore
4
+ class BuildFile
20
5
 
21
- data = { url: node.text.strip }
6
+ include ActiveModel::Model
7
+ include ActiveModel::Serialization
8
+ include Opera::MobileStore::InspectableAttributes
22
9
 
23
- # Extract width + height data:
24
- file_size = node.xpath("string(@size)")
25
- data[:size] = file_size.to_i if file_size.present?
10
+ # All attributes are Read-Only...
11
+ attr_accessor :size, :url
26
12
 
27
- self.new data
13
+ def attributes
14
+ [:size, :url].inject({}) do |hash, field_name|
15
+ field_value = self.public_send field_name
16
+ hash[field_name.to_s] = field_value if field_value.present?
17
+ hash
28
18
  end
19
+ end
29
20
 
30
- def inspect
31
- "<#{self.class.name} #{attributes.inspect}>"
32
- end
21
+ def self.build_from_nokogiri_node(node)
33
22
 
34
- self.singleton_class.send :alias_method, :deserialize, :new
23
+ data = { url: node.text.strip }
35
24
 
25
+ # Extract width + height data:
26
+ file_size = node.xpath("string(@size)")
27
+ data[:size] = file_size.to_i if file_size.present?
28
+
29
+ self.new data
36
30
  end
31
+
32
+ self.singleton_class.send :alias_method, :deserialize, :new
33
+
37
34
  end
38
35
  end
@@ -1,29 +1,27 @@
1
- module Opera
2
- module MobileStore
3
- class Category
1
+ require "active_model"
4
2
 
5
- include ActiveModel::Model
6
- include ActiveModel::Serialization
3
+ module Opera::MobileStore
4
+ class Category
7
5
 
8
- include Opera::MobileStoreSDK::IdentityMapable
6
+ include ActiveModel::Model
7
+ include ActiveModel::Serialization
9
8
 
10
- # All attributes are Read-Only...
11
- attr_accessor :id, :code, :name
9
+ include Opera::MobileStore::InspectableAttributes
12
10
 
13
- def attributes
14
- [:id, :code, :name].inject({}) do |hash, field_name|
15
- field_value = self.public_send field_name
16
- hash[field_name.to_s] = field_value unless field_value.nil?
17
- hash
18
- end
19
- end
11
+ include Opera::MobileStoreSDK::IdentityMapable
12
+
13
+ # All attributes are Read-Only...
14
+ attr_accessor :id, :code, :name
20
15
 
21
- def inspect
22
- "<#{self.class.name} #{attributes.inspect}>"
16
+ def attributes
17
+ [:id, :code, :name].inject({}) do |hash, field_name|
18
+ field_value = self.public_send field_name
19
+ hash[field_name.to_s] = field_value unless field_value.nil?
20
+ hash
23
21
  end
22
+ end
24
23
 
25
- self.singleton_class.send :alias_method, :deserialize, :new
24
+ self.singleton_class.send :alias_method, :deserialize, :new
26
25
 
27
- end
28
26
  end
29
27
  end
@@ -1,70 +1,72 @@
1
1
  require "active_model"
2
2
 
3
- module Opera
4
- module MobileStore
5
- class Developer
6
-
7
- include ActiveModel::Model
8
-
9
- include Opera::MobileStoreSDK::APIAccessible
10
-
11
- # All attributes are Read-Only...
12
- attr_accessor :id, :login, :email, :name,
13
- :address1, :address2,
14
- :city, :state, :zip, :country_code, :website_url,
15
- :orders_email, :contact_email, :payment_info
16
-
17
- def self.build_from_nokogiri_node(node)
18
-
19
- data = { id: node.xpath("string(@id)").to_i }
20
-
21
- login = node.xpath("string(@login)").strip
22
- data[:login] = login if login.present?
23
-
24
- data[:email] = node.xpath("string(email)").strip
25
- data[:name] = node.xpath("string(name)").strip
26
-
27
- data[:address1] = node.xpath("string(address1)").strip
28
- data[:address2] = node.xpath("string(address2)").strip
29
-
30
- [
31
- :city, :state, :zip, :country_code, :website_url,
32
- :orders_email, :contact_email
33
- ].each do |attribute_name|
34
- value = node.xpath("string(#{attribute_name})").strip
35
- data[attribute_name] = value if value.present?
36
- end
37
-
38
- phones = node.xpath("phones").text
39
- byebug if phones.present?
40
-
41
- payment_info = PaymentInfo.build_from_nokogiri_node node.xpath("payment").first
42
- data[:payment_info] = payment_info if payment_info.present?
43
-
44
-
45
- self.new data
3
+ module Opera::MobileStore
4
+ class Developer
5
+
6
+ include ActiveModel::Model
7
+ include ActiveModel::Serialization
8
+
9
+ include Opera::MobileStore::InspectableAttributes
10
+
11
+ include Opera::MobileStoreSDK::APIAccessible
12
+ include Opera::MobileStoreSDK::IdentityMapable
13
+
14
+ # All attributes are Read-Only...
15
+ attr_accessor :id, :login, :email, :name,
16
+ :address1, :address2,
17
+ :city, :state, :zip, :country_code, :website_url,
18
+ :orders_email, :contact_email, :phones, :payment_info
19
+
20
+ def attributes
21
+ [
22
+ :id, :login, :email, :name, :address1, :address2, :city, :state, :zip,
23
+ :country_code, :website_url, :orders_email, :contact_email, :payment_info
24
+ ].inject({}) do |attributes_hash, field_name|
25
+ field_value = public_send field_name
26
+ attributes_hash[field_name.to_s] = field_value if field_value.present?
27
+ attributes_hash
46
28
  end
29
+ end
47
30
 
48
- def attributes
49
- [
50
- :id, :login, :email, :name, :address1, :address2, :city, :state, :zip,
51
- :country_code, :website_url, :orders_email, :contact_email, :payment_info
52
- ].inject({}) do |hash, method|
53
- value = public_send method
54
- hash[method] = value if value.present?
55
- hash
56
- end
57
- end
31
+ # Override of serializable_hash:
32
+ #
33
+ # This override will prevent dumping special objects to the hash:
34
+ def serializable_hash(options = nil)
35
+ attributes.inject({}) do |shsh, keyval|
36
+ field_name, field_value = keyval
58
37
 
59
- def inspect
60
- attr_inspect = attributes.inject [] do |attributes, keyval|
61
- key, val = keyval
62
- attributes + ["#{key}:#{val}"]
63
- end.join(", ")
38
+ # Get the payment_info serializable hash:
39
+ field_value = field_value.serializable_hash \
40
+ if field_name == 'payment_info'
64
41
 
65
- "<#{self.class.name} #{attr_inspect}>"
42
+ shsh[field_name] = field_value
43
+ shsh
66
44
  end
45
+ end
67
46
 
47
+ def self.build_from_nokogiri_node(node)
48
+ data = {
49
+ id: node.xpath("string(@id)").to_i,
50
+ login: node.xpath("string(@login)").strip,
51
+ email: node.xpath("string(email)").strip,
52
+ name: node.xpath("string(name)").strip,
53
+ address1: node.xpath("string(address1)").strip,
54
+ address2: node.xpath("string(address2)").strip,
55
+ city: node.xpath("string(city)").strip,
56
+ state: node.xpath("string(state)").strip,
57
+ zip: node.xpath("string(zip)").strip,
58
+ country_code: node.xpath("string(country_code)").strip,
59
+ website_url: node.xpath("string(website_url)").strip,
60
+ orders_email: node.xpath("string(orders_email)").strip,
61
+ contact_email: node.xpath("string(contact_email)").strip,
62
+ phones: node.xpath("phones").text
63
+ }.select { |key, value| value.present? }
64
+
65
+ payment_info = PaymentInfo.build_from_nokogiri_node node.xpath("payment").first
66
+ data[:payment_info] = payment_info if payment_info.present?
67
+
68
+ self.new data
68
69
  end
70
+
69
71
  end
70
72
  end