napa 0.4.1 → 0.4.3

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.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +18 -0
  3. data/README.md +11 -12
  4. data/Rakefile +4 -0
  5. data/docs/quickstart.md +2 -2
  6. data/lib/napa/authentication.rb +5 -2
  7. data/lib/napa/cli/base/console.rb +32 -0
  8. data/lib/napa/cli/base/deploy.rb +22 -0
  9. data/lib/napa/cli/base/new.rb +49 -0
  10. data/lib/napa/cli/base/server.rb +29 -0
  11. data/lib/napa/cli/base/version.rb +14 -0
  12. data/lib/napa/cli/base.rb +17 -0
  13. data/lib/napa/cli/generate/api.rb +42 -0
  14. data/lib/napa/cli/generate/readme.rb +50 -0
  15. data/lib/napa/cli/generate.rb +18 -0
  16. data/lib/napa/{generators/migration_generator.rb → cli/migration.rb} +3 -3
  17. data/lib/napa/{generators → cli}/templates/api/app/apis/%name_tableize%_api.rb.tt +0 -0
  18. data/lib/napa/{generators → cli}/templates/api/app/models/%name_underscore%.rb.tt +0 -0
  19. data/lib/napa/{generators → cli}/templates/api/app/representers/%name_underscore%_representer.rb.tt +0 -0
  20. data/lib/napa/{generators → cli}/templates/api/spec/apis/%name_tableize%_api_spec.rb.tt +0 -0
  21. data/lib/napa/{generators → cli}/templates/api/spec/models/%name_underscore%_spec.rb.tt +0 -0
  22. data/lib/napa/{generators → cli}/templates/create_table_migration/%migration_filename%.rb.tt +0 -0
  23. data/lib/napa/{generators → cli}/templates/migration/%migration_filename%.rb.tt +0 -0
  24. data/lib/napa/{generators/templates/scaffold → cli/templates/new}/.env.test.tt +1 -1
  25. data/lib/napa/{generators/templates/scaffold → cli/templates/new}/.env.tt +1 -1
  26. data/lib/napa/{generators/templates/scaffold → cli/templates/new}/.gitignore.tt +0 -0
  27. data/lib/napa/{generators/templates/scaffold → cli/templates/new}/.rubocop.yml +0 -0
  28. data/lib/napa/{generators/templates/scaffold → cli/templates/new}/.ruby-gemset.tt +0 -0
  29. data/lib/napa/{generators/templates/scaffold → cli/templates/new}/.ruby-version.tt +0 -0
  30. data/lib/napa/{generators/templates/scaffold → cli/templates/new}/Gemfile.tt +2 -2
  31. data/lib/napa/{generators/templates/scaffold → cli/templates/new}/README.md +0 -0
  32. data/lib/napa/{generators/templates/scaffold → cli/templates/new}/Rakefile +0 -0
  33. data/lib/napa/{generators/templates/scaffold → cli/templates/new}/app/apis/application_api.rb +0 -0
  34. data/lib/napa/{generators/templates/scaffold → cli/templates/new}/app/apis/hello_api.rb.tt +0 -0
  35. data/lib/napa/{generators/templates/scaffold → cli/templates/new}/app.rb +0 -0
  36. data/lib/napa/{generators/templates/scaffold → cli/templates/new}/config/database.yml.tt +0 -0
  37. data/lib/napa/{generators/templates/scaffold → cli/templates/new}/config/initializers/active_record.rb +0 -0
  38. data/lib/napa/{generators/templates/scaffold → cli/templates/new}/config/middleware/honeybadger.rb +0 -0
  39. data/lib/napa/{generators/templates/scaffold → cli/templates/new}/config.ru.tt +1 -2
  40. data/lib/napa/{generators/templates/scaffold → cli/templates/new}/db/schema.rb +0 -0
  41. data/lib/napa/{generators/templates/scaffold → cli/templates/new}/lib/.keep +0 -0
  42. data/lib/napa/{generators/templates/scaffold → cli/templates/new}/log/.keep +0 -0
  43. data/lib/napa/{generators/templates/scaffold → cli/templates/new}/spec/apis/hello_api_spec.rb.tt +0 -0
  44. data/lib/napa/{generators/templates/readme → cli/templates/new}/spec/docs/readme_spec.rb +0 -0
  45. data/lib/napa/{generators/templates/scaffold → cli/templates/new}/spec/factories/.gitkeep +0 -0
  46. data/lib/napa/{generators/templates/scaffold → cli/templates/new}/spec/spec_helper.rb +0 -0
  47. data/lib/napa/{generators → cli}/templates/readme/README.md.tt +0 -0
  48. data/lib/napa/cli/templates/readme/spec/docs/readme_spec.rb +7 -0
  49. data/lib/napa/cli.rb +3 -89
  50. data/lib/napa/middleware/authentication.rb +16 -4
  51. data/lib/napa/param_sanitizer.rb +1 -1
  52. data/lib/napa/version.rb +1 -1
  53. data/spec/{generators/scaffold_generator_spec.rb → cli/base/new_spec.rb} +4 -3
  54. data/spec/{generators/api_generator_spec.rb → cli/generate/api_spec.rb} +5 -4
  55. data/spec/{generators/readme_generator_spec.rb → cli/generate/readme_spec.rb} +5 -4
  56. data/spec/{generators/migration_generator_spec.rb → cli/migration_spec.rb} +9 -9
  57. data/spec/middleware/authentication_spec.rb +95 -34
  58. data/spec/spec_helper.rb +14 -23
  59. data/tasks/spec.rake +9 -0
  60. metadata +54 -48
  61. data/lib/napa/generators/api_generator.rb +0 -30
  62. data/lib/napa/generators/readme_generator.rb +0 -47
  63. data/lib/napa/generators/scaffold_generator.rb +0 -29
  64. 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
