punkapi 1.0.0 → 2.0.0
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/README.md +3 -9
- data/lib/punkapi/client.rb +6 -8
- data/lib/punkapi/version.rb +1 -1
- data/punkapi.gemspec +4 -5
- data/spec/lib/client_spec.rb +3 -9
- data/spec/spec_helper.rb +0 -2
- metadata +7 -21
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 713a18d218879130768adb4a0ec294cd3b24d31b
|
|
4
|
+
data.tar.gz: e9448ffcd5dd50d8c034de3a04fb6d027fdb2b24
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0c51892ab7895c15aa114f5a159174e79a01e0ca30e1759a61b5154991eab3902bd8e9626e95f8fded05d6f8125c822e4cd75911e2cab890832f25721d2e609a
|
|
7
|
+
data.tar.gz: 9974b9a6e5b8565fee69d4545793d3f545b2156f485e9fe87f964450d89b003198f3f49e1f74d1a218f88b31c30d1479aab5af88e589ea69ebf9611de98d31e4
|
data/README.md
CHANGED
|
@@ -7,13 +7,13 @@ A ruby wrapper for the PunkAPI, an API that takes Brewdog's DIY Dog and makes it
|
|
|
7
7
|
Add this line to your application's Gemfile:
|
|
8
8
|
|
|
9
9
|
```ruby
|
|
10
|
-
gem 'punkapi', '~>
|
|
10
|
+
gem 'punkapi', '~> 2.0.0'
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
Or install it yourself as:
|
|
14
14
|
|
|
15
15
|
```
|
|
16
|
-
$ gem install punkapi
|
|
16
|
+
$ gem install punkapi
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
## Usage
|
|
@@ -21,7 +21,7 @@ $ gem install punkapi-ruby
|
|
|
21
21
|
### Initialize
|
|
22
22
|
|
|
23
23
|
```ruby
|
|
24
|
-
client = PunkAPI::Client.new
|
|
24
|
+
client = PunkAPI::Client.new
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
### Get a Beer
|
|
@@ -58,12 +58,6 @@ beers.first.name
|
|
|
58
58
|
=> "Dog A"
|
|
59
59
|
```
|
|
60
60
|
|
|
61
|
-
## Development
|
|
62
|
-
|
|
63
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
64
|
-
|
|
65
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
66
|
-
|
|
67
61
|
## Contributing
|
|
68
62
|
Bug reports and pull requests are welcome on GitHub at https://github.com/samjbmason/punkapi-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
|
69
63
|
|
data/lib/punkapi/client.rb
CHANGED
|
@@ -3,16 +3,14 @@ require 'json'
|
|
|
3
3
|
|
|
4
4
|
module PunkAPI
|
|
5
5
|
class Client
|
|
6
|
-
|
|
6
|
+
DEFAULT_API_URL = 'https://api.punkapi.com/v2'.freeze
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
def initialize(api_key)
|
|
11
|
-
@api_key = api_key
|
|
8
|
+
def initialize
|
|
12
9
|
end
|
|
13
10
|
|
|
14
11
|
def beer(id)
|
|
15
|
-
request('beers', id: id)
|
|
12
|
+
beer = request('beers', id: id)
|
|
13
|
+
beer[0]
|
|
16
14
|
end
|
|
17
15
|
|
|
18
16
|
def beers(params = {})
|
|
@@ -20,7 +18,8 @@ module PunkAPI
|
|
|
20
18
|
end
|
|
21
19
|
|
|
22
20
|
def random_beer
|
|
23
|
-
request('beers/random')
|
|
21
|
+
beer = request('beers/random')
|
|
22
|
+
beer[0]
|
|
24
23
|
end
|
|
25
24
|
|
|
26
25
|
def request(url, params = {})
|
|
@@ -37,7 +36,6 @@ module PunkAPI
|
|
|
37
36
|
|
|
38
37
|
def connection
|
|
39
38
|
@connection ||= Faraday.new(DEFAULT_API_URL, ssl: { verify: false })
|
|
40
|
-
@connection.basic_auth(@api_key, '')
|
|
41
39
|
@connection
|
|
42
40
|
end
|
|
43
41
|
end
|
data/lib/punkapi/version.rb
CHANGED
data/punkapi.gemspec
CHANGED
|
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
|
|
|
8
8
|
spec.authors = ['Sam Mason']
|
|
9
9
|
spec.email = ['sam.jbmason@gmail.com']
|
|
10
10
|
|
|
11
|
-
spec.summary = 'A wrapper for the PunkAPI
|
|
12
|
-
spec.description = 'A wrapper for the PunkAPI
|
|
11
|
+
spec.summary = 'A wrapper for the PunkAPI API'
|
|
12
|
+
spec.description = 'A wrapper for the PunkAPI API'
|
|
13
13
|
spec.homepage = 'https://github.com/samjbmason/punkapi-ruby'
|
|
14
14
|
spec.license = 'MIT'
|
|
15
15
|
|
|
@@ -17,12 +17,11 @@ Gem::Specification.new do |spec|
|
|
|
17
17
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
18
18
|
spec.require_paths = ['lib']
|
|
19
19
|
|
|
20
|
-
spec.required_ruby_version = '>= 1.9
|
|
20
|
+
spec.required_ruby_version = '>= 1.9'
|
|
21
21
|
|
|
22
|
-
spec.add_runtime_dependency 'faraday', '~> 0.
|
|
22
|
+
spec.add_runtime_dependency 'faraday', '~> 0.10.0'
|
|
23
23
|
|
|
24
24
|
spec.add_development_dependency 'bundler', '~> 1.11'
|
|
25
25
|
spec.add_development_dependency 'rake', '~> 10.0'
|
|
26
26
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
|
27
|
-
spec.add_development_dependency 'dotenv', '~> 2.1.0'
|
|
28
27
|
end
|
data/spec/lib/client_spec.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe PunkAPI::Client do
|
|
4
|
-
let(:client) { PunkAPI::Client.new
|
|
4
|
+
let(:client) { PunkAPI::Client.new }
|
|
5
5
|
|
|
6
6
|
it 'has a version number' do
|
|
7
7
|
expect(PunkAPI::VERSION).not_to be nil
|
|
@@ -10,6 +10,7 @@ describe PunkAPI::Client do
|
|
|
10
10
|
describe '#beer' do
|
|
11
11
|
it 'given an id, returns a PunkAPI::Entity object' do
|
|
12
12
|
beer = client.beer(1)
|
|
13
|
+
puts beer
|
|
13
14
|
expect(beer).to be_a PunkAPI::Entity
|
|
14
15
|
expect(beer.name).to eq('Buzz')
|
|
15
16
|
end
|
|
@@ -26,6 +27,7 @@ describe PunkAPI::Client do
|
|
|
26
27
|
describe '#beers' do
|
|
27
28
|
it 'returns a PunkAPI::Entity object with an abv greater than 10' do
|
|
28
29
|
beers = client.beers(abv_gt: 10)
|
|
30
|
+
puts beers
|
|
29
31
|
expect(beers[0]).to be_a PunkAPI::Entity
|
|
30
32
|
expect(beers[0].abv).to be > 10
|
|
31
33
|
end
|
|
@@ -41,13 +43,5 @@ describe PunkAPI::Client do
|
|
|
41
43
|
expect(beers[0]).to be_a PunkAPI::Entity
|
|
42
44
|
expect(beers.count).to eq(25)
|
|
43
45
|
end
|
|
44
|
-
|
|
45
|
-
context 'incorrect api_key' do
|
|
46
|
-
it 'returns an error status of 401' do
|
|
47
|
-
client = PunkAPI::Client.new('fake')
|
|
48
|
-
resp = client.beers
|
|
49
|
-
expect(resp.code).to eq(401)
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
46
|
end
|
|
53
47
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: punkapi
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 2.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sam Mason
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2016-
|
|
11
|
+
date: 2016-12-19 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|
|
@@ -16,14 +16,14 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: 0.
|
|
19
|
+
version: 0.10.0
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: 0.
|
|
26
|
+
version: 0.10.0
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: bundler
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -66,21 +66,7 @@ dependencies:
|
|
|
66
66
|
- - "~>"
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
68
|
version: '3.0'
|
|
69
|
-
|
|
70
|
-
name: dotenv
|
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
|
72
|
-
requirements:
|
|
73
|
-
- - "~>"
|
|
74
|
-
- !ruby/object:Gem::Version
|
|
75
|
-
version: 2.1.0
|
|
76
|
-
type: :development
|
|
77
|
-
prerelease: false
|
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
-
requirements:
|
|
80
|
-
- - "~>"
|
|
81
|
-
- !ruby/object:Gem::Version
|
|
82
|
-
version: 2.1.0
|
|
83
|
-
description: A wrapper for the PunkAPI, well...API
|
|
69
|
+
description: A wrapper for the PunkAPI API
|
|
84
70
|
email:
|
|
85
71
|
- sam.jbmason@gmail.com
|
|
86
72
|
executables: []
|
|
@@ -116,7 +102,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
116
102
|
requirements:
|
|
117
103
|
- - ">="
|
|
118
104
|
- !ruby/object:Gem::Version
|
|
119
|
-
version: 1.9
|
|
105
|
+
version: '1.9'
|
|
120
106
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
121
107
|
requirements:
|
|
122
108
|
- - ">="
|
|
@@ -127,7 +113,7 @@ rubyforge_project:
|
|
|
127
113
|
rubygems_version: 2.5.1
|
|
128
114
|
signing_key:
|
|
129
115
|
specification_version: 4
|
|
130
|
-
summary: A wrapper for the PunkAPI
|
|
116
|
+
summary: A wrapper for the PunkAPI API
|
|
131
117
|
test_files:
|
|
132
118
|
- spec/lib/client_spec.rb
|
|
133
119
|
- spec/spec_helper.rb
|