eac_rails_base0 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +5 -5
  2. data/Gemfile +5 -0
  3. data/README.rdoc +16 -0
  4. data/app/assets/javascripts/eac_rails_base0.js +6 -0
  5. data/app/assets/stylesheets/eac_rails_base0/bootstrap_import.scss +2 -0
  6. data/app/assets/stylesheets/eac_rails_base0.scss +15 -0
  7. data/app/controllers/eac_rails_base0/application_controller.rb +26 -0
  8. data/app/helpers/eac_rails_base0/layout_helper.rb +15 -0
  9. data/app/views/layouts/eac_rails_base0/_flash.html.erb +3 -0
  10. data/app/views/layouts/eac_rails_base0/_main_menu.html.erb +5 -0
  11. data/app/views/layouts/eac_rails_base0/_navbar_user.html.erb +10 -0
  12. data/app/views/layouts/eac_rails_base0/application.html.erb +35 -0
  13. data/config/initializers/backport_pg_10_support_to_rails_4.rb +59 -0
  14. data/config/initializers/backtrace_silencers.rb +10 -0
  15. data/config/initializers/cookies_serializer.rb +4 -0
  16. data/config/initializers/filter_parameter_logging.rb +5 -0
  17. data/config/initializers/mime_types.rb +5 -0
  18. data/config/initializers/session_store.rb +4 -0
  19. data/config/initializers/wrap_parameters.rb +15 -0
  20. data/config/locales/pt-BR.yml +9 -0
  21. data/config/routes.rb +5 -0
  22. data/exe/eac_rails_base0_app +19 -0
  23. data/lib/eac_rails_base0/app_base/application.rb +36 -0
  24. data/lib/eac_rails_base0/app_generator/builder.rb +61 -0
  25. data/lib/eac_rails_base0/app_generator/generator.rb +23 -0
  26. data/lib/eac_rails_base0/app_generator/templates/Gemfile +19 -0
  27. data/lib/eac_rails_base0/app_generator/templates/app/assets/javascripts/application.js +1 -0
  28. data/lib/eac_rails_base0/app_generator/templates/app/assets/stylesheets/application.scss +1 -0
  29. data/lib/eac_rails_base0/app_generator/templates/app/controllers/application_controller.rb +3 -0
  30. data/lib/eac_rails_base0/app_generator/templates/app/controllers/welcome_controller.rb +5 -0
  31. data/lib/eac_rails_base0/app_generator/templates/app/views/welcome/index.html.erb +1 -0
  32. data/lib/eac_rails_base0/app_generator/templates/bin/bundle +4 -0
  33. data/lib/eac_rails_base0/app_generator/templates/bin/bundle_all +10 -0
  34. data/lib/eac_rails_base0/app_generator/templates/bin/rails +5 -0
  35. data/lib/eac_rails_base0/app_generator/templates/bin/rake +5 -0
  36. data/lib/eac_rails_base0/app_generator/templates/bin/setup +30 -0
  37. data/lib/eac_rails_base0/app_generator/templates/config/application.rb +5 -0
  38. data/lib/eac_rails_base0/app_generator/templates/config/boot.rb +5 -0
  39. data/lib/eac_rails_base0/app_generator/templates/config/database.yml +19 -0
  40. data/lib/eac_rails_base0/app_generator/templates/config/environment.rb +7 -0
  41. data/lib/eac_rails_base0/app_generator/templates/config/environments/development.rb +45 -0
  42. data/lib/eac_rails_base0/app_generator/templates/config/environments/production.rb +82 -0
  43. data/lib/eac_rails_base0/app_generator/templates/config/environments/test.rb +44 -0
  44. data/lib/eac_rails_base0/app_generator/templates/config/routes.rb +5 -0
  45. data/lib/eac_rails_base0/app_generator/templates/config.ru +5 -0
  46. data/lib/eac_rails_base0/app_generator/templates/lib/local_plugins.rb +60 -0
  47. data/lib/eac_rails_base0/version.rb +1 -1
  48. data/lib/generators/eac_rails_base0/abilities/abilities_generator.rb +13 -0
  49. data/lib/generators/eac_rails_base0/abilities/templates/ability.rb +8 -0
  50. data/lib/generators/eac_rails_base0/abilities/templates/ability_mapping.rb +8 -0
  51. data/lib/generators/eac_rails_base0/rspec/rspec_generator.rb +13 -0
  52. data/lib/generators/eac_rails_base0/{install/rspec → rspec}/templates/bin_rspec.rb +0 -0
  53. data/lib/generators/eac_rails_base0/{install/rspec → rspec}/templates/rspec.rc +0 -0
  54. data/lib/generators/eac_rails_base0/{install/rspec → rspec}/templates/spec_rails_helper.rb +0 -0
  55. data/lib/generators/eac_rails_base0/rubocop/rubocop_generator.rb +16 -0
  56. data/lib/generators/eac_rails_base0/rubocop/templates/rubocop.rb +7 -0
  57. data/lib/generators/eac_rails_base0_generator.rb +11 -0
  58. metadata +61 -9
  59. data/lib/generators/eac_rails_base0/install/rspec/rspec_generator.rb +0 -14
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 7f76d15e3ad1188b9c239073102eac9f26a173bd
4
- data.tar.gz: 86c8cf5b4134e9881eb80a7dbf73bec4abf541c3
2
+ SHA256:
3
+ metadata.gz: ca8d9a8a689385fb318e9f7dd744f1e3ef2acc0a3819a6d229b371eed51fc29c
4
+ data.tar.gz: f724b0ed1729a83cf44a0b5e22be1f8bca8351ca241887c925da3a72a312dd79
5
5
  SHA512:
