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.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/.rspec +2 -0
- data/.ruby-version +1 -0
- data/.yardopts +1 -0
- data/CODE_OF_CONDUCT.md +22 -0
- data/Gemfile +16 -0
- data/Gemfile.lock +42 -0
- data/LICENSE.txt +20 -0
- data/README.md +112 -0
- data/VERSION +1 -0
- data/lib/ravelry.rb +39 -0
- data/lib/ravelry/author.rb +27 -0
- data/lib/ravelry/category.rb +57 -0
- data/lib/ravelry/configuration.rb +11 -0
- data/lib/ravelry/craft.rb +19 -0
- data/lib/ravelry/data.rb +25 -0
- data/lib/ravelry/pack.rb +135 -0
- data/lib/ravelry/pattern.rb +390 -0
- data/lib/ravelry/pattern_needle.rb +54 -0
- data/lib/ravelry/pattern_type.rb +34 -0
- data/lib/ravelry/photo.rb +69 -0
- data/lib/ravelry/printing.rb +70 -0
- data/lib/ravelry/utils/build.rb +128 -0
- data/lib/ravelry/utils/utilities.rb +14 -0
- data/lib/ravelry/version.rb +3 -0
- data/lib/ravelry/yarn.rb +39 -0
- data/lib/ravelry/yarn_weight.rb +48 -0
- data/ravelry.gemspec +27 -0
- data/spec/helpers/helpers.rb +106 -0
- data/spec/helpers/pack_helpers.rb +107 -0
- data/spec/helpers/pattern_helpers.rb +190 -0
- data/spec/helpers/yarn_helpers.rb +27 -0
- data/spec/helpers/yarn_weight_helpers.rb +25 -0
- data/spec/ravelry/author_spec.rb +33 -0
- data/spec/ravelry/category_spec.rb +46 -0
- data/spec/ravelry/craft_spec.rb +22 -0
- data/spec/ravelry/data_spec.rb +27 -0
- data/spec/ravelry/pack_spec.rb +114 -0
- data/spec/ravelry/pattern_needle_spec.rb +52 -0
- data/spec/ravelry/pattern_spec.rb +301 -0
- data/spec/ravelry/pattern_type_spec.rb +28 -0
- data/spec/ravelry/photo_spec.rb +56 -0
- data/spec/ravelry/printing_spec.rb +65 -0
- data/spec/ravelry/utils/build_spec.rb +187 -0
- data/spec/ravelry/yarn_spec.rb +30 -0
- data/spec/ravelry/yarn_weight_spec.rb +42 -0
- data/spec/ravelry_spec.rb +3 -0
- data/spec/spec_helper.rb +30 -0
- metadata +154 -0
@@ -0,0 +1,28 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
describe Ravelry::PatternType do
|
4
|
+
before do
|
5
|
+
@type = Ravelry::PatternType.new(pattern_type)
|
6
|
+
@data = pattern_type
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'creates an instance of PatternType' do
|
10
|
+
expect(@type).to be_instance_of(Ravelry::PatternType)
|
11
|
+
end
|
12
|
+
|
13
|
+
context 'has and sets reader attributes for' do
|
14
|
+
it '#permalink' do
|
15
|
+
expect(@type.permalink).to eq(@data[:permalink])
|
16
|
+
end
|
17
|
+
|
18
|
+
it '#name' do
|
19
|
+
expect(@type.name).to eq(@data[:name])
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'class methods' do
|
24
|
+
it '#clothing?' do
|
25
|
+
expect(@type.clothing?).to eq(@data[:clothing])
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
describe Ravelry::Photo do
|
4
|
+
before do
|
5
|
+
@photo = Ravelry::Photo.new
|
6
|
+
@photo.data = photo
|
7
|
+
@data = photo
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'creates an instance of Photo' do
|
11
|
+
expect(@photo).to be_instance_of(Ravelry::Photo)
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'class methods' do
|
15
|
+
it 'get'
|
16
|
+
it 'post'
|
17
|
+
it 'delete'
|
18
|
+
it 'get_sizes'
|
19
|
+
|
20
|
+
it '#flickr_url' do
|
21
|
+
expect(@photo.flickr_url).to eq(@data[:flickr_url])
|
22
|
+
end
|
23
|
+
|
24
|
+
it '#small_url' do
|
25
|
+
expect(@photo.small_url).to eq(@data[:small_url])
|
26
|
+
end
|
27
|
+
|
28
|
+
it '#medium_url' do
|
29
|
+
expect(@photo.medium_url).to eq(@data[:medium_url])
|
30
|
+
end
|
31
|
+
|
32
|
+
it '#square_url' do
|
33
|
+
expect(@photo.square_url).to eq(@data[:square_url])
|
34
|
+
end
|
35
|
+
|
36
|
+
it '#thumbnail_url' do
|
37
|
+
expect(@photo.thumbnail_url).to eq(@data[:thumbnail_url])
|
38
|
+
end
|
39
|
+
|
40
|
+
it '#shelved_url' do
|
41
|
+
expect(@photo.shelved_url).to eq(@data[:shelved_url])
|
42
|
+
end
|
43
|
+
|
44
|
+
it '#sort_order' do
|
45
|
+
expect(@photo.sort_order).to eq(@data[:sort_order])
|
46
|
+
end
|
47
|
+
|
48
|
+
it '#x_offset' do
|
49
|
+
expect(@photo.x_offset).to eq(@data[:x_offset])
|
50
|
+
end
|
51
|
+
|
52
|
+
it '#y_offset' do
|
53
|
+
expect(@photo.y_offset).to eq(@data[:y_offset])
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
describe Ravelry::Printing do
|
4
|
+
before do
|
5
|
+
@printing = Ravelry::Printing.new(printing.first)
|
6
|
+
@data = printing[0][:pattern_source]
|
7
|
+
@primary_source = printing[0][:primary_source]
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'creates an instance of Printing' do
|
11
|
+
expect(@printing).to be_instance_of(Ravelry::Printing)
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'has and sets reader attributes for' do
|
15
|
+
it '#price' do
|
16
|
+
expect(@printing.price).to eq(@data[:price])
|
17
|
+
end
|
18
|
+
|
19
|
+
it '#permalink' do
|
20
|
+
expect(@printing.permalink).to eq(@data[:permalink])
|
21
|
+
end
|
22
|
+
|
23
|
+
it '#name' do
|
24
|
+
expect(@printing.name).to eq(@data[:name])
|
25
|
+
end
|
26
|
+
|
27
|
+
it '#author' do
|
28
|
+
expect(@printing.author).to eq(@data[:author])
|
29
|
+
end
|
30
|
+
|
31
|
+
it '#url' do
|
32
|
+
expect(@printing.url).to eq(@data[:url])
|
33
|
+
end
|
34
|
+
|
35
|
+
it '#amazon_rating' do
|
36
|
+
expect(@printing.amazon_rating).to eq(@data[:amazon_rating])
|
37
|
+
end
|
38
|
+
|
39
|
+
it '#pattern_count' do
|
40
|
+
expect(@printing.pattern_count).to eq(@data[:pattern_count])
|
41
|
+
end
|
42
|
+
|
43
|
+
it '#amazon_url' do
|
44
|
+
expect(@printing.amazon_url).to eq(@data[:amazon_url])
|
45
|
+
end
|
46
|
+
|
47
|
+
it '#shelf_image_path' do
|
48
|
+
expect(@printing.shelf_image_path).to eq(@data[:shelf_image_path])
|
49
|
+
end
|
50
|
+
|
51
|
+
it '#list_price' do
|
52
|
+
expect(@printing.list_price).to eq(@data[:list_price])
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
context 'class methods' do
|
57
|
+
it '#out_of_print?' do
|
58
|
+
expect(@printing.out_of_print?).to eq(@data[:out_of_print])
|
59
|
+
end
|
60
|
+
|
61
|
+
it '#primary_source?' do
|
62
|
+
expect(@printing.primary_source?).to eq(@primary_source)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,187 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
|
3
|
+
describe Ravelry::Build do
|
4
|
+
context 'author' do
|
5
|
+
before do
|
6
|
+
@author = Ravelry::Build.author(paid_pattern_stub)
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'exists' do
|
10
|
+
expect(@author).to be
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'returns an instance of Author' do
|
14
|
+
expect(@author).to be_instance_of(Ravelry::Author)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context '#categories' do
|
19
|
+
before do
|
20
|
+
@categories = Ravelry::Build.categories(paid_pattern_stub)
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'exists' do
|
24
|
+
expect(@categories).to be_true
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'returns an array' do
|
28
|
+
expect(@categories).to be_instance_of(Array)
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'contains at least 1 item' do
|
32
|
+
expect(@categories.length).to be > 0
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'returns an array with Category objects' do
|
36
|
+
expect(@categories[0]).to be_instance_of(Ravelry::Category)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context '#craft' do
|
41
|
+
before do
|
42
|
+
@craft = Ravelry::Build.craft(paid_pattern_stub)
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'exists' do
|
46
|
+
expect(@craft).to be_true
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'returns an instance of Craft' do
|
50
|
+
expect(@craft).to be_instance_of(Ravelry::Craft)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
context '#needles' do
|
55
|
+
before do
|
56
|
+
@needles = Ravelry::Build.needles(paid_pattern_stub)
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'exists' do
|
60
|
+
expect(@needles).to be_true
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'returns an Array' do
|
64
|
+
expect(@needles).to be_instance_of(Array)
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'returns an Array of Needle objects' do
|
68
|
+
expect(@needles[0]).to be_instance_of(Ravelry::PatternNeedle)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
context '#packs' do
|
73
|
+
before do
|
74
|
+
@packs = Ravelry::Build.packs(paid_pattern_stub)
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'exists' do
|
78
|
+
expect(@packs).to be_true
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'returns an Array' do
|
82
|
+
expect(@packs).to be_instance_of(Array)
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'contains at least 1' do
|
86
|
+
expect(@packs.length).to be > 0
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'returns an Array of Pack objects' do
|
90
|
+
expect(@packs[0]).to be_instance_of(Ravelry::Pack)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
context '#photos' do
|
95
|
+
before do
|
96
|
+
@photos = Ravelry::Build.photos(paid_pattern_stub)
|
97
|
+
end
|
98
|
+
|
99
|
+
it 'exists' do
|
100
|
+
expect(@photos).to be_true
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'returns an Array' do
|
104
|
+
expect(@photos).to be_instance_of(Array)
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'returns an array of Photo objects' do
|
108
|
+
expect(@photos[0]).to be_instance_of(Ravelry::Photo)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
context '#printings' do
|
113
|
+
before do
|
114
|
+
@printings = Ravelry::Build.printings(paid_pattern_stub)
|
115
|
+
end
|
116
|
+
|
117
|
+
it 'exists' do
|
118
|
+
expect(@printings).to be_true
|
119
|
+
end
|
120
|
+
|
121
|
+
it 'returns an array' do
|
122
|
+
expect(@printings).to be_instance_of(Array)
|
123
|
+
end
|
124
|
+
|
125
|
+
it 'returns an array with Printing objects' do
|
126
|
+
expect(@printings[0]).to be_instance_of(Ravelry::Printing)
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
context '#type' do
|
131
|
+
before do
|
132
|
+
@type = Ravelry::Build.pattern_type(paid_pattern_stub)
|
133
|
+
end
|
134
|
+
|
135
|
+
it 'exists' do
|
136
|
+
expect(@type).to be_true
|
137
|
+
end
|
138
|
+
|
139
|
+
it 'returns an instance of Type' do
|
140
|
+
expect(@type).to be_instance_of(Ravelry::PatternType)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
context '#yarns' do
|
145
|
+
before do
|
146
|
+
@yarns = Ravelry::Build.yarns(paid_pattern_stub)
|
147
|
+
end
|
148
|
+
|
149
|
+
it 'exists' do
|
150
|
+
expect(@yarns).to be_true
|
151
|
+
end
|
152
|
+
|
153
|
+
it 'returns an array' do
|
154
|
+
expect(@yarns).to be_instance_of(Array)
|
155
|
+
end
|
156
|
+
|
157
|
+
it 'contains at least 1' do
|
158
|
+
expect(@yarns.length).to be > 0
|
159
|
+
end
|
160
|
+
|
161
|
+
it 'returns an array of Yarn objects' do
|
162
|
+
expect(@yarns[0]).to be_instance_of(Ravelry::Yarn)
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
context '#yarn_weights' do
|
167
|
+
before do
|
168
|
+
@yw = Ravelry::Build.yarn_weights(paid_pattern_stub)
|
169
|
+
end
|
170
|
+
|
171
|
+
it 'exists' do
|
172
|
+
expect(@yw).to be_true
|
173
|
+
end
|
174
|
+
|
175
|
+
it 'contains at least 1' do
|
176
|
+
expect(@yw.length).to be > 0
|
177
|
+
end
|
178
|
+
|
179
|
+
it 'returns an array' do
|
180
|
+
expect(@yw).to be_instance_of(Array)
|
181
|
+
end
|
182
|
+
|
183
|
+
it 'returns an array of YarnWeight objects' do
|
184
|
+
expect(@yw[0]).to be_instance_of(Ravelry::YarnWeight)
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
describe Ravelry::Yarn do
|
4
|
+
it 'creates an instance of Yarn' do
|
5
|
+
yarn = y_initialize_with_data_and_id
|
6
|
+
expect(yarn).to be_instance_of(Ravelry::Yarn)
|
7
|
+
end
|
8
|
+
|
9
|
+
context 'has and sets reader attributes for' do
|
10
|
+
before do
|
11
|
+
@yarn = y_initialize_with_data
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'permalink' do
|
15
|
+
expect(@yarn.permalink).to eq(yarn_hash[:permalink])
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'company' do
|
19
|
+
expect(@yarn.company).to eq(yarn_hash[:yarn_company_name])
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'name' do
|
23
|
+
expect(@yarn.name).to eq(yarn_hash[:name])
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'company_id' do
|
27
|
+
expect(@yarn.company_id).to eq(yarn_hash[:yarn_company_id])
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
describe Ravelry::YarnWeight do
|
4
|
+
it 'creates an instance of YarnWeight' do
|
5
|
+
yarn_weight = yw_initialize_with_data_and_id
|
6
|
+
expect(yarn_weight).to be_instance_of(Ravelry::YarnWeight)
|
7
|
+
end
|
8
|
+
|
9
|
+
context 'has and sets reader attributes for' do
|
10
|
+
before do
|
11
|
+
@yarn_weight = yw_initialize_with_data
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'name' do
|
15
|
+
expect(@yarn_weight.name).to eq(yarn_weight_hash[:name])
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'min_gauge' do
|
19
|
+
expect(@yarn_weight.min_gauge).to eq(yarn_weight_hash[:min_gauge])
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'wpi' do
|
23
|
+
expect(@yarn_weight.wpi).to eq(yarn_weight_hash[:wpi])
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'crochet_gauge' do
|
27
|
+
expect(@yarn_weight.crochet_gauge).to eq(yarn_weight_hash[:crochet_gauge])
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'ply' do
|
31
|
+
expect(@yarn_weight.ply).to eq(yarn_weight_hash[:ply])
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'knit_gauge' do
|
35
|
+
expect(@yarn_weight.knit_gauge).to eq(yarn_weight_hash[:knit_gauge])
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'max_gauge' do
|
39
|
+
expect(@yarn_weight.max_gauge).to eq(yarn_weight_hash[:max_gauge])
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'rspec'
|
4
|
+
require 'pry'
|
5
|
+
require 'ravelry'
|
6
|
+
require_relative 'helpers/helpers'
|
7
|
+
require_relative 'helpers/pattern_helpers'
|
8
|
+
require_relative 'helpers/pack_helpers'
|
9
|
+
require_relative 'helpers/yarn_helpers'
|
10
|
+
require_relative 'helpers/yarn_weight_helpers'
|
11
|
+
|
12
|
+
# Requires supporting files with custom matchers and macros, etc,
|
13
|
+
# in ./support/ and its subdirectories.
|
14
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
15
|
+
|
16
|
+
RSpec.configure do |config|
|
17
|
+
config.include Helpers
|
18
|
+
config.include PatternHelpers
|
19
|
+
config.include PackHelpers
|
20
|
+
config.include YarnHelpers
|
21
|
+
config.include YarnWeightHelpers
|
22
|
+
config.order = "random"
|
23
|
+
config.before(:all) do
|
24
|
+
Ravelry.configure do |config|
|
25
|
+
config.access_key = ENV['RAV_ACCESS']
|
26
|
+
config.secret_key = ENV['RAV_SECRET']
|
27
|
+
config.personal_key = ENV['RAV_PERSONAL']
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|