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.
@@ -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:
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{big_door}
5
- s.version = "0.0.2"
5
+ s.version = "0.0.3"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Alex L. Demidov"]
@@ -36,5 +36,5 @@ $log.debug( $log.datetime_format)
36
36
 
37
37
 
38
38
  module BigDoor
39
- VERSION = '0.0.2'
39
+ VERSION = '0.0.3'
40
40
  end
@@ -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
@@ -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 = %s', decoded_response.inspect )
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
@@ -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: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
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-03 00:00:00 +03:00
18
+ date: 2011-02-24 00:00:00 +03:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency