api_bucket 1.0.0

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.
Files changed (47) hide show
  1. data/.document +5 -0
  2. data/.gitignore +19 -0
  3. data/.rspec +1 -0
  4. data/Gemfile +11 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +54 -0
  7. data/Rakefile +1 -0
  8. data/VERSION +1 -0
  9. data/api-bucket.gemspec +23 -0
  10. data/lib/api_bucket/amazon/client/http.rb +61 -0
  11. data/lib/api_bucket/amazon/client.rb +73 -0
  12. data/lib/api_bucket/amazon/configration.rb +13 -0
  13. data/lib/api_bucket/amazon/item.rb +63 -0
  14. data/lib/api_bucket/amazon/response.rb +28 -0
  15. data/lib/api_bucket/amazon.rb +12 -0
  16. data/lib/api_bucket/base/client/http.rb +40 -0
  17. data/lib/api_bucket/base/element.rb +54 -0
  18. data/lib/api_bucket/base/item.rb +39 -0
  19. data/lib/api_bucket/base/response.rb +20 -0
  20. data/lib/api_bucket/itunes/client/http.rb +9 -0
  21. data/lib/api_bucket/itunes/client.rb +61 -0
  22. data/lib/api_bucket/itunes/configuration.rb +13 -0
  23. data/lib/api_bucket/itunes/item.rb +71 -0
  24. data/lib/api_bucket/itunes/response.rb +35 -0
  25. data/lib/api_bucket/itunes.rb +13 -0
  26. data/lib/api_bucket/rakuten/client/http.rb +9 -0
  27. data/lib/api_bucket/rakuten/client.rb +80 -0
  28. data/lib/api_bucket/rakuten/configuration.rb +13 -0
  29. data/lib/api_bucket/rakuten/item.rb +52 -0
  30. data/lib/api_bucket/rakuten/response.rb +32 -0
  31. data/lib/api_bucket/rakuten.rb +13 -0
  32. data/lib/api_bucket/version.rb +3 -0
  33. data/lib/api_bucket/yahooauction/client/http.rb +26 -0
  34. data/lib/api_bucket/yahooauction/client.rb +65 -0
  35. data/lib/api_bucket/yahooauction/configuration.rb +13 -0
  36. data/lib/api_bucket/yahooauction/item.rb +29 -0
  37. data/lib/api_bucket/yahooauction/response.rb +39 -0
  38. data/lib/api_bucket/yahooauction.rb +16 -0
  39. data/lib/api_bucket.rb +91 -0
  40. data/spec/api_bucket/amazon_spec.rb +66 -0
  41. data/spec/api_bucket/itunes_spec.rb +65 -0
  42. data/spec/api_bucket/rakuten_spec.rb +67 -0
  43. data/spec/api_bucket/yahooauction_spec.rb +69 -0
  44. data/spec/api_bucket_spec.rb +90 -0
  45. data/spec/secret.rb.skel +14 -0
  46. data/spec/spec_helper.rb +12 -0
  47. metadata +146 -0
