amazon-ecs 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/README +39 -23
  2. data/lib/amazon/ecs.rb +2 -2
  3. data/test/amazon/ecs_test.rb +11 -1
  4. metadata +12 -18
  5. data/CHANGELOG +0 -46
data/README CHANGED
@@ -17,22 +17,22 @@ instead you just need to update the element path.
17
17
 
18
18
  == EXAMPLE
19
19
 
20
- require "amazon/ecs"
20
+ require 'amazon/ecs'
21
21
 
22
22
  # set the default options; options will be camelized and converted to REST request parameters.
23
- Amazon::Ecs.options = {:aWS_access_key_id => "[your access key]"}
23
+ Amazon::Ecs.options = {:aWS_access_key_id => '[your access key]'}
24
24
 
25
25
  # to generate signed requests include your secret key:
26
- Amazon::Ecs.options = {:aWS_access_key_id => "[your developer token]", :aWS_secret_key => "[your secret access key]"}
26
+ Amazon::Ecs.options = {:aWS_access_key_id => '[your developer token]', :aWS_secret_key => '[your secret access key]'}
27
27
 
28
28
  # alternatively,
29
29
  Amazon::Ecs.configure do |options|
30
- options[:aWS_access_key_id] = "[your access key]"
31
- options[:aWS_secret_key] = "[you secret key]"
30
+ options[:aWS_access_key_id] = '[your access key]'
31
+ options[:aWS_secret_key] = '[you secret key]'
32
32
  end
33
33
 
34
34
  # options provided on method call will merge with the default options
35
- res = Amazon::Ecs.item_search("ruby", {:response_group => "Medium", :sort => "salesrank"})
35
+ res = Amazon::Ecs.item_search('ruby', {:response_group => 'Medium', :sort => 'salesrank'})
36
36
 
37
37
  # some common response object methods
38
38
  res.is_valid_request? # return true if request is valid
@@ -45,31 +45,31 @@ instead you just need to update the element path.
45
45
  # traverse through each item (Amazon::Element)
46
46
  res.items.each do |item|
47
47
  # retrieve string value using XML path
48
- item.get("asin")
49
- item.get("itemattributes/title")
48
+ item.get('asin')
49
+ item.get('itemattributes/title')
50
50
 
51
51
  # return Amazon::Element instance
52
- item_attributes = item.get_element("itemattributes")
53
- item_attributes.get("title")
52
+ item_attributes = item.get_element('itemattributes')
53
+ item_attributes.get('title')
54
54
 
55
55
  # return first author or a string array of authors
56
- item_attributes.get("author") # "Author 1"
57
- item_attributes.get_array("author") # ["Author 1", "Author 2", ...]
56
+ item_attributes.get('author') # 'Author 1'
57
+ item_attributes.get_array('author') # ['Author 1', 'Author 2', ...]
58
58
 
59
59
  # return an hash of children text values with the element names as the keys
60
- item.get_hash("smallimage") # {:url => ..., :width => ..., :height => ...}
60
+ item.get_hash('smallimage') # {:url => ..., :width => ..., :height => ...}
61
61
 
62
62
  # return the first matching path as Amazon::Element
63
- item_height = item.get_element("itemdimensions/height")
63
+ item_height = item.get_element('itemdimensions/height')
64
64
 
65
65
  # retrieve attributes from Amazon::Element
66
- item_height.attributes["units"] # "hundredths-inches"
66
+ item_height.attributes['units'] # 'hundredths-inches'
67
67
 
68
68
  # return an array of Amazon::Element
69
- authors = item.get_elements("author")
69
+ authors = item.get_elements('author')
70
70
 
71
71
  # return Hpricot::Elements object or nil if not found
72
- reviews = item/"editorialreview"
72
+ reviews = item/'editorialreview'
73
73
 
74
74
  # traverse through Hpricot elements
75
75
  reviews.each do |review|
@@ -77,21 +77,37 @@ instead you just need to update the element path.
77
77
  Amazon::Element.get_hash(review) # [:source => ..., :content ==> ...]
