mecha 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -2
- data/bin/mecha +10 -0
- data/lib/mecha/app_builder.rb +57 -24
- data/lib/mecha/support/string.rb +16 -0
- data/lib/mecha/templates/Gemfile.erb +7 -8
- data/lib/mecha/templates/README.md.erb +8 -2
- data/lib/mecha/templates/bitbucket-pipelines.yml.erb +19 -0
- data/lib/mecha/templates/config/databases/postgresql.yml.erb +29 -0
- data/lib/mecha/templates/rubocop.yml +10 -1
- data/lib/mecha/templates/simplecov +10 -0
- data/lib/mecha/version.rb +1 -1
- data/lib/mecha.rb +11 -0
- data/mecha.gemspec +1 -0
- metadata +21 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a1b4e173bd19a46c5c102c5a9a2e39eef3f1c474
|
4
|
+
data.tar.gz: ff7fd9cb4ec89a2fa9ebfaa037ec9300c4625d58
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8fd2135d7dff7350b157a5572a762787ba1cc9f82f77f16d8d75c80f7c00be693b1c5ca37fa092e7841ce7c8f28b147c2b1c2c69ef3d6fe1dd8696dae644ba4d
|
7
|
+
data.tar.gz: 419210038f9549d19bdbcacd0b355811e564443ca41d9c2b27bfb2f2c09065d761b5bda41c64f2cf5b9a5c8489662a71966729cffff92d2882d16d3f10c39826
|
data/README.md
CHANGED
@@ -26,7 +26,13 @@ This will create a Rails app with name `<projectname>` and add all our defaults.
|
|
26
26
|
|
27
27
|
## Development
|
28
28
|
|
29
|
-
|
29
|
+
Run `rake test` or simply just `rake` to run tests.
|
30
|
+
|
31
|
+
To install Mecha in your local environment run:
|
32
|
+
|
33
|
+
```bash
|
34
|
+
rake install
|
35
|
+
```
|
30
36
|
|
31
37
|
## Contributing
|
32
38
|
|
@@ -34,7 +40,6 @@ Bug reports and pull requests are welcome on [GitHub](https://github.com/magrath
|
|
34
40
|
intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the
|
35
41
|
[Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
42
|
|
37
|
-
|
38
43
|
## License
|
39
44
|
|
40
45
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/bin/mecha
CHANGED
@@ -2,7 +2,17 @@
|
|
2
2
|
|
3
3
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
4
4
|
|
5
|
+
require 'slop'
|
5
6
|
require 'mecha'
|
6
7
|
|
8
|
+
Mecha.opts = Slop.parse do |o|
|
9
|
+
o.bool '-d', '--devise', 'Install and config Devise'
|
10
|
+
o.bool '-bp', '--bitbucket-pipelines', 'Config Bitbucket Pipelines'
|
11
|
+
o.on '--version', 'print the version' do
|
12
|
+
puts Mecha::VERSION
|
13
|
+
exit
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
7
17
|
Mecha.config_templates_path
|
8
18
|
Mecha::AppGenerator.start
|
data/lib/mecha/app_builder.rb
CHANGED
@@ -1,21 +1,39 @@
|
|
1
1
|
module Mecha
|
2
2
|
class AppBuilder < Rails::AppBuilder
|
3
3
|
def config_application
|
4
|
-
inject_into_class('config/application.rb', 'Application')
|
5
|
-
<<-DOC
|
6
|
-
config.assets.initialize_on_precompile = false
|
7
|
-
config.autoload_paths += %W(\#{config.root}/lib \#{config.root}/app/uploaders \#{config.root}/services)
|
8
|
-
config.i18n.default_locale = :'pt-BR'
|
9
|
-
config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}')]
|
10
|
-
config.generators do |g|
|
11
|
-
g.view_specs false
|
12
|
-
g.routing_specs false
|
13
|
-
g.stylesheets false
|
14
|
-
g.javascripts false
|
15
|
-
g.helper false
|
4
|
+
inject_into_class('config/application.rb', 'Application') { inject_to_application_rb }
|
16
5
|
end
|
17
|
-
|
18
|
-
|
6
|
+
|
7
|
+
def config_bitbucket_pipelines
|
8
|
+
return unless Mecha.opts.bitbucket_pipelines?
|
9
|
+
say('Config Bitbucket Pipelines', :green)
|
10
|
+
template('bitbucket-pipelines.yml.erb', 'bitbucket-pipelines.yml')
|
11
|
+
end
|
12
|
+
|
13
|
+
def config_devise
|
14
|
+
return unless Mecha.opts.devise?
|
15
|
+
say('Installing devise from generator', :green)
|
16
|
+
system('rails generate devise:install')
|
17
|
+
inject_into_file(
|
18
|
+
'config/environments/development.rb',
|
19
|
+
"\n\n config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }",
|
20
|
+
before: "\nend"
|
21
|
+
)
|
22
|
+
system('rails generate devise User')
|
23
|
+
system('rails generate devise:views')
|
24
|
+
inject_into_file(
|
25
|
+
'app/controllers/application_controller.rb',
|
26
|
+
"\n before_action :authenticate_user!",
|
27
|
+
before: "\nend"
|
28
|
+
)
|
29
|
+
end
|
30
|
+
|
31
|
+
def config_guardfile
|
32
|
+
copy_file('Guardfile', 'Guardfile')
|
33
|
+
end
|
34
|
+
|
35
|
+
def config_rubocop
|
36
|
+
copy_file('rubocop.yml', '.rubocop.yml')
|
19
37
|
end
|
20
38
|
|
21
39
|
def config_test
|
@@ -25,8 +43,8 @@ module Mecha
|
|
25
43
|
end
|
26
44
|
|
27
45
|
def database_yml
|
28
|
-
template "config/databases/#{options[:database]}.yml", 'config/database.example.yml'
|
29
|
-
template "config/databases/#{options[:database]}.yml", 'config/database.yml'
|
46
|
+
template "config/databases/#{options[:database]}.yml.erb", 'config/database.example.yml'
|
47
|
+
template "config/databases/#{options[:database]}.yml.erb", 'config/database.yml'
|
30
48
|
end
|
31
49
|
|
32
50
|
def gemfile
|
@@ -38,27 +56,42 @@ module Mecha
|
|
38
56
|
@generator.append_file('.gitignore', append_to_gitignore)
|
39
57
|
end
|
40
58
|
|
41
|
-
def guardfile
|
42
|
-
copy_file('Guardfile', 'Guardfile')
|
43
|
-
end
|
44
|
-
|
45
59
|
def readme
|
46
60
|
template('README.md.erb', 'README.md')
|
47
61
|
end
|
48
62
|
|
49
|
-
def
|
50
|
-
copy_file('
|
63
|
+
def config_simplecov
|
64
|
+
copy_file('simplecov', '.simplecov')
|
51
65
|
end
|
52
66
|
|
53
67
|
def leftovers
|
54
|
-
guardfile
|
55
|
-
rubocop
|
56
68
|
config_application
|
69
|
+
config_bitbucket_pipelines
|
70
|
+
config_devise
|
71
|
+
config_simplecov
|
72
|
+
config_guardfile
|
73
|
+
config_rubocop
|
57
74
|
config_test
|
58
75
|
end
|
59
76
|
|
60
77
|
private
|
61
78
|
|
79
|
+
def inject_to_application_rb
|
80
|
+
<<-DOC
|
81
|
+
config.assets.initialize_on_precompile = false
|
82
|
+
config.autoload_paths += %W(\#{config.root}/lib \#{config.root}/app/uploaders \#{config.root}/services)
|
83
|
+
config.i18n.default_locale = :'pt-BR'
|
84
|
+
config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}')]
|
85
|
+
config.generators do |g|
|
86
|
+
g.view_specs false
|
87
|
+
g.routing_specs false
|
88
|
+
g.stylesheets false
|
89
|
+
g.javascripts false
|
90
|
+
g.helper false
|
91
|
+
end
|
92
|
+
DOC
|
93
|
+
end
|
94
|
+
|
62
95
|
def append_to_gitignore
|
63
96
|
<<-DOC.strip_heredoc
|
64
97
|
.DS_Store
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class String
|
2
|
+
# Underscore a string, replacing dashes and spaces using underscores.
|
3
|
+
#
|
4
|
+
# @example Convert a camel case String to snake case
|
5
|
+
# 'Snake - Case'.snakecase #=> 'snake_case'
|
6
|
+
#
|
7
|
+
# @return [String] the object converted to underscore format.
|
8
|
+
def underscore
|
9
|
+
tr('-', '_')
|
10
|
+
.gsub(/\s/, '_')
|
11
|
+
.gsub(/__+/, '_')
|
12
|
+
.downcase
|
13
|
+
end
|
14
|
+
|
15
|
+
alias snakecase underscore
|
16
|
+
end
|
@@ -8,14 +8,13 @@ end
|
|
8
8
|
|
9
9
|
gem 'rails', '<%= Mecha::RAILS_VERSION %>'
|
10
10
|
|
11
|
-
gem 'pg'
|
12
|
-
gem 'puma'
|
11
|
+
gem 'pg', '~> 0.18.4'
|
12
|
+
gem 'puma', '~> 3.8.0'
|
13
13
|
|
14
|
-
gem 'devise', '~> 4.2'
|
14
|
+
<%= "gem 'devise', '~> 4.2'\n" unless Mecha.opts.skip_devise? -%>
|
15
15
|
|
16
|
-
gem 'jquery-rails'
|
17
|
-
gem '
|
18
|
-
gem 'uglifier', '>= 1.3.0'
|
16
|
+
gem 'jquery-rails', '~> 4.3.1'
|
17
|
+
gem 'uglifier', '~> 3.1.12'
|
19
18
|
|
20
19
|
group :development, :test do
|
21
20
|
gem 'byebug', platform: :mri
|
@@ -31,11 +30,11 @@ group :development do
|
|
31
30
|
gem 'guard-minitest'
|
32
31
|
gem 'guard-rails', require: false
|
33
32
|
gem 'guard-rubocop'
|
34
|
-
gem 'listen'
|
33
|
+
gem 'listen'
|
35
34
|
gem 'rubocop', require: false
|
36
35
|
gem 'spring'
|
37
36
|
gem 'spring-watcher-listen'
|
38
|
-
gem 'web-console'
|
37
|
+
gem 'web-console'
|
39
38
|
end
|
40
39
|
|
41
40
|
group :test do
|
@@ -8,7 +8,7 @@
|
|
8
8
|
|
9
9
|
## Dependencies
|
10
10
|
|
11
|
-
- Ruby
|
11
|
+
- Ruby <%= Mecha::RUBY_VERSION %>
|
12
12
|
- PostgreSQL 9.6.1
|
13
13
|
- PhantomJS 1.8.1
|
14
14
|
|
@@ -60,7 +60,13 @@ open coverage/index.html
|
|
60
60
|
|
61
61
|
## Staging
|
62
62
|
|
63
|
-
|
63
|
+
We're using Heroku as Staging environment. Take a look in the
|
64
|
+
[documentation](https://devcenter.heroku.com/articles/getting-started-with-rails5) to setup Heroku in your machine.
|
65
|
+
|
66
|
+
```sh
|
67
|
+
git push heroku master
|
68
|
+
heroku run rake db:migrate
|
69
|
+
```
|
64
70
|
|
65
71
|
## Style
|
66
72
|
|
@@ -0,0 +1,19 @@
|
|
1
|
+
image: magrathealabs/ruby:2.3
|
2
|
+
|
3
|
+
clone:
|
4
|
+
depth: 3
|
5
|
+
|
6
|
+
pipelines:
|
7
|
+
default:
|
8
|
+
- step:
|
9
|
+
script:
|
10
|
+
- /etc/init.d/postgresql start
|
11
|
+
- sudo -u postgres sh -c 'createuser <%= app_name.underscore %>_test & createdb <%= app_name.underscore %>_test'
|
12
|
+
- sudo -u postgres psql -c "ALTER USER <%= app_name.underscore %>_test PASSWORD '<%= app_name.underscore %>_test' CREATEDB SUPERUSER;"
|
13
|
+
- cp config/database.yml.example config/database.yml
|
14
|
+
- apt-get update -yqqq
|
15
|
+
- apt-get -qq -y --force-yes install apt-utils bzip2 nodejs-legacy npm
|
16
|
+
- npm install -g phantomjs-prebuilt
|
17
|
+
- bundle install --jobs $(nproc)
|
18
|
+
- bundle exec rake db:schema:load RAILS_ENV=test
|
19
|
+
- bundle exec rake test
|
@@ -0,0 +1,29 @@
|
|
1
|
+
default: &default
|
2
|
+
adapter: postgresql
|
3
|
+
encoding: unicode
|
4
|
+
# http://guides.rubyonrails.org/configuring.html#database-pooling
|
5
|
+
pool: <%%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
|
6
|
+
|
7
|
+
development:
|
8
|
+
<<: *default
|
9
|
+
database: <%= app_name.underscore %>_development
|
10
|
+
username: <%%= ENV['POSTGRESQL_USERNAME'] || 'postgres' %>
|
11
|
+
password: <%%= ENV['POSTGRESQL_PASSWORD'] || '' %>
|
12
|
+
host: localhost
|
13
|
+
port: 5432
|
14
|
+
|
15
|
+
test:
|
16
|
+
<<: *default
|
17
|
+
encoding: utf8
|
18
|
+
host: localhost
|
19
|
+
timeout: 5000
|
20
|
+
database: <%= app_name.underscore %>_test
|
21
|
+
username: <%= app_name.underscore %>_test
|
22
|
+
password: <%= app_name.underscore %>_test
|
23
|
+
template: template0
|
24
|
+
|
25
|
+
production:
|
26
|
+
<<: *default
|
27
|
+
database: <%= app_name.underscore %>_production
|
28
|
+
username: <%= app_name.underscore %>
|
29
|
+
password: <%%= ENV['KAVO_DATABASE_PASSWORD'] %>
|
@@ -4,15 +4,19 @@ Rails:
|
|
4
4
|
AllCops:
|
5
5
|
Exclude:
|
6
6
|
- 'db/schema.rb'
|
7
|
+
- 'bin/**'
|
7
8
|
- 'vendor/**/*'
|
8
9
|
- 'tmp/**/*'
|
10
|
+
- 'Guardfile'
|
11
|
+
- 'config/**/*'
|
12
|
+
- 'lib/tasks/*.rake'
|
9
13
|
|
10
14
|
Documentation:
|
11
15
|
Enabled: false
|
12
16
|
|
13
17
|
Metrics/AbcSize:
|
14
18
|
Exclude:
|
15
|
-
- 'db
|
19
|
+
- 'db/**/*'
|
16
20
|
|
17
21
|
Metrics/BlockLength:
|
18
22
|
Exclude:
|
@@ -24,6 +28,11 @@ Metrics/ClassLength:
|
|
24
28
|
Exclude:
|
25
29
|
- 'test/**/*'
|
26
30
|
|
31
|
+
Metrics/BlockLength:
|
32
|
+
Exclude:
|
33
|
+
- 'db/migrate/**'
|
34
|
+
- 'test/**/*'
|
35
|
+
|
27
36
|
Metrics/LineLength:
|
28
37
|
Max: 120
|
29
38
|
|
data/lib/mecha/version.rb
CHANGED
data/lib/mecha.rb
CHANGED
@@ -1,8 +1,19 @@
|
|
1
1
|
require 'mecha/version'
|
2
|
+
require 'mecha/support/string'
|
2
3
|
require 'mecha/generators/app_generator'
|
3
4
|
require 'mecha/app_builder'
|
4
5
|
|
5
6
|
module Mecha
|
7
|
+
@opts = nil
|
8
|
+
|
9
|
+
def self.opts=(opts)
|
10
|
+
@opts = opts
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.opts
|
14
|
+
@opts
|
15
|
+
end
|
16
|
+
|
6
17
|
def self.config_templates_path
|
7
18
|
templates_path = File.expand_path(File.join('mecha', 'templates'), File.dirname(__FILE__))
|
8
19
|
Mecha::AppGenerator.source_root(templates_path)
|
data/mecha.gemspec
CHANGED
@@ -27,6 +27,7 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.required_ruby_version = Mecha::RUBY_VERSION
|
28
28
|
|
29
29
|
spec.add_dependency 'rails', Mecha::RAILS_VERSION
|
30
|
+
spec.add_dependency 'slop'
|
30
31
|
|
31
32
|
spec.add_development_dependency 'bundler', '~> 1.14'
|
32
33
|
spec.add_development_dependency 'rake', '~> 12.0'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mecha
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Magrathea Labs
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-04-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 5.0.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: slop
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: bundler
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -89,10 +103,14 @@ files:
|
|
89
103
|
- lib/mecha.rb
|
90
104
|
- lib/mecha/app_builder.rb
|
91
105
|
- lib/mecha/generators/app_generator.rb
|
106
|
+
- lib/mecha/support/string.rb
|
92
107
|
- lib/mecha/templates/Gemfile.erb
|
93
108
|
- lib/mecha/templates/Guardfile
|
94
109
|
- lib/mecha/templates/README.md.erb
|
110
|
+
- lib/mecha/templates/bitbucket-pipelines.yml.erb
|
111
|
+
- lib/mecha/templates/config/databases/postgresql.yml.erb
|
95
112
|
- lib/mecha/templates/rubocop.yml
|
113
|
+
- lib/mecha/templates/simplecov
|
96
114
|
- lib/mecha/templates/test_helper.rb
|
97
115
|
- lib/mecha/version.rb
|
98
116
|
- mecha.gemspec
|
@@ -117,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
135
|
version: '0'
|
118
136
|
requirements: []
|
119
137
|
rubyforge_project:
|
120
|
-
rubygems_version: 2.6.
|
138
|
+
rubygems_version: 2.6.11
|
121
139
|
signing_key:
|
122
140
|
specification_version: 4
|
123
141
|
summary: Generate a Rails app using MLabs defaults.
|