@@ -0,0 +1,65 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
4
+
5
+ require File.expand_path(File.dirname(__FILE__) + '/../../lib/api_bucket')
6
+ require File.expand_path(File.dirname(__FILE__) + '/../../lib/api_bucket/itunes')
7
+
8
+ describe "ApiBucket::Itunes" do
9
+
10
+ describe '#search_item' do
11
+ it 'response is ApiBucket::Itunes::Response' do
12
+ service = ApiBucket::Itunes::Client.new
13
+ expect(service.search('ruby').class).to eq ApiBucket::Itunes::Response
14
+ end
15
+
16
+ it 'item in response is ApiBucket::Itunes::Item' do
17
+ service = ApiBucket::Itunes::Client.new
18
+ expect(service.search('ruby').items[0].class).to eq ApiBucket::Itunes::Item
19
+ end
20
+
21
+ it 'can search items' do
22
+ service = ApiBucket::Itunes::Client.new
23
+ response = service.search(Keywords: 'ruby')
24
+ expect(response.items.count).to be > 2
25
+ end
26
+
27
+ it 'is invalid setting' do
28
+ service = ApiBucket::Itunes::Client.new
29
+ expect(service.search(nil).items).to be_empty
30
+ end
31
+ end
32
+
33
+ describe '#lookup' do
34
+ before(:all) do
35
+ service = ApiBucket::Itunes::Client.new
36
+ @response = service.lookup('332209930')
37
+ end
38
+
39
+ it 'is invalid setting' do
40
+ service = ApiBucket::Itunes::Client.new
41
+ expect(service.lookup(nil).items.first).to be_nil
42
+ end
43
+
44
+ it 'can lookup item' do
45
+ expect(@response.items.count).to eq 1
46
+ end
47
+
48
+ it 'can get product_code' do
49
+ expect(@response.items.first.product_code).to match(/[a-zA-Z1-9]+/)
50
+ end
51
+
52
+ it 'can get detail_url' do
53
+ expect(@response.items.first.detail_url).to match(/[a-zA-Z1-9:\/]+/)
54
+ end
55
+
56
+ it 'can get images' do
57
+ expect(@response.items.first.image.count).to be > 2
58
+ end
59
+
60
+ it 'can get image' do
61
+ expect(@response.items.first.image[:l][:url]).to match(/[a-zA-Z1-9:\/]+/)
62
+ end
63
+
64
+ end
65
+ end
@@ -0,0 +1,67 @@
1
+ # coding: utf-8
2
+
3
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
4
+
5
+ require File.expand_path(File.dirname(__FILE__) + '/../../lib/api_bucket')
6
+ require File.expand_path(File.dirname(__FILE__) + '/../../lib/api_bucket/amazon')
7
+ require File.expand_path(File.dirname(__FILE__) + '/../../lib/api_bucket/rakuten')
8
+ require File.expand_path(File.dirname(__FILE__) + '/../../lib/api_bucket/yahooauction')
9
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec/secret')
10
+
11
+ describe "ApiBucket::Rakuten" do
12
+
13
+ describe '#search_item' do
14
+ it 'response is ApiBucket::Rakuten::Response' do
15
+ service = ApiBucket::Rakuten::Client.new
16
+ expect(service.search('ruby').class).to eq ApiBucket::Rakuten::Response
17
+ end
18
+
19
+ it 'item in response is ApiBucket::Rakuten::Item' do
20
+ service = ApiBucket::Rakuten::Client.new
21
+ expect(service.search('ruby').items[0].class).to eq ApiBucket::Rakuten::Item
22
+ end
23
+
24
+ it 'can search items' do
25
+ service = ApiBucket::Rakuten::Client.new
26
+ response = service.search('ruby')
27
+ expect(response.items.count).to be > 2
28
+ end
29
+
30
+ it 'is invalid setting' do
31
+ service = ApiBucket::Rakuten::Client.new
32
+ expect(service.search(nil).items).to be_empty
33
+ end
34
+ end
35
+
36
+ describe '#lookup' do
37
+ before(:all) do
38
+ sleep 3
39
+ service = ApiBucket::Rakuten::Client.new
40
+ @response = service.lookup('book:15917863')
41
+ end
42
+
43
+ it 'is invalid setting' do
44
+ service = ApiBucket::Rakuten::Client.new
45
+ expect(service.lookup(nil).items.first).to be_nil
46
+ end
47
+ it 'can lookup item' do
48
+ expect(@response.items.count).to eq 1
49
+ end
50
+
51
+ it 'can get product_code' do
52
+ expect(@response.items.first.product_code).to match(/[a-zA-Z1-9:]+/)
53
+ end
54
+
55
+ it 'can get detail_url' do
56
+ expect(@response.items.first.detail_url).to match(/[a-zA-Z1-9:\/]+/)
57
+ end
58
+
59
+ it 'can get images' do
60
+ expect(@response.items.first.image.count).to be > 2
61
+ end
62
+
63
+ it 'can get image' do
64
+ expect(@response.items.first.image[:l][:url]).to match(/[a-zA-Z1-9:\/]+/)
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,69 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
4
+
5
+ require File.expand_path(File.dirname(__FILE__) + '/../../lib/api_bucket')
6
+ require File.expand_path(File.dirname(__FILE__) + '/../../lib/api_bucket/amazon')
7
+ require File.expand_path(File.dirname(__FILE__) + '/../../lib/api_bucket/rakuten')
8
+ require File.expand_path(File.dirname(__FILE__) + '/../../lib/api_bucket/yahooauction')
9
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec/secret')
10
+
11
+ describe "ApiBucket::Yahooauction" do
12
+
13
+ context '#search_item' do
14
+ it 'response is ApiBucket::Yahooauction::Response' do
15
+ service = ApiBucket::Yahooauction::Client.new
16
+ expect(service.search('ruby').class).to eq ApiBucket::Yahooauction::Response
17
+ end
18
+
19
+ it 'item in response is ApiBucket::Yahooauction::Item' do
20
+ service = ApiBucket::Yahooauction::Client.new
21
+ expect(service.search('ruby').items[0].class).to eq ApiBucket::Yahooauction::Item
22
+ end
23
+
24
+ it 'can search items' do
25
+ service = ApiBucket::Yahooauction::Client.new
26
+ response = service.search('ruby')
27
+ expect(response.items.count).to be > 2
28
+ end
29
+
30
+ it 'is invalid setting' do
31
+ service = ApiBucket::Yahooauction::Client.new
32
+ expect(service.search(nil).items).to be_empty
33
+ end
34
+ end
35
+
36
+ context '#lookup' do
37
+ before(:all) do
38
+ sleep 1
39
+ service = ApiBucket::Yahooauction::Client.new
40
+ @response = service.lookup('l170668533')
41
+ end
42
+
43
+ it 'is invalid setting' do
44
+ sleep 3
45
+ service = ApiBucket::Yahooauction::Client.new
46
+ expect(service.lookup(nil).items.first).to be_nil
47
+ end
48
+
49
+ it 'can lookup item' do
50
+ expect(@response.items.count).to eq 1
51
+ end
52
+
53
+ it 'can get product_code' do
54
+ expect(@response.items.first.product_code).to match(/[a-zA-Z1-9:]+/)
55
+ end
56
+
57
+ it 'can get detail_url' do
58
+ expect(@response.items.first.detail_url).to match(/[a-zA-Z1-9:\/]+/)
59
+ end
60
+
61
+ it 'can get images' do
62
+ expect(@response.items.first.image.count).to be > 2
63
+ end
64
+
65
+ it 'can get image' do
66
+ expect(@response.items.first.image[:l][:url]).to match(/[a-zA-Z1-9:\/]+/)
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,90 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ require File.expand_path(File.dirname(__FILE__) + '/../lib/api_bucket')
4
+ require File.expand_path(File.dirname(__FILE__) + '/../lib/api_bucket/amazon')
5
+ require File.expand_path(File.dirname(__FILE__) + '/../lib/api_bucket/rakuten')
6
+ require File.expand_path(File.dirname(__FILE__) + '/../lib/api_bucket/yahooauction')
7
+ require File.expand_path(File.dirname(__FILE__) + '/../lib/api_bucket/itunes')
8
+
9
+ describe "ApiBucket" do
10
+
11
+ context 'when we select Amazon ECS' do
12
+ describe 'ApiBucket::Service' do
13
+ it 'can get instance' do
14
+ ApiBucket::Service::instance(:amazon).should be_a_kind_of(ApiBucket::Amazon::Client)
15
+ end
16
+
17
+ it 'can get service code(string)' do
18
+ ApiBucket::Service::code('amazon').should == ApiBucket::Service::SERVICE_AMAZON
19
+ end
20
+
21
+ it 'can get service code(symbol)' do
22
+ ApiBucket::Service::code(:amazon).should == ApiBucket::Service::SERVICE_AMAZON
23
+ end
24
+
25
+ it 'can get service name' do
26
+ ApiBucket::Service::name(ApiBucket::Service::SERVICE_AMAZON).should == :amazon
27
+ end
28
+ end
29
+ end
30
+
31
+ context 'when we select iTunes' do
32
+ describe 'ApiBucket::Service' do
33
+ it 'can get instance' do
34
+ ApiBucket::Service::instance(:itunes).should be_a_kind_of(ApiBucket::Itunes::Client)
35
+ end
36
+
37
+ it 'can get service code(string)' do
38
+ ApiBucket::Service::code('itunes').should == ApiBucket::Service::SERVICE_ITUNES
39
+ end
40
+
41
+ it 'can get service code(symbol)' do
42
+ ApiBucket::Service::code(:itunes).should == ApiBucket::Service::SERVICE_ITUNES
43
+ end
44
+
45
+ it 'can get service name' do
46
+ ApiBucket::Service::name(ApiBucket::Service::SERVICE_ITUNES).should == :itunes
47
+ end
48
+ end
49
+ end
50
+
51
+ context 'when we select Rakuten' do
52
+ describe 'ApiBucket::Service' do
53
+ it 'can get instance' do
54
+ ApiBucket::Service::instance(:rakuten).should be_a_kind_of(ApiBucket::Rakuten::Client)
55
+ end
56
+
57
+ it 'can get service code(string)' do
58
+ ApiBucket::Service::code('rakuten').should == ApiBucket::Service::SERVICE_RAKUTEN
59
+ end
60
+
61
+ it 'can get service code(symbol)' do
62
+ ApiBucket::Service::code(:rakuten).should == ApiBucket::Service::SERVICE_RAKUTEN
63
+ end
64
+
65
+ it 'can get service name' do
66
+ ApiBucket::Service::name(ApiBucket::Service::SERVICE_RAKUTEN).should == :rakuten
67
+ end
68
+ end
69
+ end
70
+
71
+ context 'when we select Yahooauction' do
72
+ describe 'ApiBucket::Service' do
73
+ it 'can get instance' do
74
+ ApiBucket::Service::instance(:yahooauction).should be_a_kind_of(ApiBucket::Yahooauction::Client)
75
+ end
76
+
77
+ it 'can get service code(string)' do
78
+ ApiBucket::Service::code('yahooauction').should == ApiBucket::Service::SERVICE_YAHOOAUCTION
79
+ end
80
+
81
+ it 'can get service code(symbol)' do
82
+ ApiBucket::Service::code(:yahooauction).should == ApiBucket::Service::SERVICE_YAHOOAUCTION
83
+ end
84
+
85
+ it 'can get service name' do
86
+ ApiBucket::Service::name(ApiBucket::Service::SERVICE_YAHOOAUCTION).should == :yahooauction
87
+ end
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,14 @@
1
+ ApiBucket::Rakuten.configure do |o|
2
+ o.application_id = ''
3
+ o.affiliate_id = ''
4
+ end
5
+
6
+ ApiBucket::Amazon.configure do |o|
7
+ o.a_w_s_access_key_id = ''
8
+ o.a_w_s_secret_key = ''
9
+ o.associate_tag = ''
10
+ end
11
+
12
+ ApiBucket::Yahooauction.configure do |o|
13
+ o.appid = ''
14
+ end
@@ -0,0 +1,12 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'api_bucket'
5
+
6
+ # Requires supporting files with custom matchers and macros, etc,
7
+ # in ./support/ and its subdirectories.
8
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
+
10
+ RSpec.configure do |config|
11
+
12
+ end
metadata ADDED
@@ -0,0 +1,146 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: api_bucket
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - nakajijapan
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-02-11 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: nokogiri
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: ruby-hmac
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 2.8.0
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 2.8.0
62
+ description: We can use sevral APIs with common interface.
63
+ email:
64
+ - pp.kupepo.gattyanmo@gmail.com
65
+ executables: []
66
+ extensions: []
67
+ extra_rdoc_files: []
68
+ files:
69
+ - .document
70
+ - .gitignore
71
+ - .rspec
72
+ - Gemfile
73
+ - LICENSE.txt
74
+ - README.md
75
+ - Rakefile
76
+ - VERSION
77
+ - api-bucket.gemspec
78
+ - lib/api_bucket.rb
79
+ - lib/api_bucket/amazon.rb
80
+ - lib/api_bucket/amazon/client.rb
81
+ - lib/api_bucket/amazon/client/http.rb
82
+ - lib/api_bucket/amazon/configration.rb
83
+ - lib/api_bucket/amazon/item.rb
84
+ - lib/api_bucket/amazon/response.rb
85
+ - lib/api_bucket/base/client/http.rb
86
+ - lib/api_bucket/base/element.rb
87
+ - lib/api_bucket/base/item.rb
88
+ - lib/api_bucket/base/response.rb
89
+ - lib/api_bucket/itunes.rb
90
+ - lib/api_bucket/itunes/client.rb
91
+ - lib/api_bucket/itunes/client/http.rb
92
+ - lib/api_bucket/itunes/configuration.rb
93
+ - lib/api_bucket/itunes/item.rb
94
+ - lib/api_bucket/itunes/response.rb
95
+ - lib/api_bucket/rakuten.rb
96
+ - lib/api_bucket/rakuten/client.rb
97
+ - lib/api_bucket/rakuten/client/http.rb
98
+ - lib/api_bucket/rakuten/configuration.rb
99
+ - lib/api_bucket/rakuten/item.rb
100
+ - lib/api_bucket/rakuten/response.rb
101
+ - lib/api_bucket/version.rb
102
+ - lib/api_bucket/yahooauction.rb
103
+ - lib/api_bucket/yahooauction/client.rb
104
+ - lib/api_bucket/yahooauction/client/http.rb
105
+ - lib/api_bucket/yahooauction/configuration.rb
106
+ - lib/api_bucket/yahooauction/item.rb
107
+ - lib/api_bucket/yahooauction/response.rb
108
+ - spec/api_bucket/amazon_spec.rb
109
+ - spec/api_bucket/itunes_spec.rb
110
+ - spec/api_bucket/rakuten_spec.rb
111
+ - spec/api_bucket/yahooauction_spec.rb
112
+ - spec/api_bucket_spec.rb
113
+ - spec/secret.rb.skel
114
+ - spec/spec_helper.rb
115
+ homepage: https://github.com/nakajijapan/api_bucket
116
+ licenses: []
117
+ post_install_message:
118
+ rdoc_options: []
119
+ require_paths:
120
+ - lib
121
+ required_ruby_version: !ruby/object:Gem::Requirement
122
+ none: false
123
+ requirements:
124
+ - - ! '>='
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ required_rubygems_version: !ruby/object:Gem::Requirement
128
+ none: false
129
+ requirements:
130
+ - - ! '>='
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ requirements: []
134
+ rubyforge_project:
135
+ rubygems_version: 1.8.23
136
+ signing_key:
137
+ specification_version: 3
138
+ summary: We can use sevral APIs with common interface
139
+ test_files:
140
+ - spec/api_bucket/amazon_spec.rb
141
+ - spec/api_bucket/itunes_spec.rb
142
+ - spec/api_bucket/rakuten_spec.rb
143
+ - spec/api_bucket/yahooauction_spec.rb
144
+ - spec/api_bucket_spec.rb
145
+ - spec/secret.rb.skel
146
+ - spec/spec_helper.rb