78
78
 
79
79
  # Or to get unescaped HTML values
80
- Amazon::Element.get_unescaped(review, "source")
81
- Amazon::Element.get_unescaped(review, "content")
80
+ Amazon::Element.get_unescaped(review, 'source')
81
+ Amazon::Element.get_unescaped(review, 'content')
82
82
 
83
83
  # Or this way
84
84
  el = Amazon::Element.new(review)
85
- el.get_unescaped("source")
86
- el.get_unescaped("content")
85
+ el.get_unescaped('source')
86
+ el.get_unescaped('content')
87
87
  end
88
88
  end
89
+
90
+ # Extend Amazon::Ecs, replace 'other_operation' with the appropriate name
91
+ module Amazon
92
+ class Ecs
93
+ def self.other_operation(item_id, opts={})
94
+ opts[:operation] = '[other valid operation supported by Product Advertising API]'
95
+
96
+ # setting default option value
97
+ opts[:item_id] = item_id
98
+
99
+ self.send_request(opts)
100
+ end
101
+ end
102
+ end
103
+
104
+ Amazon::Ecs.other_operation('[item_id]', :param1 => 'abc', :param2 => 'xyz')
89
105
 
90
106
  Refer to Amazon Product Advertising API documentation for more information
91
- on Amazon REST request parameters and XML output:
107
+ on other valid operations, request parameters and the XML response output:
92
108
  https://affiliate-program.amazon.com/gp/advertising/api/detail/main.html
93
109
 
94
- To get a sample of Amazon REST response XML output, use AWSZone.com scratch pad:
110
+ To get a sample of Amazon REST XML response output, use AWSZone.com scratch pad:
95
111
  http://www.awszone.com/scratchpads/aws/ecs.us/index.aws
96
112
 
97
113
  == SOURCE CODES
@@ -241,7 +241,7 @@ module Amazon
241
241
 
242
242
  def self.url_encode(string)
243
243
  string.gsub( /([^a-zA-Z0-9_.~-]+)/ ) do
244
- '%' + $1.unpack( 'H2' * $1.size ).join( '%' ).upcase
244
+ '%' + $1.unpack( 'H2' * $1.bytesize ).join( '%' ).upcase
245
245
  end
246
246
  end
247
247
 
@@ -379,4 +379,4 @@ module Amazon
379
379
  elem.to_s if elem
380
380
  end
381
381
  end
382
- end
382
+ end
@@ -1,4 +1,9 @@
1
- require File.dirname(__FILE__) + '/../test_helper'
1
+ # coding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'test/unit'
5
+
6
+ require './' + File.dirname(__FILE__) + '/../../lib/amazon/ecs'
2
7
 
3
8
  class Amazon::EcsTest < Test::Unit::TestCase
4
9
 
@@ -150,4 +155,9 @@ class Amazon::EcsTest < Test::Unit::TestCase
150
155
  item_height = item.get_element("itemdimensions/height")
151
156
  assert_equal "hundredths-inches", item_height.attributes['units']
152
157
  end
158
+
159
+ def test_multibyte_search
160
+ resp = Amazon::Ecs.item_search("パソコン")
161
+ assert(resp.is_valid_request?)
162
+ end
153
163
  end
metadata CHANGED
@@ -1,21 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: amazon-ecs
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
5
4
  prerelease: false
6
5
  segments:
7
6
  - 1
8
- - 1
7
+ - 2
9
8
  - 0
10
- version: 1.1.0
9
+ version: 1.2.0
11
10
  platform: ruby
12
11
  authors:
13
12
  - Herryanto Siatono
14
- autorequire: name
13
+ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2010-11-11 00:00:00 +08:00
17
+ date: 2011-02-07 00:00:00 +08:00
19
18
  default_executable:
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
@@ -26,7 +25,6 @@ dependencies:
26
25
  requirements:
27
26
  - - ">="
28
27
  - !ruby/object:Gem::Version
29
- hash: 3
30
28
  segments:
31
29
  - 0
