mecha 0.6.0 → 0.6.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: a28edddf93f1eb5889441168fb10bd60f01d4c89
4
- data.tar.gz: cd183b5d98831ad2bd74be3534c76ca193048906
3
+ metadata.gz: f4bfaaf4d0c582b9c4cd4745fe762809bc8ba211
4
+ data.tar.gz: e4422a8542e9f4203479df2d5998b580ee102f85
5
5
  SHA512:
6
- metadata.gz: a35fe88529a1af5a62c2f77dcfaa9f3eee85c3a0ced077a150ccfb41caed5460e4907591107af1cf503ff2cc5891fb105b2cddb64c3521072cf662ff10e3f13c
7
- data.tar.gz: f82b4745b7367d2c4ddccc36a57012127dcf5b700188c59ff9c7fac3a8d81f5cccbb3120e6d283a04737287370dccb02fa47565fd3e0dfbd13c0369c229c0ddc
6
+ metadata.gz: 9ee898f6a81fd948fcd5923d853d5f33468cc1b3915450b2afafd8d7e1cc68fa723680fb8b775f03634f165fe6e9171f00a603a3baf7ec08aed7b8e4b09a043e
7
+ data.tar.gz: '072928907be9afdd4d0199cafd24a22c08c7a71dabaca0e336f9d030cd1ef47fb1a8a2cfdd6ccf6bcb9b0e37aa311c908fbf3343335f92f8bcbbd5836c2fbd96'
data/README.md CHANGED
@@ -19,10 +19,25 @@ gem install mecha
19
19
  ## Usage
20
20
 
21
21
  ```bash
22
- mecha <projectname>
22
+ mecha <projectname> --devise --bitbucket-pipelines --sentry
23
23
  ```
24
24
 
25
- This will create a Rails app with name `<projectname>` and add all our defaults.
25
+ This will create a Rails app with name `<projectname>` and add all our defaults. It configures the app to use sass, remove turbolinks and coffescript, configure Guard, Rubocop and Simplecov. Also, installs Factory Girl, Faker, Timecop, Capibara, Poltergeist, Database Rewinder.
26
+
27
+ ### Available Generators
28
+
29
+ **Devise**
30
+
31
+ `--devise` installs Devise, generates `User`, i18n files and the internatinalized views for english and brazillian portuguese.
32
+
33
+ **Bitbucket Pipelines**
34
+
35
+ `--bitbucket-pipelines` generates the `bitbucket-pipelines.yml` and a special database config for it.
36
+
37
+ **Sentry**
38
+
39
+ `--sentry` installs sentry and adds configs to `application.rb` and `application_controller.rb`. Remember to create an environment
40
+ variable with you dsn key. `ENV['DNS']`.
26
41
 
27
42
  ## Development
28
43
 
@@ -19,8 +19,8 @@ module Mecha
19
19
  end
20
20
 
21
21
  def config_application
22
- inject_into_class('config/application.rb', 'Application') { config_autoload_paths }
23
- inject_into_class('config/application.rb', 'Application') { config_generators }
22
+ application(config_autoload_paths)
23
+ application(config_generators)
24
24
  create_file('app/services/.keep')
25
25
  create_file('app/uploaders/.keep')
26
26
  end
@@ -32,20 +32,18 @@ module Mecha
32
32
  private
33
33
 
34
34
  def config_autoload_paths
