ravelry 0.0.9 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a926a75405032fc909ee8df1a74c3ebbf947f113
4
- data.tar.gz: e642b941fedf2f5898b67708bb5bdbb17cce4fe0
3
+ metadata.gz: 25a41c11df25b2d4a67b928fb0b4c9d51667e804
4
+ data.tar.gz: c8b6c5d8bbcb91a209b850e91494000c9e3a8880
5
5
  SHA512:
6
- metadata.gz: a87301d42b07e5d4dd69443ebe0a33f8aa12b38997f968ce378895f7967e9a00419c4835264ade5c23053836079bdd7dce33d7f65e72c0c73ea79a14f55e49e2
7
- data.tar.gz: 52a1201b777a686ceb5b1c5ab6fd691ef12bd147059d3814a3f1312dd1b67213e31323b5ef27718886b822d8ef1e7fdf69788359af42f9108d63af085213d133
6
+ metadata.gz: fc78ade45ca85b3b9d9582e7592b97192194407ff4ca396e729274dc38c8682b6092e9f50fa3f375e7091c850083b2bf81f60a904ce426db7fc342e0baaaffac
7
+ data.tar.gz: 88a307f89f51096792082eac8234cd5b8ec92a44d8ad651443828db671f97d4d8383251abea1709bfb25acc7aec8f44b98bd68dfe80fbddf05fac60b898e09aa
@@ -1,24 +1,41 @@
1
- # Contributor Code of Conduct
1
+ # Contributor Covenant Code of Conduct
2
2
 
3
- As contributors and maintainers of this project, and in the interest of
4
- fostering an open and welcoming community, we pledge to respect all people who
5
- contribute through reporting issues, posting feature requests, updating
6
- documentation, submitting pull requests or patches, and other activities.
3
+ ## Our Pledge
7
4
 
8
- We are committed to making participation in this project a harassment-free
9
- experience for everyone, regardless of level of experience, gender, gender
10
- identity and expression, sexual orientation, disability, personal appearance,
11
- body size, race, ethnicity, age, religion, or nationality.
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
12
22
 
13
23
  Examples of unacceptable behavior by participants include:
14
24
 
15
- * The use of sexualized language or imagery
16
- * Personal attacks
17
- * Trolling or insulting/derogatory comments
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
18
28
  * Public or private harassment
19
- * Publishing other's private information, such as physical or electronic
20
- addresses, without explicit permission
21
- * Other unethical or unprofessional conduct
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
22
39
 
23
40
  Project maintainers have the right and responsibility to remove, edit, or
24
41
  reject comments, commits, code, wiki edits, issues, and other contributions
@@ -26,25 +43,32 @@ that are not aligned to this Code of Conduct, or to ban temporarily or
26
43
  permanently any contributor for other behaviors that they deem inappropriate,
27
44
  threatening, offensive, or harmful.
28
45
 
29
- By adopting this Code of Conduct, project maintainers commit themselves to
30
- fairly and consistently applying these principles to every aspect of managing
31
- this project. Project maintainers who do not follow or enforce the Code of
32
- Conduct may be permanently removed from the project team.
46
+ ## Scope
33
47
 
34
48
  This Code of Conduct applies both within project spaces and in public spaces
35
- when an individual is representing the project or its community.
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
36
56
 
37
57
  Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
- reported by contacting a project maintainer at [INSERT EMAIL ADDRESS]. All
58
+ reported by contacting the project team at me@liz.codes. All
39
59
  complaints will be reviewed and investigated and will result in a response that
40
- is deemed necessary and appropriate to the circumstances. Maintainers are
41
- obligated to maintain confidentiality with regard to the reporter of an
42
- incident.
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
43
67
 
68
+ ## Attribution
44
69
 
