napa 0.4.1 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +18 -0
- data/README.md +11 -12
- data/Rakefile +4 -0
- data/docs/quickstart.md +2 -2
- data/lib/napa/authentication.rb +5 -2
- data/lib/napa/cli/base/console.rb +32 -0
- data/lib/napa/cli/base/deploy.rb +22 -0
- data/lib/napa/cli/base/new.rb +49 -0
- data/lib/napa/cli/base/server.rb +29 -0
- data/lib/napa/cli/base/version.rb +14 -0
- data/lib/napa/cli/base.rb +17 -0
- data/lib/napa/cli/generate/api.rb +42 -0
- data/lib/napa/cli/generate/readme.rb +50 -0
- data/lib/napa/cli/generate.rb +18 -0
- data/lib/napa/{generators/migration_generator.rb → cli/migration.rb} +3 -3
- data/lib/napa/{generators → cli}/templates/api/app/apis/%name_tableize%_api.rb.tt +0 -0
- data/lib/napa/{generators → cli}/templates/api/app/models/%name_underscore%.rb.tt +0 -0
- data/lib/napa/{generators → cli}/templates/api/app/representers/%name_underscore%_representer.rb.tt +0 -0
- data/lib/napa/{generators → cli}/templates/api/spec/apis/%name_tableize%_api_spec.rb.tt +0 -0
- data/lib/napa/{generators → cli}/templates/api/spec/models/%name_underscore%_spec.rb.tt +0 -0
- data/lib/napa/{generators → cli}/templates/create_table_migration/%migration_filename%.rb.tt +0 -0
- data/lib/napa/{generators → cli}/templates/migration/%migration_filename%.rb.tt +0 -0
- data/lib/napa/{generators/templates/scaffold → cli/templates/new}/.env.test.tt +1 -1
- data/lib/napa/{generators/templates/scaffold → cli/templates/new}/.env.tt +1 -1
- data/lib/napa/{generators/templates/scaffold → cli/templates/new}/.gitignore.tt +0 -0
- data/lib/napa/{generators/templates/scaffold → cli/templates/new}/.rubocop.yml +0 -0
- data/lib/napa/{generators/templates/scaffold → cli/templates/new}/.ruby-gemset.tt +0 -0
- data/lib/napa/{generators/templates/scaffold → cli/templates/new}/.ruby-version.tt +0 -0
- data/lib/napa/{generators/templates/scaffold → cli/templates/new}/Gemfile.tt +2 -2
- data/lib/napa/{generators/templates/scaffold → cli/templates/new}/README.md +0 -0
- data/lib/napa/{generators/templates/scaffold → cli/templates/new}/Rakefile +0 -0
- data/lib/napa/{generators/templates/scaffold → cli/templates/new}/app/apis/application_api.rb +0 -0
- data/lib/napa/{generators/templates/scaffold → cli/templates/new}/app/apis/hello_api.rb.tt +0 -0
- data/lib/napa/{generators/templates/scaffold → cli/templates/new}/app.rb +0 -0
- data/lib/napa/{generators/templates/scaffold → cli/templates/new}/config/database.yml.tt +0 -0
- data/lib/napa/{generators/templates/scaffold → cli/templates/new}/config/initializers/active_record.rb +0 -0
- data/lib/napa/{generators/templates/scaffold → cli/templates/new}/config/middleware/honeybadger.rb +0 -0
- data/lib/napa/{generators/templates/scaffold → cli/templates/new}/config.ru.tt +1 -2
- data/lib/napa/{generators/templates/scaffold → cli/templates/new}/db/schema.rb +0 -0
- data/lib/napa/{generators/templates/scaffold → cli/templates/new}/lib/.keep +0 -0
- data/lib/napa/{generators/templates/scaffold → cli/templates/new}/log/.keep +0 -0
- data/lib/napa/{generators/templates/scaffold → cli/templates/new}/spec/apis/hello_api_spec.rb.tt +0 -0
- data/lib/napa/{generators/templates/readme → cli/templates/new}/spec/docs/readme_spec.rb +0 -0
- data/lib/napa/{generators/templates/scaffold → cli/templates/new}/spec/factories/.gitkeep +0 -0
- data/lib/napa/{generators/templates/scaffold → cli/templates/new}/spec/spec_helper.rb +0 -0
- data/lib/napa/{generators → cli}/templates/readme/README.md.tt +0 -0
- data/lib/napa/cli/templates/readme/spec/docs/readme_spec.rb +7 -0
- data/lib/napa/cli.rb +3 -89
- data/lib/napa/middleware/authentication.rb +16 -4
- data/lib/napa/param_sanitizer.rb +1 -1
- data/lib/napa/version.rb +1 -1
- data/spec/{generators/scaffold_generator_spec.rb → cli/base/new_spec.rb} +4 -3
- data/spec/{generators/api_generator_spec.rb → cli/generate/api_spec.rb} +5 -4
- data/spec/{generators/readme_generator_spec.rb → cli/generate/readme_spec.rb} +5 -4
- data/spec/{generators/migration_generator_spec.rb → cli/migration_spec.rb} +9 -9
- data/spec/middleware/authentication_spec.rb +95 -34
- data/spec/spec_helper.rb +14 -23
- data/tasks/spec.rake +9 -0
- metadata +54 -48
- data/lib/napa/generators/api_generator.rb +0 -30
- data/lib/napa/generators/readme_generator.rb +0 -47
- data/lib/napa/generators/scaffold_generator.rb +0 -29
- data/lib/napa/generators.rb +0 -4
@@ -3,9 +3,15 @@ module Napa
|
|
3
3
|
class Authentication
|
4
4
|
def initialize(app)
|
5
5
|
@app = app
|
6
|
+
@old_allowed_passwords = []
|
7
|
+
@allowed_header_passwords = []
|
6
8
|
|
7
9
|
if ENV['HEADER_PASSWORDS']
|
8
|
-
@
|
10
|
+
@old_allowed_passwords += ENV['HEADER_PASSWORDS'].split(',').map(&:strip).freeze
|
11
|
+
end
|
12
|
+
|
13
|
+
if ENV['ALLOWED_HEADER_PASSWORDS']
|
14
|
+
@allowed_header_passwords += ENV['ALLOWED_HEADER_PASSWORDS'].split(',').map(&:strip).freeze
|
9
15
|
end
|
10
16
|
end
|
11
17
|
|
@@ -13,7 +19,7 @@ module Napa
|
|
13
19
|
if authenticated_request?(env)
|
14
20
|
@app.call(env)
|
15
21
|
else
|
16
|
-
|
22
|
+
unless @old_allowed_passwords.blank? && @allowed_header_passwords.blank?
|
17
23
|
error_response = Napa::JsonError.new('bad_password', 'bad password').to_json
|
18
24
|
else
|
19
25
|
error_response = Napa::JsonError.new('not_configured', 'password not configured').to_json
|
@@ -21,11 +27,17 @@ module Napa
|
|
21
27
|
|
22
28
|
[401, { 'Content-type' => 'application/json' }, Array.wrap(error_response)]
|
23
29
|
end
|
24
|
-
|
25
30
|
end
|
26
31
|
|
27
32
|
def authenticated_request?(env)
|
28
|
-
@
|
33
|
+
return if @old_allowed_passwords.blank? && @allowed_header_passwords.blank?
|
34
|
+
|
35
|
+
if env['HTTP_PASSWORDS'].present?
|
36
|
+
possible_passwords = env['HTTP_PASSWORDS'].to_s.split(',')
|
37
|
+
(@allowed_header_passwords & possible_passwords).any?
|
38
|
+
else
|
39
|
+
@old_allowed_passwords.include? env['HTTP_PASSWORD']
|
40
|
+
end
|
29
41
|
end
|
30
42
|
end
|
31
43
|
end
|
data/lib/napa/param_sanitizer.rb
CHANGED
data/lib/napa/version.rb
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require 'napa/
|
3
|
-
require 'napa/cli'
|
2
|
+
require 'napa/cli/base/new'
|
4
3
|
|
5
|
-
describe Napa::
|
4
|
+
describe Napa::CLI::Base do
|
6
5
|
let(:app_name) { 'my_test_app' }
|
7
6
|
let(:app_path) { 'spec/my_different_directory' }
|
8
7
|
let(:options) { {} }
|
9
8
|
|
9
|
+
silence_thor
|
10
|
+
|
10
11
|
before do
|
11
12
|
scaffold = Napa::CLI::Base.new(args, options)
|
12
13
|
scaffold.invoke(:new)
|
@@ -1,14 +1,15 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require 'napa/
|
3
|
-
require 'napa/cli'
|
2
|
+
require 'napa/cli/generate/api'
|
4
3
|
|
5
|
-
describe Napa::
|
4
|
+
describe Napa::CLI::Generate do
|
6
5
|
let(:api_name) { 'foo' }
|
7
6
|
let(:test_api_directory) { 'spec/tmp' }
|
8
7
|
|
8
|
+
silence_thor
|
9
|
+
|
9
10
|
before do
|
10
11
|
allow_any_instance_of(described_class).to receive(:output_directory).and_return(test_api_directory)
|
11
|
-
Napa::CLI::
|
12
|
+
Napa::CLI::Generate.new.api(api_name)
|
12
13
|
end
|
13
14
|
|
14
15
|
after do
|
@@ -1,13 +1,14 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require 'napa/
|
3
|
-
require 'napa/cli'
|
2
|
+
require 'napa/cli/generate/readme'
|
4
3
|
|
5
|
-
describe Napa::
|
4
|
+
describe Napa::CLI::Generate do
|
6
5
|
let(:test_readme_directory) { 'spec/tmp' }
|
7
6
|
|
7
|
+
silence_thor
|
8
|
+
|
8
9
|
before do
|
9
10
|
allow_any_instance_of(described_class).to receive(:output_directory).and_return(test_readme_directory)
|
10
|
-
Napa::CLI::
|
11
|
+
Napa::CLI::Generate.new.readme
|
11
12
|
end
|
12
13
|
|
13
14
|
after do
|
@@ -1,12 +1,13 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require 'napa/
|
3
|
-
require 'napa/cli'
|
2
|
+
require 'napa/cli/migration'
|
4
3
|
|
5
|
-
describe Napa::
|
4
|
+
describe Napa::CLI::Migration do
|
6
5
|
|
7
6
|
let(:migration_filename) { 'foo' }
|
8
7
|
let(:test_migrations_directory) { 'spec/tmp' }
|
9
8
|
|
9
|
+
silence_thor
|
10
|
+
|
10
11
|
before do
|
11
12
|
allow_any_instance_of(described_class).to receive(:output_directory).and_return(test_migrations_directory)
|
12
13
|
allow_any_instance_of(described_class).to receive(:migration_filename).and_return(migration_filename)
|
@@ -18,7 +19,8 @@ describe Napa::Generators::MigrationGenerator do
|
|
18
19
|
|
19
20
|
describe 'AddFooToBar flew:string:index brew:integer' do
|
20
21
|
before do
|
21
|
-
Napa::CLI::
|
22
|
+
Napa::CLI::Migration.new(['AddFooToBar', 'flew:string:index', 'brew:integer']).invoke_all
|
23
|
+
|
22
24
|
expected_migration_file = File.join(test_migrations_directory, 'foo.rb')
|
23
25
|
@migration_code = File.read(expected_migration_file)
|
24
26
|
end
|
@@ -39,7 +41,7 @@ describe Napa::Generators::MigrationGenerator do
|
|
39
41
|
|
40
42
|
describe 'RemoveFooFromBar flew:string brew:integer' do
|
41
43
|
before do
|
42
|
-
Napa::CLI::
|
44
|
+
Napa::CLI::Migration.new(['RemoveFooFromBar', 'flew:string', 'brew:integer']).invoke_all
|
43
45
|
expected_migration_file = File.join(test_migrations_directory, 'foo.rb')
|
44
46
|
@migration_code = File.read(expected_migration_file)
|
45
47
|
end
|
@@ -56,7 +58,7 @@ describe Napa::Generators::MigrationGenerator do
|
|
56
58
|
|
57
59
|
describe 'CreateJoinTableFooBar foo bar' do
|
58
60
|
before do
|
59
|
-
Napa::CLI::
|
61
|
+
Napa::CLI::Migration.new(['CreateJoinTableFooBar', 'foo', 'bar']).invoke_all
|
60
62
|
expected_migration_file = File.join(test_migrations_directory, 'foo.rb')
|
61
63
|
@migration_code = File.read(expected_migration_file)
|
62
64
|
end
|
@@ -77,7 +79,7 @@ describe Napa::Generators::MigrationGenerator do
|
|
77
79
|
|
78
80
|
describe 'CreateSkrillex drops:integer hair:string:index' do
|
79
81
|
before do
|
80
|
-
Napa::CLI::
|
82
|
+
Napa::CLI::Migration.new(['CreateSkrillex', 'drops:integer', 'hair:string:index']).invoke_all
|
81
83
|
expected_migration_file = File.join(test_migrations_directory, 'foo.rb')
|
82
84
|
@migration_code = File.read(expected_migration_file)
|
83
85
|
end
|
@@ -100,6 +102,4 @@ describe Napa::Generators::MigrationGenerator do
|
|
100
102
|
end
|
101
103
|
end
|
102
104
|
|
103
|
-
describe
|
104
|
-
|
105
105
|
end
|
@@ -3,52 +3,113 @@ require 'napa/middleware/authentication'
|
|
3
3
|
require 'pry'
|
4
4
|
|
5
5
|
describe Napa::Identity do
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
context 'using HEADER_PASSWORDS' do
|
7
|
+
before do
|
8
|
+
ENV['HEADER_PASSWORDS'] = 'foo'
|
9
|
+
end
|
10
|
+
context 'an authenticated request' do
|
11
|
+
it 'allows the request to continue if given a correct password header' do
|
12
|
+
app = lambda { |env| [200, {'Content-Type' => 'application/json'}, Array.new] }
|
13
|
+
middleware = Napa::Middleware::Authentication.new(app)
|
14
|
+
env = Rack::MockRequest.env_for('/test', {'HTTP_PASSWORD' => 'foo'})
|
15
|
+
status, headers, body = middleware.call(env)
|
16
|
+
|
17
|
+
expect(status).to eq(200)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'a failed authentication request' do
|
22
|
+
it 'returns an error message if the Password header is not supplied' do
|
23
|
+
app = lambda { |env| [200, {'Content-Type' => 'application/json'}, Array.new] }
|
24
|
+
middleware = Napa::Middleware::Authentication.new(app)
|
25
|
+
env = Rack::MockRequest.env_for('/test')
|
26
|
+
status, headers, body = middleware.call(env)
|
27
|
+
|
28
|
+
expect(status).to eq(401)
|
29
|
+
expect(body).to eq([Napa::JsonError.new('bad_password', 'bad password').to_json])
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'returns an error message if an incorrect Password header is supplied' do
|
33
|
+
app = lambda { |env| [200, {'Content-Type' => 'application/json'}, Array.new] }
|
34
|
+
middleware = Napa::Middleware::Authentication.new(app)
|
35
|
+
env = Rack::MockRequest.env_for('/test', {'HTTP_PASSWORD' => 'incorrect'})
|
36
|
+
status, headers, body = middleware.call(env)
|
37
|
+
|
38
|
+
expect(status).to eq(401)
|
39
|
+
expect(body).to eq([Napa::JsonError.new('bad_password', 'bad password').to_json])
|
40
|
+
end
|
9
41
|
|
10
|
-
|
11
|
-
|
12
|
-
app = lambda { |env| [200, {'Content-Type' => 'application/json'}, Array.new] }
|
13
|
-
middleware = Napa::Middleware::Authentication.new(app)
|
14
|
-
env = Rack::MockRequest.env_for('/test', {'HTTP_PASSWORD' => 'foo'})
|
15
|
-
status, headers, body = middleware.call(env)
|
42
|
+
it 'returns an error message if HEADER_PASSWORDS is not configured' do
|
43
|
+
ENV['HEADER_PASSWORDS'] = nil
|
16
44
|
|
17
|
-
|
45
|
+
app = lambda { |env| [200, {'Content-Type' => 'application/json'}, Array.new] }
|
46
|
+
middleware = Napa::Middleware::Authentication.new(app)
|
47
|
+
env = Rack::MockRequest.env_for('/test', {'HTTP_PASSWORD' => 'incorrect'})
|
48
|
+
status, headers, body = middleware.call(env)
|
49
|
+
|
50
|
+
expect(status).to eq(401)
|
51
|
+
expect(body).to eq([Napa::JsonError.new('not_configured', 'password not configured').to_json])
|
52
|
+
end
|
18
53
|
end
|
19
54
|
end
|
20
55
|
|
21
|
-
context '
|
22
|
-
|
23
|
-
|
24
|
-
middleware = Napa::Middleware::Authentication.new(app)
|
25
|
-
env = Rack::MockRequest.env_for('/test')
|
26
|
-
status, headers, body = middleware.call(env)
|
27
|
-
|
28
|
-
expect(status).to eq(401)
|
29
|
-
expect(body).to eq([Napa::JsonError.new('bad_password', 'bad password').to_json])
|
56
|
+
context 'using ALLOWED_HEADER_PASSWORDS' do
|
57
|
+
before do
|
58
|
+
ENV['ALLOWED_HEADER_PASSWORDS'] = 'foo,bar'
|
30
59
|
end
|
31
60
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
61
|
+
context 'an authenticated request' do
|
62
|
+
it 'allows the request to continue if given a correct password header' do
|
63
|
+
app = lambda { |env| [200, {'Content-Type' => 'application/json'}, Array.new] }
|
64
|
+
middleware = Napa::Middleware::Authentication.new(app)
|
65
|
+
env = Rack::MockRequest.env_for('/test', {'HTTP_PASSWORDS' => 'foo'})
|
66
|
+
status, headers, body = middleware.call(env)
|
67
|
+
|
68
|
+
expect(status).to eq(200)
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'allows the request to continue if one password is correct' do
|
72
|
+
app = lambda { |env| [200, {'Content-Type' => 'application/json'}, Array.new] }
|
73
|
+
middleware = Napa::Middleware::Authentication.new(app)
|
74
|
+
env = Rack::MockRequest.env_for('/test', {'HTTP_PASSWORDS' => 'foo,baz'})
|
75
|
+
status, headers, body = middleware.call(env)
|
37
76
|
|
38
|
-
|
39
|
-
|
77
|
+
expect(status).to eq(200)
|
78
|
+
end
|
40
79
|
end
|
41
80
|
|
42
|
-
|
43
|
-
|
81
|
+
context 'a failed authentication request' do
|
82
|
+
it 'returns an error message if the Password header is not supplied' do
|
83
|
+
app = lambda { |env| [200, {'Content-Type' => 'application/json'}, Array.new] }
|
84
|
+
middleware = Napa::Middleware::Authentication.new(app)
|
85
|
+
env = Rack::MockRequest.env_for('/test')
|
86
|
+
status, headers, body = middleware.call(env)
|
87
|
+
|
88
|
+
expect(status).to eq(401)
|
89
|
+
expect(body).to eq([Napa::JsonError.new('bad_password', 'bad password').to_json])
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'returns an error message if an incorrect Password header is supplied' do
|
93
|
+
app = lambda { |env| [200, {'Content-Type' => 'application/json'}, Array.new] }
|
94
|
+
middleware = Napa::Middleware::Authentication.new(app)
|
95
|
+
env = Rack::MockRequest.env_for('/test', {'HTTP_PASSWORD' => 'incorrect'})
|
96
|
+
status, headers, body = middleware.call(env)
|
97
|
+
|
98
|
+
expect(status).to eq(401)
|
99
|
+
expect(body).to eq([Napa::JsonError.new('bad_password', 'bad password').to_json])
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'returns an error message if ALLOWED_HEADER_PASSWORDS is not configured' do
|
103
|
+
ENV['ALLOWED_HEADER_PASSWORDS'] = nil
|
44
104
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
105
|
+
app = lambda { |env| [200, {'Content-Type' => 'application/json'}, Array.new] }
|
106
|
+
middleware = Napa::Middleware::Authentication.new(app)
|
107
|
+
env = Rack::MockRequest.env_for('/test', {'HTTP_PASSWORD' => 'incorrect'})
|
108
|
+
status, headers, body = middleware.call(env)
|
49
109
|
|
50
|
-
|
51
|
-
|
110
|
+
expect(status).to eq(401)
|
111
|
+
expect(body).to eq([Napa::JsonError.new('not_configured', 'password not configured').to_json])
|
112
|
+
end
|
52
113
|
end
|
53
114
|
end
|
54
115
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -11,35 +11,26 @@ Napa.skip_initialization = true
|
|
11
11
|
require 'napa'
|
12
12
|
require 'napa/rspec_extensions/response_helpers'
|
13
13
|
|
14
|
+
module NapaSpecClassHelpers
|
15
|
+
def silence_thor
|
16
|
+
before do |spec|
|
17
|
+
allow_any_instance_of(Thor::Shell::Basic)
|
18
|
+
.to receive(:stdout).and_return(object_spy $stdout)
|
19
|
+
allow_any_instance_of(Thor::Shell::Basic)
|
20
|
+
.to receive(:stderr).and_return(object_spy $stderr)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
ActiveRecord::Schema.verbose = false
|
26
|
+
|
14
27
|
# from https://gist.github.com/adamstegman/926858
|
15
28
|
RSpec.configure do |config|
|
16
29
|
config.include Napa::RspecExtensions::ResponseHelpers
|
17
|
-
|
18
|
-
config.before(:all) { silence_output }
|
19
|
-
config.after(:all) { enable_output }
|
20
|
-
|
30
|
+
config.extend NapaSpecClassHelpers
|
21
31
|
config.include ActsAsFu
|
22
32
|
|
23
33
|
config.before(:each) do
|
24
|
-
allow(Napa).to receive(:initialize)
|
25
34
|
allow(Napa::Logger).to receive_message_chain('logger.info').with(:napa_deprecation_warning)
|
26
35
|
end
|
27
36
|
end
|
28
|
-
|
29
|
-
# Redirects stderr and stdout to /dev/null.
|
30
|
-
def silence_output
|
31
|
-
@orig_stderr = $stderr
|
32
|
-
@orig_stdout = $stdout
|
33
|
-
|
34
|
-
# redirect stderr and stdout to /dev/null
|
35
|
-
$stderr = File.new('/dev/null', 'w')
|
36
|
-
$stdout = File.new('/dev/null', 'w')
|
37
|
-
end
|
38
|
-
|
39
|
-
# Replace stdout and stderr so anything else is output correctly.
|
40
|
-
def enable_output
|
41
|
-
$stderr = @orig_stderr
|
42
|
-
$stdout = @orig_stdout
|
43
|
-
@orig_stderr = nil
|
44
|
-
@orig_stdout = nil
|
45
|
-
end
|
data/tasks/spec.rake
ADDED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: napa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Darby Frey
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -316,6 +316,48 @@ files:
|
|
316
316
|
- lib/napa/active_record_extensions/stats.rb
|
317
317
|
- lib/napa/authentication.rb
|
318
318
|
- lib/napa/cli.rb
|
319
|
+
- lib/napa/cli/base.rb
|
320
|
+
- lib/napa/cli/base/console.rb
|
321
|
+
- lib/napa/cli/base/deploy.rb
|
322
|
+
- lib/napa/cli/base/new.rb
|
323
|
+
- lib/napa/cli/base/server.rb
|
324
|
+
- lib/napa/cli/base/version.rb
|
325
|
+
- lib/napa/cli/generate.rb
|
326
|
+
- lib/napa/cli/generate/api.rb
|
327
|
+
- lib/napa/cli/generate/readme.rb
|
328
|
+
- lib/napa/cli/migration.rb
|
329
|
+
- lib/napa/cli/templates/api/app/apis/%name_tableize%_api.rb.tt
|
330
|
+
- lib/napa/cli/templates/api/app/models/%name_underscore%.rb.tt
|
331
|
+
- lib/napa/cli/templates/api/app/representers/%name_underscore%_representer.rb.tt
|
332
|
+
- lib/napa/cli/templates/api/spec/apis/%name_tableize%_api_spec.rb.tt
|
333
|
+
- lib/napa/cli/templates/api/spec/models/%name_underscore%_spec.rb.tt
|
334
|
+
- lib/napa/cli/templates/create_table_migration/%migration_filename%.rb.tt
|
335
|
+
- lib/napa/cli/templates/migration/%migration_filename%.rb.tt
|
336
|
+
- lib/napa/cli/templates/new/.env.test.tt
|
337
|
+
- lib/napa/cli/templates/new/.env.tt
|
338
|
+
- lib/napa/cli/templates/new/.gitignore.tt
|
339
|
+
- lib/napa/cli/templates/new/.rubocop.yml
|
340
|
+
- lib/napa/cli/templates/new/.ruby-gemset.tt
|
341
|
+
- lib/napa/cli/templates/new/.ruby-version.tt
|
342
|
+
- lib/napa/cli/templates/new/Gemfile.tt
|
343
|
+
- lib/napa/cli/templates/new/README.md
|
344
|
+
- lib/napa/cli/templates/new/Rakefile
|
345
|
+
- lib/napa/cli/templates/new/app.rb
|
346
|
+
- lib/napa/cli/templates/new/app/apis/application_api.rb
|
347
|
+
- lib/napa/cli/templates/new/app/apis/hello_api.rb.tt
|
348
|
+
- lib/napa/cli/templates/new/config.ru.tt
|
349
|
+
- lib/napa/cli/templates/new/config/database.yml.tt
|
350
|
+
- lib/napa/cli/templates/new/config/initializers/active_record.rb
|
351
|
+
- lib/napa/cli/templates/new/config/middleware/honeybadger.rb
|
352
|
+
- lib/napa/cli/templates/new/db/schema.rb
|
353
|
+
- lib/napa/cli/templates/new/lib/.keep
|
354
|
+
- lib/napa/cli/templates/new/log/.keep
|
355
|
+
- lib/napa/cli/templates/new/spec/apis/hello_api_spec.rb.tt
|
356
|
+
- lib/napa/cli/templates/new/spec/docs/readme_spec.rb
|
357
|
+
- lib/napa/cli/templates/new/spec/factories/.gitkeep
|
358
|
+
- lib/napa/cli/templates/new/spec/spec_helper.rb
|
359
|
+
- lib/napa/cli/templates/readme/README.md.tt
|
360
|
+
- lib/napa/cli/templates/readme/spec/docs/readme_spec.rb
|
319
361
|
- lib/napa/deploy.rb
|
320
362
|
- lib/napa/deprecations.rb
|
321
363
|
- lib/napa/deprecations/active_support_behavior.rb
|
@@ -323,42 +365,6 @@ files:
|
|
323
365
|
- lib/napa/deprecations/grape_entity.rb
|
324
366
|
- lib/napa/deprecations/napa_setup.rb
|
325
367
|
- lib/napa/gem_dependency.rb
|
326
|
-
- lib/napa/generators.rb
|
327
|
-
- lib/napa/generators/api_generator.rb
|
328
|
-
- lib/napa/generators/migration_generator.rb
|
329
|
-
- lib/napa/generators/readme_generator.rb
|
330
|
-
- lib/napa/generators/scaffold_generator.rb
|
331
|
-
- lib/napa/generators/templates/api/app/apis/%name_tableize%_api.rb.tt
|
332
|
-
- lib/napa/generators/templates/api/app/models/%name_underscore%.rb.tt
|
333
|
-
- lib/napa/generators/templates/api/app/representers/%name_underscore%_representer.rb.tt
|
334
|
-
- lib/napa/generators/templates/api/spec/apis/%name_tableize%_api_spec.rb.tt
|
335
|
-
- lib/napa/generators/templates/api/spec/models/%name_underscore%_spec.rb.tt
|
336
|
-
- lib/napa/generators/templates/create_table_migration/%migration_filename%.rb.tt
|
337
|
-
- lib/napa/generators/templates/migration/%migration_filename%.rb.tt
|
338
|
-
- lib/napa/generators/templates/readme/README.md.tt
|
339
|
-
- lib/napa/generators/templates/readme/spec/docs/readme_spec.rb
|
340
|
-
- lib/napa/generators/templates/scaffold/.env.test.tt
|
341
|
-
- lib/napa/generators/templates/scaffold/.env.tt
|
342
|
-
- lib/napa/generators/templates/scaffold/.gitignore.tt
|
343
|
-
- lib/napa/generators/templates/scaffold/.rubocop.yml
|
344
|
-
- lib/napa/generators/templates/scaffold/.ruby-gemset.tt
|
345
|
-
- lib/napa/generators/templates/scaffold/.ruby-version.tt
|
346
|
-
- lib/napa/generators/templates/scaffold/Gemfile.tt
|
347
|
-
- lib/napa/generators/templates/scaffold/README.md
|
348
|
-
- lib/napa/generators/templates/scaffold/Rakefile
|
349
|
-
- lib/napa/generators/templates/scaffold/app.rb
|
350
|
-
- lib/napa/generators/templates/scaffold/app/apis/application_api.rb
|
351
|
-
- lib/napa/generators/templates/scaffold/app/apis/hello_api.rb.tt
|
352
|
-
- lib/napa/generators/templates/scaffold/config.ru.tt
|
353
|
-
- lib/napa/generators/templates/scaffold/config/database.yml.tt
|
354
|
-
- lib/napa/generators/templates/scaffold/config/initializers/active_record.rb
|
355
|
-
- lib/napa/generators/templates/scaffold/config/middleware/honeybadger.rb
|
356
|
-
- lib/napa/generators/templates/scaffold/db/schema.rb
|
357
|
-
- lib/napa/generators/templates/scaffold/lib/.keep
|
358
|
-
- lib/napa/generators/templates/scaffold/log/.keep
|
359
|
-
- lib/napa/generators/templates/scaffold/spec/apis/hello_api_spec.rb.tt
|
360
|
-
- lib/napa/generators/templates/scaffold/spec/factories/.gitkeep
|
361
|
-
- lib/napa/generators/templates/scaffold/spec/spec_helper.rb
|
362
368
|
- lib/napa/grape_extenders.rb
|
363
369
|
- lib/napa/grape_extensions/error_formatter.rb
|
364
370
|
- lib/napa/grape_extensions/grape_helpers.rb
|
@@ -389,14 +395,14 @@ files:
|
|
389
395
|
- spec/active_record_extensions/filter_by_hash_spec.rb
|
390
396
|
- spec/active_record_extensions/seeder_spec.rb
|
391
397
|
- spec/authentication_spec.rb
|
398
|
+
- spec/cli/base/new_spec.rb
|
399
|
+
- spec/cli/generate/api_spec.rb
|
400
|
+
- spec/cli/generate/readme_spec.rb
|
401
|
+
- spec/cli/migration_spec.rb
|
392
402
|
- spec/deprecations/application_api_spec.rb
|
393
403
|
- spec/deprecations/entity_spec.rb
|
394
404
|
- spec/deprecations/filter_by_hash_spec.rb
|
395
405
|
- spec/deprecations/napa_setup_spec.rb
|
396
|
-
- spec/generators/api_generator_spec.rb
|
397
|
-
- spec/generators/migration_generator_spec.rb
|
398
|
-
- spec/generators/readme_generator_spec.rb
|
399
|
-
- spec/generators/scaffold_generator_spec.rb
|
400
406
|
- spec/grape_extenders_spec.rb
|
401
407
|
- spec/grape_extensions/error_formatter_spec.rb
|
402
408
|
- spec/grape_extensions/include_nil_spec.rb
|
@@ -413,6 +419,7 @@ files:
|
|
413
419
|
- spec/stats_d_timer_spec.rb
|
414
420
|
- spec/stats_spec.rb
|
415
421
|
- spec/version_spec.rb
|
422
|
+
- tasks/spec.rake
|
416
423
|
- tasks/version.rake
|
417
424
|
homepage: https://tech.bellycard.com
|
418
425
|
licenses:
|
@@ -434,7 +441,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
434
441
|
version: '0'
|
435
442
|
requirements: []
|
436
443
|
rubyforge_project:
|
437
|
-
rubygems_version: 2.
|
444
|
+
rubygems_version: 2.4.5
|
438
445
|
signing_key:
|
439
446
|
specification_version: 4
|
440
447
|
summary: A rack-based framework wrapping around the Grape REST-like framework for
|
@@ -443,14 +450,14 @@ test_files:
|
|
443
450
|
- spec/active_record_extensions/filter_by_hash_spec.rb
|
444
451
|
- spec/active_record_extensions/seeder_spec.rb
|
445
452
|
- spec/authentication_spec.rb
|
453
|
+
- spec/cli/base/new_spec.rb
|
454
|
+
- spec/cli/generate/api_spec.rb
|
455
|
+
- spec/cli/generate/readme_spec.rb
|
456
|
+
- spec/cli/migration_spec.rb
|
446
457
|
- spec/deprecations/application_api_spec.rb
|
447
458
|
- spec/deprecations/entity_spec.rb
|
448
459
|
- spec/deprecations/filter_by_hash_spec.rb
|
449
460
|
- spec/deprecations/napa_setup_spec.rb
|
450
|
-
- spec/generators/api_generator_spec.rb
|
451
|
-
- spec/generators/migration_generator_spec.rb
|
452
|
-
- spec/generators/readme_generator_spec.rb
|
453
|
-
- spec/generators/scaffold_generator_spec.rb
|
454
461
|
- spec/grape_extenders_spec.rb
|
455
462
|
- spec/grape_extensions/error_formatter_spec.rb
|
456
463
|
- spec/grape_extensions/include_nil_spec.rb
|
@@ -467,4 +474,3 @@ test_files:
|
|
467
474
|
- spec/stats_d_timer_spec.rb
|
468
475
|
- spec/stats_spec.rb
|
469
476
|
- spec/version_spec.rb
|
470
|
-
has_rdoc:
|
@@ -1,30 +0,0 @@
|
|
1
|
-
require 'thor'
|
2
|
-
require 'active_support/all'
|
3
|
-
|
4
|
-
module Napa
|
5
|
-
module Generators
|
6
|
-
class ApiGenerator < Thor::Group
|
7
|
-
include Thor::Actions
|
8
|
-
argument :name
|
9
|
-
|
10
|
-
def name_underscore
|
11
|
-
name.underscore
|
12
|
-
end
|
13
|
-
|
14
|
-
def name_tableize
|
15
|
-
name.tableize
|
16
|
-
end
|
17
|
-
|
18
|
-
def output_directory
|
19
|
-
'.'
|
20
|
-
end
|
21
|
-
|
22
|
-
def api
|
23
|
-
self.class.source_root "#{File.dirname(__FILE__)}/templates/api"
|
24
|
-
say 'Generating api...'
|
25
|
-
directory '.', output_directory
|
26
|
-
say 'Done!', :green
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,47 +0,0 @@
|
|
1
|
-
require 'thor'
|
2
|
-
require 'active_support/all'
|
3
|
-
require 'napa/setup'
|
4
|
-
require 'napa/identity'
|
5
|
-
require 'dotenv'
|
6
|
-
|
7
|
-
module Napa
|
8
|
-
module Generators
|
9
|
-
class ReadmeGenerator < Thor::Group
|
10
|
-
include Thor::Actions
|
11
|
-
|
12
|
-
def load_environment
|
13
|
-
Napa.load_environment
|
14
|
-
end
|
15
|
-
|
16
|
-
def service_name
|
17
|
-
Napa::Identity.name
|
18
|
-
end
|
19
|
-
|
20
|
-
def routes
|
21
|
-
routes = ""
|
22
|
-
|
23
|
-
if defined? ApplicationApi
|
24
|
-
ApplicationApi.routes.each do |api|
|
25
|
-
method = api.route_method.ljust(10)
|
26
|
-
path = api.route_path.ljust(40)
|
27
|
-
description = api.route_description
|
28
|
-
routes += " #{method} #{path} # #{description}"
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
routes
|
33
|
-
end
|
34
|
-
|
35
|
-
def output_directory
|
36
|
-
'.'
|
37
|
-
end
|
38
|
-
|
39
|
-
def readme
|
40
|
-
self.class.source_root "#{File.dirname(__FILE__)}/templates/readme"
|
41
|
-
say 'Generating readme...'
|
42
|
-
directory '.', output_directory
|
43
|
-
say 'Done!', :green
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
require 'thor'
|
2
|
-
require 'active_support/core_ext/string'
|
3
|
-
|
4
|
-
module Napa
|
5
|
-
module Generators
|
6
|
-
class ScaffoldGenerator < Thor::Group
|
7
|
-
include Thor::Actions
|
8
|
-
|
9
|
-
source_root "#{File.dirname(__FILE__)}/templates/scaffold"
|
10
|
-
|
11
|
-
argument :app_name
|
12
|
-
argument :app_path, optional: true
|
13
|
-
class_option :database, default: 'mysql', aliases: '-d', desc: 'Preconfigure for selected database (options: mysql/postgres/pg)'
|
14
|
-
|
15
|
-
def generate
|
16
|
-
say 'Generating scaffold...'
|
17
|
-
|
18
|
-
@database_gem = ['pg','postgres'].include?(options[:database]) ? 'pg' : 'mysql2'
|
19
|
-
@database_adapter = ['pg','postgres'].include?(options[:database]) ? 'postgresql' : 'mysql2'
|
20
|
-
@database_encoding = ['pg','postgres'].include?(options[:database]) ? 'unicode' : 'utf8'
|
21
|
-
@database_user = ['pg','postgres'].include?(options[:database]) ? '' : 'root'
|
22
|
-
|
23
|
-
directory ".", (app_path || app_name)
|
24
|
-
|
25
|
-
say 'Done!', :green
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|