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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 441f86070f5ed1bc5f058a4b3afc824d1584b3fe
4
- data.tar.gz: 88dc320b91902db9ab7b092c8406995818c46ce4
3
+ metadata.gz: f04a26ff0678a82685efa1f0e0c90a6c91d0a9c5
4
+ data.tar.gz: e48bc153435a2df5907b0646fbce135ed567f61c
5
5
  SHA512:
6
- metadata.gz: 6c7123657481c97a14a1e7c66edd01581a4d2667c67c5a275e93df2a7be7ca6066f4981ff33af45f0bc115334aa525c24931075334b7984ed88b5bbd0ea00250
7
- data.tar.gz: 7b955e4fb8f61e916cba98f57d7717867e9a9e421387583a615f08d717de28597544071bd8a11b35c73477478347fec505445fad792bef418afebb517def438e
6
+ metadata.gz: 8d3b77256187963a4ea43a37387ba9c072033078a4b9eacab44751799782a4bd41a588d90e8da6f723aefd03e379759d6c0c532e920dea25c912a5328628054c
7
+ data.tar.gz: e4827791b2b3e4eb1122e4c91312191ec88d6651461f557f9c95237cb1357e2e2b6bf897a21c294914c69b76c35b9c1fb2669724d1b6a9195f84dcb3f04392a3
data/README.md CHANGED
@@ -1,8 +1,12 @@
1
1
  # DflRailsConfig
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/dfl_rails_config`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ You can use this gem to generate common settings for your project. See below:
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
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
- TODO: Write usage instructions here
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
 
@@ -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
 
@@ -0,0 +1,5 @@
1
+ module DflRailsConfig
2
+ module Generators
3
+ VERSION = "0.1.1"
4
+ end
5
+ end
@@ -1,5 +1,5 @@
1
- require "dfl_rails_config/version"
2
-
3
1
  module DflRailsConfig
4
- # Do a generator to run all sub generators
2
+ module Generators
3
+
4
+ end
5
5
  end
@@ -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
- class InstallGenerator < Rails::Generators::Base
6
- source_root File.expand_path('../templates', __FILE__)
7
-
8
- def create_version_file
9
- create_file "lib/version.rb", <<-FILE
10
- module #{application_name}
11
- VERSION = '0.0.1'
12
- end
13
- FILE
14
- end
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
- def copy_bin
17
- directory 'bin/', 'bin/'
18
- end
17
+ def copy_bin
18
+ directory 'bin/', 'bin/'
19
+ end
19
20
 
20
- def replace_deploy_vars
21
- f = 'bin/_heroku_vars.sh'
22
- gsub_file f, '_STAGING_APP', "#{application_name.underscore}_staging"
23
- gsub_file f, '_STAGING_NAME', "'#{application_name.underscore.humanize} Staging'"
24
- gsub_file f, '_PRODUCTION_APP', application_name.underscore
25
- gsub_file f, '_PRODUCTION_NAME', "'#{application_name.underscore.humanize}'"
26
- gsub_file f, '_APP_DOMAIN', "#{application_name.underscore}.com.br"
27
- end
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
- def add_flash_types
30
- file_name = 'app/controllers/application_controller.rb'
31
- unless File.read(file_name) =~ /add_flash_types/
32
- inject_into_file file_name, after: 'protect_from_forgery with: :exception' do
33
- "\n add_flash_types :warning, :error, :info"
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
- def inject_default_date_formats
39
- file_name = 'config/application.rb'
40
- unless File.read(file_name) =~ /Date::DATE_FORMATS/
41
- inject_into_file file_name, after: "raise_in_transactional_callbacks = true" do
42
- "\n Date::DATE_FORMATS[:default] = '%d/%m/%Y'"
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
- end
45
- unless File.read(file_name) =~ /Time::DATE_FORMATS/
46
- inject_into_file file_name, after: "raise_in_transactional_callbacks = true" do
47
- "\n Time::DATE_FORMATS[:default] = '%d/%m/%Y %H:%M:%S'"
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
- end
51
-
52
- def rubocop_config
53
- file_name = '.rubocop.yml'
54
- copy_file file_name, file_name
55
- end
52
+
53
+ def rubocop_config
54
+ file_name = '.rubocop.yml'
55
+ copy_file file_name, file_name
56
+ end
56
57
 
57
- def gem_font_awesome_rails
58
- append_file 'Gemfile', "\ngem 'font-awesome-rails'" unless File.read('Gemfile') =~ /font-awesome-rails/
59
- end
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
- def gem_better_errors
62
- unless File.read('Gemfile') =~ /better_errors/
63
- inject_into_file 'Gemfile', after: "group :development, :test do" do
64
- "\n gem 'better_errors'\n"
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
- def gem_ruby_version
70
- unless File.read('Gemfile') =~ /ruby /
71
- inject_into_file 'Gemfile', after: "source 'https://rubygems.org'\n" do
72
- "\nruby '2.2.2'"
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
- def include_gems_directory
78
- string_to_append = "\nDir.glob('gemfiles/**/*.rb') { |f| eval_gemfile f }\n"
79
- regex = /Dir.glob\('gemfiles\/\*\*\/\*.rb'\)/
80
- directory 'gemfiles/', 'gemfiles/'
81
- append_file 'Gemfile', string_to_append unless File.read('Gemfile') =~ regex
82
- Bundler.with_clean_env {run "bundle install --without production"}
83
- end
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
- def overcommit_install
86
- # run 'overcommit --install'
87
- file_name = '.overcommit.yml'
88
- remove_file file_name
89
- copy_file file_name, file_name
90
- end
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
- def rspec_install
93
- run 'rails generate rspec:install'
94
- end
93
+ def rspec_install
94
+ run 'rails generate rspec:install'
95
+ end
95
96
 
96
- def devise_install
97
- run 'rails generate devise:install'
97
+ def devise_install
98
+ run 'rails generate devise:install'
98
99
 
99
- #password length
100
- old_config = 'config.password_length = 8..72'
101
- new_config = 'config.password_length = Rails.env.production? ? 8..72 : 1..8'
102
- gsub_file 'config/initializers/devise.rb', old_config, new_config
103
- end
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
- def kaminari_views
106
- run 'rails g kaminari:views bootstrap3'
107
- end
106
+ def kaminari_views
107
+ run 'rails g kaminari:views bootstrap3'
108
+ end
108
109
 
109
- def simple_form_install
110
- run 'rails generate simple_form:install --bootstrap'
111
- end
110
+ def simple_form_install
111
+ run 'rails generate simple_form:install --bootstrap'
112
+ end
112
113
 
113
- def rspec_always_test_env
114
- gsub_file 'spec/rails_helper.rb', "ENV['RAILS_ENV'] ||= 'test'", "ENV['RAILS_ENV'] = 'test'"
115
- end
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
- def i18n_pt_br
118
- file_name = 'config/application.rb'
119
- gsub_file file_name, '# config.i18n.default_locale = :de', "config.i18n.default_locale = :'pt-BR'"
120
- end
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
- def ransak_simple_form
123
- file_name = 'config/application.rb'
124
- unless File.read(file_name) =~ /RANSACK_FORM_BUILDER/
125
- inject_into_file file_name, before: "require 'rails/all'" do
126
- "ENV['RANSACK_FORM_BUILDER'] = '::SimpleForm::FormBuilder'\n"
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
- def configure_database
132
- file_name = 'config/database.yml'
133
- remove_file file_name
134
- copy_file file_name.split('/').last, file_name
135
- gsub_file file_name, 'database_name', application_name.underscore
136
- gsub_file file_name, 'database_name_test', "#{application_name.underscore}_test"
137
- end
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
- def application_js
140
- file_name = 'app/assets/javascripts/application.js'
141
- remove_file file_name
142
- copy_file file_name.split('/').last, file_name
143
- end
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
- def application_css
146
- rm_file_name = 'app/assets/stylesheets/application.css'
147
- file_name = 'app/assets/stylesheets/application.css.scss'
148
- remove_file rm_file_name
149
- copy_file file_name.split('/').last, file_name
150
- end
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
- protected
153
+ protected
153
154
 
154
- def application_name
155
- Rails.application.class.parent_name
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.0
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-09 00:00:00.000000000 Z
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
@@ -1,3 +0,0 @@
1
- module DflRailsConfig
2
- VERSION = "0.1.0"
3
- end