atum 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -7
- data/lib/atum/core/link.rb +8 -1
- data/lib/atum/version.rb +1 -1
- data/spec/integration/client_integration_spec.rb +14 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3b4f88a40552482c7b7db6d3f8c273ca8dd86e8
|
4
|
+
data.tar.gz: 0bf525b21bba1cca79a48cab6e78a06c647bf3c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ba17fd52fdf6dda1241ece37036e07904105fbaa682206cfa5c1b620c7e45bd42c6d4695672a18915244934bb388966e5bff91a327d2df91a65388006546bed
|
7
|
+
data.tar.gz: 689cef30df036f8368f00e4d877ecac77f6dc266836dfd23cbea8ed165b28e93e15f4e04cf1b2a12192da45d115642ad10431b30c78022b9ad610e1f4dfabda1
|
data/README.md
CHANGED
@@ -24,7 +24,7 @@ in Atum's spec fixtures
|
|
24
24
|
|
25
25
|
#### 1. Create a New Gem
|
26
26
|
|
27
|
-
To generate a new rubygem client, you can run:
|
27
|
+
To generate a new rubygem client (for our ficitional *Fruity* API), you can run:
|
28
28
|
|
29
29
|
```
|
30
30
|
$ atum new fruity-api
|
@@ -32,11 +32,11 @@ $ atum new fruity-api
|
|
32
32
|
|
33
33
|
This will does several things:
|
34
34
|
|
35
|
-
-
|
35
|
+
- Creates a new gem called `fruity-api` in a `fruity-api` folder in the current
|
36
36
|
directory
|
37
37
|
|
38
38
|
```
|
39
|
-
|
39
|
+
$ atum new fruity-api
|
40
40
|
create fruity-api/Gemfile
|
41
41
|
create fruity-api/Rakefile
|
42
42
|
create fruity-api/LICENSE.txt
|
@@ -74,13 +74,13 @@ If your client needs to pass custom headers with each request these can be
|
|
74
74
|
specified using `--default-headers or -H`:
|
75
75
|
|
76
76
|
```
|
77
|
-
atum generate -H 'Accept: application/vnd.myapp+json; version=3'
|
77
|
+
$ atum generate -H 'Accept: application/vnd.myapp+json; version=3'
|
78
78
|
```
|
79
79
|
|
80
80
|
To pass multiple headers, just give multiple strings:
|
81
81
|
|
82
82
|
```
|
83
|
-
atum generate -H 'header1' 'header2' 'header3'
|
83
|
+
$ atum generate -H 'header1' 'header2' 'header3'
|
84
84
|
```
|
85
85
|
|
86
86
|
You can also define a default\_headers section in your .atum.yml file.
|
@@ -96,7 +96,7 @@ default_headers:
|
|
96
96
|
The generated client has [Yard](http://yardoc.org/)-compatible docstrings. You can therefore generate documentation using `yard`:
|
97
97
|
|
98
98
|
```
|
99
|
-
yard doc -m markdown .
|
99
|
+
$ yard doc -m markdown .
|
100
100
|
```
|
101
101
|
|
102
102
|
This will generate HTML in the `docs` directory. Note that Yard creates an
|
@@ -131,7 +131,7 @@ Assuming the error response form the server is in JSON format, like:
|
|
131
131
|
}
|
132
132
|
```
|
133
133
|
|
134
|
-
Atum will return an Atum::Core::ApiError error. You can access the raw hash (unenveloped) via a `.errors` method,
|
134
|
+
Atum will return an Atum::Core::ApiError error. You can access the raw hash (unenveloped) via a `.errors` method, by default the error message will contain the error's message and a link to the documentation if it exists.
|
135
135
|
|
136
136
|
|
137
137
|
|
data/lib/atum/core/link.rb
CHANGED
@@ -18,9 +18,16 @@ module Atum
|
|
18
18
|
# include:
|
19
19
|
# - default_headers: Optionally, a set of headers to include in every
|
20
20
|
# request made by the client. Default is no custom headers.
|
21
|
+
# - http_adapter: Optionally, the http adapter to use; for now we accept
|
22
|
+
# adapters according to Faraday's builder:
|
23
|
+
# https://github.com/lostisland/faraday/blob/v0.8.9/lib/faraday/builder.rb
|
24
|
+
# e.g. http_adapter: [:rack, Rails.application]
|
21
25
|
def initialize(url, link_schema, options = {})
|
22
26
|
root_url, @path_prefix = unpack_url(url)
|
23
|
-
|
27
|
+
http_adapter = options[:http_adapter] || [:net_http]
|
28
|
+
@connection = Faraday.new(url: root_url) do |faraday|
|
29
|
+
faraday.adapter(*http_adapter)
|
30
|
+
end
|
24
31
|
@link_schema = link_schema
|
25
32
|
@headers = options[:default_headers] || {}
|
26
33
|
end
|
data/lib/atum/version.rb
CHANGED
@@ -117,4 +117,18 @@ describe 'The Generated Client' do
|
|
117
117
|
expect(Fruity::VERSION).to eq(version)
|
118
118
|
end
|
119
119
|
end
|
120
|
+
|
121
|
+
context 'when using a :test http_adapter' do
|
122
|
+
before do
|
123
|
+
stubs = Faraday::Adapter::Test::Stubs.new do |stub|
|
124
|
+
stub.get("#{url}/lemon") { |_| [200, {}, 5] }
|
125
|
+
end
|
126
|
+
Fruity.connect(url, 'USER', 'PASSWORD',
|
127
|
+
http_adapter: [:test, stubs])
|
128
|
+
end
|
129
|
+
|
130
|
+
it 'uses the defined stubs' do
|
131
|
+
expect(Fruity.lemon.list).to eq(5)
|
132
|
+
end
|
133
|
+
end
|
120
134
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: atum
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- isaacseymour
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-10-
|
12
|
+
date: 2014-10-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|