generapp 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,47 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2016-01-15 16:49:41 -0500 using RuboCop version 0.35.1.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
10
+ # Configuration parameters: CountComments.
11
+ Metrics/ClassLength:
12
+ Max: 109
13
+
14
+ # Offense count: 8
15
+ # Configuration parameters: AllowURI, URISchemes.
16
+ Metrics/LineLength:
17
+ Max: 104
18
+
19
+ # Offense count: 2
20
+ # Configuration parameters: CountComments.
21
+ Metrics/MethodLength:
22
+ Max: 13
23
+
24
+ # Offense count: 1
25
+ Style/AccessorMethodName:
26
+ Exclude:
27
+ - 'lib/generapp/generators/app_generator.rb'
28
+
29
+ # Offense count: 1
30
+ # Cop supports --auto-correct.
31
+ # Configuration parameters: AllowForAlignment.
32
+ Style/ExtraSpacing:
33
+ Exclude:
34
+ - 'templates/config/puma.rb'
35
+
36
+ # Offense count: 2
37
+ # Cop supports --auto-correct.
38
+ Style/SingleSpaceBeforeFirstArg:
39
+ Exclude:
40
+ - 'templates/config/puma.rb'
41
+
42
+ # Offense count: 2
43
+ # Cop supports --auto-correct.
44
+ # Configuration parameters: MultiSpaceAllowedForOperators.
45
+ Style/SpaceAroundOperators:
46
+ Exclude:
47
+ - 'templates/config/puma.rb'
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
1
  ### master
2
2
 
3
+ ### 0.2.0 - 2016-01-13
4
+
5
+ * bug fixes
6
+ * fix configuration generation
7
+
8
+ ### 0.1.0 - 2016-01-13
9
+
3
10
  Initial release
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
1
  # Generapp