6
- metadata.gz: a433f6422d51d4620ca2b092ed0b0b5a7d7094a2fa12d63a6072fbe651627224ef25dda6e2b55d9c5c160bf402e437f4dc042ed3b8c0e2a27015c484423da56a
7
- data.tar.gz: f607cd7267e1fca4a1358f5c2edc8b1dfadc854512f559facd1835c9af283c7ffc955711bcf42ec016f9fe3c1855d48d3246244a92c73dc98971da60e30f3302
6
+ metadata.gz: 3c3b4a67e4e74921ada96361f75d4d68865c13dd50fd90085515193ab288282b3f1af2554ad21b78e023a8fb7327fe67edebbe1c5c24fe0da7919b474943f515
7
+ data.tar.gz: 27347d249df9056f4499f646e0a597e82bfb71897b0d6a5757de75794e16514558c0d3e7390c98387f406a5929a9215a8e422a65a8262f00583ecf08b10498bd
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gemspec
data/README.rdoc ADDED
@@ -0,0 +1,16 @@
1
+ = E.A.C. Rails base #0
2
+
3
+ A Rails base for multiple Rails projects developed by Esquilo Azul Company.
4
+
5
+ {<img src="https://badge.fury.io/rb/eac_rails_base0.svg" alt="Gem Version" />
6
+ }[https://badge.fury.io/rb/eac_rails_base0]
7
+ {<img src="https://travis-ci.org/esquilo-azul/eac_rails_base0.svg?branch=master" alt="Build Status"
8
+ />}[https://travis-ci.org/esquilo-azul/eac_rails_base0]
9
+ {<img src="https://api.codeclimate.com/v1/badges/268ee9c414fbad3a650e/maintainability"
10
+ />}[https://codeclimate.com/github/esquilo-azul/eac_rails_base0/maintainability]
11
+ {<img src="https://api.codeclimate.com/v1/badges/268ee9c414fbad3a650e/test_coverage"
12
+ />}[https://codeclimate.com/github/esquilo-azul/eac_rails_base0/test_coverage]
13
+ {<img src="https://beta.gemnasium.com/badges/github.com/esquilo-azul/can_can_dry.svg"
14
+ alt="Dependency Status" />}[https://beta.gemnasium.com/projects/github.com/esquilo-azul/can_can_dry]
15
+ {<img src="http://inch-ci.org/github/esquilo-azul/eac_rails_base0.svg?branch=master" alt="Inline docs" />
16
+ }[http://inch-ci.org/github/esquilo-azul/eac_rails_base0]
@@ -0,0 +1,6 @@
1
+ //= require jquery
2
+ //= require jquery_ujs
3
+ //= require turbolinks
4
+ //= require eac_users_support/application
5
+ //= require bootstrap-sprockets
6
+ //= require eac_rails_utils
@@ -0,0 +1,2 @@
1
+ @import "bootstrap-sprockets";
2
+ @import "bootstrap";
@@ -0,0 +1,15 @@
1
+ @import 'eac_users_support/application';
2
+ @import 'eac_rails_base0/bootstrap_import';
3
+ @import "eac_rails_utils";
4
+
5
+ .alert-notice {
6
+ @extend .alert-info;
7
+ }
8
+
9
+ .alert-error {
10
+ @extend .alert-danger;
11
+ }
12
+
13
+ .alert-alert {
14
+ @extend .alert-warning;
15
+ }
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacRailsBase0
4
+ class ApplicationController < ActionController::Base
5
+ include ::CanCanDry::ControllerAuthorization
6
+
7
+ layout 'eac_rails_base0/application'
8
+ helper ::EacRailsBase0::LayoutHelper
9
+
10
+ # Prevent CSRF attacks by raising an exception.
11
+ # For APIs, you may want to use :null_session instead.
12
+ protect_from_forgery with: :exception
13
+
14
+ before_action :authorize_by_ability_mapping
15
+
16
+ rescue_from CanCan::AccessDenied do |exception|
17
+ if current_user
18
+ flash[:error] = "Conteúdo indisponível: #{exception}"
19
+ redirect_to main_app.root_url
20
+ else
21
+ flash[:danger] = 'Por favor faça o login.'
22
+ redirect_to eac_users_support.new_user_session_path
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacRailsBase0
4
+ module LayoutHelper
5
+ APP_TITLE_METHOD = 'app_title'
6
+
7
+ def base0_app_title
8
+ if respond_to?(APP_TITLE_METHOD)
9
+ send(APP_TITLE_METHOD)
10
+ else
11
+ "Implement the helper method \"#{APP_TITLE_METHOD}\""
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,3 @@
1
+ <% flash.each do |name, message| %>
2
+ <%= content_tag :div, message, class: "alert alert-#{name}" %>
3
+ <% end %>
@@ -0,0 +1,5 @@
1
+ <%= bootstrap_dropdown_menu({
2
+ 'Administração' => {
3
+ ::EacUsersSupport::User.model_name.human(count: 2) => [eac_users_support.admin_users_path],
4
+ }
5
+ }, class: 'navbar-left') %>
@@ -0,0 +1,10 @@
1
+ <%
2
+ user_menu = {}
3
+ if current_user
4
+ user_menu[current_user.to_s] = [main_app.root_path]
5
+ user_menu['Sair'] = [eac_users_support.destroy_user_session_path, link_method: :delete]
6
+ else
7
+ user_menu['Entrar'] = [eac_users_support.new_user_session_path]
8
+ end
9
+ %>
10
+ <%= bootstrap_dropdown_menu(user_menu, class: 'navbar-right') %>
@@ -0,0 +1,35 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1">
7
+ <title><%= base0_app_title %></title>
8
+ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
9
+ <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
10
+ <%= csrf_meta_tags %>
11
+ </head>
12
+ <body>
13
+ <nav class="navbar navbar-inverse">
14
+ <div class="container">
15
+ <div class="navbar-header">
16
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
17
+ <span class="sr-only">Toggle navigation</span>
18
+ <span class="icon-bar"></span>
19
+ <span class="icon-bar"></span>
20
+ <span class="icon-bar"></span>
21
+ </button>
22
+ <a class="navbar-brand" href="<%= main_app.root_path %>"><%= base0_app_title %></a>
23
+ </div>
24
+ <div id="navbar" class="collapse navbar-collapse">
25
+ <%= render partial: '/layouts/eac_rails_base0/main_menu' %>
26
+ <%= render partial: '/layouts/eac_rails_base0/navbar_user' %>
27
+ </div>
28
+ </div>
29
+ </nav>
30
+ <div class="container" >
31
+ <%= render partial: '/layouts/eac_rails_base0/flash' %>
32
+ <%= yield %>
33
+ </div>
34
+ </body>
35
+ </html>
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+ require 'active_record/connection_adapters/postgresql/schema_statements'
3
+
4
+ #
5
+ # Monkey-patch the refused Rails 4.2 patch at https://github.com/rails/rails/pull/31330
6
+ #
7
+ # Updates sequence logic to support PostgreSQL 10.
8
+ #
9
+
10
+ module ActiveRecord
11
+ module ConnectionAdapters
12
+ module PostgreSQL
13
+ module SchemaStatements
14
+ # Resets the sequence of a table's primary key to the maximum value.
15
+ def reset_pk_sequence!(table, pk = nil, sequence = nil) #:nodoc:
16
+ unless pk && sequence
17
+ default_pk, default_sequence = pk_and_sequence_for(table)
18
+ pk ||= default_pk
19
+ sequence ||= default_sequence
20
+ end
21
+ reset_pk_sequence_log(sequence, table, pk)
22
+ return unless pk && sequence
23
+ reset_pk_sequence_select_value(sequence, table, pk)
24
+ end
25
+
26
+ private
27
+
28
+ def reset_pk_sequence_max_pk(table, pk)
29
+ select_value("SELECT MAX(#{quote_column_name pk}) FROM #{quote_table_name(table)}")
30
+ end
31
+
32
+ def reset_pk_sequence_minvalue(max_pk, quoted_sequence)
33
+ return nil unless max_pk.nil?
34
+ if postgresql_version >= 100_000
35
+ select_value('SELECT seqmin FROM pg_sequence WHERE seqrelid = ' \
36
+ "#{quote(quoted_sequence)}::regclass")
37
+ else
38
+ select_value("SELECT min_value FROM #{quoted_sequence}")
39
+ end
40
+ end
41
+
42
+ def reset_pk_sequence_log(sequence, table, pk)
43
+ if @logger && pk && !sequence
44
+ @logger.warn "#{table} has primary key #{pk} with no default sequence"
45
+ end
46
+ end
47
+
48
+ def reset_pk_sequence_select_value(sequence, table, pk)
49
+ quoted_sequence = quote_table_name(sequence)
50
+ max_pk = reset_pk_sequence_max_pk(table, pk)
51
+ minvalue = reset_pk_sequence_minvalue(max_pk, quoted_sequence)
52
+ select_value <<-end_sql, 'SCHEMA'
53
+ SELECT setval(#{quote(quoted_sequence)}, #{max_pk ? max_pk : minvalue}, #{max_pk ? true : false})
54
+ end_sql
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+ # Be sure to restart your server when you modify this file.
3
+
4
+ # You can add backtrace silencers for libraries that you're using but don't wish to see in your
5
+ # backtraces.
6
+ # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
7
+
8
+ # You can also remove all the silencers if you're trying to debug a problem that might stem from
9
+ # framework code.
10
+ Rails.backtrace_cleaner.remove_silencers! if ENV['RAILS_REMOVE_SILENCERS'].present?
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+ # Be sure to restart your server when you modify this file.
3
+
4
+ Rails.application.config.action_dispatch.cookies_serializer = :json
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+ # Be sure to restart your server when you modify this file.
3
+
4
+ # Configure sensitive parameters which will be filtered from the log file.
5
+ Rails.application.config.filter_parameters += [:password]
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+ # Be sure to restart your server when you modify this file.
3
+
4
+ # Add new mime types for use in respond_to blocks:
5
+ # Mime::Type.register "text/richtext", :rtf
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+ # Be sure to restart your server when you modify this file.
3
+
4
+ Rails.application.config.session_store :cookie_store, key: '_ehb-utils_session'
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+ # Be sure to restart your server when you modify this file.
3
+
4
+ # This file contains settings for ActionController::ParamsWrapper which
5
+ # is enabled by default.
6
+
7
+ # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
8
+ ActiveSupport.on_load(:action_controller) do
9
+ wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
10
+ end
11
+
12
+ # To enable root element in JSON for ActiveRecord objects.
13
+ # ActiveSupport.on_load(:active_record) do
14
+ # self.include_root_in_json = true
15
+ # end
@@ -0,0 +1,9 @@
1
+ pt-BR:
2
+ date:
3
+ formats:
4
+ default: '%d/%m/%Y'
5
+ short: '%d/%m/%y'
6
+ time:
7
+ formats:
8
+ default: "%d/%m/%Y %H:%M"
9
+ short: '%d/%m/%y %H:%M'
data/config/routes.rb ADDED
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ Rails.application.routes.draw do
4
+ mount ::EacUsersSupport::Engine => '/'
5
+ end
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env ruby
2
+ require 'pathname'
3
+
4
+ source_path = (Pathname.new(__FILE__).dirname + '../lib').expand_path
5
+ $LOAD_PATH << source_path
6
+
7
+ require 'eac_rails_base0/app_generator/generator'
8
+
9
+ if ARGV.empty?
10
+ puts "Please provide a path for the new application"
11
+ puts
12
+ puts "See --help for more info"
13
+ exit 1
14
+ elsif ['-v', '--version'].include? ARGV[0]
15
+ puts Suspenders::VERSION
16
+ exit 0
17
+ end
18
+
19
+ ::EacRailsBase0::AppGenerator::Generator.start
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+ require 'rails/all'
3
+
4
+ # Require the gems listed in Gemfile, including any gems
5
+ # you've limited to :test, :development, or :production.
6
+ Bundler.require(*Rails.groups)
7
+
8
+ module EacRailsBase0App
9
+ class Application < Rails::Application
10
+ # Settings in config/environments/* take precedence over those specified here.
11
+ # Application configuration should go into files in config/initializers
12
+ # -- all .rb files in that directory are automatically loaded.
13
+
14
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
15
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
16
+ # config.time_zone = 'Central Time (US & Canada)'
17
+
18
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
19
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
20
+ # config.i18n.default_locale = :de
21
+ config.i18n.default_locale = :'pt-BR'
22
+
23
+ # Do not swallow errors in after_commit/after_rollback callbacks.
24
+ config.active_record.raise_in_transactional_callbacks = true
25
+
26
+ # Autoload do código em /lib.
27
+ config.autoload_paths << Rails.root.join('lib')
28
+
29
+ config.after_initialize do
30
+ ActiveRecord::Base.logger = nil
31
+ end
32
+ end
33
+ end
34
+
35
+ local_configuration = ::File.join(APP_PATH, 'config', 'local_configuration.rb')
36
+ require local_configuration if File.exist?(local_configuration)
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+ module EacRailsBase0
3
+ module AppGenerator
4
+ class Builder < Rails::AppBuilder
5
+ def readme
6
+ # Do nothing
7
+ end
8
+
9
+ def app
10
+ directory 'app'
11
+ end
12
+
13
+ def config
14
+ inside 'config' do
15
+ template 'routes.rb'
16
+ template 'application.rb'
17
+ template 'environment.rb'
18
+ template 'secrets.yml'
19
+ directory 'environments'
20
+ end
21
+ end
22
+
23
+ def database_yml
24
+ template 'config/database.yml'
25
+ end
26
+
27
+ def db
28
+ # Do nothing
29
+ end
30
+
31
+ def lib
32
+ directory 'lib'
33
+ end
34
+
35
+ def log
36
+ # Do nothing
37
+ empty_directory_with_keep_file 'log'
38
+ end
39
+
40
+ def test
41
+ template 'test/test_helper.rb'
42
+ end
43
+
44
+ def tmp
45
+ # Do nothing
46
+ end
47
+
48
+ def vendor
49
+ # Do nothing
50
+ end
51
+
52
+ def vendor_javascripts
53
+ # Do nothing
54
+ end
55
+
56
+ def vendor_stylesheets
57
+ # Do nothing
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails/generators/rails/app/app_generator'
4
+ require 'eac_rails_base0/app_generator/builder'
5
+
6
+ module EacRailsBase0
7
+ module AppGenerator
8
+ class Generator < Rails::Generators::AppGenerator
9
+ source_root ::File.join(__dir__, 'templates')
10
+ source_paths << source_root << ::Rails::Generators::AppGenerator.source_root
11
+
12
+ def initialize(*args)
13
+ super
14
+ end
15
+
16
+ protected
17
+
18
+ def get_builder_class # rubocop:disable Style/AccessorMethodName
19
+ ::EacRailsBase0::AppGenerator::Builder
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gem 'eac_rails_base0'
6
+
7
+ group :development, :test do
8
+ gem 'quiet_assets'
9
+ end
10
+
11
+ group :production do
12
+ gem 'rails_12factor'
13
+ end
14
+
15
+ # Gems locais
16
+ require_relative 'lib/local_plugins'
17
+ LocalPlugins.plugins.each do |p|
18
+ gem p.name, path: p.root
19
+ end
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+ class ApplicationController < ::EacRailsBase0::ApplicationController
3
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ class WelcomeController < ApplicationController
4
+ def index; end
5
+ end
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
4
+ load Gem.bin_path('bundler', 'bundle')
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require_relative '../lib/local_plugins'
5
+
6
+ LocalPlugins.app_and_plugins.each do |p|
7
+ puts '----------------------------------------'
8
+ puts "Diretório: #{p.root}"
9
+ p.bundle_execute(ARGV)
10
+ end
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
4
+ require_relative '../config/boot'
5
+ require 'rails/commands'
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ require_relative '../config/boot'
4
+ require 'rake'
5
+ Rake.application.run
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ require 'pathname'
4
+
5
+ # path to your application root.
6
+ APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
7
+
8
+ Dir.chdir APP_ROOT do
9
+ # This script is a starting point to setup your application.
10
+ # Add necessary setup steps to this file:
11
+
12
+ puts '== Installing dependencies =='
13
+ system 'gem install bundler --conservative'
14
+ system 'bundle check || bundle install'
15
+
16
+ # puts "\n== Copying sample files =="
17
+ # unless File.exist?("config/database.yml")
18
+ # system "cp config/database.yml.sample config/database.yml"
19
+ # end
20
+
21
+ puts "\n== Preparing database =="
22
+ system 'bin/rake db:setup'
23
+
24
+ puts "\n== Removing old logs and tempfiles =="
25
+ system 'rm -f log/*'
26
+ system 'rm -rf tmp/cache'
27
+
28
+ puts "\n== Restarting application server =="
29
+ system 'touch tmp/restart.txt'
30
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ APP_PATH = ::File.dirname(__dir__) unless defined?(APP_PATH)
4
+ require File.expand_path('../boot', __FILE__)
5
+ require 'eac_rails_base0/app_base/application.rb'
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
4
+
5
+ require 'bundler/setup' # Set up gems listed in the Gemfile.
@@ -0,0 +1,19 @@
1
+ default: &default
2
+ adapter: postgresql
3
+ pool: 5
4
+ timeout: 5000
5
+ encoding: unicode
6
+ username: <%= app_name %>
7
+ password: <%= app_name %>
8
+ host: localhost
9
+
10
+ development: &development
11
+ <<: *default
12
+ database: <%= app_name %>
13
+
14
+ production:
15
+ <<: *development
16
+
17
+ test:
18
+ <<: *default
19
+ database: <%= app_name %>_test
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Load the Rails application.
4
+ require File.expand_path('../application', __FILE__)
5
+
6
+ # Initialize the Rails application.
7
+ Rails.application.initialize!
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ Rails.application.configure do
4
+ # Settings specified here will take precedence over those in config/application.rb.
5
+
6
+ # In the development environment your application's code is reloaded on
7
+ # every request. This slows down response time but is perfect for development
8
+ # since you don't have to restart the web server when you make code changes.
9
+ config.cache_classes = false
10
+
11
+ # Do not eager load code on boot.
12
+ config.eager_load = false
13
+
14
+ # Show full error reports and disable caching.
15
+ config.consider_all_requests_local = true
16
+ config.action_controller.perform_caching = false
17
+
18
+ # Don't care if the mailer can't send.
19
+ config.action_mailer.raise_delivery_errors = false
20
+
21
+ # Print deprecation notices to the Rails logger.
22
+ config.active_support.deprecation = :log
23
+
24
+ # Raise an error on page load if there are pending migrations.
25
+ config.active_record.migration_error = :page_load
26
+
27
+ # Debug mode disables concatenation and preprocessing of assets.
28
+ # This option may cause significant delays in view rendering with a large
29
+ # number of complex assets.
30
+ config.assets.debug = true
31
+
32
+ # Asset digests allow you to set far-future HTTP expiration dates on all assets,
33
+ # yet still be able to expire them through the digest params.
34
+ config.assets.digest = true
35
+
36
+ # Adds additional error checking when serving assets at runtime.
37
+ # Checks for improperly declared sprockets dependencies.
38
+ # Raises helpful error messages.
39
+ config.assets.raise_runtime_errors = true
40
+
41
+ # Raises error for missing translations
42
+ # config.action_view.raise_on_missing_translations = true
43
+
44
+ config.logger = Logger.new(STDOUT)
45
+ end
@@ -0,0 +1,82 @@
1
+ # frozen_string_literal: true
2
+
3
+ Rails.application.configure do
4
+ # Settings specified here will take precedence over those in config/application.rb.
5
+
6
+ # Code is not reloaded between requests.
7
+ config.cache_classes = true
8
+
9
+ # Eager load code on boot. This eager loads most of Rails and
10
+ # your application in memory, allowing both threaded web servers
11
+ # and those relying on copy on write to perform better.
12
+ # Rake tasks automatically ignore this option for performance.
13
+ config.eager_load = true
14
+
15
+ # Full error reports are disabled and caching is turned on.
16
+ config.consider_all_requests_local = false
17
+ config.action_controller.perform_caching = true
18
+
19
+ # Enable Rack::Cache to put a simple HTTP cache in front of your application
20
+ # Add `rack-cache` to your Gemfile before enabling this.
21
+ # For large-scale production use, consider using a caching reverse proxy like
22
+ # NGINX, varnish or squid.
23
+ # config.action_dispatch.rack_cache = true
24
+
25
+ # Disable serving static files from the `/public` folder by default since
26
+ # Apache or NGINX already handles this.
27
+ config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
28
+
29
+ # Compress JavaScripts and CSS.
30
+ config.assets.js_compressor = :uglifier
31
+ # config.assets.css_compressor = :sass
32
+
33
+ # Do not fallback to assets pipeline if a precompiled asset is missed.
34
+ config.assets.compile = false
35
+
36
+ # Asset digests allow you to set far-future HTTP expiration dates on all assets,
37
+ # yet still be able to expire them through the digest params.
38
+ config.assets.digest = true
39
+
40
+ # `config.assets.precompile` and `config.assets.version` have moved to
41
+ # config/initializers/assets.rb
42
+
43
+ # Specifies the header that your server uses for sending files.
44
+ # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
45
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
46
+
47
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
48
+ # config.force_ssl = true
49
+
50
+ # Use the lowest log level to ensure availability of diagnostic information
51
+ # when problems arise.
52
+ config.log_level = :debug
53
+
54
+ # Prepend all log lines with the following tags.
55
+ # config.log_tags = [ :subdomain, :uuid ]
56
+
57
+ # Use a different logger for distributed setups.
58
+ # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
59
+
60
+ # Use a different cache store in production.
61
+ # config.cache_store = :mem_cache_store
62
+
63
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server.
64
+ # config.action_controller.asset_host = 'http://assets.example.com'
65
+
66
+ # Ignore bad email addresses and do not raise email delivery errors.
67
+ # Set this to true and configure the email server for immediate delivery to raise delivery errors.
68
+ # config.action_mailer.raise_delivery_errors = false
69
+
70
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
71
+ # the I18n.default_locale when a translation cannot be found).
72
+ config.i18n.fallbacks = true
73
+
74
+ # Send deprecation notices to registered listeners.
75
+ config.active_support.deprecation = :notify
76
+
77
+ # Use default logging formatter so that PID and timestamp are not suppressed.
78
+ config.log_formatter = ::Logger::Formatter.new
79
+
80
+ # Do not dump schema after migrations.
81
+ config.active_record.dump_schema_after_migration = false
82
+ end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ Rails.application.configure do
4
+ # Settings specified here will take precedence over those in config/application.rb.
5
+
6
+ # The test environment is used exclusively to run your application's
7
+ # test suite. You never need to work with it otherwise. Remember that
8
+ # your test database is "scratch space" for the test suite and is wiped
9
+ # and recreated between test runs. Don't rely on the data there!
10
+ config.cache_classes = true
11
+
12
+ # Do not eager load code on boot. This avoids loading your whole application
13
+ # just for the purpose of running a single test. If you are using a tool that
14
+ # preloads Rails for running tests, you may have to set it to true.
15
+ config.eager_load = false
16
+
17
+ # Configure static file server for tests with Cache-Control for performance.
18
+ config.serve_static_files = true
19
+ config.static_cache_control = 'public, max-age=3600'
20
+
21
+ # Show full error reports and disable caching.
22
+ config.consider_all_requests_local = true
23
+ config.action_controller.perform_caching = false
24
+
25
+ # Raise exceptions instead of rendering exception templates.
26
+ config.action_dispatch.show_exceptions = false
27
+
28
+ # Disable request forgery protection in test environment.
29
+ config.action_controller.allow_forgery_protection = false
30
+
31
+ # Tell Action Mailer not to deliver emails to the real world.
32
+ # The :test delivery method accumulates sent emails in the
33
+ # ActionMailer::Base.deliveries array.
34
+ config.action_mailer.delivery_method = :test
35
+
36
+ # Randomize the order test cases are executed.
37
+ config.active_support.test_order = :random
38
+
39
+ # Print deprecation notices to the stderr.
40
+ config.active_support.deprecation = :stderr
41
+
42
+ # Raises error for missing translations
43
+ # config.action_view.raise_on_missing_translations = true
44
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ Rails.application.routes.draw do
4
+ root 'welcome#index'
5
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+ # This file is used by Rack-based servers to start the application.
3
+
4
+ require ::File.expand_path('../config/environment', __FILE__)
5
+ run Rails.application
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ class LocalPlugins
4
+ def self.rails_root
5
+ File.expand_path('..', __dir__)
6
+ end
7
+
8
+ def self.plugins_roots
9
+ [File.expand_path('vendor/gems', rails_root), File.expand_path('engines', rails_root)]
10
+ end
11
+
12
+ def self.plugins
13
+ r = []
14
+ plugins_roots.each do |root|
15
+ Dir.glob("#{root}/*/").each do |plugin_dir|
16
+ next unless File.directory?(plugin_dir)
17
+ next unless Dir.entries(plugin_dir).any? { |f| f.match(/\.gemspec/) }
18
+ r << LocalPlugin.new(plugin_dir)
19
+ end
20
+ end
21
+ r
22
+ end
23
+
24
+ def self.app
25
+ LocalPlugin.new(rails_root)
26
+ end
27
+
28
+ def self.app_and_plugins
29
+ plugins + [app]
30
+ end
31
+ end
32
+
33
+ class LocalPlugin
34
+ attr_reader :root
35
+
36
+ def initialize(root)
37
+ @root = root
38
+ end
39
+
40
+ def bundle
41
+ bin_bundle = File.expand_path('bin/bundle', root)
42
+ File.exist?(bin_bundle) ? 'bin/bundle' : 'bundle'
43
+ end
44
+
45
+ def subpath(path)
46
+ File.expand_path(path, root)
47
+ end
48
+
49
+ def name
50
+ app? ? 'APP' : File.basename(root)
51
+ end
52
+
53
+ def app?
54
+ root == LocalPlugins.rails_root
55
+ end
56
+
57
+ def bundle_execute(args)
58
+ Dir.chdir(root) { system(*([bundle] + args)) }
59
+ end
60
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRailsBase0
4
- VERSION = '0.4.0'
4
+ VERSION = '0.5.0'
5
5
  end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacRailsBase0
4
+ class AbilitiesGenerator < Rails::Generators::Base
5
+ source_root File.expand_path('templates', __dir__)
6
+
7
+ def copy_bin
8
+ %w(ability ability_mapping).each do |base|
9
+ copy_file "#{base}.rb", "lib/#{base}.rb"
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Ability < ::EacRailsBase0::Ability
4
+ def initialize(*args)
5
+ super
6
+ can :read, :public
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AbilityMapping < ::EacRailsBase0::AbilityMapping
4
+ def initialize(*args)
5
+ super
6
+ map_action 'Welcome', 'index', :read, :public
7
+ end
8
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacRailsBase0
4
+ class RspecGenerator < Rails::Generators::Base
5
+ source_root File.expand_path('../templates', __FILE__)
6
+
7
+ def create_initializer_files
8
+ copy_file 'rspec.rc', '.rspec'
9
+ copy_file 'spec_rails_helper.rb', 'lib/spec_rails_helper.rb'
10
+ copy_file 'bin_rspec.rb', 'bin/rspec'
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacRailsBase0
4
+ class RubocopGenerator < Rails::Generators::Base
5
+ source_root File.expand_path('templates', __dir__)
6
+
7
+ def install_gem
8
+ gem 'rubocop'
9
+ end
10
+
11
+ def copy_bin
12
+ copy_file 'rubocop.rb', 'bin/rubocop'
13
+ chmod 'bin', 0755 & ~File.umask, verbose: false
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ system(
5
+ File.join(File.dirname(__FILE__), 'bundle'),
6
+ 'exec', 'rubocop', *ARGV
7
+ )
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ class EacRailsBase0Generator < Rails::Generators::Base
4
+ SUB_GENERATORS = %w(abilities rspec rubocop).freeze
5
+
6
+ def run_other_generators
7
+ SUB_GENERATORS.each do |generator|
8
+ generate "eac_rails_base0:#{generator}"
9
+ end
10
+ end
11
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eac_rails_base0
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esquilo Azul Company
8
8
  autorequire:
9
- bindir: bin
9
+ bindir: exe
10
10
  cert_chain: []
11
- date: 2018-08-10 00:00:00.000000000 Z
11
+ date: 2018-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bootstrap-sass
@@ -312,23 +312,75 @@ dependencies:
312
312
  version: '0'
313
313
  description:
314
314
  email:
315
- executables: []
315
+ executables:
316
+ - eac_rails_base0_app
316
317
  extensions: []
317
318
  extra_rdoc_files: []
318
319
  files:
320
+ - Gemfile
321
+ - README.rdoc
322
+ - app/assets/javascripts/eac_rails_base0.js
323
+ - app/assets/stylesheets/eac_rails_base0.scss
324
+ - app/assets/stylesheets/eac_rails_base0/bootstrap_import.scss
325
+ - app/controllers/eac_rails_base0/application_controller.rb
326
+ - app/helpers/eac_rails_base0/layout_helper.rb
327
+ - app/views/layouts/eac_rails_base0/_flash.html.erb
328
+ - app/views/layouts/eac_rails_base0/_main_menu.html.erb
329
+ - app/views/layouts/eac_rails_base0/_navbar_user.html.erb
330
+ - app/views/layouts/eac_rails_base0/application.html.erb
331
+ - config/initializers/backport_pg_10_support_to_rails_4.rb
332
+ - config/initializers/backtrace_silencers.rb
333
+ - config/initializers/cookies_serializer.rb
334
+ - config/initializers/filter_parameter_logging.rb
335
+ - config/initializers/mime_types.rb
336
+ - config/initializers/session_store.rb
337
+ - config/initializers/wrap_parameters.rb
338
+ - config/locales/pt-BR.yml
339
+ - config/routes.rb
340
+ - exe/eac_rails_base0_app
319
341
  - lib/eac_rails_base0.rb
320
342
  - lib/eac_rails_base0/ability.rb
321
343
  - lib/eac_rails_base0/ability_mapping.rb
344
+ - lib/eac_rails_base0/app_base/application.rb
345
+ - lib/eac_rails_base0/app_generator/builder.rb
346
+ - lib/eac_rails_base0/app_generator/generator.rb
347
+ - lib/eac_rails_base0/app_generator/templates/Gemfile
348
+ - lib/eac_rails_base0/app_generator/templates/app/assets/javascripts/application.js
349
+ - lib/eac_rails_base0/app_generator/templates/app/assets/stylesheets/application.scss
350
+ - lib/eac_rails_base0/app_generator/templates/app/controllers/application_controller.rb
351
+ - lib/eac_rails_base0/app_generator/templates/app/controllers/welcome_controller.rb
352
+ - lib/eac_rails_base0/app_generator/templates/app/views/welcome/index.html.erb
353
+ - lib/eac_rails_base0/app_generator/templates/bin/bundle
354
+ - lib/eac_rails_base0/app_generator/templates/bin/bundle_all
355
+ - lib/eac_rails_base0/app_generator/templates/bin/rails
356
+ - lib/eac_rails_base0/app_generator/templates/bin/rake
357
+ - lib/eac_rails_base0/app_generator/templates/bin/setup
358
+ - lib/eac_rails_base0/app_generator/templates/config.ru
359
+ - lib/eac_rails_base0/app_generator/templates/config/application.rb
360
+ - lib/eac_rails_base0/app_generator/templates/config/boot.rb
361
+ - lib/eac_rails_base0/app_generator/templates/config/database.yml
362
+ - lib/eac_rails_base0/app_generator/templates/config/environment.rb
363
+ - lib/eac_rails_base0/app_generator/templates/config/environments/development.rb
364
+ - lib/eac_rails_base0/app_generator/templates/config/environments/production.rb
365
+ - lib/eac_rails_base0/app_generator/templates/config/environments/test.rb
366
+ - lib/eac_rails_base0/app_generator/templates/config/routes.rb
367
+ - lib/eac_rails_base0/app_generator/templates/lib/local_plugins.rb
322
368
  - lib/eac_rails_base0/engine.rb
323
369
  - lib/eac_rails_base0/spec_helper.rb
324
370
  - lib/eac_rails_base0/spec_helper/capybara.rb
325
371
  - lib/eac_rails_base0/spec_helper/eac_users_support.rb
326
372
  - lib/eac_rails_base0/spec_helper/factory_bot.rb
327
373
  - lib/eac_rails_base0/version.rb
328
- - lib/generators/eac_rails_base0/install/rspec/rspec_generator.rb
329
- - lib/generators/eac_rails_base0/install/rspec/templates/bin_rspec.rb
330
- - lib/generators/eac_rails_base0/install/rspec/templates/rspec.rc
331
- - lib/generators/eac_rails_base0/install/rspec/templates/spec_rails_helper.rb
374
+ - lib/generators/eac_rails_base0/abilities/abilities_generator.rb
375
+ - lib/generators/eac_rails_base0/abilities/templates/ability.rb
376
+ - lib/generators/eac_rails_base0/abilities/templates/ability_mapping.rb
377
+ - lib/generators/eac_rails_base0/rspec/rspec_generator.rb
378
+ - lib/generators/eac_rails_base0/rspec/templates/bin_rspec.rb
379
+ - lib/generators/eac_rails_base0/rspec/templates/rspec.rc
380
+ - lib/generators/eac_rails_base0/rspec/templates/spec_rails_helper.rb
381
+ - lib/generators/eac_rails_base0/rubocop/rubocop_generator.rb
382
+ - lib/generators/eac_rails_base0/rubocop/templates/rubocop.rb
383
+ - lib/generators/eac_rails_base0_generator.rb
332
384
  homepage: https://github.com/esquilo-azul/eac_rails_base0
333
385
  licenses:
334
386
  - MIT
@@ -350,7 +402,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
350
402
  version: '0'
351
403
  requirements: []
352
404
  rubyforge_project:
353
- rubygems_version: 2.6.14
405
+ rubygems_version: 2.7.7
354
406
  signing_key:
355
407
  specification_version: 4
356
408
  summary: A Rails base for multiple Rails projects developed by Esquilo Azul Company.
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
- module EacRailsBase0
3
- module Install
4
- class RspecGenerator < Rails::Generators::Base
5
- source_root File.expand_path('../templates', __FILE__)
6
-
7
- def create_initializer_files
8
- copy_file 'rspec.rc', '.rspec'
9
- copy_file 'spec_rails_helper.rb', 'lib/spec_rails_helper.rb'
10
- copy_file 'bin_rspec.rb', 'bin/rspec'
11
- end
12
- end
13
- end
14
- end