atum 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop_todo.yml +4 -0
- data/CHANGELOG.md +0 -3
- data/CONTRIBUTORS.md +12 -11
- data/README.md +95 -34
- data/atum.gemspec +2 -4
- data/bin/atum +1 -37
- data/lib/atum/generation.rb +1 -0
- data/lib/atum/generation/cli.rb +145 -0
- data/lib/atum/generation/erb_context.rb +13 -2
- data/lib/atum/generation/generators/views/module.erb +3 -3
- data/lib/atum/version.rb +1 -1
- data/spec/atum/generation/erb_context_spec.rb +18 -0
- data/spec/integration/client_integration_spec.rb +34 -5
- metadata +21 -19
- data/Appraisals +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e0b2d59a4b5c181a68fd73d5670f2bd8a61c150
|
4
|
+
data.tar.gz: 3a47425502fa080a76b0bf7672f23912985d9b29
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a3c1476cda130ad87820109c763a8e6eace73d260054cea9cb691262ccf760352e871b6e78ee6f124d38c65a0a69394cc4678df3899fe2e31a37731cb87d82fc
|
7
|
+
data.tar.gz: d5d5e914a53afde32eb6106a364e55c82d993650865cfb8fa333a13fca62cceda1c69ff857b94b556f8e8c6faf829e976f0f3d9bc0045646c891aaf297bbcdd8
|
data/.rubocop_todo.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/CONTRIBUTORS.md
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
# Contributors
|
2
|
-
## Original [Heroics](https://github.com/interagent/heroics) contributors:
|
3
|
-
|
4
|
-
Andrea Salicetti <andrea.salicetti@gmail.com>
|
5
|
-
Jamu Kakar <jkakar@kakar.ca>
|
6
|
-
Jonathan Roes <jroes@jroes.net>
|
7
|
-
Mark Fine <mark.fine@gmail.com>
|
8
|
-
Mark McGranaghan <mmcgrana@gmail.com>
|
9
|
-
Neil Middleton <neil@heroku.com>
|
10
|
-
Wesley Beary <geemus+github@gmail.com>
|
11
2
|
|
12
3
|
## Atum contributors
|
13
4
|
|
14
|
-
Pete Hamilton
|
15
|
-
Isaac Seymour
|
5
|
+
- [Pete Hamilton](https://github.com/petehamilton)
|
6
|
+
- [Isaac Seymour](https://github.com/isaacseymour)
|
7
|
+
|
8
|
+
## Original [Heroics](https://github.com/interagent/heroics) contributors:
|
9
|
+
|
10
|
+
- [Andrea Salicetti](andrea.salicetti@gmail.com)
|
11
|
+
- [Jamu Kakar](jkakar@kakar.ca)
|
12
|
+
- [Jonathan Roes](jroes@jroes.net)
|
13
|
+
- [Mark Fine](mark.fine@gmail.com)
|
14
|
+
- [Mark McGranaghan](mmcgrana@gmail.com)
|
15
|
+
- [Neil Middleton](neil@heroku.com)
|
16
|
+
- [Wesley Beary](geemus+github@gmail.com)
|
data/README.md
CHANGED
@@ -3,55 +3,100 @@
|
|
3
3
|
Ruby HTTP client generator for JSON APIs represented with JSON schema, forked
|
4
4
|
from [Heroics](https://github.com/interagent/heroics).
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
Add this line to your application's Gemfile:
|
9
|
-
|
10
|
-
gem 'atum'
|
11
|
-
|
12
|
-
And then execute:
|
6
|
+
**WARNING: Atum is currently in early Alpha development. You have been warned.**
|
13
7
|
|
14
|
-
|
15
|
-
|
16
|
-
Or install it yourself as:
|
8
|
+
## Installation
|
17
9
|
|
18
10
|
$ gem install atum
|
19
11
|
|
20
12
|
## Usage
|
21
13
|
|
22
|
-
### Generating
|
14
|
+
### Generating Clients
|
23
15
|
|
24
16
|
Atum generates an HTTP client from a JSON schema that describes your JSON
|
25
17
|
API. Look at [prmd](https://github.com/interagent/prmd) for tooling to help
|
26
18
|
write a JSON schema. When you have a JSON schema prepared you can generate a
|
27
|
-
client for your API
|
19
|
+
client for your API.
|
20
|
+
|
21
|
+
To see a simple example, you can look at the [Fruity API json
|
22
|
+
schema](https://github.com/gocardless/atum/blob/master/spec/fixtures/fruity_schema.json)
|
23
|
+
in Atum's spec fixtures
|
24
|
+
|
25
|
+
#### 1. Create a New Gem
|
26
|
+
|
27
|
+
To generate a new rubygem client, you can run:
|
28
28
|
|
29
29
|
```
|
30
|
-
$ atum
|
30
|
+
$ atum new fruity-api
|
31
31
|
```
|
32
32
|
|
33
|
-
This will
|
34
|
-
|
33
|
+
This will does several things:
|
34
|
+
|
35
|
+
- Createa a new gem called fruity-api in a `fruity-api` folder in the current
|
36
|
+
directory
|
37
|
+
|
38
|
+
```
|
39
|
+
> atum new fruity-api
|
40
|
+
create fruity-api/Gemfile
|
41
|
+
create fruity-api/Rakefile
|
42
|
+
create fruity-api/LICENSE.txt
|
43
|
+
create fruity-api/README.md
|
44
|
+
create fruity-api/.gitignore
|
45
|
+
create fruity-api/fruity-api.gemspec
|
46
|
+
create fruity-api/lib/fruity/api.rb
|
47
|
+
create fruity-api/lib/fruity/api/version.rb
|
48
|
+
Initializing git repo in /Users/petehamilton/projects/atum/fruity-api
|
49
|
+
```
|
50
|
+
- Creates a `.atum.yml` file in the root of the gem and populate it with:
|
51
|
+
```
|
52
|
+
gem_name: fruity-api
|
53
|
+
constant_name: FruityApi
|
54
|
+
```
|
55
|
+
You can add more configuration options to this file to prevent having to add
|
56
|
+
lots of command line arguments later. See below.
|
57
|
+
|
58
|
+
#### 2. Generate the client files
|
59
|
+
|
60
|
+
Now you have a gem, you need to populate the lib directory. To do this, navigate
|
61
|
+
to the root of your gem and run:
|
62
|
+
|
63
|
+
```
|
64
|
+
$ atum generate --file PATH_TO_SCHEMA --url API_URL
|
65
|
+
```
|
66
|
+
|
67
|
+
*Note: You can store the file and url config in your .atum.yml file for
|
68
|
+
convenience*
|
69
|
+
|
35
70
|
|
36
71
|
### Passing custom headers
|
37
72
|
|
38
73
|
If your client needs to pass custom headers with each request these can be
|
39
|
-
specified using
|
74
|
+
specified using `--default-headers or -H`:
|
40
75
|
|
41
76
|
```
|
42
|
-
atum -H
|
77
|
+
atum generate -H 'Accept: application/vnd.myapp+json; version=3'
|
43
78
|
```
|
44
79
|
|
45
|
-
|
80
|
+
To pass multiple headers, just give multiple strings:
|
81
|
+
|
82
|
+
```
|
83
|
+
atum generate -H 'header1' 'header2' 'header3'
|
84
|
+
```
|
85
|
+
|
86
|
+
You can also define a default\_headers section in your .atum.yml file.
|
87
|
+
|
88
|
+
```
|
89
|
+
default_headers:
|
90
|
+
- Accept: application/vnd.myapp+json; version=3
|
91
|
+
- Accept-Language: Fr
|
92
|
+
```
|
46
93
|
|
47
94
|
### Generating API documentation
|
48
95
|
|
49
|
-
The generated client has [Yard](http://yardoc.org/)-compatible docstrings.
|
50
|
-
You can generate documentation using `yard`:
|
96
|
+
The generated client has [Yard](http://yardoc.org/)-compatible docstrings. You can therefore generate documentation using `yard`:
|
51
97
|
|
52
|
-
__not convinced this is actually correct now it's a directory?__
|
53
98
|
```
|
54
|
-
yard doc -m markdown
|
99
|
+
yard doc -m markdown .
|
55
100
|
```
|
56
101
|
|
57
102
|
This will generate HTML in the `docs` directory. Note that Yard creates an
|
@@ -61,21 +106,37 @@ through Jekyll.
|
|
61
106
|
|
62
107
|
### Handling failures
|
63
108
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
109
|
+
When an API returns an error, Atum will return an `ApiError`.
|
110
|
+
|
111
|
+
Assuming the error response form the server is in JSON format, like:
|
112
|
+
|
113
|
+
```
|
114
|
+
{
|
115
|
+
"error": {
|
116
|
+
"documentation_url": "https://developer.gocardless.com/enterprise#validation_failed",
|
117
|
+
"message": "Validation failed",
|
118
|
+
"type": "validation_failed",
|
119
|
+
"code": 422,
|
120
|
+
"request_id": "dd50eaaf-8213-48fe-90d6-5466872efbc4",
|
121
|
+
"errors": [
|
122
|
+
{
|
123
|
+
"message": "must be a number",
|
124
|
+
"field": "sort_code"
|
125
|
+
}, {
|
126
|
+
"message": "is the wrong length (should be 8 characters)",
|
127
|
+
"field": "sort_code"
|
128
|
+
}
|
129
|
+
]
|
130
|
+
}
|
131
|
+
}
|
75
132
|
```
|
76
133
|
|
134
|
+
Atum will return an Atum::Core::ApiError error. You can access the raw hash (unenveloped) via a `.errors` method, otherwise the error message will contain the error's message and a link to the documentation if it exists.
|
135
|
+
|
136
|
+
|
137
|
+
|
77
138
|
## Supporting Ruby < 2.0.0
|
78
|
-
|
139
|
+
Atum only supports Ruby >= 2.0.0 out of the box due to our use of
|
79
140
|
Enumerable::Lazy for lazy loading of paginated API resources.
|
80
141
|
|
81
142
|
However, support for previous ruby versions can be added using a gem such as
|
data/atum.gemspec
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
1
|
lib = File.expand_path('../lib', __FILE__)
|
4
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
3
|
|
@@ -9,7 +7,7 @@ Gem::Specification.new do |spec|
|
|
9
7
|
spec.name = 'atum'
|
10
8
|
spec.version = Atum::VERSION
|
11
9
|
spec.authors = %w(isaacseymour petehamilton)
|
12
|
-
spec.email =
|
10
|
+
spec.email = %w(isaac@gocardless.com pete@gocardless.com)
|
13
11
|
spec.description = 'A Ruby client generator for JSON APIs described with a JSON schema'
|
14
12
|
spec.summary = 'A Ruby client generator for JSON APIs described with a JSON schema'
|
15
13
|
spec.homepage = 'https://github.com/gocardless/atum'
|
@@ -29,9 +27,9 @@ Gem::Specification.new do |spec|
|
|
29
27
|
spec.add_development_dependency 'webmock', '~> 1.18'
|
30
28
|
spec.add_development_dependency 'pry-nav', '~> 0.2'
|
31
29
|
spec.add_development_dependency 'yard', '~> 0.8'
|
32
|
-
spec.add_development_dependency 'appraisal', '~> 1.0.2'
|
33
30
|
|
34
31
|
spec.add_dependency 'erubis', '~> 2.7'
|
35
32
|
spec.add_dependency 'faraday', '>= 0.8.9'
|
36
33
|
spec.add_dependency 'activesupport', '~> 4.1'
|
34
|
+
spec.add_dependency 'thor', '~> 0.19'
|
37
35
|
end
|
data/bin/atum
CHANGED
@@ -1,41 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require 'optparse'
|
4
3
|
require 'atum'
|
5
4
|
|
6
|
-
|
7
|
-
|
8
|
-
option_parser = OptionParser.new do |opts|
|
9
|
-
opts.banner = 'Usage: atum module_name schema_filename url'
|
10
|
-
|
11
|
-
opts.on('-h', '--help', 'Display this screen') do
|
12
|
-
puts opts
|
13
|
-
exit
|
14
|
-
end
|
15
|
-
|
16
|
-
opts.on('-v', '--version', 'Display the version atum is running at') do
|
17
|
-
puts Atum::VERSION
|
18
|
-
exit
|
19
|
-
end
|
20
|
-
|
21
|
-
opts.on('-H', '--header [HEADER]',
|
22
|
-
'Include header with all requests') do |header|
|
23
|
-
header_key, header_value, _ = header.split(':', 0)
|
24
|
-
options[:headers][header_key] = header_value.strip
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
option_parser.parse!
|
29
|
-
|
30
|
-
if ARGV.length != 3
|
31
|
-
puts option_parser
|
32
|
-
exit
|
33
|
-
end
|
34
|
-
|
35
|
-
options = { default_headers: options[:headers] }
|
36
|
-
|
37
|
-
module_name, schema_filename, url = ARGV
|
38
|
-
|
39
|
-
generator = Atum::Generation::GeneratorService.new(module_name, schema_filename,
|
40
|
-
url, options)
|
41
|
-
generator.generate_files
|
5
|
+
Atum::Generation::CLI.start(ARGV)
|
data/lib/atum/generation.rb
CHANGED
@@ -0,0 +1,145 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'yaml'
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
# rubocop:disable Metrics/ClassLength
|
6
|
+
module Atum
|
7
|
+
module Generation
|
8
|
+
class CLI < Thor
|
9
|
+
desc 'new <client_name>', 'create a new client gem'
|
10
|
+
def new(client_name)
|
11
|
+
# Generate a basic gem
|
12
|
+
run_command("bundle gem #{client_name}")
|
13
|
+
|
14
|
+
# Add atum to the gemspec file
|
15
|
+
run_command("sed -i '$ d' #{client_name}/#{client_name}.gemspec")
|
16
|
+
run_command("echo '\n spec.add_runtime_dependency \"atum\", " \
|
17
|
+
"\"~> #{Atum::VERSION}\"' >> " \
|
18
|
+
"#{client_name}/#{client_name}.gemspec")
|
19
|
+
run_command("echo 'end' >> #{client_name}/#{client_name}.gemspec")
|
20
|
+
|
21
|
+
# Populate a .atum file in the root
|
22
|
+
Dir.chdir(client_name) do
|
23
|
+
File.open('.atum.yml', 'w') do |f|
|
24
|
+
names = name_versions(client_name)
|
25
|
+
f.puts "gem_name: #{client_name}"
|
26
|
+
f.puts "constant_name: #{names[:constant_name]}"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
desc 'generate', 'generate the atum client in a lib directory'
|
32
|
+
option :default_headers,
|
33
|
+
aliases: '-H',
|
34
|
+
desc: 'A comma separated list of headers, ' \
|
35
|
+
'e.g. Api-Version: 2010-10-03, Accept-Language: Fr',
|
36
|
+
default: '',
|
37
|
+
type: 'array'
|
38
|
+
option :constant_name, desc: 'e.g. FruityApi'
|
39
|
+
option :file
|
40
|
+
option :url
|
41
|
+
option :gem_name
|
42
|
+
option :commit, type: :boolean,
|
43
|
+
desc: 'Automatically commit the generated code'
|
44
|
+
def generate
|
45
|
+
config = options_from_atum_file.merge(options)
|
46
|
+
validate_config(config)
|
47
|
+
|
48
|
+
names = name_versions(config['gem_name'])
|
49
|
+
config['constant_name'] = names[:constant_name]
|
50
|
+
|
51
|
+
# Preserve the version file
|
52
|
+
version_file = File.join('lib', names[:namespaced_path], 'version.rb')
|
53
|
+
version_file_content = File.read(version_file)
|
54
|
+
|
55
|
+
# Nuke everything in the lib folder
|
56
|
+
FileUtils.rm_rf('lib/*')
|
57
|
+
|
58
|
+
# Regenerate everything in the lib folder
|
59
|
+
regenerate_lib_folder(config)
|
60
|
+
|
61
|
+
# Re-write the version file
|
62
|
+
File.open(version_file, 'w') { |f| f.write(version_file_content) }
|
63
|
+
|
64
|
+
# Print advice
|
65
|
+
print_closing_message
|
66
|
+
end
|
67
|
+
|
68
|
+
desc 'version', 'print Atum version'
|
69
|
+
def version
|
70
|
+
print Atum::VERSION, "\n"
|
71
|
+
end
|
72
|
+
|
73
|
+
no_commands do
|
74
|
+
|
75
|
+
def options_from_atum_file
|
76
|
+
File.file?('.atum.yml') ? YAML.load_file('.atum.yml') : {}
|
77
|
+
end
|
78
|
+
|
79
|
+
def validate_config(config)
|
80
|
+
common = ' (either in .atum.yml or via cli options)'
|
81
|
+
begin
|
82
|
+
raise 'gem_name must be given' + common unless config.key?('gem_name')
|
83
|
+
raise 'file must be given' + common unless config.key?('file')
|
84
|
+
raise 'url must be given' + common unless config.key?('url')
|
85
|
+
rescue => e
|
86
|
+
message "Error: #{e.message}\n"
|
87
|
+
help(:generate)
|
88
|
+
exit
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def parse_headers(hs)
|
93
|
+
Hash[hs.map { |header| header.split(':').map(&:strip) }]
|
94
|
+
end
|
95
|
+
|
96
|
+
def message(msg = nil)
|
97
|
+
print "#{msg}\n"
|
98
|
+
end
|
99
|
+
|
100
|
+
def run_command(cmd)
|
101
|
+
system(cmd)
|
102
|
+
end
|
103
|
+
|
104
|
+
def regenerate_lib_folder(config)
|
105
|
+
Dir.chdir('lib') do
|
106
|
+
Atum::Generation::GeneratorService.new(
|
107
|
+
config['constant_name'], config['file'], config['url'],
|
108
|
+
default_headers: parse_headers(options['default_headers'])
|
109
|
+
).generate_files
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def print_closing_message
|
114
|
+
message "Successfully regenerated with atum v#{Atum::VERSION})\n"
|
115
|
+
timestamp = Time.now.utc.iso8601
|
116
|
+
cmd = "git add . -A && git commit -am 'Regenerated client on " \
|
117
|
+
"#{timestamp} (atum v#{Atum::VERSION})'"
|
118
|
+
|
119
|
+
if options['commit']
|
120
|
+
message 'Staging files and committing changes...'
|
121
|
+
system(cmd)
|
122
|
+
else
|
123
|
+
message "We suggest you now run:\n"
|
124
|
+
message "\t#{cmd}\n"
|
125
|
+
message 'Or, run the command with the --commit flag to do this automatically'
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
def name_versions(name)
|
130
|
+
constant_name = name.split('_').map { |p| p[0..0].upcase + p[1..-1] }.join
|
131
|
+
if constant_name =~ /-/
|
132
|
+
constant_name = constant_name.split('-')
|
133
|
+
.map { |q| q[0..0].upcase + q[1..-1] }
|
134
|
+
.join('::')
|
135
|
+
end
|
136
|
+
|
137
|
+
{ underscored_name: name.tr('-', '_'),
|
138
|
+
namespaced_path: name.tr('-', '/'),
|
139
|
+
constant_name: constant_name,
|
140
|
+
constant_array: constant_name.split('::') }
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
@@ -5,13 +5,24 @@ module Atum
|
|
5
5
|
starter = (' ' * tabs) + '# '
|
6
6
|
max_line_length = 78 - (tabs * 2)
|
7
7
|
comment.split("\n")
|
8
|
-
|
9
|
-
|
8
|
+
.flat_map { |l| break_line(l, max_line_length) }
|
9
|
+
.map { |l| starter + l.strip }
|
10
|
+
.join("\n")
|
10
11
|
end
|
11
12
|
|
12
13
|
def method(name, params)
|
13
14
|
"#{name}" + (params.length > 0 ? "(#{params})" : '')
|
14
15
|
end
|
16
|
+
|
17
|
+
def break_line(line, max_line_length)
|
18
|
+
line.split.reduce([]) do |lines, word|
|
19
|
+
if lines.empty? || (lines[-1] + " #{word}").size > max_line_length
|
20
|
+
lines << word
|
21
|
+
else
|
22
|
+
lines[-1] << " #{word}" && lines
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
15
26
|
end
|
16
27
|
end
|
17
28
|
end
|
@@ -13,10 +13,10 @@ module <%= @module_name.split("::")[0..i].join("::") %>; end
|
|
13
13
|
<% end %>
|
14
14
|
|
15
15
|
version_file = '<%= @module_name.downcase.underscore.split("/").last %>/version'
|
16
|
-
if File.file?(version_file)
|
17
|
-
|
16
|
+
if File.file? File.expand_path("#{version_file}.rb", File.dirname(__FILE__))
|
17
|
+
require_relative version_file
|
18
18
|
else
|
19
|
-
<%= "#{@module_name}::VERSION" %> = ''
|
19
|
+
<%= "#{@module_name}::VERSION" %> = ''
|
20
20
|
end
|
21
21
|
require_relative '<%= @module_name.downcase.underscore.split("/").last %>/client'
|
22
22
|
<% @resources.each do |resource| %>
|
data/lib/atum/version.rb
CHANGED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Atum::Generation::ErbContext do
|
4
|
+
let(:ctx) { described_class.new }
|
5
|
+
describe '#commentify' do
|
6
|
+
let(:tabs) { 0 }
|
7
|
+
subject(:result) { ctx.commentify(comment, tabs) }
|
8
|
+
|
9
|
+
context 'when the comment is more than 78 characters' do
|
10
|
+
let(:comment) { (['abc '] * 20).join }
|
11
|
+
it 'should wrap by word' do
|
12
|
+
firstline = '# ' + (['abc '] * 19).join.strip
|
13
|
+
secondline = '# abc'
|
14
|
+
expect(result).to eq(firstline + "\n" + secondline)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -7,19 +7,23 @@ describe 'The Generated Client' do
|
|
7
7
|
end
|
8
8
|
let(:url) { 'http://USER:PASSWORD@api.fruity.com/fruits' }
|
9
9
|
let(:tmp_folder) do
|
10
|
-
File.expand_path(File.join('..', '..', '
|
10
|
+
File.expand_path(File.join('..', '..', 'tmp'), File.dirname(__FILE__))
|
11
11
|
end
|
12
12
|
let(:options) { { path: File.join(tmp_folder, 'client') } }
|
13
13
|
let(:generator_service) do
|
14
14
|
Atum::Generation::GeneratorService.new(name, schema_file, url, options)
|
15
15
|
end
|
16
|
+
let(:pre_generation_setup) { -> { generator_service.generate_files } }
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
18
|
+
around(:each) do |example|
|
19
|
+
pre_generation_setup.call
|
20
|
+
load File.join(options[:path], 'fruity.rb')
|
20
21
|
Fruity.connect(url, 'USER', 'PASSWORD')
|
22
|
+
example.run
|
23
|
+
Fruity.send(:remove_const, 'VERSION')
|
24
|
+
Fruity.send(:remove_const, 'SCHEMA')
|
25
|
+
FileUtils.rm_rf(options[:path])
|
21
26
|
end
|
22
|
-
after { FileUtils.rm_rf(tmp_folder) }
|
23
27
|
|
24
28
|
it 'can make get requests' do
|
25
29
|
stub = WebMock.stub_request(:get, "#{url}/lemon")
|
@@ -88,4 +92,29 @@ describe 'The Generated Client' do
|
|
88
92
|
.with(body: body.to_json)
|
89
93
|
expect(Fruity.lemon.create(body: body))
|
90
94
|
end
|
95
|
+
|
96
|
+
context "when a version file doesn't exist" do
|
97
|
+
it "doesn't define VERSION" do
|
98
|
+
expect(Fruity::VERSION).to eq('')
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
context 'when a version file exists' do
|
103
|
+
let(:version) { '1.2.3' }
|
104
|
+
let(:pre_generation_setup) do
|
105
|
+
lambda do
|
106
|
+
generator_service.generate_files
|
107
|
+
file = File.expand_path(File.join(options[:path], 'fruity', 'version.rb'))
|
108
|
+
File.open(file, 'w') do |f|
|
109
|
+
f.write "module #{name}\n"
|
110
|
+
f.write " VERSION = '#{version}'\n"
|
111
|
+
f.write 'end'
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
it 'includes a version file for the client when one exists' do
|
117
|
+
expect(Fruity::VERSION).to eq(version)
|
118
|
+
end
|
119
|
+
end
|
91
120
|
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.7.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-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -137,20 +137,6 @@ dependencies:
|
|
137
137
|
- - ~>
|
138
138
|
- !ruby/object:Gem::Version
|
139
139
|
version: '0.8'
|
140
|
-
- !ruby/object:Gem::Dependency
|
141
|
-
name: appraisal
|
142
|
-
requirement: !ruby/object:Gem::Requirement
|
143
|
-
requirements:
|
144
|
-
- - ~>
|
145
|
-
- !ruby/object:Gem::Version
|
146
|
-
version: 1.0.2
|
147
|
-
type: :development
|
148
|
-
prerelease: false
|
149
|
-
version_requirements: !ruby/object:Gem::Requirement
|
150
|
-
requirements:
|
151
|
-
- - ~>
|
152
|
-
- !ruby/object:Gem::Version
|
153
|
-
version: 1.0.2
|
154
140
|
- !ruby/object:Gem::Dependency
|
155
141
|
name: erubis
|
156
142
|
requirement: !ruby/object:Gem::Requirement
|
@@ -193,10 +179,24 @@ dependencies:
|
|
193
179
|
- - ~>
|
194
180
|
- !ruby/object:Gem::Version
|
195
181
|
version: '4.1'
|
182
|
+
- !ruby/object:Gem::Dependency
|
183
|
+
name: thor
|
184
|
+
requirement: !ruby/object:Gem::Requirement
|
185
|
+
requirements:
|
186
|
+
- - ~>
|
187
|
+
- !ruby/object:Gem::Version
|
188
|
+
version: '0.19'
|
189
|
+
type: :runtime
|
190
|
+
prerelease: false
|
191
|
+
version_requirements: !ruby/object:Gem::Requirement
|
192
|
+
requirements:
|
193
|
+
- - ~>
|
194
|
+
- !ruby/object:Gem::Version
|
195
|
+
version: '0.19'
|
196
196
|
description: A Ruby client generator for JSON APIs described with a JSON schema
|
197
197
|
email:
|
198
|
-
-
|
199
|
-
-
|
198
|
+
- isaac@gocardless.com
|
199
|
+
- pete@gocardless.com
|
200
200
|
executables:
|
201
201
|
- atum
|
202
202
|
extensions: []
|
@@ -207,7 +207,6 @@ files:
|
|
207
207
|
- .rubocop.yml
|
208
208
|
- .rubocop_todo.yml
|
209
209
|
- .travis.yml
|
210
|
-
- Appraisals
|
211
210
|
- CHANGELOG.md
|
212
211
|
- CONTRIBUTING.md
|
213
212
|
- CONTRIBUTORS.md
|
@@ -238,6 +237,7 @@ files:
|
|
238
237
|
- lib/atum/core/schema/parameter_choice.rb
|
239
238
|
- lib/atum/core/schema/resource_schema.rb
|
240
239
|
- lib/atum/generation.rb
|
240
|
+
- lib/atum/generation/cli.rb
|
241
241
|
- lib/atum/generation/erb_context.rb
|
242
242
|
- lib/atum/generation/errors.rb
|
243
243
|
- lib/atum/generation/generator_link.rb
|
@@ -264,6 +264,7 @@ files:
|
|
264
264
|
- spec/atum/core/schema/parameter_choice_spec.rb
|
265
265
|
- spec/atum/core/schema/parameter_spec.rb
|
266
266
|
- spec/atum/core/schema/resource_schema_spec.rb
|
267
|
+
- spec/atum/generation/erb_context_spec.rb
|
267
268
|
- spec/atum/generation/generator_link_spec.rb
|
268
269
|
- spec/atum/generation/generator_resource_spec.rb
|
269
270
|
- spec/atum/generation/generator_service_spec.rb
|
@@ -301,3 +302,4 @@ signing_key:
|
|
301
302
|
specification_version: 4
|
302
303
|
summary: A Ruby client generator for JSON APIs described with a JSON schema
|
303
304
|
test_files: []
|
305
|
+
has_rdoc:
|