sucker 1.4.0 → 1.4.1

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/README.md CHANGED
@@ -10,7 +10,7 @@ Sucker is fast and supports __the entire Amazon API__.
10
10
  Usage
11
11
  -----
12
12
 
13
- Read the [API](http://aws.amazon.com/archives/Product%20Advertising%20API). Jump to the __Operations__ section if in a hurry.
13
+ Read the [API](http://aws.amazon.com/archives/Product%20Advertising%20API). Skip to the __Operations__ section if in a hurry.
14
14
 
15
15
  Set up.
16
16
 
@@ -58,28 +58,29 @@ To dig further into the response object:
58
58
  response.to_hash,
59
59
  response.xml
60
60
 
61
- Read further [here](http://rdoc.info/github/papercavalier/sucker/master/frames) and [here](http://relishapp.com/papercavalier/sucker).
61
+ Browse the Sucker API [here](http://rdoc.info/github/papercavalier/sucker/master/frames). To see more advanced examples such as twenty-item batch requests and remote cart manipulation, read [here](http://relishapp.com/papercavalier/sucker).
62
62
 
63
- API Usage
64
- ---------
63
+ Managing calls
64
+ --------------
65
65
 
66
- I have a growing cottage industry of gems we use to manage our
67
- consumption of the Amazon API.
66
+ We have a home-grown collection of gems that help us manage our
67
+ calls to the Amazon API.
68
68
 
69
- * [Multiplex](http://github.com/papercavalier/multiplex) binds a request
70
- to a specified local IP.
69
+ * [Multiplex](http://github.com/papercavalier/multiplex) binds a
70
+ request to a specified local IP.
71
71
  * [Throttler](http://github.com/papercavalier/throttler) throttles
72
72
  requests to a venue to one per second per IP.
73
73
 
74
-
75
74
  A hypothetical setup:
76
75
 
77
76
  require 'multiplex'
78
77
  require 'throttler'
79
78
 
80
79
  ips.each do |ip|
80
+
81
81
  Thread.new do
82
82
  scope = "#{ip}-#{locale}"
83
+
83
84
  Throttler.throttle(scope) do
84
85
  Net::HTTP.bind ip do
85
86
  # Set up worker
@@ -87,12 +88,16 @@ A hypothetical setup:
87
88
  # Consume response
88
89
  end
89
90
  end
91
+
90
92
  end
93
+
91
94
  end
92
95
 
93
96
  We prefer to use [Resque](http://github.com/defunkt/resque) to manage
94
- multiple requests. Generally, four or five workers per venue per IP
95
- should provide optimum throughput.
97
+ multiple requests.
98
+
99
+ Generally, four or five workers per locale per IP proves enough to provide
100
+ optimum throughput.
96
101
 
97
102
  Stubbing in Tests
98
103
  -----------------
data/lib/sucker.rb CHANGED
@@ -6,12 +6,12 @@ require 'sucker/response'
6
6
  # Sucker is a Ruby wrapper to the Amazon Product Advertising API.
7
7
  module Sucker
8
8
 
9
- # Initializes a request object
9
+ # Initializes a request object.
10
10
  #
11
11
  # worker = Sucker.new(
12
12
  # :locale => :us,
13
- # :key => 'API KEY',
14
- # :secret => 'API SECRET')
13
+ # :key => api_key,
14
+ # :secret => api_secret)
15
15
  #
16
16
  def self.new(args={})
17
17
  Request.new(args)
data/lib/sucker.rbc CHANGED
@@ -9,7 +9,7 @@ x
9
9
  10
10
10
  __script__
11
11
  i
12
- 55
12
+ 46
13
13
  5
14
14
  7
15
15
  0
@@ -28,39 +28,30 @@ i
28
28
  1
29
29
  1
30
30
  15
31
- 5
32
- 7
33
- 3
34
- 64
35
- 47
36
- 49
37
- 1
38
- 1
39
- 15
40
31
  99
41
32
  7
42
- 4
33
+ 3
43
34
  65
44
35
  49
45
- 5
36
+ 4
46
37
  2
47
38
  13
48
39
  99
49
40
  12
50
41
  7
51
- 6
42
+ 5
52
43
  12
53
44
  7
54
- 7
45
+ 6
55
46
  12
56
47
  65
57
48
  12
58
49
  49
59
- 8
50
+ 7
60
51
  4
61
52
  15
62
53
  49
63
- 6
54
+ 5
64
55
  0
65
56
  15
66
57
  2
@@ -75,17 +66,14 @@ I
75
66
  0
76
67
  n
77
68
  p
78
- 9
69
+ 8
79
70
  s
80
- 17
81
- sucker/parameters
71
+ 14
72
+ sucker/request
82
73
  x
83
74
  7
84
75
  require
85
76
  s
86
- 14
87
- sucker/request
88
- s
89
77
  15
90
78
  sucker/response
91
79
  x
@@ -220,11 +208,11 @@ p
220
208
  I
221
209
  -1
222
210
  I
223
- 13
211
+ 10
224
212
  I
225
213
  e
226
214
  I
227
- 14
215
+ 11
228
216
  I
229
217
  2b
230
218
  x
@@ -243,7 +231,7 @@ p
243
231
  I
244
232
  2
245
233
  I
246
- 13
234
+ 10
247
235
  I
248
236
  d
249
237
  x
@@ -255,25 +243,21 @@ x
255
243
  13
256
244
  attach_method
257
245
  p
258
- 9
246
+ 7
259
247
  I
260
248
  0
261
249
  I
262
- 3
250
+ 1
263
251
  I
264
252
  9
265
253
  I
266
- 4
254
+ 2
267
255
  I
268
256
  12
269
257
  I
270
- 5
271
- I
272
- 1b
273
- I
274
- a
258
+ 7
275
259
  I
276
- 37
260
+ 2e
277
261
  x
278
262
  44
279
263
  /Users/hakanensari/code/sucker/lib/sucker.rb
data/lib/sucker/hash.rb CHANGED
@@ -1,7 +1,14 @@
1
1
  module Sucker
2
+
2
3
  class Hash < ::Hash
3
4
  class << self
4
5
 
6
+ # Builds a hash from a Nokogiri XML document.
7
+ #
8
+ # In earlier versions of Sucker, I was relying on the XML Mini
9
+ # Nokogiri module in Active Support. This method essentially
10
+ # accomplishes the same.
11
+ #
5
12
  # Based on https://gist.github.com/335286
6
13
  def from_xml(xml)
7
14
  case xml
@@ -0,0 +1,914 @@
1
+ !RBIX
2
+ 0
3
+ x
4
+ M
5
+ 1
6
+ n
7
+ n
8
+ x
9
+ 10
10
+ __script__
11
+ i
12
+ 28
13
+ 99
14
+ 7
15
+ 0
16
+ 65
17
+ 49
18
+ 1
19
+ 2
20
+ 13
21
+ 99
22
+ 12
23
+ 7
24
+ 2
25
+ 12
26
+ 7
27
+ 3
28
+ 12
29
+ 65
30
+ 12
31
+ 49
32
+ 4
33
+ 4
34
+ 15
35
+ 49
36
+ 2
37
+ 0
38
+ 15
39
+ 2
40
+ 11
41
+ I
42
+ 6
43
+ I
44
+ 0
45
+ I
46
+ 0
47
+ I
48
+ 0
49
+ n
50
+ p
51
+ 5
52
+ x
53
+ 6
54
+ Sucker
55
+ x
56
+ 11
57
+ open_module
58
+ x
59
+ 15
60
+ __module_init__
61
+ M
62
+ 1
63
+ n
64
+ n
65
+ x
66
+ 6
67
+ Sucker
68
+ i
69
+ 31
70
+ 5
71
+ 66
72
+ 99
73
+ 7
74
+ 0
75
+ 44
76
+ 43
77
+ 0
78
+ 65
79
+ 49
80
+ 1
81
+ 3
82
+ 13
83
+ 99
84
+ 12
85
+ 7
86
+ 2
87
+ 12
88
+ 7
89
+ 3
90
+ 12
91
+ 65
92
+ 12
93
+ 49
94
+ 4
95
+ 4
96
+ 15
97
+ 49
98
+ 2
99
+ 0
100
+ 11
101
+ I
102
+ 6
103
+ I
104
+ 0
105
+ I
106
+ 0
107
+ I
108
+ 0
109
+ n
110
+ p
111
+ 5
112
+ x
113
+ 4
114
+ Hash
115
+ x
116
+ 10
117
+ open_class
118
+ x
119
+ 14
120
+ __class_init__
121
+ M
122
+ 1
123
+ n
124
+ n
125
+ x
126
+ 4
127
+ Hash
128
+ i
129
+ 28
130
+ 5
131
+ 66
132
+ 5
133
+ 99
134
+ 12
135
+ 49
136
+ 0
137
+ 1
138
+ 13
139
+ 99
140
+ 12
141
+ 7
142
+ 1
143
+ 12
144
+ 7
145
+ 2
146
+ 12
147
+ 65
148
+ 12
149
+ 49
150
+ 3
151
+ 4
152
+ 15
153
+ 54
154
+ 50
155
+ 1
156
+ 0
157
+ 11
158
+ I
159
+ 6
160
+ I
161
+ 0
162
+ I
163
+ 0
164
+ I
165
+ 0
166
+ n
167
+ p
168
+ 4
169
+ x
170
+ 16
171
+ object_metaclass
172
+ x
173
+ 18
174
+ __metaclass_init__
175
+ M
176
+ 1
177
+ n
178
+ n
179
+ x
180
+ 18
181
+ __metaclass_init__
182
+ i
183
+ 16
184
+ 5
185
+ 66
186
+ 99
187
+ 7
188
+ 0
189
+ 7
190
+ 1
191
+ 65
192
+ 67
193
+ 49
194
+ 2
195
+ 0
196
+ 49
197
+ 3
198
+ 4
199
+ 11
200
+ I
201
+ 5
202
+ I
203
+ 0
204
+ I
205
+ 0
206
+ I
207
+ 0
208
+ n
209
+ p
210
+ 4
211
+ x
212
+ 8
213
+ from_xml
214
+ M
215
+ 1
216
+ n
217
+ n
218
+ x
219
+ 8
220
+ from_xml
221
+ i
222
+ 144
223
+ 20
224
+ 0
225
+ 13
226
+ 45
227
+ 0
228
+ 1
229
+ 43
230
+ 2
231
+ 43
232
+ 3
233
+ 12
234
+ 49
235
+ 4
236
+ 1
237
+ 9
238
+ 67
239
+ 15
240
+ 5
241
+ 13
242
+ 72
243
+ 5
244
+ 47
245
+ 9
246
+ 36
247
+ 47
248
+ 49
249
+ 6
250
+ 0
251
+ 13
252
+ 47
253
+ 49
254
+ 7
255
+ 0
256
+ 15
257
+ 8
258
+ 40
259
+ 47
260
+ 49
261
+ 5
262
+ 0
263
+ 20
264
+ 0
265
+ 49
266
+ 8
267
+ 0
268
+ 49
269
+ 9
270
+ 0
271
+ 5
272
+ 20
273
+ 0
274
+ 49
275
+ 8
276
+ 0
277
+ 47
278
+ 49
279
+ 10
280
+ 1
281
+ 13
282
+ 18
283
+ 3
284
+ 49
285
+ 11
286
+ 2
287
+ 15
288
+ 8
289
+ 143
290
+ 13
291
+ 45
292
+ 0
293
+ 12
294
+ 43
295
+ 2
296
+ 43
297
+ 13
298
+ 12
299
+ 49
300
+ 4
301
+ 1
302
+ 9
303
+ 134
304
+ 15
305
+ 5
306
+ 13
307
+ 72
308
+ 5
309
+ 47
310
+ 9
311
+ 101
312
+ 47
313
+ 49
314
+ 6
315
+ 0
316
+ 13
317
+ 47
318
+ 49
319
+ 7
320
+ 0
321
+ 15
322
+ 8
323
+ 105
324
+ 47
325
+ 49
326
+ 5
327
+ 0
328
+ 19
329
+ 1
330
+ 15
331
+ 20
332
+ 0
333
+ 49
334
+ 14
335
+ 0
336
+ 56
337
+ 15
338
+ 50
339
+ 16
340
+ 0
341
+ 15
342
+ 20
343
+ 0
344
+ 49
345
+ 17
346
+ 0
347
+ 56
348
+ 18
349
+ 50
350
+ 19
351
+ 0
352
+ 15
353
+ 20
354
+ 1
355
+ 8
356
+ 143
357
+ 15
358
+ 20
359
+ 0
360
+ 49
361
+ 20
362
+ 0
363
+ 49
364
+ 21
365
+ 0
366
+ 11
367
+ I
368
+ 6
369
+ I
370
+ 2
371
+ I
372
+ 1
373
+ I
374
+ 1
375
+ n
376
+ p
377
+ 22
378
+ x
379
+ 8
380
+ Nokogiri
381
+ n
382
+ x
383
+ 3
384
+ XML
385
+ x
386
+ 8
387
+ Document
388
+ x
389
+ 3
390
+ ===
391
+ x
392
+ 3
393
+ new
394
+ x
395
+ 8
396
+ allocate
397
+ x
398
+ 10
399
+ initialize
400
+ x
401
+ 4
402
+ root
403
+ x
404
+ 4
405
+ name
406
+ x
407
+ 8
408
+ from_xml
409
+ x
410
+ 3
411
+ []=
412
+ n
413
+ x
414
+ 7
415
+ Element
416
+ x
417
+ 10
418
+ attributes
419
+ M
420
+ 1
421
+ p
422
+ 2
423
+ x
424
+ 9
425
+ for_block
426
+ t
427
+ n
428
+ x
429
+ 8
430
+ from_xml
431
+ i
432
+ 28
433
+ 58
434
+ 37
435
+ 19
436
+ 0
437
+ 15
438
+ 37
439
+ 19
440
+ 1
441
+ 15
442
+ 15
443
+ 21
444
+ 1
445
+ 1
446
+ 20
447
+ 0
448
+ 20
449
+ 1
450
+ 49
451
+ 0
452
+ 0
453
+ 13
454
+ 18
455
+ 3
456
+ 49
457
+ 1
458
+ 2
459
+ 15
460
+ 11
461
+ I
462
+ 7
463
+ I
464
+ 2
465
+ I
466
+ 2
467
+ I
468
+ 2
469
+ n
470
+ p
471
+ 2
472
+ x
473
+ 5
474
+ value
475
+ x
476
+ 3
477
+ []=
478
+ p
479
+ 5
480
+ I
481
+ 0
482
+ I
483
+ 14
484
+ I
485
+ a
486
+ I
487
+ 15
488
+ I
489
+ 1c
490
+ x
491
+ 49
492
+ /Users/hakanensari/code/sucker/lib/sucker/hash.rb
493
+ p
494
+ 2
495
+ x
496
+ 3
497
+ key
498
+ x
499
+ 9
500
+ attribute
501
+ x
502
+ 9
503
+ each_pair
504
+ x
505
+ 8
506
+ children
507
+ M
508
+ 1
509
+ p
510
+ 2
511
+ x
512
+ 9
513
+ for_block
514
+ t
515
+ n
516
+ x
517
+ 8
518
+ from_xml
519
+ i
520
+ 159
521
+ 57
522
+ 19
523
+ 0
524
+ 15
525
+ 5
526
+ 20
527
+ 0
528
+ 47
529
+ 49
530
+ 0
531
+ 1
532
+ 19
533
+ 1
534
+ 15
535
+ 20
536
+ 0
537
+ 49
538
+ 1
539
+ 0
540
+ 7
541
+ 2
542
+ 64
543
+ 83
544
+ 3
545
+ 9
546
+ 56
547
+ 21
548
+ 1
549
+ 1
550
+ 49
551
+ 4
552
+ 0
553
+ 9
554
+ 39
555
+ 20
556
+ 1
557
+ 31
558
+ 8
559
+ 54
560
+ 21
561
+ 1
562
+ 1
563
+ 7
564
+ 5
565
+ 64
566
+ 20
567
+ 1
568
+ 13
569
+ 18
570
+ 3
571
+ 49
572
+ 6
573
+ 2
574
+ 15
575
+ 8
576
+ 158
577
+ 21
578
+ 1
579
+ 1
580
+ 20
581
+ 0
582
+ 49
583
+ 1
584
+ 0
585
+ 49
586
+ 7
587
+ 1
588
+ 9
589
+ 141
590
+ 21
591
+ 1
592
+ 1
593
+ 20
594
+ 0
595
+ 49
596
+ 1
597
+ 0
598
+ 49
599
+ 7
600
+ 1
601
+ 45
602
+ 8
603
+ 9
604
+ 49
605
+ 10
606
+ 1
607
+ 9
608
+ 106
609
+ 21
610
+ 1
611
+ 1
612
+ 20
613
+ 0
614
+ 49
615
+ 1
616
+ 0
617
+ 49
618
+ 7
619
+ 1
620
+ 20
621
+ 1
622
+ 49
623
+ 11
624
+ 1
625
+ 8
626
+ 139
627
+ 21
628
+ 1
629
+ 1
630
+ 20
631
+ 0
632
+ 49
633
+ 1
634
+ 0
635
+ 21
636
+ 1
637
+ 1
638
+ 20
639
+ 0
640
+ 49
641
+ 1
642
+ 0
643
+ 49
644
+ 7
645
+ 1
646
+ 35
647
+ 1
648
+ 20
649
+ 1
650
+ 49
651
+ 11
652
+ 1
653
+ 13
654
+ 18
655
+ 3
656
+ 49
657
+ 6
658
+ 2
659
+ 15
660
+ 8
661
+ 158
662
+ 21
663
+ 1
664
+ 1
665
+ 20
666
+ 0
667
+ 49
668
+ 1
669
+ 0
670
+ 20
671
+ 1
672
+ 13
673
+ 18
674
+ 3
675
+ 49
676
+ 6
677
+ 2
678
+ 15
679
+ 11
680
+ I
681
+ 7
682
+ I
683
+ 2
684
+ I
685
+ 1
686
+ I
687
+ 1
688
+ n
689
+ p
690
+ 12
691
+ x
692
+ 8
693
+ from_xml
694
+ x
695
+ 4
696
+ name
697
+ s
698
+ 4
699
+ text
700
+ x
701
+ 2
702
+ ==
703
+ x
704
+ 6
705
+ empty?
706
+ s
707
+ 11
708
+ __content__
709
+ x
710
+ 3
711
+ []=
712
+ x
713
+ 2
714
+ []
715
+ x
716
+ 5
717
+ Array
718
+ n
719
+ x
720
+ 5
721
+ is_a?
722
+ x
723
+ 2
724
+ <<
725
+ p
726
+ 23
727
+ I
728
+ 0
729
+ I
730
+ 18
731
+ I
732
+ 4
733
+ I
734
+ 19
735
+ I
736
+ e
737
+ I
738
+ 1b
739
+ I
740
+ 1a
741
+ I
742
+ 1c
743
+ I
744
+ 22
745
+ I
746
+ 1d
747
+ I
748
+ 27
749
+ I
750
+ 1f
751
+ I
752
+ 38
753
+ I
754
+ 21
755
+ I
756
+ 45
757
+ I
758
+ 22
759
+ I
760
+ 58
761
+ I
762
+ 23
763
+ I
764
+ 6a
765
+ I
766
+ 25
767
+ I
768
+ 8d
769
+ I
770
+ 28
771
+ I
772
+ 9f
773
+ x
774
+ 49
775
+ /Users/hakanensari/code/sucker/lib/sucker/hash.rb
776
+ p
777
+ 2
778
+ x
779
+ 5
780
+ child
781
+ x
782
+ 6
783
+ result
784
+ x
785
+ 4
786
+ each
787
+ x
788
+ 7
789
+ content
790
+ x
791
+ 4
792
+ to_s
793
+ p
794
+ 21
795
+ I
796
+ -1
797
+ I
798
+ d
799
+ I
800
+ 0
801
+ I
802
+ e
803
+ I
804
+ 2
805
+ I
806
+ f
807
+ I
808
+ 11
809
+ I
810
+ 10
811
+ I
812
+ 43
813
+ I
814
+ 11
815
+ I
816
+ 52
817
+ I
818
+ 12
819
+ I
820
+ 6c
821
+ I
822
+ 14
823
+ I
824
+ 77
825
+ I
826
+ 18
827
+ I
828
+ 82
829
+ I
830
+ 2c
831
+ I
832
+ 87
833
+ I
834
+ 2e
835
+ I
836
+ 90
837
+ x
838
+ 49
839
+ /Users/hakanensari/code/sucker/lib/sucker/hash.rb
840
+ p
841
+ 2
842
+ x
843
+ 3
844
+ xml
845
+ x
846
+ 11
847
+ result_hash
848
+ x
849
+ 17
850
+ method_visibility
851
+ x
852
+ 15
853
+ add_defn_method
854
+ p
855
+ 3
856
+ I
857
+ 2
858
+ I
859
+ d
860
+ I
861
+ 10
862
+ x
863
+ 49
864
+ /Users/hakanensari/code/sucker/lib/sucker/hash.rb
865
+ p
866
+ 0
867
+ x
868
+ 13
869
+ attach_method
870
+ p
871
+ 3
872
+ I
873
+ 2
874
+ I
875
+ 4
876
+ I
877
+ 1c
878
+ x
879
+ 49
880
+ /Users/hakanensari/code/sucker/lib/sucker/hash.rb
881
+ p
882
+ 0
883
+ x
884
+ 13
885
+ attach_method
886
+ p
887
+ 3
888
+ I
889
+ 2
890
+ I
891
+ 3
892
+ I
893
+ 1f
894
+ x
895
+ 49
896
+ /Users/hakanensari/code/sucker/lib/sucker/hash.rb
897
+ p
898
+ 0
899
+ x
900
+ 13
901
+ attach_method
902
+ p
903
+ 3
904
+ I
905
+ 0
906
+ I
907
+ 1
908
+ I
909
+ 1c
910
+ x
911
+ 49
912
+ /Users/hakanensari/code/sucker/lib/sucker/hash.rb
913
+ p
914
+ 0