cookbook_client 0.0.3 → 0.0.4
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 +4 -4
- data/lib/cookbook_client.rb +1 -0
- data/lib/cookbook_client/recipe_type.rb +35 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef5bd90caf116b8cd7115fbee7349e6c941ae769792d320d5f0f99e973f45555
|
4
|
+
data.tar.gz: f128f72cf6cda584cb2e758ceea0e3c0e7fb745f0542b8ce82af09d129aaa954
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e3c1db2dcc2624b82c8269fa96f33ceba76db3b7b4b8d6c794e14f6d7d471994e18a3843045939bc466b8f53360a44e7a5b34f4102eb2c4b79624622ddf26f4
|
7
|
+
data.tar.gz: e3f06dcca4aa594dd897ff8f7c02d8aaec13d76762834adf514b01d0879c7984b141e01aebb6b1a7955ed2c272eb242708adfa413894d0df55dd2547b1cc5d3e
|
data/lib/cookbook_client.rb
CHANGED
@@ -0,0 +1,35 @@
|
|
1
|
+
class CookbookClient::RecipeType
|
2
|
+
attr_accessor :id, :name
|
3
|
+
|
4
|
+
def initialize(info:)
|
5
|
+
@id = info['id']
|
6
|
+
@name = info['name']
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.all
|
10
|
+
response = CookbookClient.http.get('/api/v1/recipe_types')
|
11
|
+
|
12
|
+
if response.status != 200
|
13
|
+
raise StandardError, "Error #{response.status} - #{response.body}"
|
14
|
+
end
|
15
|
+
|
16
|
+
format_recipe_type recipe_types: JSON.parse(response.body)
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.find_by_name(name)
|
20
|
+
response = CookbookClient.http.get('/api/v1/recipe_types/name', name: name)
|
21
|
+
|
22
|
+
if response.status != 200
|
23
|
+
raise StandardError, "Error #{response.status} - #{response.body}"
|
24
|
+
end
|
25
|
+
|
26
|
+
format_recipe_type(recipe_types: JSON.parse(response.body)).first
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.format_recipe_type(recipe_types:)
|
30
|
+
recipe_types = [recipe_types] unless recipe_types.is_a? Array
|
31
|
+
recipe_types.map do |rp|
|
32
|
+
new info: rp
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cookbook_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jefferson Barbosa
|
@@ -34,6 +34,7 @@ files:
|
|
34
34
|
- lib/cookbook_client.rb
|
35
35
|
- lib/cookbook_client/cuisine.rb
|
36
36
|
- lib/cookbook_client/recipe.rb
|
37
|
+
- lib/cookbook_client/recipe_type.rb
|
37
38
|
homepage:
|
38
39
|
licenses:
|
39
40
|
- MIT
|