generapp 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +7 -0
  2. data/.coveralls.yml +1 -0
  3. data/.gitignore +18 -0
  4. data/.rspec +2 -0
  5. data/.ruby-version +1 -0
  6. data/.travis.yml +13 -0
  7. data/.yardopts +9 -0
  8. data/CHANGELOG.md +3 -0
  9. data/CODE_OF_CONDUCT.md +13 -0
  10. data/Gemfile +4 -0
  11. data/MIT-LICENSE +21 -0
  12. data/README.md +76 -0
  13. data/Rakefile +13 -0
  14. data/bin/generapp +14 -0
  15. data/bin/setup +7 -0
  16. data/generapp.gemspec +33 -0
  17. data/lib/generapp/actions/configuration.rb +34 -0
  18. data/lib/generapp/actions/database.rb +15 -0
  19. data/lib/generapp/actions/develop.rb +72 -0
  20. data/lib/generapp/actions/files.rb +14 -0
  21. data/lib/generapp/actions/production.rb +17 -0
  22. data/lib/generapp/actions/test.rb +44 -0
  23. data/lib/generapp/actions/views.rb +30 -0
  24. data/lib/generapp/app_builder.rb +54 -0
  25. data/lib/generapp/generators/app_generator.rb +137 -0
  26. data/lib/generapp/version.rb +5 -0
  27. data/lib/generapp.rb +12 -0
  28. data/templates/Gemfile.erb +49 -0
  29. data/templates/Procfile +1 -0
  30. data/templates/Procfile.dev +4 -0
  31. data/templates/README.md.erb +20 -0
  32. data/templates/application.scss +1 -0
  33. data/templates/circle.yml +7 -0
  34. data/templates/config/application.yml +17 -0
  35. data/templates/config/newrelic.yml.erb +30 -0
  36. data/templates/config/postgresql_database.yml.erb +20 -0
  37. data/templates/config/puma.rb +15 -0
  38. data/templates/generapp_gitignore +44 -0
  39. data/templates/public/humans.txt +2 -0
  40. data/templates/public/manifest.json +41 -0
  41. data/templates/simplecov +4 -0
  42. data/templates/spec/database_cleaner.rb +16 -0
  43. data/templates/spec/devise.rb +3 -0
  44. data/templates/spec/rails_helper.rb +55 -0
  45. data/templates/spec/shoulda_matchers_config.rb +6 -0
  46. data/templates/tasks/auto_annotate_models.rake +37 -0
  47. data/templates/tasks/bundler_audit.rake +12 -0
  48. data/templates/views/_flashes.html.erb +5 -0
  49. data/templates/views/_head.html.erb.erb +30 -0
  50. data/templates/views/_javascript.html.erb +3 -0
  51. data/templates/views/generapp_layout.html.erb.erb +14 -0
  52. metadata +186 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 60726e7855b19ef6434a1969d596d50a802a0714
