ravelry 0.0.4 → 0.0.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4dcc5188a55d99529661b1bde3859b5ea1351da5
4
- data.tar.gz: c526d13944150e9464254ea8d7a3a8296249d1eb
3
+ metadata.gz: 9109931a9b33ea14a93c82f5fd81d4ad1f2d47ea
4
+ data.tar.gz: 1a5fd7b46c9049d75f5255772f27d667e39ffe53
5
5
  SHA512:
6
- metadata.gz: 8ecae4dc95317877ea9f9e80d5ca9ff49adab6bd79a95da7dc634eb3b49d901348de809d5f48268c9ee64741b4dbece5f9c38cc5c045a15c33edd68d8d2b1be1
7
- data.tar.gz: 1bb66e52e6f80a1512586974e4841233bca9d89226fb369d63cb37699ecf85b9ccdd1fa39662940fb8457c6a5f3416d5645c436496076ff217bfe3203ecee3c6
6
+ metadata.gz: bac3a69cd317f41303aeb7a8accd7b85c1b64d1f549033906aadcd3100ef8259b2cf0d3403b7fa8ecc6d71d40eb1d47ec054ed096a131b26ea950c8783d5996d
7
+ data.tar.gz: 7a45bd027bf36ed7a8ff3f078132ef1e39148b8de8ecad9a5367dec2fd1f4a5ac9581ac1b92ece8080607a0f5c770c0ec206dfa3c02652cb1108320ead0a04e8
data/README.md CHANGED
@@ -1,10 +1,8 @@
1
1
  # Ravelry
2
2
 
3
- _You are reading documentation for version: 0.0.4_
3
+ _You are reading documentation for version: 0.0.5_
4
4
 