35
- <<-DOC
36
- config.autoload_paths += %W(\#{config.root}/lib \#{config.root}/app/uploaders \#{config.root}/services)
37
- DOC
35
+ "config.autoload_paths += %W(\#{config.root}/lib \#{config.root}/app/uploaders \#{config.root}/services)"
38
36
  end
39
37
 
40
38
  def config_generators
41
39
  <<-DOC
42
- config.generators do |g|
43
- g.view_specs false
44
- g.routing_specs false
45
- g.stylesheets false
46
- g.javascripts false
47
- g.helper false
48
- end
40
+ config.generators do |g|
41
+ g.view_specs false
42
+ g.routing_specs false
43
+ g.stylesheets false
44
+ g.javascripts false
45
+ g.helper false
46
+ end
49
47
  DOC
50
48
  end
51
49
  end
@@ -11,15 +11,13 @@ module Mecha
11
11
  end
12
12
 
13
13
  def config_application
14
- inject_into_class('config/application.rb', 'Application') { config_assets_precompile }
14
+ application(config_assets_precompile)
15
15
  end
16
16
 
17
17
  private
18
18
 
19
19
  def config_assets_precompile
20
- <<-DOC
21
- config.assets.initialize_on_precompile = false
22
- DOC
20
+ 'config.assets.initialize_on_precompile = false'
23
21
  end
24
22
  end
25
23
  end
@@ -15,7 +15,7 @@ module Mecha
15
15
 
16
16
  stop_spring
17
17
 
18
- generate('devise:install', verbose: false)
18
+ generate('devise:install')
19
19
  end
20
20
 
21
21
  def generate_devise_user
@@ -27,8 +27,8 @@ module Mecha
27
27
  generate('devise:i18n:locale pt-BR')
28
28
 
29
29
  empty_directory('config/locales/devise')
30
- # move_file('config/locales/devise.views.en.yml', 'config/locales/devise/views.en.yml')
31
- # move_file('config/locales/devise.views.pt-BR.yml', 'config/locales/devise/views.pt-BR.yml')
30
+ move_file('config/locales/devise.views.en.yml', 'config/locales/devise/views.en.yml')
31
+ move_file('config/locales/devise.views.pt-BR.yml', 'config/locales/devise/views.pt-BR.yml')
32
32
  remove_file('config/locales/devise.en.yml')
33
33
  end
34
34
 
@@ -0,0 +1,58 @@
1
+ require 'rails/generators'
2
+
3
+ module Mecha
4
+ module Generators
5
+ class SentryGenerator < Rails::Generators::Base
6
+ def add_gem
7
+ gem 'sentry-raven'
8
+ end
9
+
10
+ def config_application_rb
11
+ application(config_sentry)
12
+ application('config.filter_parameters << :password')
13
+ environment('config.action_dispatch.show_exceptions = false', env: 'production')
14
+ end
15
+
16
+ def config_application_controller
17
+ inject_into_file(
18
+ 'app/controllers/application_controller.rb',
19
+ application_controller_set_raven_context,
20
+ before: "end"
21
+ )
22
+
23
+ inject_into_file(
24
+ 'app/controllers/application_controller.rb',
25
+ application_controller_before_action,
26
+ after: 'class ApplicationController < ActionController::Base'
27
+ )
28
+ end
29
+
30
+ private
31
+
32
+ def config_sentry
33
+ <<-DOC
34
+ Raven.configure do |config|
35
+ config.dsn = ENV['DNS'] || ''
36
+ config.sanitize_fields = Rails.application.config.filter_parameters.map(&:to_s)
37
+ config.environments = ['staging', 'production']
38
+ end
39
+ DOC
40
+ end
41
+
42
+ def application_controller_before_action
43
+ "\n before_action :set_raven_context"
44
+ end
45
+
46
+ def application_controller_set_raven_context
47
+ <<-DOC
48
+ \n private
49
+
50
+ def set_raven_context
51
+ Raven.user_context(id: session[:current_user_id])
52
+ Raven.extra_context(params: params.to_unsafe_h, url: request.url)
53
+ end
54
+ DOC
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,47 @@
1
+ Rails:
2
+ Enabled: true
3
+
4
+ AllCops:
5
+ Exclude:
6
+ - 'db/schema.rb'
7
+ - 'bin/**'
8
+ - 'vendor/**/*'
9
+ - 'tmp/**/*'
10
+ - 'Guardfile'
11
+ - 'config/**/*'
12
+ - 'lib/tasks/*.rake'
13
+
14
+ Documentation:
15
+ Enabled: false
16
+
17
+ Metrics/AbcSize:
18
+ Exclude:
19
+ - 'db/**/*'
20
+
21
+ Metrics/BlockLength:
22
+ Exclude:
23
+ - 'Rakefile'
24
+ - '**/*.rake'
25
+ - 'test/**/*'
26
+
27
+ Metrics/ClassLength:
28
+ Exclude:
29
+ - 'test/**/*'
30
+
31
+ Metrics/BlockLength:
32
+ Exclude:
33
+ - 'db/migrate/**'
34
+ - 'test/**/*'
35
+
36
+ Metrics/LineLength:
37
+ Max: 120
38
+
39
+ Metrics/MethodLength:
40
+ Exclude:
41
+ - 'db/migrate/**'
42
+ - 'test/**/*'
43
+
44
+ Style/ClassAndModuleChildren:
45
+ EnforcedStyle: nested
46
+ Exclude:
47
+ - 'test/test_helper.rb'
@@ -5,6 +5,12 @@ module Mecha
5
5
  class SimplecovGenerator < Rails::Generators::Base
6
6
  source_root File.join(File.dirname(__FILE__), 'templates')
7
7
 
8
+ def add_gem
9
+ gem_group :test do
10
+ gem 'simplecov', require: false
11
+ end
12
+ end
13
+
8
14
  def copy_simplecov
9
15
  copy_file('simplecov', '.simplecov')
10
16
  end
data/lib/mecha/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Mecha
2
- VERSION = '0.6.0'.freeze
2
+ VERSION = '0.6.1'.freeze
3
3
  RUBY_VERSION = '>= 2.4'.freeze
4
4
  RAILS_VERSION = '~> 5.0.0'.freeze
5
5
  end
data/lib/mecha.rb CHANGED
@@ -10,12 +10,14 @@ require 'mecha/generators/i18n/i18n_generator'
10
10
  require 'mecha/generators/tests/tests_generator'
11
11
  require 'mecha/generators/bitbucket_pipelines/bitbucket_pipelines_generator'
12
12
  require 'mecha/generators/devise/devise_generator'
13
+ require 'mecha/generators/sentry/sentry_generator'
13
14
 
14
15
  module Mecha
15
16
  def self.opts
16
17
  Slop.parse do |o|
17
- o.bool '--devise', 'install and config Devise'
18
18
  o.bool '--bitbucket-pipelines', 'config Bitbucket Pipelines'
19
+ o.bool '--devise', 'install and config Devise'
20
+ o.bool '--sentry', 'install and config Sentry'
19
21
  o.on '--version', 'print the gem version' do
20
22
  puts Mecha::VERSION
21
23
  exit
@@ -37,5 +39,6 @@ module Mecha
37
39
  Mecha::Generators::TestsGenerator.start
38
40
  Mecha::Generators::BitbucketPipelinesGenerator.start if Mecha.opts.bitbucket_pipelines?
39
41
  Mecha::Generators::DeviseGenerator.start if Mecha.opts.devise?
42
+ Mecha::Generators::SentryGenerator.start if Mecha.opts.sentry?
40
43
  end
41
44
  end
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.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Magrathea Labs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-05 00:00:00.000000000 Z
11
+ date: 2017-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -178,6 +178,8 @@ files:
178
178
  - lib/mecha/generators/i18n/templates/config/locales/pt-BR.yml
179
179
  - lib/mecha/generators/rubocop/rubocop_generator.rb
180
180
  - lib/mecha/generators/rubocop/templates/rubocop.yml
181
+ - lib/mecha/generators/sentry/sentry_generator.rb
182
+ - lib/mecha/generators/sentry/templates/rubocop.yml
181
183
  - lib/mecha/generators/simplecov/simplecov_generator.rb
182
184
  - lib/mecha/generators/simplecov/templates/simplecov
183
185
  - lib/mecha/generators/tests/templates/test/factories/.keep