acts-as-atdw 0.0.2 → 0.0.3
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/VERSION +1 -1
- data/acts-as-atdw.gemspec +2 -1
- data/lib/client.rb +9 -1
- data/lib/hashit.rb +12 -0
- metadata +3 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.3
|
data/acts-as-atdw.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "acts-as-atdw"
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Yuri Tomanek"]
|
@@ -26,6 +26,7 @@ Gem::Specification.new do |s|
|
|
26
26
|
"acts-as-atdw.gemspec",
|
27
27
|
"lib/acts_as_atdw.rb",
|
28
28
|
"lib/client.rb",
|
29
|
+
"lib/hashit.rb",
|
29
30
|
"test/helper.rb",
|
30
31
|
"test/test_acts-as-atdw.rb"
|
31
32
|
]
|
data/lib/client.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'xmlsimple'
|
2
|
+
require 'hashit'
|
2
3
|
|
3
4
|
module ActsAsAtdw
|
4
5
|
class Client
|
@@ -32,7 +33,14 @@ module ActsAsAtdw
|
|
32
33
|
if result["error"] && result["error"] == ["No rows returned"]
|
33
34
|
return []
|
34
35
|
elsif result["product_distribution"]
|
35
|
-
|
36
|
+
results = []
|
37
|
+
|
38
|
+
result["product_distribution"].each do |result|
|
39
|
+
results << Hashit.new(result["product_record"].first)
|
40
|
+
#results << result
|
41
|
+
end
|
42
|
+
|
43
|
+
return results
|
36
44
|
else
|
37
45
|
return []
|
38
46
|
end
|
data/lib/hashit.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
class Hashit
|
2
|
+
def initialize(hash)
|
3
|
+
hash.each do |k,v|
|
4
|
+
if v.class == "Array" && v.size == 1
|
5
|
+
v = v.first
|
6
|
+
end
|
7
|
+
self.instance_variable_set("@#{k}", v) ## create and initialize an instance variable for this key/value pair
|
8
|
+
self.class.send(:define_method, k, proc{self.instance_variable_get("@#{k}")}) ## create the getter that returns the instance variable
|
9
|
+
self.class.send(:define_method, "#{k}=", proc{|v| self.instance_variable_set("@#{k}", v)}) ## create the setter that sets the instance variable
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: acts-as-atdw
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Yuri Tomanek
|
@@ -97,6 +97,7 @@ files:
|
|
97
97
|
- acts-as-atdw.gemspec
|
98
98
|
- lib/acts_as_atdw.rb
|
99
99
|
- lib/client.rb
|
100
|
+
- lib/hashit.rb
|
100
101
|
- test/helper.rb
|
101
102
|
- test/test_acts-as-atdw.rb
|
102
103
|
homepage: http://github.com/yuritomanek/acts-as-atdw
|
@@ -112,7 +113,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
112
113
|
requirements:
|
113
114
|
- - ">="
|
114
115
|
- !ruby/object:Gem::Version
|
115
|
-
hash:
|
116
|
+
hash: 4342781948246999735
|
116
117
|
segments:
|
117
118
|
- 0
|
118
119
|
version: "0"
|