natra 0.0.2 → 0.0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5a2783fb8343be9af57d94d7983b64963f0a3e520a199004523383b89425f823
4
- data.tar.gz: cb7350705c44a0892794295141cbd108c2336a603d6fd1b0123ba5141a4d13ce
3
+ metadata.gz: 76b4a8e352e608faa8f15689e30b24773d3396443f9b1ec9ed41aeb3526199ea
4
+ data.tar.gz: f631d842f44216ae67644fce16c566a5ae5bfd4dfbc9e4ac086f98597663f571
5
5
  SHA512:
6
- metadata.gz: 4613cf94048d0ee11330263ccc98bdd45f4a4d675caae46a5dd76987cf294cf76eb3524c88954db2b863b9fcb923d29e08207faef82fe1138d36f67d0d26fdc2
7
- data.tar.gz: 31932e509fe3c452da83c91a85f6507cd9772ede533c59e50a4617c351ba2a534c4a0708834fefa46ee4ac34c4a3e715a3de33848970515c0380f78ef7f287aa
6
+ metadata.gz: c24ef188a704d0c8ddb0153b3326a61977ceedb0fa661daddcdd1820121492d826a5ecd8684166728f22ab0437c5d1ef1dc3964320b18a6af96c3a4ef3cd9c36
7
+ data.tar.gz: b363163c823c3f7d27df84fa6950f6bde67b265ceb0c58fea9496d445cc2eec6559828bb046a1eb572ba1c8357394528d0a609fe42745648c31a3e5d9698ddc7
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- natra (0.0.2)
4
+ natra (0.0.3)
5
5
  activesupport (~> 5.0)
6
6
  thor (~> 0.18)
7
7
 
@@ -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")) unless @database.empty?
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")) unless @database.empty?
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
@@ -16,7 +16,6 @@ gem 'bcrypt'
16
16
  gem "tux"
17
17
  gem 'oj'
18
18
  group :development, :test do
19
- gem 'pry'
20
19
  gem 'pry-byebug'
21
20
  gem 'shotgun'
22
21
  end
@@ -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,5 +2,5 @@
2
2
 
3
3
  set -e
4
4
 
5
- RACK_ENV=test DATABASE_URL=$TEST_DATABASE_URL rake db:create db:migrate --trace
5
+ SINATRA_ENV=test DATABASE_URL=$TEST_DATABASE_URL rake db:create db:migrate --trace
6
6
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  set -e
4
4
 
5
- RACK_ENV=development rake db:create db:migrate --trace
6
- RACK_ENV=development rake db:seed_fu --trace
7
- RACK_ENV=test DATABASE_URL=$TEST_DATABASE_URL rake db:create db:migrate --trace
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
- <% if @database == "sqlite" %>
3
- development: "sqlite://db/development.sqlite3"
4
- test: "sqlite://db/test.sqlite3"
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
- <% unless @database.empty? -%>
1
+
2
2
  require "yaml"
3
3
  settings = YAML::load_file("config/db.yml")
4
- <% if @database != 'mongo' -%>
5
- # Sequel Configuration
4
+
6
5
  require "sequel"
7
- DB = Sequel.connect(settings[ENV['RACK_ENV']])
8
- <% else -%>
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['RACK_ENV'] == 'test'
4
+ unless ENV['SINATRA_ENV'] == 'test'
5
5
  redis_settings = YAML::load_file("config/redis.yml")
6
- REDIS = Redis.new(redis_settings[ENV['RACK_ENV']])
6
+ REDIS = Redis.new(redis_settings[ENV['SINATRA_ENV']])
7
7
  end
@@ -6,6 +6,6 @@ workers Integer(ENV['WEB_CONCURRENCY'] || 1)
6
6
 
7
7
  preload_app!
8
8
 
9
- environment ENV['RACK_ENV'] || 'development'
9
+ environment ENV['SINATRA_ENV'] || 'development'
10
10
 
11
11
  bind "tcp://0.0.0.0:#{port}"
@@ -14,9 +14,7 @@ services:
14
14
  - db
15
15
  env_file: secrets.env
16
16
  db:
17
- <%- if @database=='postgres' -%>
18
17
  image: postgres:10-alpine
19
18
  ports:
20
19
  - "54329:5432"
21
20
  env_file: secrets.env
22
- <%- end -%>
@@ -1,12 +1,6 @@
1
1
  /tmp
2
2
  /log
3
3
  /log
4
- *.swp
5
- *.swo
6
4
  .rspec_status
7
5
  coverage
8
-
9
- client/Gemfile.lock
10
-
11
- secrets.aes
12
6
  secrets.env
@@ -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
- <%- if @database=='postgres' -%>
4
- DATABASE_URL=postgresql://docker:docker@db:5432/<%= @name.camel_case %>?pool=5
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
@@ -1,3 +1,3 @@
1
1
  module Natra
2
- VERSION = '0.0.2'.freeze
2
+ VERSION = '0.0.3'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: natra
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thiru Njuguna