2
+ [![Gem Version](https://badge.fury.io/rb/generapp.svg)](https://badge.fury.io/rb/generapp)
2
3
  [![Build Status](https://travis-ci.org/koombea/generapp.svg)](https://travis-ci.org/koombea/generapp)
3
4
  [![Coverage Status](https://coveralls.io/repos/koombea/generapp/badge.svg?branch=master&service=github)](https://coveralls.io/github/koombea/generapp?branch=master)
4
5
 
@@ -63,6 +64,10 @@ Testing gems:
63
64
  RSpec matchers
64
65
  * [Timecop](https://github.com/ferndopolis/timecop-console) for testing time
65
66
 
67
+ ### Rails ERD
68
+
69
+ If you plan to use Rails ERD you may need to install Graphviz ([instructions](http://voormedia.github.io/rails-erd/install.html))
70
+
66
71
  ## Contributing
67
72
 
68
73
  1. Fork it ( https://github.com/koombea/generapp/fork )
data/bin/generapp CHANGED
@@ -9,6 +9,8 @@ end
9
9
 
10
10
  templates_root = Generapp.templates
11
11
  Generapp::Generators::AppGenerator.source_root templates_root
12
- Generapp::Generators::AppGenerator.source_paths << Rails::Generators::AppGenerator.source_root << templates_root
12
+ Generapp::Generators::AppGenerator.source_paths <<
13
+ Rails::Generators::AppGenerator.source_root <<
14
+ templates_root
13
15
 
14
16
  Generapp::Generators::AppGenerator.start
data/generapp.gemspec CHANGED
@@ -28,6 +28,7 @@ Feel free to use it to jump start your project and don't waste any time configur
28
28
  spec.add_dependency 'bundler', '~> 1.3'
29
29
  spec.add_dependency 'rails', Generapp::RAILS_VERSION
30
30
  spec.add_development_dependency 'rspec', '~> 3.4', '>= 3.4.0'
31
+ spec.add_development_dependency 'rubocop', '~> 0.35', '>= 0.35'
31
32
  spec.add_development_dependency 'coveralls', '~>0.8.0', '>= 0.8.0'
32
33
  spec.add_development_dependency 'yard', '~> 0.8.7', '>= 0.8.0'
33
34
  end
@@ -1,19 +1,10 @@
1
1
  module Generapp
2
- module Actions
2
+ module Actions #:nodoc
3
+ # App configuration associated actions
3
4
  module Configuration
4
5
  def setup_default_rake_task
5
6
  append_file 'Rakefile' do
6
- <<-EOS
7
- task(:default).clear
8
- task default: [:spec]
9
-
10
- if defined? RSpec
11
- task(:spec).clear
12
- RSpec::Core::RakeTask.new(:spec) do |t|
13
- t.verbose = false
14
- end
15
- end
16
- EOS
7
+ rspec_task
17
8
  end
18
9
  end
19
10
 
@@ -29,6 +20,22 @@ end
29
20
  def generate_devise
30
21
  generate 'devise:install'
31
22
  end
23
+
24
+ protected
25
+
26
+ def rspec_task
27
+ <<-RUBY
28
+ task(:default).clear
29
+ task default: [:spec]
30
+
31
+ if defined? RSpec
32
+ task(:spec).clear
33
+ RSpec::Core::RakeTask.new(:spec) do |t|
34
+ t.verbose = false
35
+ end
36
+ end
37
+ RUBY
38
+ end
32
39
  end
33
40
  end
34
41
  end
@@ -1,5 +1,6 @@
1
1
  module Generapp
2
- module Actions
2
+ module Actions #:nodoc
3
+ # App database associated actions
3
4
  module Database
4
5
  def use_postgres_config_template
5
6
  template 'config/postgresql_database.yml.erb',
@@ -1,28 +1,19 @@
1
- require 'generapp/actions/files'
2
1
 
3
2
  module Generapp
4
- module Actions
3
+ module Actions #:nodoc
4
+ # App develop environment
5
+ # associated actions
5
6
  module Develop
6
- include Files
7
-
8
7
  def raise_on_delivery_errors
9
- replace_in_file 'config/environments/development.rb',
10
- 'raise_delivery_errors = false', 'raise_delivery_errors = true'
8
+ gsub_file 'config/environments/development.rb',
9
+ 'raise_delivery_errors = false',
10
+ 'raise_delivery_errors = true'
11
11
  end
12
12
 
13
13
  def add_bullet_gem_configuration
14
- config = <<-RUBY
15
- config.after_initialize do
16
- Bullet.enable = true
17
- Bullet.bullet_logger = true
18
- Bullet.rails_logger = true
19
- end
20
- RUBY
21
-
22
- inject_into_file(
23
- 'config/environments/development.rb',
24
- config,
25
- after: "config.action_mailer.raise_delivery_errors = true\n")
14
+ inject_into_file 'config/environments/development.rb',
15
+ bullet_configuration,
16
+ after: "config.action_mailer.raise_delivery_errors = true\n"
26
17
  end
27
18
 
28
19
  def configure_dalli
@@ -32,14 +23,31 @@ module Generapp
32
23
 
33
24
  RUBY
34
25
 
35
- inject_into_file(
36
- 'config/environments/development.rb',
37
- config,
38
- after: "config.action_mailer.raise_delivery_errors = true\n")
26
+ inject_into_file 'config/environments/development.rb',
27
+ config,
28
+ after: "config.action_mailer.raise_delivery_errors = true\n"
39
29
  end
40
30
 
41
31
  def configure_generators
42
- config = <<-RUBY
32
+ inject_into_class 'config/application.rb',
33
+ 'Application',
34
+ generapp_generators
35
+ end
36
+
37
+ def generate_annotate
38
+ copy_file 'tasks/auto_annotate_models.rake',
39
+ 'lib/tasks/auto_annotate_models.rake'
40
+ end
41
+
42
+ def add_secrets
43
+ copy_file 'config/application.yml', 'config/application.yml.example'
44
+ copy_file 'config/application.yml', 'config/application.yml'
45
+ end
46
+
47
+ protected
48
+
49
+ def generapp_generators
50
+ <<-RUBY
43
51
 
44
52
  config.generators do |g|
45
53
  g.assets false
@@ -54,18 +62,16 @@ module Generapp
54
62
  end
55
63
 
56
64
  RUBY
57
-
58
- inject_into_class 'config/application.rb', 'Application', config
59
- end
60
-
61
- def generate_annotate
62
- copy_file 'tasks/auto_annotate_models.rake',
63
- 'lib/tasks/auto_annotate_models.rake'
64
65
  end
65
66
 
66
- def add_secrets
67
- copy_file 'config/application.yml', 'config/application.yml.example'
68
- copy_file 'config/application.yml', 'config/application.yml'
67
+ def bullet_configuration
68
+ <<-RUBY
69
+ config.after_initialize do
70
+ Bullet.enable = true
71
+ Bullet.bullet_logger = true
72
+ Bullet.rails_logger = true
73
+ end
74
+ RUBY
69
75
  end
70
76
  end
71
77
  end
@@ -1,5 +1,7 @@
1
1
  module Generapp
2
- module Actions
2
+ module Actions #:nodoc
3
+ # App production environment
4
+ # associated actions
3
5
  module Production
4
6
  def configure_newrelic
5
7
  template 'config/newrelic.yml.erb', 'config/newrelic.yml'
@@ -1,5 +1,7 @@
1
1
  module Generapp
2
- module Actions
2
+ module Actions #:nodoc
3
+ # App test environment
4
+ # associated actions
3
5
  module Test
4
6
  def generate_rspec
5
7
  generate 'rspec:install'
@@ -27,8 +29,12 @@ module Generapp
27
29
  end
28
30
 
29
31
  def spec_folders
30
- %w(spec/lib spec/controllers spec/helpers spec/support/matchers spec/support/mixins spec/support/shared_examples).each do |dir|
31
- empty_directory_with_keep_file "#{dir}"
32
+ %w(spec/lib spec/controllers
33
+ spec/helpers
34
+ spec/support/matchers
35
+ spec/support/mixins
36
+ spec/support/shared_examples).each do |dir|
37
+ empty_directory_with_keep_file dir
32
38
  end
33
39
  end
34
40
 
@@ -1,5 +1,7 @@
1
1
  module Generapp
2
- module Actions
2
+ module Actions #:nodoc
3
+ # App views configuration
4
+ # associated actions
3
5
  module Views
4
6
  def create_shared_directory
5
7
  empty_directory_with_keep_file 'app/views/shared'
@@ -1,12 +1,7 @@
1
1
  require 'rails/generators/rails/app/app_generator'
2
- require 'generapp/actions/develop'
3
- require 'generapp/actions/test'
4
- require 'generapp/actions/production'
5
- require 'generapp/actions/views'
6
- require 'generapp/actions/configuration'
7
- require 'generapp/actions/database'
8
2
 
9
3
  module Generapp
4
+ # Rails app builder customizations
10
5
  class AppBuilder < ::Rails::AppBuilder
11
6
  include Generapp::Actions::Develop
12
7
  include Generapp::Actions::Test
@@ -38,13 +33,13 @@ module Generapp
38
33
  end
39
34
 
40
35
  def init_git
41
- run 'git init'
36
+ git :init
42
37
  end
43
38
 
44
39
  def setup_bundler_audit
45
40
  copy_file 'tasks/bundler_audit.rake',
46
41
  'lib/tasks/bundler_audit.rake'
47
- append_file 'Rakefile', %{\ntask default: "bundler:audit"\n}
42
+ append_file 'Rakefile', "\ntask default: 'bundler:audit'\n"
48
43
  end
49
44
 
50
45
  def setup_spring
@@ -2,18 +2,30 @@ require 'rails/generators'
2
2
  require 'rails/generators/rails/app/app_generator'
3
3
 
4
4
  module Generapp
5
- module Generators
5
+ module Generators #:nodoc
6
+ # Rails App generator
6
7
  class AppGenerator < ::Rails::Generators::AppGenerator
7
- class_option :database, type: :string, aliases: '-d', default: 'postgresql',
8
- desc: "Configure for selected database (options: #{DATABASES.join("/")})"
9
-
10
- class_option :skip_test_unit, type: :boolean, aliases: '-T', default: true,
8
+ class_option :database,
9
+ type: :string,
10
+ aliases: '-d',
11
+ default: 'postgresql',
12
+ desc: "Configure for selected database (options: #{DATABASES.join('/')})"
13
+
14
+ class_option :skip_test_unit,
15
+ type: :boolean,
16
+ aliases: '-T',
17
+ default: true,
11
18
  desc: 'Skip Test::Unit files'
12
19
 
13
- class_option :skip_turbolinks, type: :boolean, default: true,
20
+ class_option :skip_turbolinks,
21
+ type: :boolean,
22
+ default: true,
14
23
  desc: 'Skip turbolinks gem'
15
24
 
16
- class_option :skip_bundle, type: :boolean, aliases: '-B', default: true,
25
+ class_option :skip_bundle,
26
+ type: :boolean,
27
+ aliases: '-B',
28
+ default: true,
17
29
  desc: "Don't run bundle install"
18
30
 
19
31
  def finish_template
@@ -43,46 +55,37 @@ module Generapp
43
55
 
44
56
  def setup_development_environment
45
57
  say 'Setting up the development environment'
46
- build :raise_on_delivery_errors
47
- build :add_bullet_gem_configuration
48
- build :configure_dalli
49
- build :configure_generators
50
- build :generate_annotate
51
- build :add_secrets
58
+ Generapp::Actions::Develop.instance_methods(false).each do |action|
59
+ build action.to_sym
60
+ end
52
61
  end
53
62
 
54
63
  def setup_test_environment
55
64
  say 'Setting up the test environment'
56
- build :generate_rspec
57
- build :configure_rspec
58
- build :enable_database_cleaner
59
- build :enable_devise_tests
60
- build :provide_shoulda_matchers_config
61
- build :spec_folders
62
- build :configure_coverage
63
- build :configure_ci
65
+ Generapp::Actions::Test.instance_methods(false).each do |action|
66
+ build action.to_sym
67
+ end
64
68
  end
65
69
 
66
70
  def setup_production_environment
67
71
  say 'Setting up the production environment'
68
- build :configure_newrelic
69
- build :configure_rack_timeout
72
+ Generapp::Actions::Production.instance_methods(false).each do |action|
73
+ build action.to_sym
74
+ end
70
75
  end
71
76
 
72
77
  def create_generapp_views
73
78
  say 'Creating views'
74
- build :create_shared_directory
75
- build :create_shared_flashes
76
- build :create_shared_javascripts
77
- build :create_application_layout
79
+ Generapp::Actions::Views.instance_methods(false).each do |action|
80
+ build action.to_sym
81
+ end
78
82
  end
79
83
 
80
84
  def configure_app
81
85
  say 'Configuring app'
82
- build :setup_default_rake_task
83
- build :configure_puma
84
- build :set_up_foreman
85
- build :generate_devise
86
+ Generapp::Actions::Configuration.instance_methods(false).each do |action|
87
+ build action.to_sym
88
+ end
86
89
  end
87
90
 
88
91
  def setup_stylesheets
@@ -1,5 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Rails app generator with some minor modification and customizations
4
+ # Allows to jump start a project
5
+ # with some of Koombea's standards and practices
1
6
  module Generapp
7
+ # Default Rails Version
2
8
  RAILS_VERSION = '~> 4.2.0'.freeze
9
+ # Default Ruby Version
3
10
  RUBY_VERSION = IO.read("#{File.dirname(__FILE__)}/../../.ruby-version").strip
4
- VERSION = '0.2.0'.freeze
11
+ # Gem Version
12
+ VERSION = '0.3.0'.freeze
5
13
  end
data/lib/generapp.rb CHANGED
@@ -1,12 +1,23 @@
1
+ # Rails app generator with some minor modification and customizations
2
+ # Allows to jump start a project
3
+ # with some of Koombea's standards and practices
1
4
  module Generapp
5
+ # Gem root folder
2
6
  def self.root
3
7
  File.dirname __dir__
4
8
  end
5
9
 
10
+ # Gem template folder
6
11
  def self.templates
7
12
  File.join root, 'templates'
8
13
  end
9
14
  end
10
15
  require 'generapp/version'
16
+ require 'generapp/actions/configuration'
17
+ require 'generapp/actions/database'
18
+ require 'generapp/actions/develop'
19
+ require 'generapp/actions/production'
20
+ require 'generapp/actions/test'
21
+ require 'generapp/actions/views'
11
22
  require 'generapp/app_builder'
12
23
  require 'generapp/generators/app_generator'
@@ -2,30 +2,30 @@ source 'https://rubygems.org'
2
2
 
3
3
  ruby '<%= Generapp::RUBY_VERSION %>'
4
4
 
5
- gem 'devise'
6
- gem 'dalli' # caching
7
- gem 'honeybadger', '~> 2.0'
8
- gem 'jquery-rails'
9
- gem 'newrelic_rpm'
10
- gem 'pg'
5
+ gem 'devise' # User authentication
6
+ gem 'dalli' # Caching
7
+ gem 'honeybadger', '~> 2.0' # Error reporting
8
+ gem 'jquery-rails' # jQuery
9
+ gem 'newrelic_rpm' # Performance reports
10
+ gem 'pg' # Postgres
11
11
  gem 'puma' # Use Puma as the app server
12
12
  gem 'rails', '<%= Generapp::RAILS_VERSION %>'
13
13
  gem 'sass-rails', '~>5.0'
14
14
  gem 'uglifier'
15
15
 
16
16
  group :development do
17
- gem 'annotate'
17
+ gem 'annotate' # Schema model annotation
18
18
  gem 'better_errors'
19
19
  gem 'binding_of_caller'
20
- gem 'bullet'
21
- gem 'lol_dba', require: false
20
+ gem 'bullet' # N+1 queries reporter
21
+ gem 'lol_dba', require: false # Missing index reporter
22
22
  gem 'quiet_assets'
23
- gem 'parallel_tests'
24
- gem 'rails-erd'
23
+ gem 'rails-erd' # ER Diagrams
25
24
  gem 'spring'
26
25
  end
27
26
 
28
27
  group :development, :test do
28
+ gem 'brakeman', require: false
29
29
  gem 'bundler-audit', require: false
30
30
  gem 'factory_girl_rails'
31
31
  gem 'figaro' # Secrets
@@ -40,7 +40,7 @@ group :test do
40
40
  gem 'faker'
41
41
  gem 'shoulda-matchers'
42
42
  gem 'simplecov', require: false
43
- gem 'timecop'
43
+ gem 'timecop' # Time manipulation
44
44
  end
45
45
 
46
46
  group :production do
@@ -16,5 +16,3 @@ production: &deploy
16
16
  url: <%%= ENV['DATABASE_URL'] %>
17
17
  pool: <%%= ENV['DB_POOL'] || ENV['MAX_THREADS'] || 3 %>
18
18
  reaping_frequency: <%%= ENV['REAPING_FREQUENCY'] || nil %>
19
-
20
- staging: *deploy
@@ -4,8 +4,8 @@ threads threads_count, threads_count
4
4
 
5
5
  preload_app!
6
6
 
7
- rackup DefaultRackup
8
- port ENV['PORT'] || 3000
7
+ rackup DefaultRackup
8
+ port ENV['PORT'] || 3000
9
9
  environment ENV['RACK_ENV'] || 'development'
10
10
 
11
11
  on_worker_boot do
@@ -15,6 +15,7 @@ public/uploads/*
15
15
  coverage/*
16
16
  ssl
17
17
  .bundle/*
18
+
18
19
  # Ignore Doc
19
20
  doc/*
20
21
 
@@ -34,11 +35,14 @@ backup*.dump
34
35
  .idea
35
36
  .idea/**/*
36
37
 
37
- #rbenv
38
+ # rbenv
38
39
  .rbenv-gemsets
39
40
 
40
41
  # Ignore application configuration
41
42
  /config/application.yml
42
43
 
43
- #Ignore Vagrant
44
+ # Ignore Vagrant
44
45
  .vagrant/
46
+
47
+ # ER Diagram
48
+ erd.pdf
@@ -1,7 +1,16 @@
1
- require 'simplecov'
2
-
3
1
  # This file is copied to spec/ when you run 'rails generate rspec:install'
4
2
  ENV['RAILS_ENV'] ||= 'test'
3
+
4
+ # Coverage
5
+ require 'simplecov'
6
+ # save to CircleCI's artifacts directory if we're on CircleCI
7
+ if ENV['CIRCLE_ARTIFACTS']
8
+ dir = File.join(ENV['CIRCLE_ARTIFACTS'], 'coverage')
9
+ SimpleCov.coverage_dir(dir)
10
+ end
11
+
12
+ SimpleCov.start 'rails'
13
+
5
14
  require File.expand_path('../../config/environment', __FILE__)
6
15
  # Prevent database truncation if the environment is production
7
16
  abort('The Rails environment is running in production mode!') if Rails.env.production?
@@ -5,32 +5,40 @@ if Rails.env.development?
5
5
  task :set_annotation_options do
6
6
  # You can override any of these by setting an environment variable of the
7
7
  # same name.
8
- Annotate.set_defaults({
9
- 'position_in_routes' => 'after',
10
- 'position_in_class' => 'before',
11
- 'position_in_test' => 'before',
12
- 'position_in_fixture' => 'before',
13
- 'position_in_factory' => 'before',
14
- 'position_in_serializer' => 'before',
15
- 'show_foreign_keys' => 'true',
16
- 'show_indexes' => 'true',
17
- 'simple_indexes' => 'false',
18
- 'model_dir' => 'app/models',
19
- 'include_version' => 'false',
20
- 'require' => '',
21
- 'exclude_tests' => 'true',
22
- 'exclude_fixtures' => 'true',
23
- 'exclude_factories' => 'false',
24
- 'exclude_serializers' => 'true',
25
- 'ignore_model_sub_dir' => 'false',
26
- 'skip_on_db_migrate' => 'false',
27
- 'format_bare' => 'true',
28
- 'format_rdoc' => 'false',
29
- 'format_markdown' => 'false',
30
- 'sort' => 'false',
31
- 'force' => 'false',
32
- 'trace' => 'false',
33
- })
8
+ Annotate.set_defaults('routes' => 'true',
9
+ 'position_in_routes' => 'after',
10
+ 'position_in_class' => 'before',
11
+ 'position_in_test' => 'before',
12
+ 'position_in_fixture' => 'before',
13
+ 'position_in_factory' => 'before',
14
+ 'position_in_serializer' => 'before',
15
+ 'show_foreign_keys' => 'true',
16
+ 'show_indexes' => 'true',
17
+ 'simple_indexes' => 'false',
18
+ 'model_dir' => 'app/models',
19
+ 'root_dir' => '',
20
+ 'include_version' => 'false',
21
+ 'require' => '',
22
+ 'exclude_tests' => 'true',
23
+ 'exclude_fixtures' => 'true',
24
+ 'exclude_factories' => 'false',
25
+ 'exclude_serializers' => 'true',
26
+ 'exclude_scaffolds' => 'true',
27
+ 'exclude_controllers' => 'true',
28
+ 'exclude_helpers' => 'true',
29
+ 'ignore_model_sub_dir' => 'false',
30
+ 'ignore_columns' => nil,
31
+ 'ignore_unknown_models' => 'false',
32
+ 'hide_limit_column_types' => 'integer,boolean',
33
+ 'skip_on_db_migrate' => 'false',
34
+ 'format_bare' => 'true',
35
+ 'format_rdoc' => 'false',
36
+ 'format_markdown' => 'false',
37
+ 'sort' => 'false',
38
+ 'force' => 'false',
39
+ 'trace' => 'false',
40
+ 'wrapper_open' => nil,
41
+ 'wrapper_close' => nil)
34
42
  end
35
43
 
36
44
  Annotate.load_tasks
@@ -1,8 +1,8 @@
1
1
  if Rails.env.development? || Rails.env.test?
2
- require "bundler/audit/cli"
2
+ require 'bundler/audit/cli'
3
3
 
4
4
  namespace :bundler do
5
- desc "Updates the ruby-advisory-db and runs audit"
5
+ desc 'Updates the ruby-advisory-db and runs audit'
6
6
  task :audit do
7
7
  %w(update check).each do |command|
8
8
  Bundler::Audit::CLI.start [command]