45
- This Code of Conduct is adapted from the [Contributor Covenant][homepage],
46
- version 1.3.0, available at
47
- [http://contributor-covenant.org/version/1/3/0/][version]
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
48
72
 
49
73
  [homepage]: http://contributor-covenant.org
50
- [version]: http://contributor-covenant.org/version/1/3/0/
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/README.md CHANGED
@@ -1,21 +1,21 @@
1
1
  # Ravelry
2
2
 
3
- _You are reading documentation for version: 0.0.8_
3
+ _You are reading documentation for version: 0.1.0_
4
4
 
5
- [ ![Codeship Status for ArtCraftCode/ravelry](https://codeship.com/projects/fc6710e0-5719-0133-36cc-5ebc52a48109/status?branch=0.0.8)](https://codeship.com/projects/109462)
5
+ [ ![Codeship Status for ArtCraftCode/ravelry](https://codeship.com/projects/fc6710e0-5719-0133-36cc-5ebc52a48109/status?branch=0.1.0)](https://codeship.com/projects/109462)
6
6
 
7
7
  The Ruby gem for accessing the Ravelry API painlessly, easily, and awesomely! This gem is actively being developed. **Be sure to check the branch for the version you're using.**
8
8
 
9
9
  **Important and helpful links:**
10
10
 
11
- - [Full gem documentation (version 0.0.8)](http://www.rubydoc.info/gems/ravelry/0.0.8)
12
- - [Changelog](https://github.com/ArtCraftCode/ravelry/blob/0.0.8/CHANGELOG.md)
11
+ - [Full gem documentation (version 0.1.0)](http://www.rubydoc.info/gems/ravelry/0.1.0)
12
+ - [Changelog](https://github.com/ArtCraftCode/ravelry/blob/0.1.0/CHANGELOG.md)
13
13
  - [Project Trello board](https://trello.com/b/o8gs4cWI/ravelry)
14
14
  - [Ravelry API documentation](http://www.ravelry.com/api)
15
15
 
16
16
  ## API coverage
17
17
 
18
- See [documentation](http://www.rubydoc.info/gems/ravelry/0.0.8) for each class (or module) to see how to initialize the objects.
18
+ See [documentation](http://www.rubydoc.info/gems/ravelry/0.1.0) for each class (or module) to see how to initialize the objects.
19
19
 
20
20
  API | Endpoint | Ravelry gem class / module
21
21
  ----|----------|------------------
@@ -43,7 +43,7 @@ Hooray! You now have a gem.
43
43
  Add to your `Gemfile`:
44
44
 
45
45
  ```ruby
46
- gem "ravelry", "~> 0.0.8"
46
+ gem "ravelry", "~> 0.1.0"
47
47
  ```
48
48
 
49
49
  **I highly recommend pinning your version** because the gem is in active development and small changes and additions will be made regularly.
@@ -59,12 +59,14 @@ Ravelry.configure do |config|
59
59
  config.access_key = ''
60
60
  config.secret_key = ''
61
61
  config.personal_key = ''
62
+ config.callback_url = ''
62
63
  end
63
64
  ```
64
65
 
65
66
  * `config.access_key` - your Ravelry access key
66
67
  * `config.secret_key` - your Ravelry secret key
67
68
  * `config.personal_key` - wait for it! Your Ravelry personal key; primarily used for OAuth (not yet implemented in the gem)
69
+ * `config.callback_url` - for OAuth, the callback url for your authentication requests
68
70
 
69
71
  Getting these keys requires a (free) Ravelry account and that you agree to the terms of use for the API.
70
72
 
@@ -74,11 +76,12 @@ The keys are available to you throughout your application as:
74
76
  Ravelry.configuration.access_key
75
77
  Ravelry.configuration.secret_key
76
78
  Ravelry.configuration.personal_key
79
+ Ravelry.configuration.callback_url
77
80
  ```
78
81
 
79
82
  # Usage
80
83
 
81
- Full documentation for this gem is available [here](http://www.rubydoc.info/gems/ravelry/0.0.8).
84
+ Full documentation for this gem is available [here](http://www.rubydoc.info/gems/ravelry/0.1.0).
82
85
 
83
86
  # Conventions
84
87
 
@@ -2,6 +2,7 @@ require 'json'
2
2
  require 'typhoeus'
3
3
 
4
4
  require 'ravelry/configuration'
5
+ require 'ravelry/errors/configuration'
5
6
 
6
7
  require 'ravelry/utils/build'
7
8
  require 'ravelry/utils/request'
@@ -27,7 +28,8 @@ require 'ravelry/user_site'
27
28
  require 'ravelry/yarn'
28
29
  require 'ravelry/yarn_weight'
29
30
 
30
- # Parent grouping for all classes.
31
+ # Parent module for all classes.
32
+ #
31
33
  module Ravelry
32
34
  class << self
33
35
  attr_accessor :configuration
@@ -1,11 +1,78 @@
1
1
  module Ravelry
2
+
3
+ # Adds global configuration settings to the gem, including:
4
+ #
5
+ # * `config.access_key` - your Ravelry access key
6
+ # * `config.secret_key` - your Ravelry secret key
7
+ # * `config.personal_key` - your Ravelry personal key; primarily used for OAuth
8
+ # * `config.callback_url` - for OAuth, the callback url for your authentication requests
9
+ #
10
+ # To request API keys for Ravelry, sign up for a free Ravelry account and visit this page for instructions:
11
+ # http://www.ravelry.com/discuss/ravelry-api/topics/1979523#1
12
+ #
13
+ # # Required fields
14
+ #
15
+ # The following fields are *required* to use the gem:
16
+ #
17
+ # - Access key
18
+ # - Secret key
19
+ # - Personal key
20
+ #
21
+ # The gem will raise a `Errors::Configuration` if you fail to provide these keys.
22
+ #
23
+ # # Configuring your gem
24
+ #
25
+ # ```
26
+ # Ravelry.configure do |config|
27
+ # config.access_key = ''
28
+ # config.secret_key = ''
29
+ # config.personal_key = ''
30
+ # config.callback_url = ''
31
+ # end
32
+ # ```
33
+ #
34
+ # # Accessing configuration settings
35
+ #
36
+ # All settings are available on the `Ravelry.configuration` object:
37
+ #
38
+ # ```
39
+ # Ravelry.configuration.access_key
40
+ # Ravelry.configuration.secret_key
41
+ # Ravelry.configuration.personal_key
42
+ # Ravelry.configuration.callback_url
43
+ # ```
44
+ # # Resetting configuration
45
+ #
46
+ # To reset, simply call `Ravelry.reset`.
47
+ #
2
48
  class Configuration
3
- attr_accessor :access_key, :secret_key, :personal_key
49
+ attr_writer :access_key, :secret_key, :personal_key, :callback_url
4
50
 
5
51
  def initialize
6
52
  @access_key = nil
7
53
  @secret_key = nil
8
54
  @personal_key = nil
55
+ @callback_url = nil
56
+ end
57
+
58
+ def access_key
59
+ raise Errors::Configuration, "Ravelry access key missing! See the documentation for configuration settings." unless @access_key
60
+ @access_key
61
+ end
62
+
63
+ def secret_key
64
+ raise Errors::Configuration, "Ravelry secret key missing! See the documentation for configuration settings." unless @secret_key
65
+ @secret_key
66
+ end
67
+
68
+ def personal_key
69
+ raise Errors::Configuration, "Ravelry personal key missing! See the documentation for configuration settings." unless @personal_key
70
+ @personal_key
71
+ end
72
+
73
+ def callback_url
74
+ raise Errors::Configuration, "Oauth callback url missing! See the documentation for configuration settings." unless @callback_url
75
+ @callback_url
9
76
  end
10
77
  end
11
78
  end
@@ -1,6 +1,7 @@
1
1
  module Ravelry
2
2
 
3
3
  # Parent class that controls initialization and fetching for API objects.
4
+ #
4
5
  class Data
5
6
  attr_accessor :id
6
7
  attr_reader :data
@@ -9,6 +10,8 @@ module Ravelry
9
10
  @id = id
10
11
  end
11
12
 
13
+ # Writes the `data` instance variable and calls `build` on the child class.
14
+ #
12
15
  def data=(d)
13
16
  @data = d
14
17
  build
@@ -17,6 +20,7 @@ module Ravelry
17
20
 
18
21
  private
19
22
  # Determines if a GET request needs to be made.
23
+ #
20
24
  def get?
21
25
  @id && !@data
22
26
  end
@@ -0,0 +1,5 @@
1
+ module Ravelry
2
+ module Errors
3
+ class Configuration < StandardError; end
4
+ end
5
+ end
@@ -22,13 +22,13 @@ module Ravelry
22
22
  # ```
23
23
  #
24
24
  # After calling `get`, you have access to all of the class methods below.
25
- #
25
+ #
26
26
  # If you do not have the pattern ID, you may use the permalink:
27
- #
27
+ #
28
28
  # Ravelry URL: http://www.ravelry.com/patterns/library/traveling-woman
29
- #
29
+ #
30
30
  # Request:
31
- #
31
+ #
32
32
  # ```ruby
33
33
  # pattern = Ravelry::Pattern.new
34
34
  # pattern.permalink_get('traveling-woman')
@@ -98,15 +98,16 @@ module Ravelry
98
98
  # # Searching
99
99
  #
100
100
  # To search for patterns, use the `Pattern.search` class method, which
101
- # returns an array of patterns:
101
+ # returns an array of patterns.
102
102
  #
103
- # ```ruby
104
- # Ravelry::Pattern.search('socks')
105
- # # => [#<Pattern>, ...]
106
- # ```
103
+ # @example
104
+ # Ravelry::Pattern.search('socks')
105
+ # # => [#<Pattern>, ...]
107
106
  #
108
107
  class Pattern < Data
109
108
 
109
+ # Whitelist and default options for fetching comments.
110
+ #
110
111
  COMMENT_OPTIONS = {
111
112
  sort: ['time', 'helpful', 'time_', 'helpful_'],
112
113
  page_size: 25,
@@ -119,46 +120,49 @@ module Ravelry
119
120
  attr_reader :author, :categories, :craft, :needles, :packs, :photos, :printings, :type, :yarns, :yarn_weights
120
121
 
121
122
  # Handles GET API call and parses JSON response.
122
- #
123
+ #
123
124
  # Corresponds to Ravelry API endpoint `Patterns#show`
124
125
  #
125
126
  def get
126
127
  @data = Utils::Request.get("patterns/#{@id}.json", :pattern)
128
+ self
127
129
  end
128
130
 
129
131
  # Alternative method for the GET API call.
130
- #
132
+ #
131
133
  # Corresponds to Ravelry API endpoint `Patterns#show`
132
- #
134
+ #
133
135
  # Uses the pattern's Ravelry permalink instead of ID. Useful if you don't know the ID of a pattern, but have the permalink.
134
- #
135
- # **Example**
136
- #
137
- # Ravelry URL: http://www.ravelry.com/patterns/library/traveling-woman
138
- #
139
- # Request:
140
- #
141
- # ```ruby
142
- # pattern = Ravelry::Pattern.new
143
- # pattern.permalink_get('traveling-woman')
144
- # ```
145
- #
136
+ #
137
+ # @example
138
+ # # Ravelry URL: http://www.ravelry.com/patterns/library/traveling-woman
139
+ # pattern = Ravelry::Pattern.new
140
+ # pattern.permalink_get('traveling-woman')
141
+ #
146
142
  def permalink_get(permalink)
147
143
  @data = Utils::Request.get("patterns/#{permalink}.json", :pattern)
144
+ self
148
145
  end
149
146
 
150
147
  # Get the list of comments on a pattern object.
151
- #
148
+ #
152
149
  # To query comments for a pattern you haven't fetched yet, without fetching the pattern:
153
- #
154
- # ```ruby
155
- # pattern = Ravelry::Pattern.new
156
- # pattern.id = "000000"
157
- # pattern.comments
158
- # ```
159
- #
150
+ #
151
+ # @example
152
+ # pattern = Ravelry::Pattern.new
153
+ # pattern.id = "000000"
154
+ # pattern.comments
155
+ #
160
156
  # To query comments for a pattern you've already fetched, follow the steps above and call `pattern.comments`.
161
- #
157
+ #
158
+ # See <COMMENT_OPTIONS> for valid options.
159
+ #
160
+ # @option options [String] :sort
161
+ # @option options [Integer] :page_size
162
+ # @option options [Array] :include
163
+ # @option options [Integer] :page
164
+ # @return [Array<Comment>] an array of `Comment`s
165
+ #
162
166
  def comments(options={})
163
167
  @comment_list ||= []
164
168
  return @comment_list if @comment_list.any?
@@ -175,6 +179,7 @@ module Ravelry
175
179
  # @option options [Integer] :page
176
180
  # @option options [Integer] :page_size
177
181
  # @return [Array<Pattern>] an array of `Pattern`s
182
+ #
178
183
  def self.search(query, options={})
179
184
  params = {query: query}
180
185
  params.merge!(options)
@@ -194,13 +199,15 @@ module Ravelry
194
199
  end
195
200
 
196
201
  # Returns the original raw JSON.
197
- #
202
+ #
198
203
  def json
199
204
  data
200
205
  end
201
206
 
202
207
  # Creates all objects associated with your pattern; returns nothing; sets `attr_readers`.
203
208
  #
209
+ # @return nil
210
+ #
204
211
  def build
205
212
  @author = Build.author(data)
206
213
  @categories = Build.categories(data)
@@ -217,59 +224,79 @@ module Ravelry
217
224
 
218
225
  # Gets comments_count from existing `data`.
219
226
  #
227
+ # @return Integer
228
+ #
220
229
  def comments_count
221
230
  data[:comments_count]
222
231
  end
223
232
 
224
233
  # Gets currency from existing `data`.
225
234
  #
235
+ # @return String
236
+ #
226
237
  def currency
227
238
  data[:currency]
228
239
  end
229
240
 
230
241
  # Gets currency_symbol from existing `data`.
231
242
  #
243
+ # @return String
244
+ #
232
245
  def currency_symbol
233
246
  data[:currency_symbol]
234
247
  end
235
248
 
236
249
  # Returns the difficult average as a Float (this is how it is stored by Ravelry).
237
250
  #
251
+ # @return Float
252
+ #
238
253
  def difficulty_average_float
239
254
  data[:difficulty_average]
240
255
  end
241
256
 
242
257
  # Returns the difficulty average rounded up or down to an Integer.
243
258
  #
259
+ # @return Integer
260
+ #
244
261
  def difficulty_average_integer
245
262
  difficulty_average_float.round(0)
246
263
  end
247
264
 
248
265
  # Gets difficulty_count (Integer) from existing `data`.
249
266
  #
267
+ # @return Integer
268
+ #
250
269
  def difficulty_count
251
270
  data[:difficulty_count]
252
271
  end
253
272
 
254
273
  # Returns true if the pattern can be downloaded.
255
274
  #
275
+ # @return Boolean
276
+ #
256
277
  def downloadable?
257
278
  data[:downloadable]
258
279
  end
259
280
 
260
281
  # Gets favorites_count (Integer) from existing `data`.
261
282
  #
283
+ # @return Integer
284
+ #
262
285
  def favorites_count
263
286
  data[:favorites_count]
264
287
  end
265
288
 
266
- # Returns true if pattern is free (Boolean).
289
+ # Returns true if pattern is free.
290
+ #
291
+ # @return Boolean
267
292
  #
268
293
  def free?
269
294
  data[:free]
270
295
  end
271
296
 
272
- # Number of stitches per inch (or 4 inches) (Float).
297
+ # Number of stitches per inch (or 4 inches).
298
+ #
299
+ # @return Float
273
300
  #
274
301
  def gauge
275
302
  data[:gauge]
@@ -277,11 +304,15 @@ module Ravelry
277
304
 
278
305
  # Sentence description of sts and row gauge with stitch.
279
306
  #
307
+ # @return String
308
+ #
280
309
  def gauge_description
281
310
  data[:gauge_description]
282
311
  end
283
312
 
284
- # Either 1 or 4 (inches) (Integer).
313
+ # Either 1 or 4 (inches).
314
+ #
315
+ # @return Integer
285
316
  #
286
317
  def gauge_divisor
287
318
  data[:gauge_divisor]
@@ -289,29 +320,37 @@ module Ravelry
289
320
 
290
321
  # Pattern for gauge listed.
291
322
  #
323
+ # @return String
324
+ #
292
325
  def gauge_pattern
293
326
  data[:gauge_pattern]
294
327
  end
295
328
 
296
329
  # Gets patter name from existing `data`.
297
330
  #
331
+ # @return String
332
+ #
298
333
  def name
299
334
  data[:name]
300
335
  end
301
336
 
302
337
  # Raw pattern notes. May be mixed Markdown and HTML. Generally only useful when presenting a pattern notes editor.
303
338
  #
339
+ # @return String
340
+ #
304
341
  def notes_raw
305
342
  data[:notes]
306
343
  end
307
344
 
308
345
  # Pattern notes rendered as HTML.
309
346
  #
347
+ # @return String
348
+ #
310
349
  def notes_html
311
350
  data[:notes_html]
312
351
  end
313
352
 
314
- # Returns an array of hashes with tons of information about each yarn listed in the pattern. See {#build_packs} for a complete list of helper methods.
353
+ # Returns an array of hashes with tons of information about each yarn listed in the pattern. See {#build} for a complete list of helper methods.
315
354
  #
316
355
  # I've included this method in case you want to have more control over how your pack information is displayed. It's likely that you'll want to use the other pack methods. While you sacrifice some fine tuning control, you also don't have to worry about dealing with a messy nested hash.
317
356
  #
@@ -319,11 +358,12 @@ module Ravelry
319
358
  #
320
359
  # If iterating through the `packs` hash, you'll likely want to do something like this:
321
360
  #
322
- # `packs = pattern.packs`
323
- #
324
- # **`packs[0][:yarn_name]`** returns a formatted string with the brand and yarn name.
361
+ # @example
362
+ # packs = pattern.packs
363
+ # packs[0][:yarn_name]
364
+ # # returns a formatted string with the brand and yarn name.
325
365
  #
326
- # *Example: "Wooly Wonka Fibers Artio Sock"*
366
+ # @return [Array<Hash>]
327
367
  #
328
368
  def packs_raw
329
369
  data[:packs]
@@ -331,6 +371,8 @@ module Ravelry
331
371
 
332
372
  # Helper that will tell you how many yarns you have in your pack.
333
373
  #
374
+ # @return Integer
375
+ #
334
376
  def pack_count
335
377
  data[:packs].length
336
378
  end
@@ -341,6 +383,8 @@ module Ravelry
341
383
  #
342
384
  # See {Ravelry::Author} for more information about directly accessing author information.
343
385
  #
386
+ # @return Hash
387
+ #
344
388
  def pattern_author
345
389
  data[:pattern_author]
346
390
  end
@@ -351,6 +395,8 @@ module Ravelry
351
395
  #
352
396
  # See {Ravelry::Category} for more information about directly accessing category information.
353
397
  #
398
+ # @return [Array<Hash>]
399
+ #
354
400
  def pattern_categories_raw
355
401
  data[:pattern_categories]
356
402
  end
@@ -362,6 +408,8 @@ module Ravelry
362
408
  #
363
409
  # See {Ravelry::Needle} for more information about directly accessing category information.
364
410
  #
411
+ # @return [Array<Hash>]
412
+ #
365
413
  def pattern_needle_sizes_raw
366
414
  data[:pattern_needle_sizes]
367
415
  end
@@ -372,18 +420,24 @@ module Ravelry
372
420
  #
373
421
  # See {Ravelry::Needle} for more information about directly accessing category information.
374
422
  #
423
+ # @return [Array<Hash>]
424
+ #
375
425
  def pattern_type_raw
376
426
  data[:pattern_type]
377
427
  end
378
428
 
379
429
  # Gets pdf_url from existing `data`.
380
430
  #
431
+ # @return String
432
+ #
381
433
  def pdf_url
382
434
  data[:pdf_url]
383
435
  end
384
436
 
385
437
  # Gets Ravelry permalink from existing `data`.
386
438
  #
439
+ # @return String
440
+ #
387
441
  def permalink
388
442
  data[:permalink]
389
443
  end
@@ -394,11 +448,15 @@ module Ravelry
394
448
  #
395
449
  # See {Ravelry::Photo} for more information about directly accessing category information.
396
450
  #
451
+ # @return [Array<Hash>]
452
+ #
397
453
  def photos_raw
398
454
  data[:photos]
399
455
  end
400
456
 
401
- # Gets price from existing `data` (Float).
457
+ # Gets price from existing `data`.
458
+ #
459
+ # @return Float
402
460
  #
403
461
  def price
404
462
  data[:price]
@@ -406,47 +464,63 @@ module Ravelry
406
464
 
407
465
  # Gets product_id from existing `data`.
408
466
  #
467
+ # @return Integer
468
+ #
409
469
  def product_id
410
470
  data[:product_id]
411
471
  end
412
472
 
413
- # Gets projects_count from existing `data` (Integer).
473
+ # Gets projects_count from existing `data`.
474
+ #
475
+ # @return Integer
414
476
  #
415
477
  def projects_count
416
478
  data[:projects_count]
417
479
  end
418
480
 
419
- # Gets publication date from existing `data` (Date).
481
+ # Gets publication date from existing `data`.
482
+ #
483
+ # @return Date
420
484
  #
421
485
  def published
422
486
  Date.parse(data[:published])
423
487
  end
424
488
 
425
- # Gets number of queued projects from existing `data` (Integer).
489
+ # Gets number of queued projects from existing `data`.
490
+ #
491
+ # @return Integer
426
492
  #
427
493
  def queued_projects_count
428
494
  data[:queued_projects_count]
429
495
  end
430
496
 
431
- # Gets rating_average from existing `data` (Float).
497
+ # Gets rating_average from existing `data`.
498
+ #
499
+ # @return Float
432
500
  #
433
501
  def rating_average
434
502
  data[:rating_average]
435
503
  end
436
504
 
437
- # Gets number of ratings from existing `data` (Integer).
505
+ # Gets number of ratings from existing `data`.
506
+ #
507
+ # @return Integer
438
508
  #
439
509
  def rating_count
440
510
  data[:rating_count]
441
511
  end
442
512
 
443
- # Returns true if pattern is a Ravelry download (Boolean).
513
+ # Returns true if pattern is a Ravelry download.
514
+ #
515
+ # @return Boolean
444
516
  #
445
517
  def ravelry_download?
446
518
  data[:ravelry_download]
447
519
  end
448
520
 
449
- # Gets row gauge from existing `data` (Float).
521
+ # Gets row gauge from existing `data`.
522
+ #
523
+ # @return Float
450
524
  #
451
525
  def row_gauge
452
526
  data[:row_gauge]
@@ -454,17 +528,23 @@ module Ravelry
454
528
 
455
529
  # Gets sizes available from existing `data`.
456
530
  #
531
+ # @return String
532
+ #
457
533
  def sizes_available
458
534
  data[:sizes_available]
459
535
  end
460
536
 
461
537
  # Gets url from existing `data`.
462
538
  #
539
+ # @return String
540
+ #
463
541
  def url
464
542
  data[:url]
465
543
  end
466
544
 
467
- # Gets yardage required from existing `data` (Integer).
545
+ # Gets yardage required from existing `data`.
546
+ #
547
+ # @return Integer
468
548
  #
469
549
  def yardage
470
550
  data[:yardage]
@@ -472,11 +552,15 @@ module Ravelry
472
552
 
473
553
  # Gets nice sentence yardage description with range from existing `data`.
474
554
  #
555
+ # @return String
556
+ #
475
557
  def yardage_description
476
558
  data[:yardage_description]
477
559
  end
478
560
 
479
- # Gets max yards required from existing `data` (Integer).
561
+ # Gets max yards required from existing `data`.
562
+ #
563
+ # @return Integer
480
564
  #
481
565
  def yardage_max
482
566
  data[:yardage_max]
@@ -484,6 +568,8 @@ module Ravelry
484
568
 
485
569
  # Gets primary yarn weight description from existing `data`.
486
570
  #
571
+ # @return String
572
+ #
487
573
  def yarn_weight_description
488
574
  data[:yarn_weight_description]
489
575
  end
@@ -1,3 +1,3 @@
1
1
  module Ravelry
2
- VERSION = "0.0.9"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -0,0 +1,68 @@
1
+ require_relative '../spec_helper'
2
+
3
+ describe Ravelry::Configuration do
4
+ before do
5
+ @callback_url = "hello panda"
6
+ Ravelry.configure do |config|
7
+ config.access_key = ENV['RAV_ACCESS']
8
+ config.secret_key = ENV['RAV_SECRET']
9
+ config.personal_key = ENV['RAV_PERSONAL']
10
+ config.callback_url = @callback_url
11
+ end
12
+ end
13
+
14
+ context 'with configuration block' do
15
+ it 'returns the correct access_key' do
16
+ expect(Ravelry.configuration.access_key).to eq(ENV['RAV_ACCESS'])
17
+ end
18
+
19
+ it 'returns the correct secret_key' do
20
+ expect(Ravelry.configuration.secret_key).to eq(ENV['RAV_SECRET'])
21
+ end
22
+
23
+ it 'returns the correct personal_key' do
24
+ expect(Ravelry.configuration.personal_key).to eq(ENV['RAV_PERSONAL'])
25
+ end
26
+
27
+ it 'returns the correct callback_url' do
28
+ expect(Ravelry.configuration.callback_url).to eq(@callback_url)
29
+ end
30
+ end
31
+
32
+ context 'without configuration block' do
33
+ before do
34
+ Ravelry.reset
35
+ end
36
+
37
+ it 'raises a configuration error for access_key' do
38
+ expect { Ravelry.configuration.access_key }.to raise_error(Ravelry::Errors::Configuration)
39
+ end
40
+
41
+ it 'raises a configuration error for secret_key' do
42
+ expect { Ravelry.configuration.secret_key }.to raise_error(Ravelry::Errors::Configuration)
43
+ end
44
+
45
+ it 'raises a configuration error for personal_key' do
46
+ expect { Ravelry.configuration.personal_key }.to raise_error(Ravelry::Errors::Configuration)
47
+ end
48
+
49
+ it 'raises a configuration error for callback_url' do
50
+ expect { Ravelry.configuration.callback_url }.to raise_error(Ravelry::Errors::Configuration)
51
+ end
52
+ end
53
+
54
+ context '#reset' do
55
+ it 'resets configured values' do
56
+ expect(Ravelry.configuration.access_key).to eq(ENV['RAV_ACCESS'])
57
+ expect(Ravelry.configuration.secret_key).to eq(ENV['RAV_SECRET'])
58
+ expect(Ravelry.configuration.personal_key).to eq(ENV['RAV_PERSONAL'])
59
+ expect(Ravelry.configuration.callback_url).to eq(@callback_url)
60
+
61
+ Ravelry.reset
62
+ expect { Ravelry.configuration.access_key }.to raise_error(Ravelry::Errors::Configuration)
63
+ expect { Ravelry.configuration.secret_key }.to raise_error(Ravelry::Errors::Configuration)
64
+ expect { Ravelry.configuration.personal_key }.to raise_error(Ravelry::Errors::Configuration)
65
+ expect { Ravelry.configuration.callback_url }.to raise_error(Ravelry::Errors::Configuration)
66
+ end
67
+ end
68
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ravelry
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Liz Abinante
@@ -111,6 +111,7 @@ files:
111
111
  - lib/ravelry/configuration.rb
112
112
  - lib/ravelry/craft.rb
113
113
  - lib/ravelry/data.rb
114
+ - lib/ravelry/errors/configuration.rb
114
115
  - lib/ravelry/misc.rb
115
116
  - lib/ravelry/needle.rb
116
117
  - lib/ravelry/needles.rb
@@ -139,6 +140,7 @@ files:
139
140
  - spec/helpers/yarn_weight_helpers.rb
140
141
  - spec/ravelry/author_spec.rb
141
142
  - spec/ravelry/category_spec.rb
143
+ - spec/ravelry/configuration_spec.rb
142
144
  - spec/ravelry/craft_spec.rb
143
145
  - spec/ravelry/data_spec.rb
144
146
  - spec/ravelry/misc_spec.rb
@@ -192,6 +194,7 @@ test_files:
192
194
  - spec/helpers/yarn_weight_helpers.rb
193
195
  - spec/ravelry/author_spec.rb
194
196
  - spec/ravelry/category_spec.rb
197
+ - spec/ravelry/configuration_spec.rb
195
198
  - spec/ravelry/craft_spec.rb
196
199
  - spec/ravelry/data_spec.rb
197
200
  - spec/ravelry/misc_spec.rb