kernow-ruby-aaws 0.5.4
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +340 -0
- data/INSTALL +259 -0
- data/NEWS +382 -0
- data/README +566 -0
- data/README.rdoc +129 -0
- data/Rakefile +54 -0
- data/example/browse_node_lookup1 +46 -0
- data/example/customer_content_lookup1 +27 -0
- data/example/customer_content_search1 +21 -0
- data/example/example1 +87 -0
- data/example/help1 +25 -0
- data/example/item_lookup1 +55 -0
- data/example/item_lookup2 +55 -0
- data/example/item_search1 +30 -0
- data/example/item_search2 +37 -0
- data/example/item_search3 +23 -0
- data/example/list_lookup1 +29 -0
- data/example/list_search1 +30 -0
- data/example/multiple_operation1 +67 -0
- data/example/seller_listing_lookup1 +30 -0
- data/example/seller_listing_search1 +28 -0
- data/example/seller_lookup1 +45 -0
- data/example/shopping_cart1 +42 -0
- data/example/similarity_lookup1 +48 -0
- data/example/tag_lookup1 +34 -0
- data/example/transaction_lookup1 +26 -0
- data/lib/amazon/aws/cache.rb +141 -0
- data/lib/amazon/aws/search.rb +334 -0
- data/lib/amazon/aws/shoppingcart.rb +504 -0
- data/lib/amazon/aws.rb +1176 -0
- data/lib/amazon/locale.rb +102 -0
- data/lib/amazon.rb +139 -0
- data/ruby-aws.gemspec +57 -0
- data/ruby-aws.spec +177 -0
- data/setup.rb +1306 -0
- data/test/setup.rb +31 -0
- data/test/tc_amazon.rb +20 -0
- data/test/tc_aws.rb +151 -0
- data/test/tc_item_search.rb +21 -0
- data/test/tc_multiple_operation.rb +58 -0
- data/test/tc_operation_request.rb +58 -0
- data/test/tc_serialisation.rb +103 -0
- data/test/tc_shopping_cart.rb +214 -0
- data/test/ts_aws.rb +12 -0
- metadata +99 -0
data/NEWS
ADDED
@@ -0,0 +1,382 @@
|
|
1
|
+
$Id: NEWS,v 1.14 2008/10/03 12:00:57 ianmacd Exp $
|
2
|
+
|
3
|
+
|
4
|
+
0.4.4
|
5
|
+
-----
|
6
|
+
|
7
|
+
It's now possible to have Ruby/AWS use a user configuration file with a name
|
8
|
+
other than .amazonrc. This is achieved by defining $AMAZONRCFILE. If left
|
9
|
+
undefined, the default of .amazonrc is used.
|
10
|
+
|
11
|
+
Locations other than $HOME were not being checked for .amazonrc. This bug has
|
12
|
+
now been fixed.
|
13
|
+
|
14
|
+
|
15
|
+
0.4.3
|
16
|
+
-----
|
17
|
+
|
18
|
+
$AMAZONRCDIR is now searched for .amazonrc before $HOME and the other
|
19
|
+
directories. This allows a user-defined location to be used for the user
|
20
|
+
configuration file.
|
21
|
+
|
22
|
+
There is a new top-level class of exception for Ruby/AWS, Amazon::AmazonError.
|
23
|
+
|
24
|
+
Most non-operational exceptions, such as Amazon::AWS::HTTPError,
|
25
|
+
Amazon::Config::ConfigError, Amazon::AWS::Search::Request::AccessKeyIdError,
|
26
|
+
Amazon::AWS::Search::Request::LocaleError and
|
27
|
+
Amazon::AWS::ShoppingCart::CartError are now immediate subclasses of
|
28
|
+
AmazonError. Previously, they were subclasses of StandardError.
|
29
|
+
|
30
|
+
Amazon::AWS::Error::AWSError was previously a class that generated exceptions,
|
31
|
+
but it's now simply a container class derived from AmazonError. All
|
32
|
+
operational exceptions -- the ones whose class is dynamically created when AWS
|
33
|
+
returns an error -- are now subclasses of AWSError. Previously, they were
|
34
|
+
immediate subclasses of StandardError.
|
35
|
+
|
36
|
+
This has the advantage of allowing all of the exceptions resulting from
|
37
|
+
operational errors to be caught by rescuing just the container class,
|
38
|
+
AWSError.
|
39
|
+
|
40
|
+
|
41
|
+
0.4.2
|
42
|
+
-----
|
43
|
+
|
44
|
+
The version of the Amazon AWS API requested when performing operations is now
|
45
|
+
2008-08-19. This is the latest at the time of writing.
|
46
|
+
|
47
|
+
The exception class Amazon::Config::ConfigError was mysteriously not defined.
|
48
|
+
|
49
|
+
Amazon::Config.new now accepts an optional argument, config_str, which may
|
50
|
+
contain the string equivalent of a config file's contents. When config_str is
|
51
|
+
not nil (nil is the default), this string is read instead of /etc/amazonrc and
|
52
|
+
~/.amazonrc. This addition is really just to aid unit-testing of the
|
53
|
+
Amazon::Config class, as Amazon::Config.new never needs to be called by user
|
54
|
+
code.
|
55
|
+
|
56
|
+
Config file lines may now contain leading whitespace.
|
57
|
+
|
58
|
+
The Amazon::AWS::MAX_PAGES constant has gone, replaced by the PAGINATION hash.
|
59
|
+
Only ItemSearch should use ItemPage to page through results up to MAX_PAGES
|
60
|
+
when ALL_PAGES has been requested, but the same approach was attempted for all
|
61
|
+
types of operation.
|
62
|
+
|
63
|
+
Each operation has its own pagination parameter and its own maximum number of
|
64
|
+
pages that can be fetched. This is now stored in the Amazon::AWS::PAGINATION
|
65
|
+
hash.
|
66
|
+
|
67
|
+
Note that ItemLookup has three possible pagination parameters: OfferPage,
|
68
|
+
VariationPage and ReviewPage. Ruby/AWS uses OfferPage for the purposes of
|
69
|
+
ALL_PAGES.
|
70
|
+
|
71
|
+
Operations that do not explicitly provide a pagination parameter (or, at
|
72
|
+
least, those for which there isn't one listed in the AWS Developer's Guide)
|
73
|
+
use ItemPage and pagination up to page 400. This is likely to throw an
|
74
|
+
exception, as such operations almost certainly don't support multiple results
|
75
|
+
pages.
|
76
|
+
|
77
|
+
|
78
|
+
0.4.1
|
79
|
+
-----
|
80
|
+
|
81
|
+
The exception class Amazon::AWS::HTTPError was not actually defined, which
|
82
|
+
caused an error when an attempt was made to raise it.
|
83
|
+
|
84
|
+
If you're using Windows, %HOME% typically isn't defined. Therefore, the
|
85
|
+
following sequence of paths is now searched for your .amazonrc configuration
|
86
|
+
file:
|
87
|
+
|
88
|
+
%HOME%
|
89
|
+
%HOMEDRIVE% + %HOMEPATH%
|
90
|
+
%USERPROFILE%
|
91
|
+
|
92
|
+
Choose one of these at your convenience.
|
93
|
+
|
94
|
+
The Ruby/AWS gem has been renamed ruby-aaws (from ruby-aws) to avoid a
|
95
|
+
namespace clash with another project. This clash prevented remote installation
|
96
|
+
of the gem.
|
97
|
+
|
98
|
+
|
99
|
+
0.4.0
|
100
|
+
-----
|
101
|
+
|
102
|
+
The version of the Amazon AWS API requested when performing operations is now
|
103
|
+
2008-06-26. This is the latest at the time of writing.
|
104
|
+
|
105
|
+
A new method, Amazon::AWS::ShoppingCart::Cart#cart_get, has been added, to
|
106
|
+
allow the retrieval of an existing shopping-cart from AWS. This is necessary
|
107
|
+
when the original Cart object no longer exists.
|
108
|
+
|
109
|
+
A bug in Amazon::AWS::ShoppingCart::Cart#cart_modify has been fixed, which
|
110
|
+
caused carts with no items in their active section to raise an exception.
|
111
|
+
|
112
|
+
|
113
|
+
0.3.3
|
114
|
+
-----
|
115
|
+
|
116
|
+
YAML.aws_load has been removed. Its functionality is available directly from
|
117
|
+
Amazon::AWS::AWSObject.yaml_load and it wasn't logical or necessary to
|
118
|
+
duplicate that in the YAML class itself. There was no corresponding
|
119
|
+
Marshal.aws_load method, but if there had been, that, too, would have been
|
120
|
+
removed.
|
121
|
+
|
122
|
+
Ruby/AWS is finally available as a RubyGems package and can be found here:
|
123
|
+
|
124
|
+
http://www.caliban.org/files/ruby/ruby-aws-0.3.3.gem
|
125
|
+
|
126
|
+
The enclosed Rakefile can be used to build the gem from scratch. First make
|
127
|
+
sure you have rake and rubygems installed, and then simply type 'rake' in the
|
128
|
+
top level directory of the archive. The gem will be generated and placed in
|
129
|
+
the ./pkg subdirectory, from where you can 'sudo gem install' it.
|
130
|
+
|
131
|
+
This is my first gem, so bear with me. It appears to work properly, but I
|
132
|
+
offer no guarantees. One thing that doesn't currently work is installing the
|
133
|
+
package with gem's -t option to run the supplied unit tests.
|
134
|
+
|
135
|
+
More information about RubyGems can be found here:
|
136
|
+
|
137
|
+
http://www.rubygems.org/
|
138
|
+
|
139
|
+
|
140
|
+
0.3.2
|
141
|
+
-----
|
142
|
+
|
143
|
+
Serialisation, e.g. with Marshal and YAML, has been a problem until now.
|
144
|
+
|
145
|
+
This is because subclasses of Amazon::AWS::AWSObject are created as needed
|
146
|
+
when XML responses from AWS are parsed. Whilst there is no problem dumping
|
147
|
+
objects instantiated from such classes, the difficulty arises when later
|
148
|
+
loading and attempting to reinstantiate them in a new process, because the
|
149
|
+
dynamic classes from which they were spawned no longer exist.
|
150
|
+
|
151
|
+
The solution to the problem comes in the form of the new methods
|
152
|
+
Amazon::AWS::AWSObject.load and Amazon::AWS::AWSObject.yaml_load. Use these as
|
153
|
+
alternatives to Marshal.load and YAML.load, respectively.
|
154
|
+
|
155
|
+
|
156
|
+
0.3.1
|
157
|
+
-----
|
158
|
+
|
159
|
+
This release mostly features refinements to the support for remote
|
160
|
+
shopping-carts.
|
161
|
+
|
162
|
+
The 'Save For Later' area of remote shopping-carts is now implemented.
|
163
|
+
|
164
|
+
Cart#cart_modify now takes an extra parameter, save_for_later. If true, items
|
165
|
+
are moved from the active to the Save For Later area of the cart. If false,
|
166
|
+
they are moved in the opposite direction.
|
167
|
+
|
168
|
+
In both cases, the quantity parameter is ignored, because attempting to pass
|
169
|
+
it through to AWS results in an error, even though the AWS documentation
|
170
|
+
claims this can be done to move partial quantities from one area of the cart
|
171
|
+
to the other.
|
172
|
+
|
173
|
+
Cart objects now have a @saved_for_later_items attribute, aliased to
|
174
|
+
@saved_items and @saved. Take your pick.
|
175
|
+
|
176
|
+
@cart_items is now set to [] when Cart.new is called. Previously, it wasn't set
|
177
|
+
until Cart#cart_create was used, at which time it was set to nil.
|
178
|
+
@saved_for_later_items is also set to [] by Cart.new.
|
179
|
+
|
180
|
+
Cart#include? now also returns true if the item being queried is in the Save
|
181
|
+
For Later area of the cart. Previously, only the active area was inspected.
|
182
|
+
|
183
|
+
New methods, Cart#active? and Cart#saved_for_later? (alias Cart#saved?),
|
184
|
+
return whether or not an item is present in a particular area of the cart. If
|
185
|
+
the item is present, its CartItemId is returned; otherwise 'false'.
|
186
|
+
|
187
|
+
A bug that caused shopping-cart transactions to use the cache if one was
|
188
|
+
requested has been fixed. Shopping-carts should never use the cache under any
|
189
|
+
circumstances.
|
190
|
+
|
191
|
+
Request objects can now have their @cache attribute assigned to. A Cache
|
192
|
+
object may be directly assigned to it, or you may assign the value 'true'. If
|
193
|
+
@cache is set to 'true', a Cache object will automatically be assigned to it
|
194
|
+
the next time @cache is referenced. This is most useful when one wishes to
|
195
|
+
switch from using no cache to using one, or vice versa.
|
196
|
+
|
197
|
+
Cache#flush_expired invariably threw an exception. This bug has been fixed.
|
198
|
+
|
199
|
+
Geolocation of users by host and IP address now raises an
|
200
|
+
Amazon::Locale::GeoError exception if the host or IP address is unresolvable.
|
201
|
+
|
202
|
+
There's a new Ruby/AWS mailing-list for discussion of the development and
|
203
|
+
usage of this library:
|
204
|
+
|
205
|
+
http://www.caliban.org/mailman/listinfo/ruby-aws
|
206
|
+
|
207
|
+
|
208
|
+
0.3.0
|
209
|
+
-----
|
210
|
+
|
211
|
+
The version of the Amazon AWS API requested when performing operations is now
|
212
|
+
2008-04-07. This is the latest at the time of writing.
|
213
|
+
|
214
|
+
Remote shopping-carts are now implemented. See the Amazon::AWS::ShoppingCart
|
215
|
+
module and the Amazon::AWS::ShoppingCart::Cart class in
|
216
|
+
./amazon/aws/shoppingcart.rb for more details.
|
217
|
+
|
218
|
+
Basically, the new methods are Cart.new, Cart#cart_create, Cart#cart_add,
|
219
|
+
Cart#cart_modify and Cart#cart_clear. There's also Cart#each for iterating
|
220
|
+
over the items in a cart.
|
221
|
+
|
222
|
+
This adds the following AWS operations to the list of those supported:
|
223
|
+
|
224
|
+
CartCreate
|
225
|
+
CartAdd
|
226
|
+
CartModify
|
227
|
+
CartClear
|
228
|
+
|
229
|
+
It's currently not possible to update a wishlist at purchase time by referring
|
230
|
+
to the item's ListItemId when adding it to a cart.
|
231
|
+
|
232
|
+
It's also currently not possible to add items to the 'Saved For Later' section
|
233
|
+
of the cart.
|
234
|
+
|
235
|
+
A new iterator method, AWSObject#each, yields each |property, value| of the
|
236
|
+
AWSObject.
|
237
|
+
|
238
|
+
The AWSObject and AWSArray classes have received a few new helper methods that
|
239
|
+
should make AWSObject and single element AWSArray objects behave more akin to
|
240
|
+
strings when they are being compared with strings, matched against regexes,
|
241
|
+
etc.
|
242
|
+
|
243
|
+
An otherwise undocumented method, AWSObject#kernel, provides unnested (i.e.
|
244
|
+
top level) AWSObject objects with a shortcut reference to the data most likely
|
245
|
+
of interest to the user.
|
246
|
+
|
247
|
+
For example, if a top level AWSObject is formed as the result of an
|
248
|
+
ItemSearch, one might normally refer to the items returned with something like
|
249
|
+
this:
|
250
|
+
|
251
|
+
foo.item_search_response[0].items[0].item
|
252
|
+
|
253
|
+
AWSObject#kernel allows the same data to be referred to as follows:
|
254
|
+
|
255
|
+
foo.kernel
|
256
|
+
|
257
|
+
The path to the data is programatically determined, so this method only works
|
258
|
+
for top level AWSObject objects created by a class of operation whose name can
|
259
|
+
be used to derive the path. This is why this method is not documented.
|
260
|
+
|
261
|
+
When searches are performed, greater efforts are now made to determine whether
|
262
|
+
Amazon returned any errors. In particular, batch operations and
|
263
|
+
MultipleOperations may return errors at different locations in the XML tree
|
264
|
+
than normal operations.
|
265
|
+
|
266
|
+
A bug that materialised only when using an HTTP proxy has been fixed.
|
267
|
+
|
268
|
+
|
269
|
+
0.2.0
|
270
|
+
-----
|
271
|
+
|
272
|
+
In previous versions, only 5 types of operation were supported:
|
273
|
+
|
274
|
+
BrowseNodeLookup
|
275
|
+
ItemLookup
|
276
|
+
ItemSearch
|
277
|
+
ListSearch
|
278
|
+
SellerListingSearch
|
279
|
+
|
280
|
+
This version supports all remaining non-shopping-cart operations:
|
281
|
+
|
282
|
+
CustomerContentLookup
|
283
|
+
CustomerContentSearch
|
284
|
+
Help
|
285
|
+
ListLookup
|
286
|
+
SellerListingSearch
|
287
|
+
SellerLookup
|
288
|
+
SimilarityLookup
|
289
|
+
TagLookup
|
290
|
+
TransactionLookup
|
291
|
+
|
292
|
+
Examples of each of these can be found in ./examples/
|
293
|
+
|
294
|
+
It is hoped that shopping-carts will make their debut in the next release of
|
295
|
+
Ruby/AWS.
|
296
|
+
|
297
|
+
One can now use a Symbol for search indices and hash keys when instantiating
|
298
|
+
operation objects and response group objects.
|
299
|
+
|
300
|
+
For example:
|
301
|
+
|
302
|
+
is = ItemSearch.new( 'Books', { 'Title' => 'Ruby' } )
|
303
|
+
rg = ResponseGroup.new( 'Large' )
|
304
|
+
|
305
|
+
can now be written like this:
|
306
|
+
|
307
|
+
is = ItemSearch.new( :Books, { :Title => 'Ruby' } )
|
308
|
+
rg = ResponseGroup.new( :Large )
|
309
|
+
|
310
|
+
It's up to you which form you use. The Symbol form saves one character. :-)
|
311
|
+
|
312
|
+
AWSObject#to_s has been improved to provide something better looking. There's
|
313
|
+
still room for improvement, though.
|
314
|
+
|
315
|
+
AWSObject#to_i has been added. This allows, for example, AWSObjects to be used
|
316
|
+
with the %d format specifier in formatted strings. It's up to you, though, to
|
317
|
+
know when an AWSObject can be expected to contain a String that's usable as an
|
318
|
+
Integer.
|
319
|
+
|
320
|
+
Objects of a class whose name matches AWSObject::.*Image typically have a @url
|
321
|
+
attribute that points to the URL of the image in question. Such objects now
|
322
|
+
have a #get method, which can be used to retrieve the image in question. This
|
323
|
+
method takes a single parameter, an integer precentage, which causes the
|
324
|
+
retrieved image to be overlayed with a discount icon.
|
325
|
+
|
326
|
+
Various compatibility fixes were made to allow Ruby/AWS to work under Ruby
|
327
|
+
1.9. The use of Ruby/AWS with this version is still not recommended, however.
|
328
|
+
For one thing, Ruby 1.9 seems to use #inspect in places that Ruby 1.8 used
|
329
|
+
#to_s.
|
330
|
+
|
331
|
+
|
332
|
+
0.1.0
|
333
|
+
-----
|
334
|
+
|
335
|
+
Version 0.1.0 of Ruby/AWS has undergone fundamental changes from the previous,
|
336
|
+
very crude versions, 0.0.1 and 0.0.2.
|
337
|
+
|
338
|
+
For one thing, the AWS XML parser has been completely rewritten. In this new
|
339
|
+
version, classes are dynamically generated as required, based on the elements
|
340
|
+
present in the XML pages returned by AWS.
|
341
|
+
|
342
|
+
Previous versions of Ruby/AWS (and also Ruby/Amazon), manually defined most
|
343
|
+
of these classes, based on Amazon's developer documentation and examination of
|
344
|
+
AWS XML reponses. This time-consuming, unwieldy and unnecessary approach was
|
345
|
+
largely the result of my own lack of aptitude with the Ruby REXML library.
|
346
|
+
|
347
|
+
While these manually defined classes accounted for much of the data returned
|
348
|
+
by AWS, a smaller section of the data was, nevertheless, dynamically converted
|
349
|
+
to Ruby data structures. This mix of manually and automatically treated
|
350
|
+
objects led to inconsistencies in the Ruby representation of the hierarchical
|
351
|
+
XML structure. This meant that it was not quite possible to look at an AWS XML
|
352
|
+
response and reliably determine how the resulting Ruby data structure would
|
353
|
+
look.
|
354
|
+
|
355
|
+
That inconsistency has been ironed out in version 0.1.0. As of now,
|
356
|
+
_everything_ is dynamically generated from the AWS XML response. All manual
|
357
|
+
class definitions have been removed and all classes are now defined at the
|
358
|
+
time they first need to be instantiated.
|
359
|
+
|
360
|
+
This has the following advantages:
|
361
|
+
|
362
|
+
- Changes in the structure of AWS XML responses will not break Ruby/AWS. They
|
363
|
+
may break user code (if, for example, you depend on the presence of a piece
|
364
|
+
of data that later disappears from AWS responses [and even this should not
|
365
|
+
happen, because AWS v4 has a versioned API]), but they will not break the
|
366
|
+
library. The library will always create whichever classes are needed to
|
367
|
+
represent any given XML structure returned by AWS.
|
368
|
+
|
369
|
+
- Changes in the structure of AWS XML that results in new data being
|
370
|
+
included in responses will automatically cause said data to be made
|
371
|
+
available via Ruby/AWS. If, for example, Amazon starts to return data about
|
372
|
+
the duration of each CD in their catalogue, perhaps using a <Duration> tag,
|
373
|
+
foo.duration would automatically start to return that property.
|
374
|
+
|
375
|
+
- It should be faster, but I haven't verified this.
|
376
|
+
|
377
|
+
Multiple operations are now supported.
|
378
|
+
|
379
|
+
Geolocation of locale is now working.
|
380
|
+
|
381
|
+
Documentation in this version has been radically improved, but is still
|
382
|
+
lacking.
|