4
+ data.tar.gz: 771789cc7e3b3c426a5ddf618532320f7a337df5
5
+ SHA512:
6
+ metadata.gz: 8d1c68876bffe4e79761ee9f3d695723f453b3cc86f5f72600adbf3b6aa6804c1464d1b34185dbf87a375a996247737aa0b629c1853e469d4ec0640ebae9a092
7
+ data.tar.gz: 3b7a107d9920b1780a2e8ba6a1a8aad0193331be9c1ec2448dfaeb44f595589e53f30b94f8c578638631b3be220c045c7f86b554b50abb843964fe897452e7a6
data/.coveralls.yml ADDED
@@ -0,0 +1 @@
1
+ service_name: travis-ci
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ /.bundle/
2
+ /.yardoc/
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ spec/fake_app/log/
11
+ spec/tmp/
12
+ gemfiles/*.lock
13
+
14
+ # Idea
15
+ .idea
16
+ .idea/**/*
17
+
18
+ .ruby-gemset
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.3.0
data/.travis.yml ADDED
@@ -0,0 +1,13 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.3.0
4
+ - ruby-head
5
+
6
+ sudo: false
7
+ script: 'bundle exec rake'
8
+ cache: bundler
9
+
10
+ matrix:
11
+ allow_failures:
12
+ - rvm: ruby-head
13
+ fast_finish: true
data/.yardopts ADDED
@@ -0,0 +1,9 @@
1
+ --protected
2
+ --no-private
3
+ --embed-mixin ClassMethods
4
+ --markup markdown
5
+ -
6
+ README.md
7
+ CHANGELOG.md
8
+ CODE_OF_CONDUCT.md
9
+ MIT-LICENSE
data/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ ### master
2
+
3
+ Initial release
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in generapp.gemspec
4
+ gemspec
data/MIT-LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Koombea
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,76 @@
1
+ # Generapp
2
+ [![Build Status](https://travis-ci.org/koombea/generapp.svg)](https://travis-ci.org/koombea/generapp)
3
+ [![Coverage Status](https://coveralls.io/repos/koombea/generapp/badge.svg?branch=master&service=github)](https://coveralls.io/github/koombea/generapp?branch=master)
4
+
5
+ A Rails app template to jump start your project with some of Koombea's best practices and recommendations.
6
+
7
+ ## Installation
8
+
9
+ Install it yourself as:
10
+
11
+ $ gem install generapp
12
+
13
+ ## Usage
14
+
15
+ Just run:
16
+
17
+ generapp my_project
18
+
19
+ This will create a Rails app in `my_project` using the latest version of Ruby and Rails.
20
+
21
+ ## Gemfile
22
+
23
+ To see the latest gems, look at Generapp's
24
+ [Gemfile](templates/Gemfile.erb), which will be used as the project's Gemfile.
25
+
26
+ Application gems included:
27
+ * [Devise](https://github.com/plataformatec/devise) for user authentication
28
+ * [Dalli](https://github.com/petergoldstein/dalli) for memcached client
29
+ * [Honeybadger](https://github.com/honeybadger-io/honeybadger-ruby) for reporting
30
+ errors to honeybadger.io
31
+ * [jQuery Rails](https://github.com/rails/jquery-rails) for jQuery
32
+ * [New Relic RPM](https://github.com/newrelic/rpm) for monitoring performance
33
+ * [Postgres](https://github.com/ged/ruby-pg) for access to the Postgres database
34
+ * [Rack Timeout](https://github.com/heroku/rack-timeout) to abort requests that are
35
+ taking too long
36
+ * [Puma](https://github.com/puma/puma) to serve HTTP requests
37
+
38
+ Development gems:
39
+ * [Annotate](https://github.com/ctran/annotate_models) for annotating Rails classes
40
+ with schema and routes info
41
+ * [Better errors](https://github.com/charliesome/better_errors) for better error page
42
+ for Rack apps
43
+ * [Bullet](https://github.com/flyerhzm/bullet) for help killing N+1 queries and
44
+ unused eager loading
45
+ * [Bundler Audit](https://github.com/rubysec/bundler-audit) for scanning the
46
+ Gemfile for insecure dependencies based on published CVEs
47
+ * [Figaro](https://github.com/laserlemon/figaro) for Heroku-friendly Rails app
48
+ configuration using `ENV`
49
+ * [lol_dba](https://github.com/plentz/lol_dba) for scanning missing indexes
50
+ * [Pry Rails](https://github.com/rweng/pry-rails) for interactively exploring
51
+ objects
52
+ * [Quiet Assets](https://github.com/evrone/quiet_assets) for muting assets
53
+ pipeline log messages
54
+ * [rails-erd](https://github.com/voormedia/rails-erd) for generating Entity-Relationship Diagrams
55
+ * [Spring](https://github.com/rails/spring) for fast Rails actions via
56
+ pre-loading
57
+
58
+ Testing gems:
59
+
60
+ * [Factory Girl](https://github.com/thoughtbot/factory_girl) for test data
61
+ * [RSpec](https://github.com/rspec/rspec) for unit testing
62
+ * [Shoulda Matchers](https://github.com/thoughtbot/shoulda-matchers) for common
63
+ RSpec matchers
64
+ * [Timecop](https://github.com/ferndopolis/timecop-console) for testing time
65
+
66
+ ## Contributing
67
+
68
+ 1. Fork it ( https://github.com/koombea/generapp/fork )
69
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
70
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
71
+ 4. Push to the branch (`git push origin my-new-feature`)
72
+ 5. Create a new Pull Request
73
+
74
+ ## License
75
+
76
+ MIT License. Copyright 2016 Koombea. https://koombea.com/
data/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ require 'bundler/setup'
2
+ require 'bundler/gem_tasks'
3
+ require 'rspec/core/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new(:rspec)
6
+
7
+ desc 'Run the test suite'
8
+ task default: :rspec
9
+
10
+ desc 'generate rdoc'
11
+ task :rdoc do
12
+ sh 'yardoc'
13
+ end
data/bin/generapp ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ require 'bundler/setup'
3
+ require 'generapp'
4
+
5
+ if %w(-v --version).include? ARGV[0]
6
+ puts Generapp::VERSION
7
+ exit 0
8
+ end
9
+
10
+ templates_root = Generapp.templates
11
+ Generapp::Generators::AppGenerator.source_root templates_root
12
+ Generapp::Generators::AppGenerator.source_paths << Rails::Generators::AppGenerator.source_root << templates_root
13
+
14
+ Generapp::Generators::AppGenerator.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
data/generapp.gemspec ADDED
@@ -0,0 +1,33 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'generapp/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'generapp'
8
+ spec.version = Generapp::VERSION
9
+ spec.authors = ['Gustavo Bazan']
10
+ spec.email = ['gustavo.bazan@koombea.com']
11
+
12
+ spec.summary = 'Koombea Rails app generator'
13
+ spec.description = <<-HERE
14
+ Generapp is a Rails app generator with some of Koombea's defaults and practices.
15
+ Feel free to use it to jump start your project and don't waste any time configuring basic things.
16
+ HERE
17
+
18
+ spec.homepage = 'https://github.com/koombea/generapp'
19
+ spec.license = 'MIT'
20
+
21
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
22
+
23
+ spec.executables = ['generapp']
24
+ spec.require_paths = ['lib']
25
+
26
+ spec.required_ruby_version = ">= #{Generapp::RUBY_VERSION}"
27
+
28
+ spec.add_dependency 'bundler', '~> 1.3'
29
+ spec.add_dependency 'rails', Generapp::RAILS_VERSION
30
+ spec.add_development_dependency 'rspec', '~> 3.4', '>= 3.4.0'
31
+ spec.add_development_dependency 'coveralls', '~>0.8.0', '>= 0.8.0'
32
+ spec.add_development_dependency 'yard', '~> 0.8.7', '>= 0.8.0'
33
+ end
@@ -0,0 +1,34 @@
1
+ module Generapp
2
+ module Actions
3
+ module Configuration
4
+ def setup_default_rake_task
5
+ 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
17
+ end
18
+ end
19
+
20
+ def configure_puma
21
+ copy_file 'config/puma.rb', 'config/puma.rb'
22
+ end
23
+
24
+ def set_up_foreman
25
+ copy_file 'Procfile', 'Procfile'
26
+ copy_file 'Procfile.dev', 'Procfile.dev'
27
+ end
28
+
29
+ def generate_devise
30
+ generate 'devise:install'
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,15 @@
1
+ module Generapp
2
+ module Actions
3
+ module Database
4
+ def use_postgres_config_template
5
+ template 'config/postgresql_database.yml.erb',
6
+ 'config/database.yml',
7
+ force: true
8
+ end
9
+
10
+ def create_database
11
+ bundle_command 'exec rake db:create db:migrate'
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,72 @@
1
+ require 'generapp/actions/files'
2
+
3
+ module Generapp
4
+ module Actions
5
+ module Develop
6
+ include Files
7
+
8
+ def raise_on_delivery_errors
9
+ replace_in_file 'config/environments/development.rb',
10
+ 'raise_delivery_errors = false', 'raise_delivery_errors = true'
11
+ end
12
+
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")
26
+ end
27
+
28
+ def configure_dalli
29
+ config = <<-RUBY
30
+
31
+ config.cache_store = :dalli_store, '127.0.0.1'
32
+
33
+ RUBY
34
+
35
+ inject_into_file(
36
+ 'config/environments/development.rb',
37
+ config,
38
+ after: "config.action_mailer.raise_delivery_errors = true\n")
39
+ end
40
+
41
+ def configure_generators
42
+ config = <<-RUBY
43
+
44
+ config.generators do |g|
45
+ g.assets false
46
+ g.test_framework :rspec,
47
+ fixtures: true,
48
+ view_specs: false,
49
+ helper_specs: false,
50
+ routing_specs: false,
51
+ controller_specs: true,
52
+ request_specs: false
53
+ g.fixture_replacement :factory_girl, dir: 'spec/factories'
54
+ end
55
+
56
+ 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
+ end
65
+
66
+ def add_secrets
67
+ copy_file 'config/application.yml', 'config/application.yml.example'
68
+ copy_file 'config/application.yml', 'config/application.yml'
69
+ end
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,14 @@
1
+ module Generapp
2
+ module Actions
3
+ module Files
4
+ def replace_in_file(relative_path, find, replace)
5
+ path = File.join(destination_root, relative_path)
6
+ contents = IO.read(path)
7
+ unless contents.gsub!(find, replace)
8
+ raise "#{find.inspect} not found in #{relative_path}"
9
+ end
10
+ File.open(path, 'w') { |file| file.write(contents) }
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,17 @@
1
+ module Generapp
2
+ module Actions
3
+ module Production
4
+ def configure_newrelic
5
+ template 'config/newrelic.yml.erb', 'config/newrelic.yml'
6
+ end
7
+
8
+ def configure_rack_timeout
9
+ rack_timeout_config = <<-RUBY
10
+ Rack::Timeout.timeout = Integer(ENV['RACK_TIMEOUT'] || 10)
11
+ RUBY
12
+
13
+ append_file 'config/environments/production.rb', rack_timeout_config
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,44 @@
1
+ module Generapp
2
+ module Actions
3
+ module Test
4
+ def generate_rspec
5
+ generate 'rspec:install'
6
+ end
7
+
8
+ def configure_rspec
9
+ remove_file 'spec/rails_helper.rb'
10
+ copy_file 'spec/rails_helper.rb',
11
+ 'spec/rails_helper.rb'
12
+ end
13
+
14
+ def enable_database_cleaner
15
+ copy_file 'spec/database_cleaner.rb',
16
+ 'spec/support/database_cleaner.rb'
17
+ end
18
+
19
+ def enable_devise_tests
20
+ copy_file 'spec/devise.rb',
21
+ 'spec/support/devise.rb'
22
+ end
23
+
24
+ def provide_shoulda_matchers_config
25
+ copy_file 'spec/shoulda_matchers_config.rb',
26
+ 'spec/support/shoulda_matchers.rb'
27
+ end
28
+
29
+ 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
+ end
33
+ end
34
+
35
+ def configure_coverage
36
+ copy_file 'simplecov', '.simplecov'
37
+ end
38
+
39
+ def configure_ci
40
+ copy_file 'circle.yml', 'circle.yml'
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,30 @@
1
+ module Generapp
2
+ module Actions
3
+ module Views
4
+ def create_shared_directory
5
+ empty_directory_with_keep_file 'app/views/shared'
6
+ end
7
+
8
+ def create_shared_flashes
9
+ copy_file 'views/_flashes.html.erb',
10
+ 'app/views/shared/_flashes.html.erb'
11
+ end
12
+
13
+ def create_shared_javascripts
14
+ copy_file 'views/_javascript.html.erb',
15
+ 'app/views/shared/_javascript.html.erb'
16
+ end
17
+
18
+ def create_shared_head
19
+ template 'views/_head.html.erb.erb',
20
+ 'app/views/shared/_head.html.erb'
21
+ end
22
+
23
+ def create_application_layout
24
+ template 'views/generapp_layout.html.erb.erb',
25
+ 'app/views/layouts/application.html.erb',
26
+ force: true
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,54 @@
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
+
9
+ module Generapp
10
+ class AppBuilder < ::Rails::AppBuilder
11
+ include Generapp::Actions::Develop
12
+ include Generapp::Actions::Test
13
+ include Generapp::Actions::Production
14
+ include Generapp::Actions::Views
15
+ include Generapp::Actions::Configuration
16
+ include Generapp::Actions::Database
17
+
18
+ def readme
19
+ template 'README.md.erb', 'README.md'
20
+ end
21
+
22
+ def gitignore
23
+ template 'generapp_gitignore', '.gitignore'
24
+ end
25
+
26
+ def gemfile
27
+ template 'Gemfile.erb', 'Gemfile'
28
+ end
29
+
30
+ def set_ruby_version
31
+ create_file '.ruby-version', "#{Generapp::RUBY_VERSION}\n"
32
+ end
33
+
34
+ def setup_stylesheets
35
+ remove_file 'app/assets/stylesheets/application.css'
36
+ copy_file 'application.scss',
37
+ 'app/assets/stylesheets/application.scss'
38
+ end
39
+
40
+ def init_git
41
+ run 'git init'
42
+ end
43
+
44
+ def setup_bundler_audit
45
+ copy_file 'tasks/bundler_audit.rake',
46
+ 'lib/tasks/bundler_audit.rake'
47
+ append_file 'Rakefile', %{\ntask default: "bundler:audit"\n}
48
+ end
49
+
50
+ def setup_spring
51
+ bundle_command 'exec spring binstub --all'
52
+ end
53
+ end
54
+ end