natra 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/natra/generators/app/app_generator.rb +2 -3
- data/lib/natra/generators/app/templates/Dockerfile +1 -4
- data/lib/natra/generators/app/templates/Gemfile +0 -1
- data/lib/natra/generators/app/templates/app/views/welcome.erb +1 -13
- data/lib/natra/generators/app/templates/bin/ci +1 -1
- data/lib/natra/generators/app/templates/bin/setup +3 -3
- data/lib/natra/generators/app/templates/config.ru +1 -1
- data/lib/natra/generators/app/templates/config/db.yml +3 -34
- data/lib/natra/generators/app/templates/config/environment.rb +1 -4
- data/lib/natra/generators/app/templates/config/initializers/database.rb +4 -8
- data/lib/natra/generators/app/templates/config/initializers/redis.rb +2 -2
- data/lib/natra/generators/app/templates/config/puma.rb +1 -1
- data/lib/natra/generators/app/templates/docker-compose.yml +0 -2
- data/lib/natra/generators/app/templates/gitignore +0 -6
- data/lib/natra/generators/app/templates/rubocop.yml +0 -29
- data/lib/natra/generators/app/templates/secrets.env +4 -5
- data/lib/natra/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76b4a8e352e608faa8f15689e30b24773d3396443f9b1ec9ed41aeb3526199ea
|
4
|
+
data.tar.gz: f631d842f44216ae67644fce16c566a5ae5bfd4dfbc9e4ac086f98597663f571
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c24ef188a704d0c8ddb0153b3326a61977ceedb0fa661daddcdd1820121492d826a5ecd8684166728f22ab0437c5d1ef1dc3964320b18a6af96c3a4ef3cd9c36
|
7
|
+
data.tar.gz: b363163c823c3f7d27df84fa6950f6bde67b265ceb0c58fea9496d445cc2eec6559828bb046a1eb572ba1c8357394528d0a609fe42745648c31a3e5d9698ddc7
|
data/Gemfile.lock
CHANGED
@@ -9,7 +9,6 @@ module Natra
|
|
9
9
|
desc "Creates a new Sinatra application"
|
10
10
|
argument :name, :type => :string, :desc => "The name of the new application"
|
11
11
|
class_option :capistrano, :type => :boolean, :desc => "Include Capistrano configuration"
|
12
|
-
class_option :database, :aliases => "-d", :default => "", :desc => "The type of database to use"
|
13
12
|
class_option :redis, :type => :boolean, :desc => "Include Redis configuration"
|
14
13
|
class_option :rvm, :type => :boolean, :desc => "Create .ruby-version (ruby-2.1.0) and .ruby-gemset"
|
15
14
|
class_option :bundle, :type => :boolean, :desc => "Run bundle after generating the app"
|
@@ -76,11 +75,11 @@ module Natra
|
|
76
75
|
end
|
77
76
|
|
78
77
|
def create_db_config
|
79
|
-
template("config/db.yml", File.join(@app_path, "config/db.yml"))
|
78
|
+
template("config/db.yml", File.join(@app_path, "config/db.yml"))
|
80
79
|
end
|
81
80
|
|
82
81
|
def create_database_initializer
|
83
|
-
template("config/initializers/database.rb", File.join(@app_path, "config/initializers/database.rb"))
|
82
|
+
template("config/initializers/database.rb", File.join(@app_path, "config/initializers/database.rb"))
|
84
83
|
end
|
85
84
|
|
86
85
|
def create_redis_config
|
@@ -1,4 +1,3 @@
|
|
1
|
-
# base layer
|
2
1
|
FROM ruby AS base
|
3
2
|
|
4
3
|
WORKDIR /usr/src/app
|
@@ -7,18 +6,16 @@ RUN gem install bundler
|
|
7
6
|
|
8
7
|
COPY Gemfile /usr/src/app/
|
9
8
|
|
10
|
-
# development and test layer with all dependencies
|
11
9
|
FROM base AS development
|
12
10
|
|
13
11
|
RUN bundle install -j5 --without staging production
|
14
12
|
|
15
13
|
COPY . /usr/src/app
|
16
14
|
|
17
|
-
# release layer
|
18
15
|
FROM base AS release
|
19
16
|
|
20
17
|
RUN bundle install -j5 --without development test
|
21
18
|
|
22
19
|
COPY . /usr/src/app
|
23
20
|
|
24
|
-
CMD puma
|
21
|
+
CMD puma
|
@@ -1,13 +1,3 @@
|
|
1
|
-
<div class="container">
|
2
|
-
<div class="col-md-8 col-md-offset-2">
|
3
|
-
<h2>Sinatra Template Default Page</h2>
|
4
|
-
|
5
|
-
<div class="content">
|
6
|
-
<p>Welcome to the Sinatra Template! If you're seeing this page, then everything is working
|
7
|
-
as expected. To get started, delete this file (<code>app/views/welcome.erb)</code> and begin adding
|
8
|
-
your own actions to <code>application_controller.rb</code>. For more information, see the <a href="https://github.com/thirunjuguna/natra">README</a>.</p>
|
9
|
-
</div>
|
10
|
-
|
11
1
|
<div class="sidebar">
|
12
2
|
<h3>Environment</h3>
|
13
3
|
<ul>
|
@@ -15,8 +5,6 @@
|
|
15
5
|
<li><b>Environment:</b> <%= ENV["RACK_ENV"] %></li>
|
16
6
|
<li><b>Server:</b> <%= @env["SERVER_SOFTWARE"] %></li>
|
17
7
|
<li><b>Port:</b> <%= @env["SERVER_PORT"] %></li>
|
8
|
+
<li><b>Help:</b>see the <a href="https://github.com/thirunjuguna/natra">README</a> </li>
|
18
9
|
</ul>
|
19
10
|
</div>
|
20
|
-
|
21
|
-
</div>
|
22
|
-
</div>
|
@@ -2,6 +2,6 @@
|
|
2
2
|
|
3
3
|
set -e
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
SINATRA_ENV=development rake db:create db:migrate --trace
|
6
|
+
SINATRA_ENV=development rake db:seed_fu --trace
|
7
|
+
SINATRA_ENV=test DATABASE_URL=$TEST_DATABASE_URL rake db:create db:migrate --trace
|
@@ -2,7 +2,7 @@ require './config/environment'
|
|
2
2
|
# Call as early as possible so rack-timeout runs before all other middleware.
|
3
3
|
use Rack::Timeout, service_timeout: 5
|
4
4
|
|
5
|
-
ScoutApm::Rack.install
|
5
|
+
ScoutApm::Rack.install!
|
6
6
|
|
7
7
|
if ActiveRecord::Migrator.needs_migration?
|
8
8
|
raise 'Migrations are pending. Run `rake db:migrate` to resolve the issue.'
|
@@ -1,35 +1,4 @@
|
|
1
1
|
# Sequel Database Configuration
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
production: "sqlite://db/production.sqlite3"
|
6
|
-
<% elsif @database == "postgres" %>
|
7
|
-
development: "postgres://<%= `whoami`.chop %>@localhost/<%= @name %>_development"
|
8
|
-
test: "postgres://<%= `whoami`.chop %>@localhost/<%= @name %>_test"
|
9
|
-
production: "postgres://<%= `whoami`.chop %>@localhost/<%= @name %>_production"
|
10
|
-
<% elsif @database == "mysql" %>
|
11
|
-
development: "mysql2://<%= `whoami`.chop %>@localhost/<%= @name %>_development"
|
12
|
-
test: "mysql2://<%= `whoami`.chop %>@localhost/<%= @name %>_test"
|
13
|
-
production: "mysql2://<%= `whoami`.chop %>@localhost/<%= @name %>_production"
|
14
|
-
<% elsif @database == "mongo" %>
|
15
|
-
development:
|
16
|
-
host: localhost
|
17
|
-
port: 27017
|
18
|
-
database: <%= @name %>_development
|
19
|
-
username:
|
20
|
-
password:
|
21
|
-
|
22
|
-
test:
|
23
|
-
host: localhost
|
24
|
-
port: 27017
|
25
|
-
database: <%= @name %>_test
|
26
|
-
username:
|
27
|
-
password:
|
28
|
-
|
29
|
-
production:
|
30
|
-
host: localhost
|
31
|
-
port: 27017
|
32
|
-
database: <%= @name %>_production
|
33
|
-
username:
|
34
|
-
password:
|
35
|
-
<% end %>
|
2
|
+
development: ENV['DEV_DATABASE_URL']
|
3
|
+
test: ENV['TEST_DATABASE_URL']
|
4
|
+
production: ENV['PROD_DATABASE_URL']
|
@@ -10,10 +10,7 @@ require 'rack-timeout'
|
|
10
10
|
require 'scout_apm'
|
11
11
|
|
12
12
|
require 'oj'
|
13
|
-
ActiveRecord::Base.establish_connection(
|
14
|
-
:adapter => "sqlite3",
|
15
|
-
:database => "db/#{ENV['SINATRA_ENV']}.sqlite"
|
16
|
-
)
|
13
|
+
ActiveRecord::Base.establish_connection(ENV['DEV_DATABASE_URL'])
|
17
14
|
|
18
15
|
require './app/controllers/application_controller'
|
19
16
|
require_all 'app'
|
@@ -1,11 +1,7 @@
|
|
1
|
-
|
1
|
+
|
2
2
|
require "yaml"
|
3
3
|
settings = YAML::load_file("config/db.yml")
|
4
|
-
|
5
|
-
# Sequel Configuration
|
4
|
+
|
6
5
|
require "sequel"
|
7
|
-
|
8
|
-
|
9
|
-
# MongoDB Configuration
|
10
|
-
<% end -%>
|
11
|
-
<% end -%>
|
6
|
+
DB = Sequel.connect(settings[ENV['SINATRA_ENV']])
|
7
|
+
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require "yaml"
|
2
2
|
|
3
3
|
# Redis Configuration
|
4
|
-
unless ENV['
|
4
|
+
unless ENV['SINATRA_ENV'] == 'test'
|
5
5
|
redis_settings = YAML::load_file("config/redis.yml")
|
6
|
-
REDIS = Redis.new(redis_settings[ENV['
|
6
|
+
REDIS = Redis.new(redis_settings[ENV['SINATRA_ENV']])
|
7
7
|
end
|
@@ -6,62 +6,33 @@ AllCops:
|
|
6
6
|
- tmp/**
|
7
7
|
|
8
8
|
Documentation:
|
9
|
-
# don't require classes to be documented
|
10
9
|
Enabled: false
|
11
10
|
|
12
11
|
Style/FrozenStringLiteralComment:
|
13
|
-
# don't require frozen literal comment
|
14
12
|
Enabled: false
|
15
13
|
|
16
14
|
Encoding:
|
17
|
-
# no need to always specify encoding
|
18
15
|
Enabled: false
|
19
16
|
|
20
17
|
AlignParameters:
|
21
|
-
# allow for multi-line methods to have normal indentation.
|
22
|
-
# for example:
|
23
|
-
#
|
24
|
-
# Person.where(
|
25
|
-
# first_name: 'tom',
|
26
|
-
# last_name: 'foolery'
|
27
|
-
# )
|
28
18
|
EnforcedStyle: with_fixed_indentation
|
29
19
|
|
30
20
|
Layout/AlignParameters:
|
31
|
-
# allow for end of if to be aligned with a variable.
|
32
|
-
# for example:
|
33
|
-
#
|
34
|
-
# foo = if a == b
|
35
|
-
# 'bar'
|
36
|
-
# else
|
37
|
-
# 'baz'
|
38
|
-
# end
|
39
21
|
EnforcedStyle: with_fixed_indentation
|
40
22
|
|
41
23
|
Layout/MultilineMethodCallIndentation:
|
42
24
|
EnforcedStyle: indented
|
43
25
|
|
44
26
|
Layout/MultilineOperationIndentation:
|
45
|
-
# allow for operations to be indented at two spaces.
|
46
|
-
# for example:
|
47
|
-
#
|
48
|
-
# @valid ||= present &&
|
49
|
-
# positive?
|
50
27
|
EnforcedStyle: indented
|
51
28
|
|
52
29
|
Layout/EndAlignment:
|
53
30
|
EnforcedStyleAlignWith: variable
|
54
31
|
|
55
32
|
ClassAndModuleChildren:
|
56
|
-
# ok to use compact style when modules are predefined.
|
57
|
-
# for example the following is fine so long as we're sure that
|
58
|
-
# module MDB has already been required/defined.
|
59
|
-
#
|
60
|
-
# class MDB::Person; end
|
61
33
|
Enabled: false
|
62
34
|
|
63
35
|
Metrics/BlockLength:
|
64
|
-
# Certain DSL use blocks and can be lengthy
|
65
36
|
Exclude:
|
66
37
|
- 'spec/**/*'
|
67
38
|
- 'Guardfile'
|
@@ -1,9 +1,8 @@
|
|
1
1
|
SINATRA_ENV=development
|
2
2
|
LOG_LEVEL=Logger::INFO
|
3
|
-
|
4
|
-
|
3
|
+
DEV_DATABASE_URL=postgresql://docker:docker@db:5432/<%= @name.camel_case %>_dev?pool=5
|
4
|
+
PROD_DATABASE_URL=postgresql://docker:docker@db:5432/<%= @name.camel_case %>_prod?pool=5
|
5
|
+
TEST_DATABASE_URL=postgresql://docker:docker@db:5432/<%= @name.camel_case %>_test?pool=5
|
5
6
|
POSTGRES_USER=docker
|
6
7
|
POSTGRES_PASSWORD=docker
|
7
|
-
POSTGRES_DB=<%= @name.camel_case %>
|
8
|
-
<%- end -%>
|
9
|
-
|
8
|
+
POSTGRES_DB=<%= @name.camel_case %>_dev
|
data/lib/natra/version.rb
CHANGED