5
- You may be wondering what happened to 0.0.3. Apparently, I don't understand how publishing works. LOL WHOOOOOPS.
6
-
7
- [ ![Codeship Status for ArtCraftCode/ravelry](https://codeship.com/projects/fc6710e0-5719-0133-36cc-5ebc52a48109/status?branch=0.0.4)](https://codeship.com/projects/109462)
5
+ [ ![Codeship Status for ArtCraftCode/ravelry](https://codeship.com/projects/fc6710e0-5719-0133-36cc-5ebc52a48109/status?branch=0.0.5)](https://codeship.com/projects/109462)
8
6
 
9
7
  This gem is actively being developed. Be sure to check the branch for the version you're using as breaking changes can (and will!) be introduced.
10
8
 
@@ -18,6 +16,8 @@ Ravelry API documentation is currently available [here](http://www.ravelry.com/a
18
16
 
19
17
  * [`Patterns#show`](http://www.ravelry.com/api#patterns_show) maps to `Ravelry::Pattern`
20
18
  * [`People#show`](http://www.ravelry.com/api#people_show) maps to `Ravelry::User`
19
+ * [`Misc#color_families`](http://www.ravelry.com/api#/_color_families) maps to `Ravelry::Misc.color_families`
20
+ * [`Misc#yarn_weights`](http://www.ravelry.com/api#/_yarn_weights) maps to `Ravelry::Misc.yarn_weights`
21
21
 
22
22
  # Installation
23
23
 
@@ -32,7 +32,7 @@ Hooray! You now have a gem.
32
32
  Add to your `Gemfile`:
33
33
 
34
34
  ```ruby
35
- gem "ravelry", "~> 0.0.4"
35
+ gem "ravelry", "~> 0.0.5"
36
36
  ```
37
37
 
38
38
  **I highly recommend pinning your version** because the gem is in active development and I _promise_ I will break shit.
@@ -67,7 +67,7 @@ Ravelry.configuration.personal_key
67
67
 
68
68
  # Usage
69
69
 
70
- Full documentation for this gem is available [here](http://www.rubydoc.info/gems/ravelry/0.0.4).
70
+ Full documentation for this gem is available [here](http://www.rubydoc.info/gems/ravelry/0.0.5).
71
71
 
72
72
  # API quirks
73
73
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.4
1
+ 0.0.5
@@ -8,8 +8,10 @@ require 'ravelry/utils/utilities'
8
8
 
9
9
  require 'ravelry/author'
10
10
  require 'ravelry/category'
11
+ require 'ravelry/color_family'
11
12
  require 'ravelry/craft'
12
13
  require 'ravelry/data'
14
+ require 'ravelry/misc'
13
15
  require 'ravelry/pack'
14
16
  require 'ravelry/pattern'
15
17
  require 'ravelry/pattern_needle'
@@ -1,20 +1,20 @@
1
1
  module Ravelry
2
2
 
3
3
  # There is no API access point for PatternAuthors. The information used to create `Ravelry::Author` comes from {Ravelry::Pattern} objects.
4
- #
4
+ #
5
5
  # You should not create `Author` objects manually; they are all created–and owned by–by a {Ravelry::Pattern}.
6
- #
6
+ #
7
7
  # See {Ravelry::Pattern} for more information about `Pattern` objects.
8
- #
8
+ #
9
9
  # This does not inherit from {Ravelry::Data} because it doesn't have a corresponding API endpoint.
10
- #
10
+ #
11
11
  class Author
12
12
  attr_reader :id, :name, :permalink, :patterns_count, :favorites_count
13
13
 
14
14
  # Creates new `Author` from Ravelry API PatternAuthor attributes.
15
- #
15
+ #
16
16
  # All class variables are readonly.
17
- #
17
+ #
18
18
  def initialize(pattern_author)
19
19
  @id = pattern_author[:id]
20
20
  @name = pattern_author[:name]
@@ -0,0 +1,23 @@
1
+ module Ravelry
2
+
3
+ # The API endpoint for fetching `ColorFamilies` can be found in {Ravelry::Misc}.
4
+ #
5
+ # A `ColorFamily` object can be created by several different endpoints but is currently only implemented in {Ravelry::Misc}.
6
+ #
7
+ class ColorFamily
8
+ attr_reader :id, :name, :permalink, :spectrum_order, :color
9
+
10
+ # Creates new `ColorFamily` from Ravelry API ColorFamily attributes.
11
+ #
12
+ # All class variables are readonly.
13
+ #
14
+ def initialize(color_family)
15
+ @id = color_family[:id]
16
+ @color = color_family[:color]
17
+ @permalink = color_family[:permalink]
18
+ @name = color_family[:name]
19
+ @spectrum_order = color_family[:spectrum_order]
20
+ end
21
+ end
22
+
23
+ end
@@ -0,0 +1,24 @@
1
+ module Ravelry
2
+
3
+ module Misc
4
+ extend self
5
+
6
+ # Handles GET API call and parses JSON response for the `Misc#color_families` Ravelry endpoint.
7
+ #
8
+ # Returns an array of {Ravelry::ColorFamily} objects.
9
+ #
10
+ def color_families
11
+ request = Typhoeus::Request.get("https://api.ravelry.com/color_families.json", userpwd: "#{Ravelry.configuration.access_key}:#{Ravelry.configuration.personal_key}")
12
+ result = JSON.parse(request.response_body, {symbolize_names: true})
13
+ @data = result[:color_families]
14
+ @data.map { |d| ColorFamily.new(d) }
15
+ end
16
+
17
+ def yarn_weights
18
+ request = Typhoeus::Request.get("https://api.ravelry.com/yarn_weights.json", userpwd: "#{Ravelry.configuration.access_key}:#{Ravelry.configuration.personal_key}")
19
+ result = JSON.parse(request.response_body, {symbolize_names: true})
20
+ @data = result[:yarn_weights]
21
+ @data.map { |d| YarnWeight.new(d) }
22
+ end
23
+ end
24
+ end
@@ -22,17 +22,17 @@ 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
  # ##Initializing with an id
27
- #
27
+ #
28
28
  # Optionally, you can initialize with an id:
29
- #
29
+ #
30
30
  # ```ruby
31
31
  # pattern = Ravelry::Pattern.new(id)
32
32
  # ```
33
- #
33
+ #
34
34
  # And then run your get request:
35
- #
35
+ #
36
36
  # ```ruby
37
37
  # pattern.get
38
38
  # ```
@@ -49,7 +49,7 @@ module Ravelry
49
49
  # You now have access to all class methods for your pattern. Be warned: if you run `get` again, you will override your data with fresh information from the API call.
50
50
  #
51
51
  # # Pattern data
52
- #
52
+ #
53
53
  # After you have pattern data from the API, you have access to all of the pattern attributes through the class methods (see documentation). Example:
54
54
  #
55
55
  # ```ruby
@@ -1,3 +1,3 @@
1
1
  module Ravelry
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -7,7 +7,7 @@ Gem::Specification.new do |spec|
7
7
  spec.name = "ravelry"
8
8
  spec.version = Ravelry::VERSION
9
9
  spec.authors = ["Liz Abinante"]
10
- spec.date = "2015-10-17"
10
+ spec.date = "2015-11-10"
11
11
  spec.summary = "Ruby gem for accessing the Ravelry API."
12
12
  spec.description = "Ruby gem for accessing the Ravelry API painlessly, easily, and awesomely."
13
13
  spec.email = "me@liz.codes"
@@ -0,0 +1,17 @@
1
+ require_relative '../spec_helper'
2
+
3
+ describe Ravelry::Misc do
4
+ context '#color_families' do
5
+ it 'should return an array of color families' do
6
+ result = Ravelry::Misc.color_families
7
+ expect(result.first).to be_instance_of(Ravelry::ColorFamily)
8
+ end
9
+ end
10
+
11
+ context '#yarn_weights' do
12
+ it 'should return an array of color families' do
13
+ result = Ravelry::Misc.yarn_weights
14
+ expect(result.first).to be_instance_of(Ravelry::YarnWeight)
15
+ end
16
+ end
17
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ravelry
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Liz Abinante
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-17 00:00:00.000000000 Z
11
+ date: 2015-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -71,9 +71,11 @@ files:
71
71
  - lib/ravelry.rb
72
72
  - lib/ravelry/author.rb
73
73
  - lib/ravelry/category.rb
74
+ - lib/ravelry/color_family.rb
74
75
  - lib/ravelry/configuration.rb
75
76
  - lib/ravelry/craft.rb
76
77
  - lib/ravelry/data.rb
78
+ - lib/ravelry/misc.rb
77
79
  - lib/ravelry/pack.rb
78
80
  - lib/ravelry/pattern.rb
79
81
  - lib/ravelry/pattern_needle.rb
@@ -98,6 +100,7 @@ files:
98
100
  - spec/ravelry/category_spec.rb
99
101
  - spec/ravelry/craft_spec.rb
100
102
  - spec/ravelry/data_spec.rb
103
+ - spec/ravelry/misc_spec.rb
101
104
  - spec/ravelry/pack_spec.rb
102
105
  - spec/ravelry/pattern_needle_spec.rb
103
106
  - spec/ravelry/pattern_spec.rb
@@ -130,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
130
133
  version: '0'
131
134
  requirements: []
132
135
  rubyforge_project:
133
- rubygems_version: 2.2.2
136
+ rubygems_version: 2.4.8
134
137
  signing_key:
135
138
  specification_version: 4
136
139
  summary: Ruby gem for accessing the Ravelry API.
@@ -144,6 +147,7 @@ test_files:
144
147
  - spec/ravelry/category_spec.rb
145
148
  - spec/ravelry/craft_spec.rb
146
149
  - spec/ravelry/data_spec.rb
150
+ - spec/ravelry/misc_spec.rb
147
151
  - spec/ravelry/pack_spec.rb
148
152
  - spec/ravelry/pattern_needle_spec.rb
149
153
  - spec/ravelry/pattern_spec.rb
@@ -156,4 +160,3 @@ test_files:
156
160
  - spec/ravelry/yarn_weight_spec.rb
157
161
  - spec/ravelry_spec.rb
158
162
  - spec/spec_helper.rb
159
- has_rdoc: