natra 0.0.4 → 0.0.5
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 +4 -4
- data/Gemfile.lock +2 -2
- data/lib/natra/generators/app/app_generator.rb +17 -9
- data/lib/natra/generators/app/templates/Dockerfile +2 -10
- data/lib/natra/generators/app/templates/Gemfile +10 -11
- data/lib/natra/generators/app/templates/README.md +1 -1
- data/lib/natra/generators/app/templates/Rakefile +1 -2
- data/lib/natra/generators/app/templates/bin/setup +3 -3
- data/lib/natra/generators/app/templates/config.ru +0 -7
- data/lib/natra/generators/app/templates/config/database.yml +15 -0
- data/lib/natra/generators/app/templates/config/environment.rb +2 -6
- data/lib/natra/generators/app/templates/config/initializers/redis.rb +2 -2
- data/lib/natra/generators/app/templates/db/migrate/add_extensions.rb +1 -1
- data/lib/natra/generators/app/templates/secrets.env +14 -5
- data/lib/natra/generators/app/templates/spec/spec_helper.rb +4 -4
- data/lib/natra/version.rb +1 -1
- data/natra.gemspec +1 -1
- metadata +4 -6
- data/lib/natra/generators/app/templates/bin/ci +0 -6
- data/lib/natra/generators/app/templates/config/db.yml +0 -4
- data/lib/natra/generators/app/templates/config/initializers/database.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b142253933ee63c2bb48a082f688d53234cdccd7a7c6429126efacc701c836e7
|
4
|
+
data.tar.gz: 98dc768e1383632df1fe8f1a851108787a38c051d311d9999ba9f05c1728d8b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c3be2c2363bd0b537af2ed27c9ef70f58588852a443c638a2527960268c34c7fbcaa675da3f0ba6831e68604d42995a5b8b8572596482b08213bbec5f2cc82a
|
7
|
+
data.tar.gz: 0e864e74a9cc31f81107077ee43fc1d2e73e2ffd89949060220343f7b515528679e21932aefa9eb325e54d52cd2b085a6a06ed9408885312e8ebf644a9e02df9
|
data/Gemfile.lock
CHANGED
@@ -14,7 +14,7 @@ module Natra
|
|
14
14
|
def setup
|
15
15
|
@app_path = name.directory_name
|
16
16
|
@name = name.file_name
|
17
|
-
options.each {|key, value| instance_variable_set "@#{key}".to_sym, value}
|
17
|
+
options.each { |key, value| instance_variable_set "@#{key}".to_sym, value }
|
18
18
|
end
|
19
19
|
|
20
20
|
def self.source_root
|
@@ -73,11 +73,7 @@ module Natra
|
|
73
73
|
end
|
74
74
|
|
75
75
|
def create_db_config
|
76
|
-
template('config/
|
77
|
-
end
|
78
|
-
|
79
|
-
def create_database_initializer
|
80
|
-
template('config/initializers/database.rb', File.join(@app_path, 'config/initializers/database.rb'))
|
76
|
+
template('config/database.yml', File.join(@app_path, 'config/database.yml'))
|
81
77
|
end
|
82
78
|
|
83
79
|
def create_redis_config
|
@@ -121,7 +117,7 @@ module Natra
|
|
121
117
|
end
|
122
118
|
|
123
119
|
def create_capistrano_config
|
124
|
-
inside(@app_path) {run('cap install')} if @capistrano
|
120
|
+
inside(@app_path) { run('cap install') } if @capistrano
|
125
121
|
end
|
126
122
|
|
127
123
|
def create_rvm_gemset
|
@@ -135,11 +131,23 @@ module Natra
|
|
135
131
|
end
|
136
132
|
|
137
133
|
def initialize_git_repo
|
138
|
-
inside(@app_path) {run('git init .') if @git}
|
134
|
+
inside(@app_path) { run('git init .') if @git }
|
139
135
|
end
|
140
136
|
|
141
137
|
def install_dependencies
|
142
|
-
inside(@app_path) {run('bundle') if @bundle}
|
138
|
+
inside(@app_path) { run('bundle') if @bundle }
|
139
|
+
end
|
140
|
+
|
141
|
+
def initialize_app
|
142
|
+
system <<~SCRIPT
|
143
|
+
cd #{@app_path}
|
144
|
+
#{'chmod +x bin/setup'}
|
145
|
+
git init
|
146
|
+
git add .
|
147
|
+
docker-compose build --pull
|
148
|
+
docker-compose run --rm web bundle
|
149
|
+
#{'nib setup web'}
|
150
|
+
SCRIPT
|
143
151
|
end
|
144
152
|
end
|
145
153
|
end
|
@@ -1,21 +1,13 @@
|
|
1
1
|
FROM ruby AS base
|
2
|
-
|
3
2
|
WORKDIR /usr/src/app
|
4
|
-
|
5
3
|
RUN gem install bundler
|
6
|
-
|
7
4
|
COPY Gemfile /usr/src/app/
|
8
|
-
|
9
5
|
FROM base AS development
|
10
|
-
|
11
6
|
RUN bundle install -j5 --without staging production
|
12
|
-
|
13
7
|
COPY . /usr/src/app
|
14
|
-
|
15
8
|
FROM base AS release
|
16
|
-
|
17
9
|
RUN bundle install -j5 --without development test
|
18
|
-
|
10
|
+
RUN chmod 755 ./usr/src/app
|
11
|
+
RUN chmod 755 ./usr/src/app/bin/setup
|
19
12
|
COPY . /usr/src/app
|
20
|
-
|
21
13
|
CMD puma
|
@@ -1,33 +1,32 @@
|
|
1
1
|
source 'http://rubygems.org'
|
2
2
|
ruby '2.5.3'
|
3
|
+
gem 'bcrypt'
|
4
|
+
gem 'coveralls'
|
5
|
+
gem 'natra'
|
6
|
+
gem 'seed-fu'
|
7
|
+
gem 'scout_apm'
|
3
8
|
gem 'sinatra'
|
4
|
-
gem 'activerecord', '~> 4.2', '>= 4.2.6', :require => 'active_record'
|
5
9
|
gem 'sinatra-activerecord', :require => 'sinatra/activerecord'
|
6
10
|
gem 'rake'
|
7
11
|
gem 'rack-timeout'
|
8
12
|
gem 'require_all'
|
9
|
-
gem 'thin'
|
10
|
-
gem 'shotgun'
|
11
|
-
gem 'scout_apm'
|
12
|
-
gem 'seed-fu'
|
13
|
-
gem 'pry'
|
14
|
-
gem 'bcrypt'
|
15
13
|
gem "tux"
|
14
|
+
gem 'pg', '~> 0.21.0'
|
15
|
+
gem 'puma'
|
16
16
|
gem 'oj'
|
17
17
|
group :development, :test do
|
18
18
|
gem 'pry-byebug'
|
19
|
-
gem '
|
19
|
+
gem 'pry'
|
20
20
|
end
|
21
21
|
group :test do
|
22
22
|
gem 'awesome_print'
|
23
|
+
gem 'capybara'
|
23
24
|
gem 'database_cleaner'
|
24
25
|
gem 'factory_bot'
|
25
26
|
gem 'faker'
|
26
27
|
gem 'guard-rspec'
|
27
28
|
gem 'guard-rubocop'
|
28
|
-
gem 'rack-test'
|
29
29
|
gem 'simplecov'
|
30
|
-
gem 'rspec'
|
31
|
-
gem 'capybara'
|
32
30
|
gem 'rack-test'
|
31
|
+
gem 'rspec'
|
33
32
|
end
|
@@ -2,6 +2,6 @@
|
|
2
2
|
|
3
3
|
set -e
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
RACK_ENV=development rake db:create db:migrate --trace
|
6
|
+
RACK_ENV=development rake db:seed --trace
|
7
|
+
RACK_ENV=test DATABASE_URL=$TEST_DATABASE_URL rake db:create db:migrate --trace
|
@@ -1,11 +1,4 @@
|
|
1
1
|
require './config/environment'
|
2
|
-
# Call as early as possible so rack-timeout runs before all other middleware.
|
3
2
|
use Rack::Timeout, service_timeout: 5
|
4
|
-
|
5
3
|
ScoutApm::Rack.install!
|
6
|
-
|
7
|
-
if ActiveRecord::Migrator.needs_migration?
|
8
|
-
raise 'Migrations are pending. Run `rake db:migrate` to resolve the issue.'
|
9
|
-
end
|
10
|
-
|
11
4
|
run ApplicationController
|
@@ -0,0 +1,15 @@
|
|
1
|
+
development:
|
2
|
+
adapter: postgresql
|
3
|
+
encoding: unicode
|
4
|
+
database: ENV['DEV_DATABASE']
|
5
|
+
pool: 2
|
6
|
+
production:
|
7
|
+
adapter: postgresql
|
8
|
+
encoding: unicode
|
9
|
+
database: ENV['PROD_DATABASE']
|
10
|
+
pool: 2
|
11
|
+
test:
|
12
|
+
adapter: postgresql
|
13
|
+
encoding: unicode
|
14
|
+
database: ENV['TEST_DATABASE']
|
15
|
+
pool: 2
|
@@ -1,16 +1,12 @@
|
|
1
|
-
ENV['
|
1
|
+
ENV['RACK_ENV'] ||= 'development'
|
2
2
|
require 'rubygems'
|
3
3
|
require 'bundler/setup'
|
4
|
-
Bundler.require(:default, ENV['
|
4
|
+
Bundler.require(:default, ENV['RACK_ENV'])
|
5
5
|
require 'active_support'
|
6
6
|
require 'active_support/core_ext/hash/indifferent_access'
|
7
7
|
require 'active_support/core_ext/string'
|
8
|
-
|
9
8
|
require 'rack-timeout'
|
10
9
|
require 'scout_apm'
|
11
|
-
|
12
10
|
require 'oj'
|
13
|
-
ActiveRecord::Base.establish_connection(ENV['DEV_DATABASE_URL'])
|
14
|
-
|
15
11
|
require './app/controllers/application_controller'
|
16
12
|
require_all 'app'
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require "yaml"
|
2
2
|
|
3
3
|
# Redis Configuration
|
4
|
-
unless ENV['
|
4
|
+
unless ENV['RACK_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['RACK_ENV']])
|
7
7
|
end
|
@@ -1,8 +1,17 @@
|
|
1
|
-
|
1
|
+
RACK_ENV=development
|
2
2
|
LOG_LEVEL=Logger::INFO
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
|
4
|
+
DEV_DATABASE=development_<%=@name.directory_name%>
|
5
|
+
|
6
|
+
PROD_DATABASE=production_<%=@name.directory_name%>
|
7
|
+
|
8
|
+
|
9
|
+
TEST_DATABASE=test_<%=@name.directory_name%>
|
10
|
+
|
11
|
+
|
6
12
|
POSTGRES_USER=docker
|
7
13
|
POSTGRES_PASSWORD=docker
|
8
|
-
POSTGRES_DB
|
14
|
+
POSTGRES_DB=development_<%=@name.directory_name%>
|
15
|
+
|
16
|
+
DATABASE_URL=postgresql://docker:docker@db:5432/development_<%=@name.directory_name%>?pool=5
|
17
|
+
TEST_DATABASE_URL=postgresql://docker:docker@db:5432/test_<%=@name.directory_name%>?pool=5
|
@@ -1,12 +1,12 @@
|
|
1
|
-
ENV["
|
2
|
-
|
1
|
+
ENV["RACK_ENV"] = "test"
|
3
2
|
require_relative '../config/environment'
|
4
3
|
require 'rack/test'
|
5
4
|
require 'capybara/rspec'
|
6
5
|
require 'capybara/dsl'
|
7
|
-
|
6
|
+
require 'coveralls'
|
7
|
+
Coveralls.wear!
|
8
8
|
if ActiveRecord::Migrator.needs_migration?
|
9
|
-
raise 'Migrations are pending. Run `rake db:migrate
|
9
|
+
raise 'Migrations are pending. Run `rake db:migrate RACK_ENV=test` to resolve the issue.'
|
10
10
|
end
|
11
11
|
|
12
12
|
ActiveRecord::Base.logger = nil
|
data/lib/natra/version.rb
CHANGED
data/natra.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.email = ['thirunjuguna@outlook.com']
|
10
10
|
|
11
11
|
spec.summary = 'Natra generate a light weight sinatra application'
|
12
|
-
spec.description = 'Natra generate a light weight sinatra application.It\'s ideal for building micro-services'
|
12
|
+
spec.description = 'Natra generate a light weight sinatra application.It\'s ideal for building containerized micro-services with postgres database'
|
13
13
|
spec.homepage = 'https://github.com/thirunjuguna/natra'
|
14
14
|
spec.license = 'MIT'
|
15
15
|
if spec.respond_to?(:metadata)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: natra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thiru Njuguna
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-11-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -53,7 +53,7 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0.18'
|
55
55
|
description: Natra generate a light weight sinatra application.It's ideal for building
|
56
|
-
micro-services
|
56
|
+
containerized micro-services with postgres database
|
57
57
|
email:
|
58
58
|
- thirunjuguna@outlook.com
|
59
59
|
executables:
|
@@ -88,12 +88,10 @@ files:
|
|
88
88
|
- lib/natra/generators/app/templates/app/models/.gitkeep
|
89
89
|
- lib/natra/generators/app/templates/app/views/layout.erb.tt
|
90
90
|
- lib/natra/generators/app/templates/app/views/welcome.erb
|
91
|
-
- lib/natra/generators/app/templates/bin/ci
|
92
91
|
- lib/natra/generators/app/templates/bin/setup
|
93
92
|
- lib/natra/generators/app/templates/config.ru
|
94
|
-
- lib/natra/generators/app/templates/config/
|
93
|
+
- lib/natra/generators/app/templates/config/database.yml
|
95
94
|
- lib/natra/generators/app/templates/config/environment.rb
|
96
|
-
- lib/natra/generators/app/templates/config/initializers/database.rb
|
97
95
|
- lib/natra/generators/app/templates/config/initializers/oj.rb
|
98
96
|
- lib/natra/generators/app/templates/config/initializers/redis.rb
|
99
97
|
- lib/natra/generators/app/templates/config/puma.rb
|