32
30
  - 4
@@ -41,7 +39,6 @@ dependencies:
41
39
  requirements:
42
40
  - - ">="
43
41
  - !ruby/object:Gem::Version
44
- hash: 23
45
42
  segments:
46
43
  - 0
47
44
  - 3
@@ -49,7 +46,7 @@ dependencies:
49
46
  version: 0.3.2
50
47
  type: :runtime
51
48
  version_requirements: *id002
52
- description:
49
+ description: Generic Amazon Product Advertising Ruby API
53
50
  email: herryanto@gmail.com
54
51
  executables: []
55
52
 
@@ -57,19 +54,18 @@ extensions: []
57
54
 
58
55
  extra_rdoc_files:
59
56
  - README
60
- - CHANGELOG
61
57
  files:
58
+ - README
62
59
  - lib/amazon/ecs.rb
63
60
  - test/amazon/ecs_test.rb
64
- - README
65
- - CHANGELOG
66
61
  has_rdoc: true
67
62
  homepage: https://github.com/jugend/amazon-ecs
68
63
  licenses: []
69
64
 
70
65
  post_install_message:
71
- rdoc_options: []
72
-
66
+ rdoc_options:
67
+ - --inline-source
68
+ - --charset=UTF-8
73
69
  require_paths:
74
70
  - lib
75
71
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -77,7 +73,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
77
73
  requirements:
78
74
  - - ">="
79
75
  - !ruby/object:Gem::Version
80
- hash: 3
81
76
  segments:
82
77
  - 0
83
78
  version: "0"
@@ -86,7 +81,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
81
  requirements:
87
82
  - - ">="
88
83
  - !ruby/object:Gem::Version
89
- hash: 3
90
84
  segments:
91
85
  - 0
92
86
  version: "0"
@@ -95,7 +89,7 @@ requirements: []
95
89
  rubyforge_project:
96
90
  rubygems_version: 1.3.7
97
91
  signing_key:
98
- specification_version: 3
92
+ specification_version: 2
99
93
  summary: Generic Amazon Product Advertising Ruby API
100
- test_files:
101
- - test/amazon/ecs_test.rb
94
+ test_files: []
95
+
data/CHANGELOG DELETED
@@ -1,46 +0,0 @@
1
- 1.1.0 2010-11-11
2
- ----------------
3
- * Add get_elements, get_element, and attributes instance methods in Amazon::Element
4
- * Deprecate Amazon::Element#search_and_convert
5
-
6
- 1.0.0 2010-11-09
7
- ----------------
8
- * Set default Amazon API version to 2010-10-01
9
-
10
- 0.5.7 2009-08-28
11
- ----------------
12
- * Added support for to sign request using openssl with fallback on ruby-hmac
13
-
14
- 0.5.6 2009-07-21
15
- ----------------
16
- * Update parameter value encoding to support special characters
17
-
18
- 0.5.5 2009-07-18
19
- ----------------
20
- * Sign request
21
-
22
- 0.5.4 2008-01-02
23
- ----------------
24
- * Add Response#error_code
25
-
26
- 0.5.3 2007-09-12
27
- ----------------
28
- * send_request to use default options.
29
-
30
- 0.5.2 2007-09-08
31
- ----------------
32
- * Fixed Amazon::Element.get_unescaped error when result returned for given element path is nil
33
-
34
- 0.5.1 2007-02-08
35
- ----------------
36
- * Fixed Amazon Japan and France URL error
37
- * Removed opts.delete(:search_index) from item_lookup, SearchIndex param is allowed
38
- when looking for a book with IdType other than the ASIN.
39
- * Check for defined? RAILS_DEFAULT_LOGGER to avoid exception for non-rails ruby app
40
- * Added check for LOGGER constant if RAILS_DEFAULT_LOGGER is not defined
41
- * Added Ecs.configure(&proc) method for easier configuration of default options
42
- * Added Element#search_and_convert method
43
-
44
- 0.5.0 2006-09-12
45
- ----------------
46
- Initial Release