big_door 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/History.txt +8 -0
- data/big_door.gemspec +1 -1
- data/lib/big_door.rb +1 -1
- data/lib/big_door/attribute.rb +10 -0
- data/lib/big_door/client.rb +2 -2
- data/lib/big_door/resource.rb +2 -0
- data/spec/big_door/attribute_spec.rb +3 -0
- metadata +4 -4
data/History.txt
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
=== 0.0.3 2011-02-24
|
2
|
+
* 2 minor enhanchement:
|
3
|
+
* add Attribute#search to lookup by attribute_friendly_id
|
4
|
+
* pretty print result object in debug output
|
5
|
+
|
6
|
+
* 1 minor bugfixe
|
7
|
+
* escape single quote in parsed json data
|
8
|
+
|
1
9
|
=== 0.0.2 2011-02-03
|
2
10
|
|
3
11
|
* 1 minor enhancement:
|
data/big_door.gemspec
CHANGED
data/lib/big_door.rb
CHANGED
data/lib/big_door/attribute.rb
CHANGED
@@ -17,5 +17,15 @@ module BigDoor
|
|
17
17
|
$log.debug( "Attribute default_values = #{default_values.inspect}")
|
18
18
|
super( default_values )
|
19
19
|
end
|
20
|
+
def self.search( friendly_id, client )
|
21
|
+
result = client.get( end_point , { 'format' => 'json', 'attribute_friendly_id' => friendly_id } )
|
22
|
+
$log.debug(sprintf 'result = %s', result.inspect );
|
23
|
+
found_objs = result.map{ |obj|
|
24
|
+
$log.debug("obj = #{obj.inspect}")
|
25
|
+
self.new(obj)
|
26
|
+
}
|
27
|
+
$log.debug( "found_objs = #{found_objs.inspect}")
|
28
|
+
found_objs
|
29
|
+
end
|
20
30
|
end
|
21
31
|
end
|
data/lib/big_door/client.rb
CHANGED
@@ -274,9 +274,9 @@ module BigDoor
|
|
274
274
|
}
|
275
275
|
$log.debug("delay #{'%.1f' % (ms.real * 1000)} ms")
|
276
276
|
if response && !response.empty?
|
277
|
-
$log.debug( sprintf 'undecoded_response = %s', response.inspect )
|
277
|
+
# $log.debug( sprintf 'undecoded_response = %s', response.inspect )
|
278
278
|
decoded_response = JSON.parse( response )
|
279
|
-
$log.debug( sprintf 'decoded_response
|
279
|
+
$log.debug( sprintf 'decoded_response = %s', JSON.pretty_generate(decoded_response) )
|
280
280
|
decoded_response[0]
|
281
281
|
end
|
282
282
|
rescue RestClient::Exception => ex
|
data/lib/big_door/resource.rb
CHANGED
@@ -112,6 +112,8 @@ module BigDoor
|
|
112
112
|
$log.debug('update instance from response')
|
113
113
|
response.each do |key, value|
|
114
114
|
key = 'resource_id' if key == 'id'
|
115
|
+
value = value.to_s
|
116
|
+
value.gsub!(/'/, "\\\\'")
|
115
117
|
self.instance_eval("self.#{key} = \'#{value}\'")
|
116
118
|
$log.debug(sprintf "%s = %s", key, self.instance_eval("self.#{key}") )
|
117
119
|
end
|
@@ -9,6 +9,9 @@ module BigDoor
|
|
9
9
|
it "Should respond to :all" do
|
10
10
|
BigDoor::Attribute.should respond_to(:all).with(1).arguments
|
11
11
|
end
|
12
|
+
it "Should respond to :search" do
|
13
|
+
BigDoor::Attribute.should respond_to(:search).with(2).arguments
|
14
|
+
end
|
12
15
|
it "Should load Array of Attributes at the beginning" do
|
13
16
|
currency_types = BigDoor::Attribute.all( @client )
|
14
17
|
currency_types.should be_a_instance_of( Array )
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: big_door
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Alex L. Demidov
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-02-
|
18
|
+
date: 2011-02-24 00:00:00 +03:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|