dfl_rails_config 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -13
- data/dfl_rails_config.gemspec +2 -2
- data/lib/dfl_rails_config/generators/version.rb +5 -0
- data/lib/dfl_rails_config.rb +3 -3
- data/lib/generators/dfl_rails_config/all_generator.rb +28 -0
- data/lib/generators/dfl_rails_config/install_generator.rb +120 -118
- data/lib/generators/dfl_rails_config/navbar_generator.rb +13 -0
- metadata +5 -3
- data/lib/dfl_rails_config/version.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f04a26ff0678a82685efa1f0e0c90a6c91d0a9c5
|
4
|
+
data.tar.gz: e48bc153435a2df5907b0646fbce135ed567f61c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d3b77256187963a4ea43a37387ba9c072033078a4b9eacab44751799782a4bd41a588d90e8da6f723aefd03e379759d6c0c532e920dea25c912a5328628054c
|
7
|
+
data.tar.gz: e4827791b2b3e4eb1122e4c91312191ec88d6651461f557f9c95237cb1357e2e2b6bf897a21c294914c69b76c35b9c1fb2669724d1b6a9195f84dcb3f04392a3
|
data/README.md
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
# DflRailsConfig
|
2
2
|
|
3
|
-
|
3
|
+
You can use this gem to generate common settings for your project. See below:
|
4
4
|
|
5
|
-
|
5
|
+
- Add the some gems for your project (devise, simple_form, slim, etc...)
|
6
|
+
- Set up the database
|
7
|
+
- Set deploy files
|
8
|
+
- Set I18n
|
9
|
+
- ... And many other things.
|
6
10
|
|
7
11
|
## Installation
|
8
12
|
|
@@ -22,18 +26,9 @@ Or install it yourself as:
|
|
22
26
|
|
23
27
|
## Usage
|
24
28
|
|
25
|
-
|
26
|
-
|
27
|
-
## Development
|
28
|
-
|
29
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake false` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
-
|
31
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
-
|
33
|
-
## Contributing
|
34
|
-
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/dfl_rails_config.
|
29
|
+
After install, run the command bellow:
|
36
30
|
|
31
|
+
$ rails generate dfl_rails_config:install
|
37
32
|
|
38
33
|
## License
|
39
34
|
|
data/dfl_rails_config.gemspec
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
lib = File.expand_path('../lib', __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'dfl_rails_config/version'
|
4
|
+
require 'dfl_rails_config/generators/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "dfl_rails_config"
|
8
|
-
spec.version = DflRailsConfig::VERSION
|
8
|
+
spec.version = DflRailsConfig::Generators::VERSION
|
9
9
|
spec.authors = ["Daniel Fernando Lourusso"]
|
10
10
|
spec.email = ["dflourusso@gmail.com"]
|
11
11
|
|
data/lib/dfl_rails_config.rb
CHANGED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
module DflRailsConfig
|
4
|
+
module Generators
|
5
|
+
class AllGenerator < Rails::Generators::Base
|
6
|
+
desc "Install DflRailsConfig"
|
7
|
+
def generator
|
8
|
+
# Load all generators in load path
|
9
|
+
# https://github.com/rails/rails/blob/master/railties/lib/rails/generators.rb#L291-L303
|
10
|
+
Rails::Generators.lookup!
|
11
|
+
DflRailsConfig::Generators.constants.each do |const|
|
12
|
+
generator_class = DflRailsConfig::Generators.const_get(const)
|
13
|
+
next if self.class == generator_class
|
14
|
+
if generator_class <=> Rails::Generators::Base
|
15
|
+
namespace = generator_klass_to_namespace(generator_class)
|
16
|
+
puts "#{namespace}"
|
17
|
+
invoke(namespace)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
private
|
22
|
+
def generator_klass_to_namespace(klass)
|
23
|
+
namespace = Thor::Util.namespace_from_thor_class(klass)
|
24
|
+
return namespace.sub(/_generator$/, '').sub(/:generators:/, ':')
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -2,157 +2,159 @@ require 'rails/generators'
|
|
2
2
|
|
3
3
|
# TODO: Dividir generator em partes. Ex: DeployGenerator, GemsGenerator, DatabaseGenerator, etc.
|
4
4
|
module DflRailsConfig
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
5
|
+
module Generators
|
6
|
+
class InstallGenerator < Rails::Generators::Base
|
7
|
+
source_root File.expand_path('../templates', __FILE__)
|
8
|
+
|
9
|
+
def create_version_file
|
10
|
+
create_file "lib/version.rb", <<-FILE
|
11
|
+
module #{application_name}
|
12
|
+
VERSION = '0.0.1'
|
13
|
+
end
|
14
|
+
FILE
|
15
|
+
end
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
17
|
+
def copy_bin
|
18
|
+
directory 'bin/', 'bin/'
|
19
|
+
end
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
21
|
+
def replace_deploy_vars
|
22
|
+
f = 'bin/_heroku_vars.sh'
|
23
|
+
gsub_file f, '_STAGING_APP', "#{application_name.underscore}_staging"
|
24
|
+
gsub_file f, '_STAGING_NAME', "'#{application_name.underscore.humanize} Staging'"
|
25
|
+
gsub_file f, '_PRODUCTION_APP', application_name.underscore
|
26
|
+
gsub_file f, '_PRODUCTION_NAME', "'#{application_name.underscore.humanize}'"
|
27
|
+
gsub_file f, '_APP_DOMAIN', "#{application_name.underscore}.com.br"
|
28
|
+
end
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
30
|
+
def add_flash_types
|
31
|
+
file_name = 'app/controllers/application_controller.rb'
|
32
|
+
unless File.read(file_name) =~ /add_flash_types/
|
33
|
+
inject_into_file file_name, after: 'protect_from_forgery with: :exception' do
|
34
|
+
"\n add_flash_types :warning, :error, :info"
|
35
|
+
end
|
34
36
|
end
|
35
37
|
end
|
36
|
-
end
|
37
38
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
39
|
+
def inject_default_date_formats
|
40
|
+
file_name = 'config/application.rb'
|
41
|
+
unless File.read(file_name) =~ /Date::DATE_FORMATS/
|
42
|
+
inject_into_file file_name, after: "raise_in_transactional_callbacks = true" do
|
43
|
+
"\n Date::DATE_FORMATS[:default] = '%d/%m/%Y'"
|
44
|
+
end
|
43
45
|
end
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
46
|
+
unless File.read(file_name) =~ /Time::DATE_FORMATS/
|
47
|
+
inject_into_file file_name, after: "raise_in_transactional_callbacks = true" do
|
48
|
+
"\n Time::DATE_FORMATS[:default] = '%d/%m/%Y %H:%M:%S'"
|
49
|
+
end
|
48
50
|
end
|
49
51
|
end
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
end
|
52
|
+
|
53
|
+
def rubocop_config
|
54
|
+
file_name = '.rubocop.yml'
|
55
|
+
copy_file file_name, file_name
|
56
|
+
end
|
56
57
|
|
57
|
-
|
58
|
-
|
59
|
-
|
58
|
+
def gem_font_awesome_rails
|
59
|
+
append_file 'Gemfile', "\ngem 'font-awesome-rails'" unless File.read('Gemfile') =~ /font-awesome-rails/
|
60
|
+
end
|
60
61
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
62
|
+
def gem_better_errors
|
63
|
+
unless File.read('Gemfile') =~ /better_errors/
|
64
|
+
inject_into_file 'Gemfile', after: "group :development, :test do" do
|
65
|
+
"\n gem 'better_errors'\n"
|
66
|
+
end
|
65
67
|
end
|
66
68
|
end
|
67
|
-
end
|
68
69
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
70
|
+
def gem_ruby_version
|
71
|
+
unless File.read('Gemfile') =~ /ruby /
|
72
|
+
inject_into_file 'Gemfile', after: "source 'https://rubygems.org'\n" do
|
73
|
+
"\nruby '2.2.2'"
|
74
|
+
end
|
73
75
|
end
|
74
76
|
end
|
75
|
-
end
|
76
77
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
78
|
+
def include_gems_directory
|
79
|
+
string_to_append = "\nDir.glob('gemfiles/**/*.rb') { |f| eval_gemfile f }\n"
|
80
|
+
regex = /Dir.glob\('gemfiles\/\*\*\/\*.rb'\)/
|
81
|
+
directory 'gemfiles/', 'gemfiles/'
|
82
|
+
append_file 'Gemfile', string_to_append unless File.read('Gemfile') =~ regex
|
83
|
+
Bundler.with_clean_env {run "bundle install --without production"}
|
84
|
+
end
|
84
85
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
86
|
+
def overcommit_install
|
87
|
+
# run 'overcommit --install'
|
88
|
+
file_name = '.overcommit.yml'
|
89
|
+
remove_file file_name
|
90
|
+
copy_file file_name, file_name
|
91
|
+
end
|
91
92
|
|
92
|
-
|
93
|
-
|
94
|
-
|
93
|
+
def rspec_install
|
94
|
+
run 'rails generate rspec:install'
|
95
|
+
end
|
95
96
|
|
96
|
-
|
97
|
-
|
97
|
+
def devise_install
|
98
|
+
run 'rails generate devise:install'
|
98
99
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
100
|
+
#password length
|
101
|
+
old_config = 'config.password_length = 8..72'
|
102
|
+
new_config = 'config.password_length = Rails.env.production? ? 8..72 : 1..8'
|
103
|
+
gsub_file 'config/initializers/devise.rb', old_config, new_config
|
104
|
+
end
|
104
105
|
|
105
|
-
|
106
|
-
|
107
|
-
|
106
|
+
def kaminari_views
|
107
|
+
run 'rails g kaminari:views bootstrap3'
|
108
|
+
end
|
108
109
|
|
109
|
-
|
110
|
-
|
111
|
-
|
110
|
+
def simple_form_install
|
111
|
+
run 'rails generate simple_form:install --bootstrap'
|
112
|
+
end
|
112
113
|
|
113
|
-
|
114
|
-
|
115
|
-
|
114
|
+
def rspec_always_test_env
|
115
|
+
gsub_file 'spec/rails_helper.rb', "ENV['RAILS_ENV'] ||= 'test'", "ENV['RAILS_ENV'] = 'test'"
|
116
|
+
end
|
116
117
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
118
|
+
def i18n_pt_br
|
119
|
+
file_name = 'config/application.rb'
|
120
|
+
gsub_file file_name, '# config.i18n.default_locale = :de', "config.i18n.default_locale = :'pt-BR'"
|
121
|
+
end
|
121
122
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
123
|
+
def ransak_simple_form
|
124
|
+
file_name = 'config/application.rb'
|
125
|
+
unless File.read(file_name) =~ /RANSACK_FORM_BUILDER/
|
126
|
+
inject_into_file file_name, before: "require 'rails/all'" do
|
127
|
+
"ENV['RANSACK_FORM_BUILDER'] = '::SimpleForm::FormBuilder'\n"
|
128
|
+
end
|
127
129
|
end
|
128
130
|
end
|
129
|
-
end
|
130
131
|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
132
|
+
def configure_database
|
133
|
+
file_name = 'config/database.yml'
|
134
|
+
remove_file file_name
|
135
|
+
copy_file file_name.split('/').last, file_name
|
136
|
+
gsub_file file_name, 'database_name', application_name.underscore
|
137
|
+
gsub_file file_name, 'database_name_test', "#{application_name.underscore}_test"
|
138
|
+
end
|
138
139
|
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
140
|
+
def application_js
|
141
|
+
file_name = 'app/assets/javascripts/application.js'
|
142
|
+
remove_file file_name
|
143
|
+
copy_file file_name.split('/').last, file_name
|
144
|
+
end
|
144
145
|
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
146
|
+
def application_css
|
147
|
+
rm_file_name = 'app/assets/stylesheets/application.css'
|
148
|
+
file_name = 'app/assets/stylesheets/application.css.scss'
|
149
|
+
remove_file rm_file_name
|
150
|
+
copy_file file_name.split('/').last, file_name
|
151
|
+
end
|
151
152
|
|
152
|
-
|
153
|
+
protected
|
153
154
|
|
154
|
-
|
155
|
-
|
155
|
+
def application_name
|
156
|
+
Rails.application.class.parent_name
|
157
|
+
end
|
156
158
|
end
|
157
159
|
end
|
158
160
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
module DflRailsConfig
|
4
|
+
module Generators
|
5
|
+
class NavbarGenerator < Rails::Generators::Base
|
6
|
+
source_root File.expand_path('../templates', __FILE__)
|
7
|
+
|
8
|
+
def teste
|
9
|
+
puts 'Adicionar codigo para criar navbar'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dfl_rails_config
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Fernando Lourusso
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -55,9 +55,11 @@ files:
|
|
55
55
|
- bin/setup
|
56
56
|
- dfl_rails_config.gemspec
|
57
57
|
- lib/dfl_rails_config.rb
|
58
|
-
- lib/dfl_rails_config/version.rb
|
58
|
+
- lib/dfl_rails_config/generators/version.rb
|
59
59
|
- lib/generators/dfl_rails_config/USAGE
|
60
|
+
- lib/generators/dfl_rails_config/all_generator.rb
|
60
61
|
- lib/generators/dfl_rails_config/install_generator.rb
|
62
|
+
- lib/generators/dfl_rails_config/navbar_generator.rb
|
61
63
|
- lib/generators/dfl_rails_config/templates/.overcommit.yml
|
62
64
|
- lib/generators/dfl_rails_config/templates/.rubocop.yml
|
63
65
|
- lib/generators/dfl_rails_config/templates/application.css.scss
|