ravelry 0.0.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.
Files changed (50) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +8 -0
  3. data/.rspec +2 -0
  4. data/.ruby-version +1 -0
  5. data/.yardopts +1 -0
  6. data/CODE_OF_CONDUCT.md +22 -0
  7. data/Gemfile +16 -0
  8. data/Gemfile.lock +42 -0
  9. data/LICENSE.txt +20 -0
  10. data/README.md +112 -0
  11. data/VERSION +1 -0
  12. data/lib/ravelry.rb +39 -0
  13. data/lib/ravelry/author.rb +27 -0
  14. data/lib/ravelry/category.rb +57 -0
  15. data/lib/ravelry/configuration.rb +11 -0
  16. data/lib/ravelry/craft.rb +19 -0
  17. data/lib/ravelry/data.rb +25 -0
  18. data/lib/ravelry/pack.rb +135 -0
  19. data/lib/ravelry/pattern.rb +390 -0
  20. data/lib/ravelry/pattern_needle.rb +54 -0
  21. data/lib/ravelry/pattern_type.rb +34 -0
  22. data/lib/ravelry/photo.rb +69 -0
  23. data/lib/ravelry/printing.rb +70 -0
  24. data/lib/ravelry/utils/build.rb +128 -0
  25. data/lib/ravelry/utils/utilities.rb +14 -0
  26. data/lib/ravelry/version.rb +3 -0
  27. data/lib/ravelry/yarn.rb +39 -0
  28. data/lib/ravelry/yarn_weight.rb +48 -0
  29. data/ravelry.gemspec +27 -0
  30. data/spec/helpers/helpers.rb +106 -0
  31. data/spec/helpers/pack_helpers.rb +107 -0
  32. data/spec/helpers/pattern_helpers.rb +190 -0
  33. data/spec/helpers/yarn_helpers.rb +27 -0
  34. data/spec/helpers/yarn_weight_helpers.rb +25 -0
  35. data/spec/ravelry/author_spec.rb +33 -0
  36. data/spec/ravelry/category_spec.rb +46 -0
  37. data/spec/ravelry/craft_spec.rb +22 -0
  38. data/spec/ravelry/data_spec.rb +27 -0
  39. data/spec/ravelry/pack_spec.rb +114 -0
  40. data/spec/ravelry/pattern_needle_spec.rb +52 -0
  41. data/spec/ravelry/pattern_spec.rb +301 -0
  42. data/spec/ravelry/pattern_type_spec.rb +28 -0
  43. data/spec/ravelry/photo_spec.rb +56 -0
  44. data/spec/ravelry/printing_spec.rb +65 -0
  45. data/spec/ravelry/utils/build_spec.rb +187 -0
  46. data/spec/ravelry/yarn_spec.rb +30 -0
  47. data/spec/ravelry/yarn_weight_spec.rb +42 -0
  48. data/spec/ravelry_spec.rb +3 -0
  49. data/spec/spec_helper.rb +30 -0
  50. metadata +154 -0
