bigcartel 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.mkd +38 -38
- data/lib/bigcartel/version.rb +3 -3
- data/lib/bigcartel.rb +236 -236
- data/spec/bigcartel_spec.rb +17 -17
- data/spec/helper.rb +14 -14
- metadata +38 -64
data/README.mkd
CHANGED
@@ -1,39 +1,39 @@
|
|
1
|
-
The Big Cartel Ruby Gem
|
2
|
-
====================
|
3
|
-
A Ruby wrapper for the Big Cartel External REST API.
|
4
|
-
|
5
|
-
Installation
|
6
|
-
------------
|
7
|
-
gem install bigcartel
|
8
|
-
|
9
|
-
Usage
|
10
|
-
------
|
11
|
-
require 'rubygems'
|
12
|
-
require 'bigcartel'
|
13
|
-
require 'pp'
|
14
|
-
|
15
|
-
s = BigCartel.store("tonkapark")
|
16
|
-
|
17
|
-
pp s.description
|
18
|
-
|
19
|
-
s.products.each do |product|
|
20
|
-
pp product.name
|
21
|
-
pp product.image.thumb
|
22
|
-
end
|
23
|
-
|
24
|
-
|
25
|
-
s = BigCartel.store("ugmonk")
|
26
|
-
#return products by category
|
27
|
-
products = s.products_by_category("prints")
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
Copyright
|
32
|
-
---------
|
33
|
-
Copyright (c) 2011 Matt Anderson
|
34
|
-
|
35
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
36
|
-
|
37
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
38
|
-
|
1
|
+
The Big Cartel Ruby Gem
|
2
|
+
====================
|
3
|
+
A Ruby wrapper for the Big Cartel External REST API.
|
4
|
+
|
5
|
+
Installation
|
6
|
+
------------
|
7
|
+
gem install bigcartel
|
8
|
+
|
9
|
+
Usage
|
10
|
+
------
|
11
|
+
require 'rubygems'
|
12
|
+
require 'bigcartel'
|
13
|
+
require 'pp'
|
14
|
+
|
15
|
+
s = BigCartel.store("tonkapark")
|
16
|
+
|
17
|
+
pp s.description
|
18
|
+
|
19
|
+
s.products.each do |product|
|
20
|
+
pp product.name
|
21
|
+
pp product.image.thumb
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
s = BigCartel.store("ugmonk")
|
26
|
+
#return products by category
|
27
|
+
products = s.products_by_category("prints")
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
Copyright
|
32
|
+
---------
|
33
|
+
Copyright (c) 2011 Matt Anderson
|
34
|
+
|
35
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
36
|
+
|
37
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
38
|
+
|
39
39
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/lib/bigcartel/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
module BigCartel
|
2
|
-
VERSION = "0.2.
|
3
|
-
end
|
1
|
+
module BigCartel
|
2
|
+
VERSION = "0.2.2"
|
3
|
+
end
|
data/lib/bigcartel.rb
CHANGED
@@ -1,236 +1,236 @@
|
|
1
|
-
require 'httparty'
|
2
|
-
require 'uri'
|
3
|
-
|
4
|
-
module BigCartel
|
5
|
-
|
6
|
-
# Alias for BigCartel::Store.find
|
7
|
-
#
|
8
|
-
# @return [BigCartel::Store]
|
9
|
-
def self.store(subdomain)
|
10
|
-
BigCartel::Store.find(subdomain)
|
11
|
-
end
|
12
|
-
|
13
|
-
# Delegate to BigCartel::Store
|
14
|
-
def self.method_missing(method, *args, &block)
|
15
|
-
return super unless client.respond_to?(method)
|
16
|
-
client.send(method, *args, &block)
|
17
|
-
end
|
18
|
-
|
19
|
-
class Base
|
20
|
-
include HTTParty
|
21
|
-
base_uri "http://api.bigcartel.com"
|
22
|
-
headers 'Content-Type' => 'application/json'
|
23
|
-
|
24
|
-
attr_reader :subdomain
|
25
|
-
|
26
|
-
def initialize(subdomain)
|
27
|
-
@subdomain = subdomain
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
31
|
-
|
32
|
-
class Store < Base
|
33
|
-
|
34
|
-
attr_reader :id, :description, :categories, :website, :products_count, :pages, :name, :url, :currency, :country, :artists, :currency_sign, :products
|
35
|
-
|
36
|
-
def initialize(id, data={})
|
37
|
-
@id = id
|
38
|
-
@description = data['description']
|
39
|
-
@website = data['website']
|
40
|
-
@products_count = data['products_count']
|
41
|
-
@pages = data['pages'].map{|p| Page.add(id, data['url'], p)} unless data['pages'].blank?
|
42
|
-
@name = data['name']
|
43
|
-
@url = data['url']
|
44
|
-
@currency = data['currency']['code']
|
45
|
-
@currency_sign = data['currency']['sign']
|
46
|
-
@country = data['country']['name']
|
47
|
-
@categories = data['categories'].blank? ? [] : data['categories'].map{|cat| Category.new(data['url'], cat)}
|
48
|
-
@artists = data['artists'].blank? ? [] : data['artists'].map{|cat| Artist.new(data['url'], cat)}
|
49
|
-
@products = Product.all(@id, @url)
|
50
|
-
end
|
51
|
-
|
52
|
-
def self.find(id)
|
53
|
-
Store.new(id, self.fetch(id))
|
54
|
-
end
|
55
|
-
|
56
|
-
def product_find(permalink)
|
57
|
-
#self.products.select{|f| f["permalink"] == permalink}
|
58
|
-
@products.each do |p|
|
59
|
-
if p.permalink == permalink
|
60
|
-
return p
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
def page(permalink)
|
66
|
-
self.pages.each do |p|
|
67
|
-
return p if p.permalink == permalink
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
def category(permalink)
|
72
|
-
self.categories.each do |cat, idx|
|
73
|
-
return cat if cat.permalink == permalink
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
def artist(permalink)
|
78
|
-
self.artists.each do |a, idx|
|
79
|
-
return a if a.permalink == permalink
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
def products_by_category(cat)
|
84
|
-
result = []
|
85
|
-
if self.categories.size > 0
|
86
|
-
self.products.each do |p|
|
87
|
-
cats = {}
|
88
|
-
if p.categories.size > 0
|
89
|
-
cats = p.categories.collect {|c| c.permalink}
|
90
|
-
result << p if cats.include?(cat)
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
result
|
95
|
-
end
|
96
|
-
|
97
|
-
def products_by_artist(slug)
|
98
|
-
result = []
|
99
|
-
if self.artists.size > 0
|
100
|
-
self.products.each do |p|
|
101
|
-
temp = {}
|
102
|
-
if p.artists.size > 0
|
103
|
-
temp = p.artists.collect {|a| a.permalink}
|
104
|
-
result << p if temp.include?(slug)
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
result
|
109
|
-
end
|
110
|
-
|
111
|
-
protected
|
112
|
-
def self.fetch(id)
|
113
|
-
get("/#{id}/store.js", :headers => {'Accept' => 'application/json'})
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
|
118
|
-
class Artist < Base
|
119
|
-
attr_reader :name, :url, :id, :permalink
|
120
|
-
def initialize(store_url, data={})
|
121
|
-
@name = data['name']
|
122
|
-
@url = "#{store_url}#{data['url']}"
|
123
|
-
@id = data['id']
|
124
|
-
@permalink = data['permalink']
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
class Category < Artist
|
129
|
-
end
|
130
|
-
|
131
|
-
|
132
|
-
class Image < Base
|
133
|
-
attr_reader :height, :width, :url, :thumb, :medium, :large
|
134
|
-
def initialize(data={})
|
135
|
-
url_parts = data['url'].scan(/(
|
136
|
-
|
137
|
-
@height = data['height']
|
138
|
-
@width = data['width']
|
139
|
-
@url = data['url']
|
140
|
-
@thumb = "#{url_parts[0][0]}75.#{url_parts[0][
|
141
|
-
@medium = "#{url_parts[0][0]}175.#{url_parts[0][
|
142
|
-
@large = "#{url_parts[0][0]}300.#{url_parts[0][
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|
146
|
-
|
147
|
-
class Page < Base
|
148
|
-
attr_reader :id, :name, :permalink, :url, :content, :category
|
149
|
-
def initialize(store_url, data={})
|
150
|
-
@id = data['id']
|
151
|
-
@name = data['name']
|
152
|
-
@permalink = data['permalink']
|
153
|
-
@url = "#{store_url}/#{data['permalink']}"
|
154
|
-
@content = data['content']
|
155
|
-
@category = data['category']
|
156
|
-
end
|
157
|
-
|
158
|
-
def self.add(id, store_url, page)
|
159
|
-
page_permalink = page['permalink']
|
160
|
-
Page.new(store_url, self.fetch(id, page_permalink))
|
161
|
-
end
|
162
|
-
|
163
|
-
protected
|
164
|
-
def self.fetch(id, page)
|
165
|
-
get(URI.encode("/#{id}/page/#{page}.js"), :headers => {'Accept' => 'application/json'})
|
166
|
-
end
|
167
|
-
end
|
168
|
-
|
169
|
-
class Product < Base
|
170
|
-
attr_reader :name, :permalink, :url, :full_url, :description, :artists, :on_sale, :status, :categories, :price, :position, :url, :id, :tax, :images, :shipping, :options,:default_price,:image, :image_count
|
171
|
-
def initialize(store_url, data={})
|
172
|
-
@name = data['name']
|
173
|
-
@description = data['description']
|
174
|
-
@artists = data['artists'].blank? ? [] : data['artists'].map{|cat| Artist.new(data['url'], cat)}
|
175
|
-
@on_sale= data['on_sale']
|
176
|
-
@status = data['status']
|
177
|
-
@categories = data['categories'].blank? ? [] : data['categories'].map{|cat| Category.new(data['url'], cat)}
|
178
|
-
@price = data['price']
|
179
|
-
@default_price = data['default_price']
|
180
|
-
@position = data['position']
|
181
|
-
@full_url = "#{store_url}#{data['url']}"
|
182
|
-
@url = "#{data['url']}"
|
183
|
-
@id = data['id']
|
184
|
-
@tax = data['tax']
|
185
|
-
@permalink = data['permalink']
|
186
|
-
@images = data['images'].blank? ? [] : data['images'].map{|img| Image.new(img)}
|
187
|
-
@image_count = data['images'].blank? ? 0 : data['images'].size
|
188
|
-
@shipping = data['shipping'].map{|ship| Shipping.new(ship)} unless data['shipping'].blank?
|
189
|
-
@options = data['options'].map{|opt| ProductOption.new(opt)} unless data['options'].blank?
|
190
|
-
@image = Image.new(data['images'][0]) unless data['images'].blank?
|
191
|
-
end
|
192
|
-
|
193
|
-
def has_default_option
|
194
|
-
names = {}
|
195
|
-
if self.options.size <= 1
|
196
|
-
names = self.options.collect {|x| x.name }
|
197
|
-
end
|
198
|
-
return names.include?("Default")
|
199
|
-
end
|
200
|
-
|
201
|
-
def option
|
202
|
-
self.options.first
|
203
|
-
end
|
204
|
-
|
205
|
-
|
206
|
-
def self.all(id, store_url)
|
207
|
-
self.fetch(id).map{|p| Product.new(store_url, p)}
|
208
|
-
end
|
209
|
-
|
210
|
-
protected
|
211
|
-
def self.fetch(id)
|
212
|
-
get("/#{id}/products.js", :headers => {'Accept' => 'application/json'})
|
213
|
-
end
|
214
|
-
end
|
215
|
-
|
216
|
-
|
217
|
-
class ProductOption < Base
|
218
|
-
attr_reader :name, :id,:has_custom_price, :price
|
219
|
-
def initialize(data={})
|
220
|
-
@name = data['name']
|
221
|
-
@id = data['id']
|
222
|
-
@has_custom_price = data['has_custom_price']
|
223
|
-
@price = data['price']
|
224
|
-
end
|
225
|
-
end
|
226
|
-
|
227
|
-
class Shipping < Base
|
228
|
-
attr_reader :amount_alone, :amount_combined, :country
|
229
|
-
def initialize(data={})
|
230
|
-
@amount_alone = data['amount_alone']
|
231
|
-
@amount_combined = data['amount_with_others']
|
232
|
-
@country = data['country']['code'] unless data['country'].blank?
|
233
|
-
end
|
234
|
-
end
|
235
|
-
|
236
|
-
end
|
1
|
+
require 'httparty'
|
2
|
+
require 'uri'
|
3
|
+
|
4
|
+
module BigCartel
|
5
|
+
|
6
|
+
# Alias for BigCartel::Store.find
|
7
|
+
#
|
8
|
+
# @return [BigCartel::Store]
|
9
|
+
def self.store(subdomain)
|
10
|
+
BigCartel::Store.find(subdomain)
|
11
|
+
end
|
12
|
+
|
13
|
+
# Delegate to BigCartel::Store
|
14
|
+
def self.method_missing(method, *args, &block)
|
15
|
+
return super unless client.respond_to?(method)
|
16
|
+
client.send(method, *args, &block)
|
17
|
+
end
|
18
|
+
|
19
|
+
class Base
|
20
|
+
include HTTParty
|
21
|
+
base_uri "http://api.bigcartel.com"
|
22
|
+
headers 'Content-Type' => 'application/json'
|
23
|
+
|
24
|
+
attr_reader :subdomain
|
25
|
+
|
26
|
+
def initialize(subdomain)
|
27
|
+
@subdomain = subdomain
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
class Store < Base
|
33
|
+
|
34
|
+
attr_reader :id, :description, :categories, :website, :products_count, :pages, :name, :url, :currency, :country, :artists, :currency_sign, :products
|
35
|
+
|
36
|
+
def initialize(id, data={})
|
37
|
+
@id = id
|
38
|
+
@description = data['description']
|
39
|
+
@website = data['website']
|
40
|
+
@products_count = data['products_count']
|
41
|
+
@pages = data['pages'].map{|p| Page.add(id, data['url'], p)} unless data['pages'].blank?
|
42
|
+
@name = data['name']
|
43
|
+
@url = data['url']
|
44
|
+
@currency = data['currency']['code']
|
45
|
+
@currency_sign = data['currency']['sign']
|
46
|
+
@country = data['country']['name']
|
47
|
+
@categories = data['categories'].blank? ? [] : data['categories'].map{|cat| Category.new(data['url'], cat)}
|
48
|
+
@artists = data['artists'].blank? ? [] : data['artists'].map{|cat| Artist.new(data['url'], cat)}
|
49
|
+
@products = Product.all(@id, @url)
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.find(id)
|
53
|
+
Store.new(id, self.fetch(id))
|
54
|
+
end
|
55
|
+
|
56
|
+
def product_find(permalink)
|
57
|
+
#self.products.select{|f| f["permalink"] == permalink}
|
58
|
+
@products.each do |p|
|
59
|
+
if p.permalink == permalink
|
60
|
+
return p
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def page(permalink)
|
66
|
+
self.pages.each do |p|
|
67
|
+
return p if p.permalink == permalink
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def category(permalink)
|
72
|
+
self.categories.each do |cat, idx|
|
73
|
+
return cat if cat.permalink == permalink
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def artist(permalink)
|
78
|
+
self.artists.each do |a, idx|
|
79
|
+
return a if a.permalink == permalink
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def products_by_category(cat)
|
84
|
+
result = []
|
85
|
+
if self.categories.size > 0
|
86
|
+
self.products.each do |p|
|
87
|
+
cats = {}
|
88
|
+
if p.categories.size > 0
|
89
|
+
cats = p.categories.collect {|c| c.permalink}
|
90
|
+
result << p if cats.include?(cat)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
result
|
95
|
+
end
|
96
|
+
|
97
|
+
def products_by_artist(slug)
|
98
|
+
result = []
|
99
|
+
if self.artists.size > 0
|
100
|
+
self.products.each do |p|
|
101
|
+
temp = {}
|
102
|
+
if p.artists.size > 0
|
103
|
+
temp = p.artists.collect {|a| a.permalink}
|
104
|
+
result << p if temp.include?(slug)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
result
|
109
|
+
end
|
110
|
+
|
111
|
+
protected
|
112
|
+
def self.fetch(id)
|
113
|
+
get("/#{id}/store.js", :headers => {'Accept' => 'application/json'})
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
|
118
|
+
class Artist < Base
|
119
|
+
attr_reader :name, :url, :id, :permalink
|
120
|
+
def initialize(store_url, data={})
|
121
|
+
@name = data['name']
|
122
|
+
@url = "#{store_url}#{data['url']}"
|
123
|
+
@id = data['id']
|
124
|
+
@permalink = data['permalink']
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
class Category < Artist
|
129
|
+
end
|
130
|
+
|
131
|
+
|
132
|
+
class Image < Base
|
133
|
+
attr_reader :height, :width, :url, :thumb, :medium, :large
|
134
|
+
def initialize(data={})
|
135
|
+
url_parts = data['url'].scan(/(https?:\/\/.*\/product_images\/\d*\/)(.*).(jpg|png|gif|jpeg)/i)
|
136
|
+
|
137
|
+
@height = data['height']
|
138
|
+
@width = data['width']
|
139
|
+
@url = data['url']
|
140
|
+
@thumb = "#{url_parts[0][0]}75.#{url_parts[0][2]}"
|
141
|
+
@medium = "#{url_parts[0][0]}175.#{url_parts[0][2]}"
|
142
|
+
@large = "#{url_parts[0][0]}300.#{url_parts[0][2]}"
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
|
147
|
+
class Page < Base
|
148
|
+
attr_reader :id, :name, :permalink, :url, :content, :category
|
149
|
+
def initialize(store_url, data={})
|
150
|
+
@id = data['id']
|
151
|
+
@name = data['name']
|
152
|
+
@permalink = data['permalink']
|
153
|
+
@url = "#{store_url}/#{data['permalink']}"
|
154
|
+
@content = data['content']
|
155
|
+
@category = data['category']
|
156
|
+
end
|
157
|
+
|
158
|
+
def self.add(id, store_url, page)
|
159
|
+
page_permalink = page['permalink']
|
160
|
+
Page.new(store_url, self.fetch(id, page_permalink))
|
161
|
+
end
|
162
|
+
|
163
|
+
protected
|
164
|
+
def self.fetch(id, page)
|
165
|
+
get(URI.encode("/#{id}/page/#{page}.js"), :headers => {'Accept' => 'application/json'})
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
class Product < Base
|
170
|
+
attr_reader :name, :permalink, :url, :full_url, :description, :artists, :on_sale, :status, :categories, :price, :position, :url, :id, :tax, :images, :shipping, :options,:default_price,:image, :image_count
|
171
|
+
def initialize(store_url, data={})
|
172
|
+
@name = data['name']
|
173
|
+
@description = data['description']
|
174
|
+
@artists = data['artists'].blank? ? [] : data['artists'].map{|cat| Artist.new(data['url'], cat)}
|
175
|
+
@on_sale= data['on_sale']
|
176
|
+
@status = data['status']
|
177
|
+
@categories = data['categories'].blank? ? [] : data['categories'].map{|cat| Category.new(data['url'], cat)}
|
178
|
+
@price = data['price']
|
179
|
+
@default_price = data['default_price']
|
180
|
+
@position = data['position']
|
181
|
+
@full_url = "#{store_url}#{data['url']}"
|
182
|
+
@url = "#{data['url']}"
|
183
|
+
@id = data['id']
|
184
|
+
@tax = data['tax']
|
185
|
+
@permalink = data['permalink']
|
186
|
+
@images = data['images'].blank? ? [] : data['images'].map{|img| Image.new(img)}
|
187
|
+
@image_count = data['images'].blank? ? 0 : data['images'].size
|
188
|
+
@shipping = data['shipping'].map{|ship| Shipping.new(ship)} unless data['shipping'].blank?
|
189
|
+
@options = data['options'].map{|opt| ProductOption.new(opt)} unless data['options'].blank?
|
190
|
+
@image = Image.new(data['images'][0]) unless data['images'].blank?
|
191
|
+
end
|
192
|
+
|
193
|
+
def has_default_option
|
194
|
+
names = {}
|
195
|
+
if self.options.size <= 1
|
196
|
+
names = self.options.collect {|x| x.name }
|
197
|
+
end
|
198
|
+
return names.include?("Default")
|
199
|
+
end
|
200
|
+
|
201
|
+
def option
|
202
|
+
self.options.first
|
203
|
+
end
|
204
|
+
|
205
|
+
|
206
|
+
def self.all(id, store_url)
|
207
|
+
self.fetch(id).map{|p| Product.new(store_url, p)}
|
208
|
+
end
|
209
|
+
|
210
|
+
protected
|
211
|
+
def self.fetch(id)
|
212
|
+
get("/#{id}/products.js", :headers => {'Accept' => 'application/json'})
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
|
217
|
+
class ProductOption < Base
|
218
|
+
attr_reader :name, :id,:has_custom_price, :price
|
219
|
+
def initialize(data={})
|
220
|
+
@name = data['name']
|
221
|
+
@id = data['id']
|
222
|
+
@has_custom_price = data['has_custom_price']
|
223
|
+
@price = data['price']
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
class Shipping < Base
|
228
|
+
attr_reader :amount_alone, :amount_combined, :country
|
229
|
+
def initialize(data={})
|
230
|
+
@amount_alone = data['amount_alone']
|
231
|
+
@amount_combined = data['amount_with_others']
|
232
|
+
@country = data['country']['code'] unless data['country'].blank?
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
end
|
data/spec/bigcartel_spec.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
describe BigCartel do
|
4
|
-
|
5
|
-
describe ".store" do
|
6
|
-
it "should be a BigCartel::Store" do
|
7
|
-
BigCartel.store("tonkapark").should be_a BigCartel::Store
|
8
|
-
end
|
9
|
-
|
10
|
-
it "should have id" do
|
11
|
-
store = BigCartel.store('tonkapark')
|
12
|
-
store.id.should == 'tonkapark'
|
13
|
-
end
|
14
|
-
|
15
|
-
end
|
16
|
-
|
17
|
-
end
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe BigCartel do
|
4
|
+
|
5
|
+
describe ".store" do
|
6
|
+
it "should be a BigCartel::Store" do
|
7
|
+
BigCartel.store("tonkapark").should be_a BigCartel::Store
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should have id" do
|
11
|
+
store = BigCartel.store('tonkapark')
|
12
|
+
store.id.should == 'tonkapark'
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
data/spec/helper.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
|
-
$:.unshift(File.expand_path('../../lib', __FILE__))
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
require 'bundler'
|
5
|
-
|
6
|
-
Bundler.require(:default, :development)
|
7
|
-
|
8
|
-
require 'bigcartel'
|
9
|
-
|
10
|
-
Rspec.configure do |config|
|
11
|
-
|
12
|
-
config.before(:each) do
|
13
|
-
|
14
|
-
end
|
1
|
+
$:.unshift(File.expand_path('../../lib', __FILE__))
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
|
6
|
+
Bundler.require(:default, :development)
|
7
|
+
|
8
|
+
require 'bigcartel'
|
9
|
+
|
10
|
+
Rspec.configure do |config|
|
11
|
+
|
12
|
+
config.before(:each) do
|
13
|
+
|
14
|
+
end
|
15
15
|
end
|
metadata
CHANGED
@@ -1,64 +1,46 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: bigcartel
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 2
|
9
|
-
- 1
|
10
|
-
version: 0.2.1
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.2
|
5
|
+
prerelease:
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Matt Anderson
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
date: 2011-07-29 00:00:00 -05:00
|
12
|
+
date: 2013-01-13 00:00:00.000000000 -06:00
|
19
13
|
default_executable:
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
22
16
|
name: rspec
|
23
|
-
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
17
|
+
requirement: &2153334880 !ruby/object:Gem::Requirement
|
25
18
|
none: false
|
26
|
-
requirements:
|
19
|
+
requirements:
|
27
20
|
- - ~>
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
|
30
|
-
segments:
|
31
|
-
- 2
|
32
|
-
- 3
|
33
|
-
version: "2.3"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '2.3'
|
34
23
|
type: :development
|
35
|
-
version_requirements: *id001
|
36
|
-
- !ruby/object:Gem::Dependency
|
37
|
-
name: httparty
|
38
24
|
prerelease: false
|
39
|
-
|
25
|
+
version_requirements: *2153334880
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: httparty
|
28
|
+
requirement: &2153334380 !ruby/object:Gem::Requirement
|
40
29
|
none: false
|
41
|
-
requirements:
|
30
|
+
requirements:
|
42
31
|
- - ~>
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
hash: 5
|
45
|
-
segments:
|
46
|
-
- 0
|
47
|
-
- 7
|
48
|
-
- 3
|
32
|
+
- !ruby/object:Gem::Version
|
49
33
|
version: 0.7.3
|
50
34
|
type: :runtime
|
51
|
-
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: *2153334380
|
52
37
|
description: A Ruby wrapper for the Big Cartel External REST API
|
53
|
-
email:
|
38
|
+
email:
|
54
39
|
- matt@tonkapark.com
|
55
40
|
executables: []
|
56
|
-
|
57
41
|
extensions: []
|
58
|
-
|
59
42
|
extra_rdoc_files: []
|
60
|
-
|
61
|
-
files:
|
43
|
+
files:
|
62
44
|
- .gitignore
|
63
45
|
- Gemfile
|
64
46
|
- README.mkd
|
@@ -69,38 +51,30 @@ files:
|
|
69
51
|
- spec/bigcartel_spec.rb
|
70
52
|
- spec/helper.rb
|
71
53
|
has_rdoc: true
|
72
|
-
homepage:
|
54
|
+
homepage: ''
|
73
55
|
licenses: []
|
74
|
-
|
75
56
|
post_install_message:
|
76
57
|
rdoc_options: []
|
77
|
-
|
78
|
-
require_paths:
|
58
|
+
require_paths:
|
79
59
|
- lib
|
80
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
60
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
61
|
none: false
|
82
|
-
requirements:
|
83
|
-
- -
|
84
|
-
- !ruby/object:Gem::Version
|
85
|
-
|
86
|
-
|
87
|
-
- 0
|
88
|
-
version: "0"
|
89
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
67
|
none: false
|
91
|
-
requirements:
|
92
|
-
- -
|
93
|
-
- !ruby/object:Gem::Version
|
94
|
-
|
95
|
-
segments:
|
96
|
-
- 0
|
97
|
-
version: "0"
|
68
|
+
requirements:
|
69
|
+
- - ! '>='
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
98
72
|
requirements: []
|
99
|
-
|
100
73
|
rubyforge_project: bigcartel
|
101
|
-
rubygems_version: 1.
|
74
|
+
rubygems_version: 1.6.2
|
102
75
|
signing_key:
|
103
76
|
specification_version: 3
|
104
77
|
summary: Ruby wrapper for the Big Cartel API
|
105
|
-
test_files:
|
106
|
-
|
78
|
+
test_files:
|
79
|
+
- spec/bigcartel_spec.rb
|
80
|
+
- spec/helper.rb
|