- @allowed_passwords = ENV['HEADER_PASSWORDS'].split(',').map { |pw| pw.strip }.freeze
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
- if @allowed_passwords
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
- @allowed_passwords.include? env['HTTP_PASSWORD'] unless @allowed_passwords.nil?
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
@@ -1,4 +1,4 @@
1
- require 'action_dispatch'
1
+ require 'action_dispatch/http/filter_parameters'
2
2
 
3
3
  module Napa
4
4
  module ParamSanitizer
data/lib/napa/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Napa
2
- VERSION = '0.4.1'
2
+ VERSION = '0.4.3'
3
3
 
4
4
  class Version
5
5
  class << self
@@ -1,12 +1,13 @@
1
1
  require 'spec_helper'
2
- require 'napa/generators/scaffold_generator'
3
- require 'napa/cli'
2
+ require 'napa/cli/base/new'
4
3
 
5
- describe Napa::Generators::ScaffoldGenerator do
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/generators/api_generator'
3
- require 'napa/cli'
2
+ require 'napa/cli/generate/api'
4
3
 
5
- describe Napa::Generators::ApiGenerator do
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::Base.new.generate("api", api_name)
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/generators/readme_generator'
3
- require 'napa/cli'
2
+ require 'napa/cli/generate/readme'
4
3
 
5
- describe Napa::Generators::ReadmeGenerator do
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::Base.new.generate("readme")
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/generators/migration_generator'
3
- require 'napa/cli'
2
+ require 'napa/cli/migration'
4
3
 
5
- describe Napa::Generators::MigrationGenerator do
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::Base.new.generate("migration", 'AddFooToBar', 'flew:string:index', 'brew:integer')
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::Base.new.generate("migration", 'RemoveFooFromBar', 'flew:string', 'brew:integer')
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::Base.new.generate("migration", 'CreateJoinTableFooBar', 'foo', 'bar')
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::Base.new.generate("migration", 'CreateSkrillex', 'drops:integer', 'hair:string:index')
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
- before do
7
- ENV['HEADER_PASSWORDS'] = 'foo'
8
- end
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
- context '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)
42
+ it 'returns an error message if HEADER_PASSWORDS is not configured' do
43
+ ENV['HEADER_PASSWORDS'] = nil
16
44
 
17
- expect(status).to eq(200)
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 '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])
56
+ context 'using ALLOWED_HEADER_PASSWORDS' do
57
+ before do
58
+ ENV['ALLOWED_HEADER_PASSWORDS'] = 'foo,bar'
30
59
  end
31
60
 
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)
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
- expect(status).to eq(401)
39
- expect(body).to eq([Napa::JsonError.new('bad_password', 'bad password').to_json])
77
+ expect(status).to eq(200)
78
+ end
40
79
  end
41
80
 
42
- it 'returns an error message if HEADER_PASSWORDS is not configured' do
43
- ENV['HEADER_PASSWORDS'] = nil
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
- 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)
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
- expect(status).to eq(401)
51
- expect(body).to eq([Napa::JsonError.new('not_configured', 'password not configured').to_json])
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
@@ -0,0 +1,9 @@
1
+ desc 'Run the RSpec test suite'
2
+ task :spec do
3
+ sh *%w[
4
+ bundle exec
5
+ rspec --colour
6
+ --format documentation
7
+ --fail-fast
8
+ ]
9
+ end
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.1
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-01-23 00:00:00.000000000 Z
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.0.14
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