@@ -0,0 +1,27 @@
1
+ require_relative '../spec_helper'
2
+
3
+ describe Ravelry::Data do
4
+ # testing using Ravelry::Yarn
5
+ context '#get?' do
6
+ it 'returns true if passed id, no data' do
7
+ yarn = y_initialize_empty_yarn
8
+ yarn.id = "1234"
9
+ expect(yarn.send(:get?)).to be_true
10
+ end
11
+
12
+ it 'returns false if passed id, data' do
13
+ yarn = y_initialize_with_data_and_id
14
+ expect(yarn.send(:get?)).to be_false
15
+ end
16
+
17
+ it 'returns false if passed no id, no data' do
18
+ yarn = y_initialize_empty_yarn
19
+ expect(yarn.send(:get?)).to be_false
20
+ end
21
+
22
+ it 'returns false if passed no id, data' do
23
+ yarn = y_initialize_empty_yarn
24
+ expect(yarn.send(:get?)).to be_false
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,114 @@
1
+ require_relative '../spec_helper'
2
+
3
+ describe Ravelry::Pack do
4
+ before do
5
+ @pack = Ravelry::Pack.new
6
+ @pack.data = single_pack
7
+ end
8
+
9
+ it 'creates an instance of Pack' do
10
+ expect(@pack).to be_instance_of(Ravelry::Pack)
11
+ end
12
+
13
+ context 'has and sets reader attributes for' do
14
+ before do
15
+ @data = single_pack
16
+ end
17
+
18
+ it 'quantity_description' do
19
+ expect(@pack.quantity_description).to eq(@data[:quantity_description])
20
+ end
21
+
22
+ it 'yarn_id' do
23
+ expect(@pack.yarn_id).to eq(@data[:yarn_id])
24
+ end
25
+
26
+ it 'total_grams' do
27
+ expect(@pack.total_grams).to eq(@data[:total_grams])
28
+ end
29
+
30
+ it 'project_id' do
31
+ expect(@pack.project_id).to eq(@data[:project_id])
32
+ end
33
+
34
+ it 'shop_id' do
35
+ expect(@pack.shop_id).to eq(@data[:shop_id])
36
+ end
37
+
38
+ it 'prefer_metric_weight' do
39
+ expect(@pack.prefer_metric_weight).to eq(@data[:prefer_metric_weight])
40
+ end
41
+
42
+ it 'prefer_metric_length' do
43
+ expect(@pack.prefer_metric_length).to eq(@data[:prefer_metric_length])
44
+ end
45
+
46
+ it 'ounces_per_skein' do
47
+ expect(@pack.ounces_per_skein).to eq(@data[:ounces_per_skein])
48
+ end
49
+
50
+ it 'dye_lot' do
51
+ expect(@pack.dye_lot).to eq(@data[:dye_lot])
52
+ end
53
+
54
+ it 'skeins' do
55
+ expect(@pack.skeins).to eq(@data[:skeins])
56
+ end
57
+
58
+ it 'id' do
59
+ expect(@pack.id).to eq(@data[:id])
60
+ end
61
+
62
+ it 'grams_per_skein' do
63
+ expect(@pack.grams_per_skein).to eq(@data[:grams_per_skein])
64
+ end
65
+
66
+ it 'color_family_id' do
67
+ expect(@pack.color_family_id).to eq(@data[:color_family_id])
68
+ end
69
+
70
+ it 'shop_name' do
71
+ expect(@pack.shop_name).to eq(@data[:shop_name])
72
+ end
73
+
74
+ it 'total_meters' do
75
+ expect(@pack.total_meters).to eq(@data[:total_meters])
76
+ end
77
+
78
+ it 'stash_id' do
79
+ expect(@pack.stash_id).to eq(@data[:stash_id])
80
+ end
81
+
82
+ it 'total_ounces' do
83
+ expect(@pack.total_ounces).to eq(@data[:total_ounces])
84
+ end
85
+
86
+ it 'primary_pack_id' do
87
+ expect(@pack.primary_pack_id).to eq(@data[:primary_pack_id])
88
+ end
89
+
90
+ it 'personal_name' do
91
+ expect(@pack.personal_name).to eq(@data[:personal_name])
92
+ end
93
+
94
+ it 'colorway' do
95
+ expect(@pack.colorway).to eq(@data[:colorway])
96
+ end
97
+
98
+ it 'meters_per_skein' do
99
+ expect(@pack.meters_per_skein).to eq(@data[:meters_per_skein])
100
+ end
101
+
102
+ it 'yarn_name' do
103
+ expect(@pack.yarn_name).to eq(@data[:yarn_name])
104
+ end
105
+
106
+ it 'yards_per_skein' do
107
+ expect(@pack.yards_per_skein).to eq(@data[:yards_per_skein])
108
+ end
109
+
110
+ it 'total_yards' do
111
+ expect(@pack.total_yards).to eq(@data[:total_yards])
112
+ end
113
+ end
114
+ end
@@ -0,0 +1,52 @@
1
+ require_relative '../spec_helper'
2
+
3
+ describe Ravelry::PatternNeedle do
4
+ before do
5
+ @ndl = Ravelry::PatternNeedle.new(needle)
6
+ @data = needle
7
+ end
8
+
9
+ it 'creates an instance of Needle' do
10
+ expect(@ndl).to be_instance_of(Ravelry::PatternNeedle)
11
+ end
12
+
13
+ context 'has and sets reader attributes for' do
14
+ it 'type' do
15
+ expect(@ndl.type).to eq('knitting')
16
+ end
17
+
18
+ it 'hook' do
19
+ expect(@ndl.hook).to eq(@data[:hook])
20
+ end
21
+
22
+ it 'us' do
23
+ expect(@ndl.us).to eq(@data[:us])
24
+ end
25
+
26
+ it 'metric' do
27
+ expect(@ndl.metric).to eq(@data[:metric])
28
+ end
29
+
30
+ it 'knitting' do
31
+ expect(@ndl.knitting).to eq(@data[:name])
32
+ end
33
+ end
34
+
35
+ context 'class methods' do
36
+ it '#type returns crochet' do
37
+ ndl = { :hook=>"E", :us_steel=>"00", :name=>"US 4 - 3.5 mm",
38
+ :crochet=>true, :metric=>3.5, :knitting=>false, :us=>"4 ",
39
+ :id=>4 }
40
+ needle = Ravelry::PatternNeedle.new(ndl)
41
+ expect(needle.type).to eq('crochet')
42
+ end
43
+
44
+ it '#us_string' do
45
+ expect(@ndl.us_string).to eq('US 4')
46
+ end
47
+
48
+ it '#metric_string' do
49
+ expect(@ndl.metric_string).to eq('3.5 mm')
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,301 @@
1
+ require_relative '../spec_helper'
2
+
3
+ describe Ravelry::Pattern do
4
+
5
+ it 'should be an instance of Patterns' do
6
+ pattern = p_initialize_paid_with_fetch
7
+ expect(pattern).to be_instance_of(Ravelry::Pattern)
8
+ end
9
+
10
+ context '#fetch_and_parse' do
11
+ before do
12
+ @api = p_initialize_paid_with_fetch
13
+ end
14
+
15
+ it 'should succeed' do
16
+ expect(@api).to be
17
+ end
18
+
19
+ it 'should return a pattern' do
20
+ expect(@api.data).to be
21
+ end
22
+
23
+ it 'should return a hash' do
24
+ expect(@api.data).to be_kind_of(Hash)
25
+ end
26
+ end
27
+
28
+ context 'class methods' do
29
+ before do
30
+ @api = p_initialize_with_data
31
+ @data = paid_pattern_stub
32
+ end
33
+
34
+ describe 'pattern data attributes' do
35
+ it 'comments_count' do
36
+ expect(@api.comments_count).to eq(4)
37
+ end
38
+
39
+ it 'comments_count (Integer)' do
40
+ expect(@api.comments_count).to be_kind_of(Integer)
41
+ end
42
+
43
+ it 'currency' do
44
+ expect(@api.currency).to eq(@data[:currency])
45
+ end
46
+
47
+ it 'currency_symbol' do
48
+ expect(@api.currency_symbol).to eq(@data[:currency_symbol])
49
+ end
50
+
51
+ it 'difficulty_average_float (Float)' do
52
+ expect(@api.difficulty_average_float).to be_kind_of(Float)
53
+ end
54
+
55
+ it 'difficulty_average_float' do
56
+ expect(@api.difficulty_average_float).to eq(@data[:difficulty_average])
57
+ end
58
+
59
+ it 'difficulty_average_integer (Integer)' do
60
+ expect(@api.difficulty_average_integer).to be_kind_of(Integer)
61
+ end
62
+
63
+ it 'difficulty_average_integer' do
64
+ expect(@api.difficulty_average_integer).to eq(@data[:difficulty_average].round(0))
65
+ end
66
+
67
+ it 'difficulty_count (Integer)' do
68
+ expect(@api.difficulty_count).to be_kind_of(Integer)
69
+ end
70
+
71
+ it 'difficulty_count' do
72
+ expect(@api.difficulty_count).to eq(@data[:difficulty_count])
73
+ end
74
+
75
+ it 'downloadable?' do
76
+ # testing data is true
77
+ expect(@api.downloadable?).to be_true
78
+ end
79
+
80
+ it 'favorites_count (Integer)' do
81
+ expect(@api.favorites_count).to be_kind_of(Integer)
82
+ end
83
+
84
+ it 'favorites_count' do
85
+ expect(@api.favorites_count).to eq(@data[:favorites_count])
86
+ end
87
+
88
+ it 'free?' do
89
+ # testing data is false
90
+ expect(@api.free?).to be_false
91
+ end
92
+
93
+ it 'gauge' do
94
+ expect(@api.gauge).to eq(@data[:gauge])
95
+ end
96
+
97
+ it 'gauge (Float)' do
98
+ expect(@api.gauge).to be_kind_of(Float)
99
+ end
100
+
101
+ it 'gauge_description' do
102
+ expect(@api.gauge_description).to eq(@data[:gauge_description])
103
+ end
104
+
105
+ it 'gauge_divisor' do
106
+ expect(@api.gauge_divisor).to eq(@data[:gauge_divisor])
107
+ end
108
+
109
+ it 'gauge_divisor (Integer)' do
110
+ expect(@api.gauge_divisor).to be_kind_of(Integer)
111
+ end
112
+
113
+ it 'gauge_pattern' do
114
+ expect(@api.gauge_pattern).to eq(@data[:gauge_pattern])
115
+ end
116
+
117
+ it 'notes_raw' do
118
+ expect(@api.notes_raw).to eq(@data[:notes])
119
+ end
120
+
121
+ it 'notes_html' do
122
+ expect(@api.notes_html).to eq(@data[:notes_html])
123
+ end
124
+
125
+ it 'packs_raw' do
126
+ expect(@api.packs_raw).to eq(@data[:packs])
127
+ end
128
+
129
+ it 'packs_raw (Array)' do
130
+ expect(@api.packs_raw).to be_kind_of(Array)
131
+ end
132
+
133
+ it 'packs_raw[0] (Hash)' do
134
+ expect(@api.packs_raw[0]).to be_kind_of(Hash)
135
+ end
136
+
137
+ it 'pack_count' do
138
+ expect(@api.pack_count).to eq(@data[:packs].length)
139
+ end
140
+
141
+ it 'pack_count (Integer)' do
142
+ expect(@api.pack_count).to be_kind_of(Integer)
143
+ end
144
+
145
+ it 'pattern_author' do
146
+ expect(@api.pattern_author).to eq(@data[:pattern_author])
147
+ end
148
+
149
+ it 'pattern_categories_raw' do
150
+ expect(@api.pattern_categories_raw).to eq(@data[:pattern_categories])
151
+ end
152
+
153
+ it 'pattern_needle_sizes_raw' do
154
+ expect(@api.pattern_needle_sizes_raw).to eq(@data[:pattern_needle_sizes])
155
+ end
156
+
157
+ it 'pattern_type_raw' do
158
+ expect(@api.pattern_type_raw).to eq(@data[:pattern_type])
159
+ end
160
+
161
+ it 'pdf_url' do
162
+ expect(@api.pdf_url).to eq(@data[:pdf_url])
163
+ end
164
+
165
+ it 'permalink' do
166
+ expect(@api.permalink).to eq(@data[:permalink])
167
+ end
168
+
169
+ it 'photos_raw' do
170
+ expect(@api.photos_raw).to eq(@data[:photos])
171
+ end
172
+
173
+ it 'price' do
174
+ expect(@api.price).to eq(@data[:price])
175
+ end
176
+
177
+ # TODO: FAILING?
178
+ # it 'printings' do
179
+ # expect(@api.printings).to eq(@data[:printings])
180
+ # end
181
+
182
+ it 'product_id' do
183
+ expect(@api.product_id).to eq(@data[:product_id])
184
+ end
185
+
186
+ it 'projects_count' do
187
+ expect(@api.projects_count).to eq(@data[:projects_count])
188
+ end
189
+
190
+ it 'projects_count (Integer)' do
191
+ expect(@api.projects_count).to be_kind_of(Integer)
192
+ end
193
+
194
+ it 'published' do
195
+ expect(@api.published).to eq(Date.parse(@data[:published]))
196
+ end
197
+
198
+ it 'published' do
199
+ expect(@api.published).to be_kind_of(Date)
200
+ end
201
+
202
+ it 'queued_projects_count' do
203
+ expect(@api.queued_projects_count).to eq(@data[:queued_projects_count])
204
+ end
205
+
206
+ it 'rating_average' do
207
+ expect(@api.rating_average).to eq(@data[:rating_average])
208
+ end
209
+
210
+ it 'rating_count' do
211
+ expect(@api.rating_count).to eq(@data[:rating_count])
212
+ end
213
+
214
+ it 'ravelry_download?' do
215
+ expect(@api.ravelry_download?).to eq(@data[:ravelry_download])
216
+ end
217
+
218
+ it 'row_gauge' do
219
+ expect(@api.row_gauge).to eq(@data[:row_gauge])
220
+ end
221
+
222
+ it 'sizes_available' do
223
+ expect(@api.sizes_available).to eq(@data[:sizes_available])
224
+ end
225
+
226
+ it 'url' do
227
+ expect(@api.url).to eq(@data[:url])
228
+ end
229
+
230
+ it 'yardage' do
231
+ expect(@api.yardage).to eq(@data[:yardage])
232
+ end
233
+
234
+ it 'yardage_description' do
235
+ expect(@api.yardage_description).to eq(@data[:yardage_description])
236
+ end
237
+
238
+ it 'yardage_max' do
239
+ expect(@api.yardage_max).to eq(@data[:yardage_max])
240
+ end
241
+
242
+ it 'yarn_weight' do
243
+ # TODO figure out why this is failing
244
+ # expect(@api.yarn_weight).to eq(@data[:yarn_weight])
245
+ end
246
+
247
+ it 'yarn_weight_description' do
248
+ expect(@api.yarn_weight_description).to eq(@data[:yarn_weight_description])
249
+ end
250
+
251
+ end
252
+
253
+ # Associated objects
254
+ # Further testing is done under utils/Build
255
+ describe '#build associated objects and readers for' do
256
+ before do
257
+ @api.build
258
+ end
259
+
260
+ it 'author' do
261
+ expect(@api.author).to be
262
+ end
263
+
264
+ it 'categories' do
265
+ expect(@api.categories.length).to be > 0
266
+ end
267
+
268
+ it 'craft' do
269
+ expect(@api.craft).to be_true
270
+ end
271
+
272
+ it 'needles' do
273
+ # expect(@api.needles.length).to be > 0
274
+ end
275
+
276
+ it 'packs' do
277
+ expect(@api.packs.length).to be > 0
278
+ end
279
+
280
+ it 'photos' do
281
+ # expect(@api.photos.length).to be > 0
282
+ end
283
+
284
+ it 'printings' do
285
+ expect(@api.printings.length).to be > 0
286
+ end
287
+
288
+ it 'type' do
289
+ # expect(@api.type).to be_true
290
+ end
291
+
292
+ it 'yarns' do
293
+ expect(@api.yarns.length).to be > 0
294
+ end
295
+
296
+ it 'yarn weights' do
297
+ expect(@api.yarn_weights.length).to be > 0
298
+ end
299
+ end
300
+ end
301
+ end