natra 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -2
- data/Gemfile +4 -6
- data/Gemfile.lock +5 -5
- data/Guardfile +0 -26
- data/README.md +5 -4
- data/Rakefile +1 -2
- data/bin/console +3 -4
- data/bin/natra +0 -3
- data/bin/setup +0 -1
- data/lib/extensions/string.rb +1 -4
- data/lib/natra.rb +8 -9
- data/lib/natra/cli.rb +2 -2
- data/lib/natra/generators/app/app_generator.rb +53 -56
- data/lib/natra/generators/app/templates/Gemfile +0 -1
- data/lib/natra/generators/app/templates/db/migrate/add_extensions.rb +7 -0
- data/lib/natra/generators/controller/controller_generator.rb +9 -10
- data/lib/natra/generators/model/migration.rb.erb +1 -1
- data/lib/natra/generators/model/model_generator.rb +12 -14
- data/lib/natra/generators/scaffold/scaffold_generator.rb +3 -4
- data/lib/natra/version.rb +1 -1
- data/natra.gemspec +2 -12
- metadata +5 -36
- data/lib/natra/generators/app/templates/public/images/.gitkeep +0 -0
- data/lib/natra/generators/app/templates/public/images/corneal-small.png +0 -0
- data/lib/natra/generators/app/templates/public/javascripts/.gitkeep +0 -0
- data/lib/natra/generators/app/templates/public/stylesheets/main.css +0 -115
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6e15fd5f640c81e1bd7ba2310d12953882a4abed4bfc5217e8043f03dd7700a
|
4
|
+
data.tar.gz: add394a5664c58702ab440b435711c297b7e0c3e16ec3c838cf5155eccad87f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c037f2da480e504be84dc1092f09e784ac1674985fb339037e3c6f8157adcccb9e5a076225d3f8c86f9e699a3e64cfe7fd1affa34791397f26a4268664dc144
|
7
|
+
data.tar.gz: 986be7f23d02cbfbdbc5ee2b8a1fc0e825ba6d4cec8ff9eff72913ebe2f5021ccd33972396df173bf0228811a691f0a28860f0618fb2a2620abe3395a3d6cba3
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
@@ -1,14 +1,12 @@
|
|
1
1
|
source 'https://rubygems.org/'
|
2
|
-
|
3
2
|
gemspec
|
4
|
-
|
5
3
|
gem 'active_model_serializers', '~> 0.10.0.rc1'
|
6
|
-
gem 'coveralls'
|
4
|
+
gem 'coveralls'
|
7
5
|
group :development do
|
8
|
-
gem
|
9
|
-
gem
|
6
|
+
gem 'rake'
|
7
|
+
gem 'pry'
|
10
8
|
gem 'guard'
|
11
9
|
gem 'rspec'
|
12
10
|
gem 'guard-rubocop'
|
13
11
|
gem 'guard-rspec', require: false
|
14
|
-
end
|
12
|
+
end
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
natra (0.0.
|
4
|
+
natra (0.0.4)
|
5
5
|
activesupport (~> 5.0)
|
6
6
|
thor (~> 0.18)
|
7
7
|
|
@@ -91,7 +91,7 @@ GEM
|
|
91
91
|
nenv (~> 0.1)
|
92
92
|
shellany (~> 0.0)
|
93
93
|
parallel (1.12.1)
|
94
|
-
parser (2.5.
|
94
|
+
parser (2.5.3.0)
|
95
95
|
ast (~> 2.4.0)
|
96
96
|
powerpack (0.1.2)
|
97
97
|
pry (0.11.3)
|
@@ -106,7 +106,7 @@ GEM
|
|
106
106
|
rails-html-sanitizer (1.0.4)
|
107
107
|
loofah (~> 2.2, >= 2.2.2)
|
108
108
|
rainbow (3.0.0)
|
109
|
-
rake (
|
109
|
+
rake (12.3.1)
|
110
110
|
rb-fsevent (0.10.3)
|
111
111
|
rb-inotify (0.9.10)
|
112
112
|
ffi (>= 0.5.0, < 2)
|
@@ -154,13 +154,13 @@ PLATFORMS
|
|
154
154
|
DEPENDENCIES
|
155
155
|
active_model_serializers (~> 0.10.0.rc1)
|
156
156
|
bundler (~> 1.16)
|
157
|
-
coveralls
|
157
|
+
coveralls
|
158
158
|
guard
|
159
159
|
guard-rspec
|
160
160
|
guard-rubocop
|
161
161
|
natra!
|
162
162
|
pry
|
163
|
-
rake
|
163
|
+
rake
|
164
164
|
rspec
|
165
165
|
|
166
166
|
BUNDLED WITH
|
data/Guardfile
CHANGED
@@ -1,29 +1,3 @@
|
|
1
|
-
# A sample Guardfile
|
2
|
-
# More info at https://github.com/guard/guard#readme
|
3
|
-
|
4
|
-
## Uncomment and set this to only include directories you want to watch
|
5
|
-
# directories %w(app lib config test spec features) \
|
6
|
-
# .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
|
7
|
-
|
8
|
-
## Note: if you are using the `directories` clause above and you are not
|
9
|
-
## watching the project directory ('.'), then you will want to move
|
10
|
-
## the Guardfile to a watched dir and symlink it back, e.g.
|
11
|
-
#
|
12
|
-
# $ mkdir config
|
13
|
-
# $ mv Guardfile config/
|
14
|
-
# $ ln -s config/Guardfile .
|
15
|
-
#
|
16
|
-
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
|
17
|
-
|
18
|
-
# Note: The cmd option is now required due to the increasing number of ways
|
19
|
-
# rspec may be run, below are examples of the most common uses.
|
20
|
-
# * bundler: 'bundle exec rspec'
|
21
|
-
# * bundler binstubs: 'bin/rspec'
|
22
|
-
# * spring: 'bin/rspec' (This will use spring if running and you have
|
23
|
-
# installed the spring binstubs per the docs)
|
24
|
-
# * zeus: 'zeus rspec' (requires the server to be started separately)
|
25
|
-
# * 'just' rspec: 'rspec'
|
26
|
-
|
27
1
|
guard :rspec, cmd: "bundle exec rspec" do
|
28
2
|
require "guard/rspec/dsl"
|
29
3
|
dsl = Guard::RSpec::Dsl.new(self)
|
data/README.md
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
# Natra
|
2
2
|
[![Coverage Status](https://coveralls.io/repos/github/thirunjuguna/natra/badge.svg?branch=master)](https://coveralls.io/github/thirunjuguna/natra?branch=master)
|
3
|
-
[![Build Status](https://travis-ci.com/thirunjuguna/natra.svg?branch=master)](https://travis-ci.com/thirunjuguna/natra)
|
4
|
-
|
3
|
+
[![Build Status](https://travis-ci.com/thirunjuguna/natra.svg?branch=master)](https://travis-ci.com/thirunjuguna/natra)
|
4
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/e76bbd27a1c4cb8911ae/maintainability)](https://codeclimate.com/github/thirunjuguna/natra/maintainability)
|
5
|
+
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/450f5da9d33d4adca897563ec759c1b2)](https://www.codacy.com/app/thirunjuguna/natra?utm_source=github.com&utm_medium=referral&utm_content=thirunjuguna/natra&utm_campaign=Badge_Grade)
|
5
6
|
|
6
7
|
## Installation
|
7
8
|
|
@@ -49,7 +50,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
49
50
|
|
50
51
|
## Contributing
|
51
52
|
|
52
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
53
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/thirunjuguna/natra. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
53
54
|
|
54
55
|
## License
|
55
56
|
|
@@ -57,4 +58,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
57
58
|
|
58
59
|
## Code of Conduct
|
59
60
|
|
60
|
-
Everyone interacting in the Natra project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/
|
61
|
+
Everyone interacting in the Natra project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/thirunjuguna/natra/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
CHANGED
data/bin/console
CHANGED
data/bin/natra
CHANGED
data/bin/setup
CHANGED
data/lib/extensions/string.rb
CHANGED
@@ -4,10 +4,7 @@ module Natra
|
|
4
4
|
def camel_case
|
5
5
|
return self.gsub(/^./) { |l| l.capitalize } if !match(/[_-]/)
|
6
6
|
altered_self = self.downcase.capitalize
|
7
|
-
altered_self.scan(/[_-][a-zA-Z]/).each
|
8
|
-
altered_self.gsub!(match, match[1].upcase)
|
9
|
-
end
|
10
|
-
|
7
|
+
altered_self.scan(/[_-][a-zA-Z]/).each { |match| altered_self.gsub!(match, match[1].upcase) }
|
11
8
|
altered_self
|
12
9
|
end
|
13
10
|
|
data/lib/natra.rb
CHANGED
@@ -1,9 +1,8 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
|
9
|
-
module Natra; end
|
1
|
+
require 'extensions/string'
|
2
|
+
require 'natra/generators/app/app_generator'
|
3
|
+
require 'natra/generators/model/model_generator'
|
4
|
+
require 'natra/generators/scaffold/scaffold_generator'
|
5
|
+
require 'natra/generators/controller/controller_generator'
|
6
|
+
require 'natra/version'
|
7
|
+
require 'natra/cli'
|
8
|
+
module Natra; end
|
data/lib/natra/cli.rb
CHANGED
@@ -3,11 +3,11 @@ module Natra
|
|
3
3
|
class CLI < Thor
|
4
4
|
desc '-v', 'Show Natra version number'
|
5
5
|
map %w[-v --version] => :version
|
6
|
-
|
6
|
+
|
7
7
|
def version
|
8
8
|
say "Natra #{Natra::VERSION}"
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
register Natra::Generators::AppGenerator, 'new', 'new APP_PATH', 'Creates a new Sinatra application'
|
12
12
|
register Natra::Generators::ModelGenerator, 'model', 'model NAME', 'Generate a model'
|
13
13
|
register Natra::Generators::ControllerGenerator, 'controller', 'controller NAME', 'Generate a controller'
|
@@ -1,126 +1,127 @@
|
|
1
|
-
|
2
|
-
require "thor/group"
|
3
|
-
|
1
|
+
require 'thor/group'
|
4
2
|
module Natra
|
5
3
|
module Generators
|
6
4
|
class AppGenerator < Thor::Group
|
7
5
|
include Thor::Actions
|
6
|
+
desc 'Creates a new Sinatra application'
|
7
|
+
argument :name, type: :string, desc: 'The name of the new application'
|
8
|
+
class_option :capistrano, type: :boolean, desc: 'Include Capistrano configuration'
|
9
|
+
class_option :redis, type: :boolean, desc: 'Include Redis configuration'
|
10
|
+
class_option :rvm, type: :boolean, desc: 'Create .ruby-version (ruby-2.1.0) and .ruby-gemset'
|
11
|
+
class_option :bundle, type: :boolean, desc: 'Run bundle after generating the app'
|
12
|
+
class_option :git, type: :boolean, desc: 'Initialize a Git repository'
|
8
13
|
|
9
|
-
desc "Creates a new Sinatra application"
|
10
|
-
argument :name, :type => :string, :desc => "The name of the new application"
|
11
|
-
class_option :capistrano, :type => :boolean, :desc => "Include Capistrano configuration"
|
12
|
-
class_option :redis, :type => :boolean, :desc => "Include Redis configuration"
|
13
|
-
class_option :rvm, :type => :boolean, :desc => "Create .ruby-version (ruby-2.1.0) and .ruby-gemset"
|
14
|
-
class_option :bundle, :type => :boolean, :desc => "Run bundle after generating the app"
|
15
|
-
class_option :git, :type => :boolean, :desc => "Initialize a Git repository"
|
16
|
-
|
17
|
-
# Creates instance variables from options passed to natra.
|
18
14
|
def setup
|
19
15
|
@app_path = name.directory_name
|
20
16
|
@name = name.file_name
|
21
|
-
|
22
|
-
options.each do |key, value|
|
23
|
-
instance_variable_set "@#{key.to_s}".to_sym, value
|
24
|
-
end
|
17
|
+
options.each {|key, value| instance_variable_set "@#{key}".to_sym, value}
|
25
18
|
end
|
26
19
|
|
27
20
|
def self.source_root
|
28
|
-
File.expand_path(File.join(File.dirname(__FILE__),
|
21
|
+
File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
|
29
22
|
end
|
30
23
|
|
31
|
-
# Create empty directories
|
32
24
|
def create_empty_directories
|
33
|
-
%w
|
34
|
-
empty_directory File.join(@app_path, dir)
|
35
|
-
end
|
36
|
-
|
25
|
+
%w[config/initializers lib spec].each {|dir| empty_directory File.join(@app_path, dir)}
|
37
26
|
empty_directory File.join(@app_path, 'db/migrate')
|
27
|
+
create_file File.join(@app_path, 'lib', '.keep')
|
28
|
+
template 'config/environment.rb', File.join(@app_path, 'config/environment.rb')
|
29
|
+
end
|
30
|
+
|
31
|
+
def create_seeds_file
|
32
|
+
create_file File.join(@app_path, 'db', 'seeds.rb')
|
33
|
+
end
|
38
34
|
|
39
|
-
|
40
|
-
|
35
|
+
def initialize_db
|
36
|
+
copy_file('bin/setup', File.join(@app_path, 'bin/setup'))
|
37
|
+
end
|
38
|
+
|
39
|
+
def uuid_setup
|
40
|
+
template 'db/migrate/add_extensions.rb', File.join(@app_path, "db/migrate/#{Time.now.strftime('%Y%m%d')}0000_add_extensions.rb")
|
41
41
|
end
|
42
42
|
|
43
43
|
def create_public_directory
|
44
|
-
template
|
44
|
+
template 'public/favicon.ico', File.join(@app_path, 'public/favicon.ico')
|
45
45
|
end
|
46
46
|
|
47
47
|
def create_app_directory
|
48
|
-
%w
|
49
|
-
directory dir, File.join(@app_path, dir)
|
50
|
-
end
|
48
|
+
%w[app/controllers app/views app/models].each {|dir| directory dir, File.join(@app_path, dir)}
|
51
49
|
end
|
52
50
|
|
53
51
|
def create_app_spec
|
54
|
-
template
|
52
|
+
template 'spec/application_controller_spec.rb', File.join(@app_path, 'spec/application_controller_spec.rb')
|
55
53
|
end
|
56
54
|
|
57
55
|
def create_spec_helper
|
58
|
-
template
|
56
|
+
template 'spec/spec_helper.rb', File.join(@app_path, 'spec/spec_helper.rb')
|
59
57
|
end
|
60
58
|
|
61
59
|
def create_config
|
62
|
-
template
|
60
|
+
template 'config.ru', File.join(@app_path, 'config.ru')
|
63
61
|
end
|
64
62
|
|
65
63
|
def create_gemfile
|
66
|
-
template
|
64
|
+
template 'Gemfile', File.join(@app_path, 'Gemfile')
|
67
65
|
end
|
68
66
|
|
69
67
|
def create_rakefile
|
70
|
-
template
|
68
|
+
template 'Rakefile', File.join(@app_path, 'Rakefile')
|
71
69
|
end
|
72
70
|
|
73
71
|
def create_readme
|
74
|
-
template(
|
72
|
+
template('README.md', File.join(@app_path, 'README.md'))
|
75
73
|
end
|
76
74
|
|
77
75
|
def create_db_config
|
78
|
-
template(
|
76
|
+
template('config/db.yml', File.join(@app_path, 'config/db.yml'))
|
79
77
|
end
|
80
78
|
|
81
79
|
def create_database_initializer
|
82
|
-
template(
|
80
|
+
template('config/initializers/database.rb', File.join(@app_path, 'config/initializers/database.rb'))
|
83
81
|
end
|
84
82
|
|
85
83
|
def create_redis_config
|
86
|
-
copy_file(
|
84
|
+
copy_file('config/redis.yml', File.join(@app_path, 'config/redis.yml')) if @redis
|
87
85
|
end
|
88
86
|
|
89
87
|
def create_redis_initializer
|
90
|
-
template(
|
88
|
+
template('config/initializers/redis.rb', File.join(@app_path, 'config/initializers/redis.rb')) if @redis
|
91
89
|
end
|
92
90
|
|
93
91
|
def create_gitignore
|
94
|
-
copy_file
|
92
|
+
copy_file 'gitignore', File.join(@app_path, '.gitignore')
|
95
93
|
end
|
94
|
+
|
96
95
|
def create_rspec
|
97
96
|
copy_file 'rspec', File.join(@app_path, '.rspec')
|
98
97
|
end
|
98
|
+
|
99
99
|
def create_rubocop
|
100
|
-
copy_file 'rubocop.yml', File.join(@app_path, '.rubocop.yml')
|
100
|
+
copy_file 'rubocop.yml', File.join(@app_path, '.rubocop.yml')
|
101
101
|
end
|
102
|
+
|
102
103
|
def create_docker
|
103
104
|
copy_file 'Dockerfile', File.join(@app_path, 'Dockerfile')
|
104
105
|
end
|
106
|
+
|
105
107
|
def create_docker_compose
|
106
|
-
template('docker-compose.yml', File.join(@app_path,
|
108
|
+
template('docker-compose.yml', File.join(@app_path, 'docker-compose.yml'))
|
107
109
|
end
|
110
|
+
|
108
111
|
def create_guardfile
|
109
|
-
copy_file
|
112
|
+
copy_file 'Guardfile', File.join(@app_path, 'Guardfile')
|
110
113
|
end
|
114
|
+
|
111
115
|
def create_spec_support
|
112
|
-
create_file
|
116
|
+
create_file File.join(@app_path, 'spec/support/', '.keep')
|
113
117
|
end
|
118
|
+
|
114
119
|
def create_secrets
|
115
|
-
template('secrets.env',File.join(@app_path,
|
120
|
+
template('secrets.env', File.join(@app_path, 'secrets.env'))
|
116
121
|
end
|
117
|
-
|
122
|
+
|
118
123
|
def create_capistrano_config
|
119
|
-
if @capistrano
|
120
|
-
inside(@app_path) do
|
121
|
-
run('cap install')
|
122
|
-
end
|
123
|
-
end
|
124
|
+
inside(@app_path) {run('cap install')} if @capistrano
|
124
125
|
end
|
125
126
|
|
126
127
|
def create_rvm_gemset
|
@@ -134,15 +135,11 @@ module Natra
|
|
134
135
|
end
|
135
136
|
|
136
137
|
def initialize_git_repo
|
137
|
-
inside(@app_path)
|
138
|
-
run('git init .') if @git
|
139
|
-
end
|
138
|
+
inside(@app_path) {run('git init .') if @git}
|
140
139
|
end
|
141
140
|
|
142
141
|
def install_dependencies
|
143
|
-
inside(@app_path)
|
144
|
-
run('bundle') if @bundle
|
145
|
-
end
|
142
|
+
inside(@app_path) {run('bundle') if @bundle}
|
146
143
|
end
|
147
144
|
end
|
148
145
|
end
|
@@ -1,17 +1,15 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
|
1
|
+
require 'thor/group'
|
2
|
+
require 'active_support/inflector'
|
4
3
|
module Natra
|
5
4
|
module Generators
|
6
5
|
class ControllerGenerator < Thor::Group
|
7
6
|
include Thor::Actions
|
8
7
|
attr_reader :controller_name, :class_name, :file_name
|
9
8
|
|
10
|
-
desc
|
11
|
-
argument :name, type: :string, desc:
|
9
|
+
desc 'Generate an Controller with associated views'
|
10
|
+
argument :name, type: :string, desc: 'Name of the controller'
|
12
11
|
|
13
|
-
|
14
|
-
class_option :views, type: :boolean, default: true, desc: "Generate views for controller"
|
12
|
+
class_option :views, type: :boolean, default: true, desc: 'Generate views for controller'
|
15
13
|
|
16
14
|
def self.source_root
|
17
15
|
File.dirname(__FILE__)
|
@@ -24,13 +22,14 @@ module Natra
|
|
24
22
|
end
|
25
23
|
|
26
24
|
def create_controller
|
27
|
-
template
|
28
|
-
insert_into_file
|
25
|
+
template 'templates/controller.rb.erb', File.join('app/controllers', "#{file_name}.rb")
|
26
|
+
insert_into_file 'config.ru', "use #{class_name}\n", after: "run ApplicationController\n"
|
29
27
|
end
|
30
28
|
|
31
29
|
def create_views
|
32
30
|
return unless options[:views]
|
33
|
-
|
31
|
+
|
32
|
+
directory 'templates/views', File.join('app/views', controller_name.to_s)
|
34
33
|
end
|
35
34
|
end
|
36
35
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class <%= migration_class_name %> < ActiveRecord::Migration
|
2
2
|
def change
|
3
|
-
create_table :<%= table_name %> do |t|
|
3
|
+
create_table :<%= table_name %> ,id: :uuid do |t|
|
4
4
|
<% attributes.each do |attribute| -%>
|
5
5
|
t.<%= attribute[:type] %> :<%= attribute[:name] %>
|
6
6
|
<% end %>
|
@@ -1,18 +1,16 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
|
1
|
+
require 'thor/group'
|
2
|
+
require 'active_support/inflector'
|
4
3
|
module Natra
|
5
4
|
module Generators
|
6
5
|
class ModelGenerator < Thor::Group
|
7
6
|
include Thor::Actions
|
8
7
|
attr_reader :file_name, :class_name, :model_name, :migration_name, :migration_class_name, :table_name
|
9
8
|
|
10
|
-
desc
|
11
|
-
argument :name, type: :string, desc:
|
12
|
-
argument :attributes, type: :array, default: [], banner:
|
9
|
+
desc 'Generate an ActiveRecord model'
|
10
|
+
argument :name, type: :string, desc: 'Name of the model'
|
11
|
+
argument :attributes, type: :array, default: [], banner: 'field:type field:type'
|
13
12
|
|
14
|
-
|
15
|
-
class_option :migration, type: :boolean, default: true, desc: "Generate migration for model"
|
13
|
+
class_option :migration, type: :boolean, default: true, desc: 'Generate migration for model'
|
16
14
|
|
17
15
|
def self.source_root
|
18
16
|
File.dirname(__FILE__)
|
@@ -27,8 +25,8 @@ module Natra
|
|
27
25
|
@migration_class_name = migration_name.camel_case
|
28
26
|
|
29
27
|
attributes.map! do |attribute|
|
30
|
-
field = attribute.split(
|
31
|
-
{ name: field[0], type: field[1] ||
|
28
|
+
field = attribute.split(':')
|
29
|
+
{ name: field[0], type: field[1] || 'string' }
|
32
30
|
end
|
33
31
|
end
|
34
32
|
|
@@ -37,21 +35,21 @@ module Natra
|
|
37
35
|
say "[WARNING] The model name '#{name}' was recognized as a plural, using the singular '#{model_name}' instead."
|
38
36
|
end
|
39
37
|
|
40
|
-
template
|
38
|
+
template 'model.rb.erb', File.join('app/models', "#{file_name}.rb")
|
41
39
|
end
|
42
40
|
|
43
41
|
def create_migration
|
44
42
|
return unless options[:migration]
|
45
43
|
|
46
|
-
migration_files = Dir.entries(
|
44
|
+
migration_files = Dir.entries('db/migrate').reject { |path| File.directory? path }
|
47
45
|
|
48
46
|
if duplicate = migration_files.find { |file| file.include?(migration_name) }
|
49
47
|
say_status :identical, "db/migrate/#{duplicate}", :blue
|
50
48
|
else
|
51
|
-
version = Time.now.utc.strftime(
|
49
|
+
version = Time.now.utc.strftime('%Y%m%d%H%M%S')
|
52
50
|
migration_file_name = "#{version}_#{migration_name}.rb"
|
53
51
|
|
54
|
-
template
|
52
|
+
template 'migration.rb.erb', File.join('db/migrate', migration_file_name)
|
55
53
|
end
|
56
54
|
end
|
57
55
|
end
|
@@ -1,14 +1,13 @@
|
|
1
1
|
require "thor/group"
|
2
2
|
require 'active_support/inflector'
|
3
|
-
|
4
3
|
module Natra
|
5
4
|
module Generators
|
6
5
|
class ScaffoldGenerator < Thor::Group
|
7
6
|
include Thor::Actions
|
8
7
|
|
9
|
-
desc
|
10
|
-
argument :name, type: :string, desc:
|
11
|
-
argument :attributes, type: :array, default: [], banner:
|
8
|
+
desc 'Generate an ActiveRecord model with it\'s associated views and controllers'
|
9
|
+
argument :name, type: :string, desc: 'Name of the model'
|
10
|
+
argument :attributes, type: :array, default: [], banner: 'field:type field:type'
|
12
11
|
|
13
12
|
def create_model
|
14
13
|
ModelGenerator.new([name, attributes]).invoke_all
|
data/lib/natra/version.rb
CHANGED
data/natra.gemspec
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
1
|
lib = File.expand_path('lib', __dir__)
|
4
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
3
|
require 'natra/version'
|
@@ -8,15 +6,12 @@ Gem::Specification.new do |spec|
|
|
8
6
|
spec.name = 'natra'
|
9
7
|
spec.version = Natra::VERSION
|
10
8
|
spec.authors = ['Thiru Njuguna']
|
11
|
-
spec.email = ['
|
9
|
+
spec.email = ['thirunjuguna@outlook.com']
|
12
10
|
|
13
11
|
spec.summary = 'Natra generate a light weight sinatra application'
|
14
|
-
spec.description = 'Natra generate a light weight sinatra application.It
|
12
|
+
spec.description = 'Natra generate a light weight sinatra application.It\'s ideal for building micro-services'
|
15
13
|
spec.homepage = 'https://github.com/thirunjuguna/natra'
|
16
14
|
spec.license = 'MIT'
|
17
|
-
|
18
|
-
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
19
|
-
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
20
15
|
if spec.respond_to?(:metadata)
|
21
16
|
spec.metadata['homepage_uri'] = spec.homepage
|
22
17
|
spec.metadata['source_code_uri'] = 'https://github.com/thirunjuguna/natra'
|
@@ -25,17 +20,12 @@ Gem::Specification.new do |spec|
|
|
25
20
|
raise 'RubyGems 2.0 or newer is required to protect against ' \
|
26
21
|
'public gem pushes.'
|
27
22
|
end
|
28
|
-
|
29
|
-
# Specify which files should be added to the gem when it is released.
|
30
|
-
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
31
23
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
32
24
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
33
25
|
end
|
34
26
|
spec.executables = ['natra']
|
35
27
|
spec.require_paths = ['lib']
|
36
28
|
spec.add_development_dependency 'bundler', '~> 1.16'
|
37
|
-
spec.add_development_dependency 'rake', '~> 0'
|
38
|
-
spec.add_development_dependency 'rspec', '~> 3.0'
|
39
29
|
spec.add_runtime_dependency('activesupport', '~> 5.0')
|
40
30
|
spec.add_runtime_dependency('thor', '~> 0.18')
|
41
31
|
end
|
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.4
|
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-10-
|
11
|
+
date: 2018-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -24,34 +24,6 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.16'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rake
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rspec
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '3.0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '3.0'
|
55
27
|
- !ruby/object:Gem::Dependency
|
56
28
|
name: activesupport
|
57
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,10 +52,10 @@ dependencies:
|
|
80
52
|
- - "~>"
|
81
53
|
- !ruby/object:Gem::Version
|
82
54
|
version: '0.18'
|
83
|
-
description: Natra generate a light weight sinatra application.It
|
55
|
+
description: Natra generate a light weight sinatra application.It's ideal for building
|
84
56
|
micro-services
|
85
57
|
email:
|
86
|
-
-
|
58
|
+
- thirunjuguna@outlook.com
|
87
59
|
executables:
|
88
60
|
- natra
|
89
61
|
extensions: []
|
@@ -126,13 +98,10 @@ files:
|
|
126
98
|
- lib/natra/generators/app/templates/config/initializers/redis.rb
|
127
99
|
- lib/natra/generators/app/templates/config/puma.rb
|
128
100
|
- lib/natra/generators/app/templates/config/redis.yml
|
101
|
+
- lib/natra/generators/app/templates/db/migrate/add_extensions.rb
|
129
102
|
- lib/natra/generators/app/templates/docker-compose.yml
|
130
103
|
- lib/natra/generators/app/templates/gitignore
|
131
104
|
- lib/natra/generators/app/templates/public/favicon.ico
|
132
|
-
- lib/natra/generators/app/templates/public/images/.gitkeep
|
133
|
-
- lib/natra/generators/app/templates/public/images/corneal-small.png
|
134
|
-
- lib/natra/generators/app/templates/public/javascripts/.gitkeep
|
135
|
-
- lib/natra/generators/app/templates/public/stylesheets/main.css
|
136
105
|
- lib/natra/generators/app/templates/rspec
|
137
106
|
- lib/natra/generators/app/templates/rubocop.yml
|
138
107
|
- lib/natra/generators/app/templates/secrets.env
|
File without changes
|
Binary file
|
File without changes
|
@@ -1,115 +0,0 @@
|
|
1
|
-
@media screen {
|
2
|
-
/* --- Reset Styles --- */
|
3
|
-
* {
|
4
|
-
list-style: none;
|
5
|
-
margin: 0;
|
6
|
-
padding: 0;
|
7
|
-
}
|
8
|
-
|
9
|
-
html, body {
|
10
|
-
height: 100%;
|
11
|
-
width: 100%;
|
12
|
-
}
|
13
|
-
|
14
|
-
/* --- Welcome Page Styles --- */
|
15
|
-
body {
|
16
|
-
background-color: lightblue;
|
17
|
-
color: #333;
|
18
|
-
font-family: Sans-Serif;
|
19
|
-
line-height: 18px;
|
20
|
-
}
|
21
|
-
|
22
|
-
.wrapper {
|
23
|
-
background: #fff;
|
24
|
-
-moz-box-shadow: 0 0 10px rgba(0,0,0,.3);
|
25
|
-
-webkit-box-shadow: 0 0 10px rgba(0,0,0,.3);
|
26
|
-
box-shadow: 0 0 10px rgba(0,0,0,.3);
|
27
|
-
margin: 16px auto;
|
28
|
-
max-width: 960px;
|
29
|
-
padding: 2.25%; /* 18px / 800px */
|
30
|
-
width: 85%;
|
31
|
-
}
|
32
|
-
|
33
|
-
h1 {
|
34
|
-
font-size: 36px;
|
35
|
-
line-height: 54px;
|
36
|
-
}
|
37
|
-
|
38
|
-
h2 {
|
39
|
-
border-bottom: 2px solid #ccc;
|
40
|
-
font-size: 24px;
|
41
|
-
line-height: 36px;
|
42
|
-
margin-bottom: 16px;
|
43
|
-
}
|
44
|
-
|
45
|
-
h3 {
|
46
|
-
font-size: 18px;
|
47
|
-
line-height: 36px;
|
48
|
-
}
|
49
|
-
|
50
|
-
p {
|
51
|
-
margin-bottom: 18px;
|
52
|
-
}
|
53
|
-
|
54
|
-
.main {
|
55
|
-
overflow: hidden;
|
56
|
-
}
|
57
|
-
|
58
|
-
.content {
|
59
|
-
float: left;
|
60
|
-
width: 60%; /* 480px / 800px */
|
61
|
-
}
|
62
|
-
|
63
|
-
.sidebar {
|
64
|
-
background: #eee;
|
65
|
-
border: 1px solid #ccc;
|
66
|
-
float: right;
|
67
|
-
padding: 2.08333333333%; /* 5px / 240px */
|
68
|
-
width: 30%; /* 240px / 800px */
|
69
|
-
}
|
70
|
-
|
71
|
-
.sidebar ul {
|
72
|
-
font-size: 14px;
|
73
|
-
}
|
74
|
-
|
75
|
-
.branding {
|
76
|
-
clear: both;
|
77
|
-
}
|
78
|
-
|
79
|
-
footer.branding {
|
80
|
-
border-top: 2px solid #ccc;
|
81
|
-
margin-top: 20px;
|
82
|
-
padding-top: 20px;
|
83
|
-
}
|
84
|
-
}
|
85
|
-
|
86
|
-
@media screen and (max-width: 600px) {
|
87
|
-
.wrapper {
|
88
|
-
-moz-box-shadow: none;
|
89
|
-
-webkit-box-shadow: none;
|
90
|
-
box-shadow: none;
|
91
|
-
width: auto;
|
92
|
-
}
|
93
|
-
|
94
|
-
.content, .sidebar {
|
95
|
-
float: none;
|
96
|
-
width: 100%;
|
97
|
-
}
|
98
|
-
|
99
|
-
.sidebar {
|
100
|
-
background: transparent;
|
101
|
-
border: none;
|
102
|
-
border-top: 2px solid #ccc;
|
103
|
-
padding: 0;
|
104
|
-
}
|
105
|
-
|
106
|
-
h1 {
|
107
|
-
font-size: 24px;
|
108
|
-
line-height: 36px;
|
109
|
-
}
|
110
|
-
|
111
|
-
h2 {
|
112
|
-
font-size: 18px;
|
113
|
-
line-height: 24px;
|
114
|
-
}
|
115
|
-
}
|