diff --git a/README.md b/README.md index 5d006b5..17f0fa2 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,7 @@ http://github.com/kebab-project/cybele/issues ## Contributing -Cybele uses [TomDoc](http://tomdoc.org/), [rDoc](http://rubydoc.info/gems/cybele) and [SemVer](http://semver.org/), and takes it seriously. +Cybele uses [rDoc](http://rubydoc.info/gems/cybele) and [SemVer](http://semver.org/), and takes it seriously. Once you've made your great commits: diff --git a/lib/cybele/app_builder.rb b/lib/cybele/app_builder.rb index 7566503..6c7df26 100644 --- a/lib/cybele/app_builder.rb +++ b/lib/cybele/app_builder.rb @@ -1,39 +1,30 @@ -module Cybele #:nodoc:# +module Cybele - # Public: This allows you to override entire operations, like the creation of the - # cybele_Gemfile, README, or JavaScript files, without needing to know exactly - # what those operations do so you can create another template action. class AppBuilder < Rails::AppBuilder - # Internal: Overwrite super class readme def readme template 'README.md.erb', 'README.md', :force => true end - # Internal: Remove README.rdoc file def remove_readme_rdoc remove_file 'README.rdoc' end - # Internal: Replace gemfile def replace_gemfile remove_file 'Gemfile' copy_file 'cybele_Gemfile', 'Gemfile' end - # Internal: Replace config/application.rb file def replace_application_rb_file remove_file 'config/application.rb' copy_file 'config/application.rb', 'config/application.rb' end - # Internal: Replace erb files with html files def replace_erb_with_haml remove_file 'app/views/layouts/application.html.erb' template 'app/views/layouts/application.html.haml.erb', 'app/views/layouts/application.html.haml', :force => true end - # Internal: Replace responders controller template def install_responder_gem copy_file 'lib/application_responder.rb', 'lib/application_responder.rb' remove_file 'app/controllers/application_controller.rb' @@ -43,23 +34,19 @@ def install_responder_gem copy_file 'config/locales/responders.tr.yml', 'config/locales/responders.tr.yml' end - # Internal: Setup database config def replace_database_yml template 'config/database.yml.erb', 'config/database.yml', :force => true end - # Internal: Create database def create_database bundle_command 'exec rake db:create' end - # Internal: Setup gitignore files def setup_gitignore_files remove_file '.gitignore' copy_file 'cybele_gitignore', '.gitignore' end - # Internal: Setup gitignore folders def setup_gitignore_folders %w( app/assets/images @@ -75,8 +62,6 @@ def setup_gitignore_folders end end - # Internal: Setup asset precompile - # Look for information https://github.com/thomas-mcdonald/bootstrap-sass#rails-4 def setup_asset_precompile config = <<-RUBY @@ -89,19 +74,16 @@ def setup_asset_precompile inject_into_file 'config/application.rb', config, :after => '# config.i18n.default_locale = :de' end - # Interval: Convert application.js to application.js.coffee def convert_application_js_to_coffee remove_file 'app/assets/javascripts/application.js' copy_file 'app/assets/javascripts/application.js.coffee', 'app/assets/javascripts/application.js.coffee' end - # Interval: Convert application.css to application.css.sass def convert_application_css_to_sass remove_file 'app/assets/stylesheets/application.css' copy_file 'app/assets/stylesheets/application.css.sass', 'app/assets/stylesheets/application.css.sass' end - # Interval: Configure smtp def configure_smtp config = <<-RUBY @@ -119,14 +101,12 @@ def configure_smtp configure_environment 'production', config end - # Interval: Configure action mailer def configure_action_mailer action_mailer_host 'development', "#{app_name}.dev" action_mailer_host 'test', "#{app_name}.com" action_mailer_host 'production', "#{app_name}.com" end - # Interval: Setup letter opener def setup_letter_opener config = 'config.action_mailer.delivery_method = :letter_opener' configure_environment 'development', config @@ -161,32 +141,23 @@ def generate_factory_girl end end - # Interval: Setup simple form def generate_simple_form generate 'simple_form:install --bootstrap' copy_file 'config/locales/simple_form.tr.yml', 'config/locales/simple_form.tr.yml' copy_file 'config/locales/tr.yml', 'config/locales/tr.yml' end - # Internal: Generate exception notification - # - # This command generates an initialize file (config/initializers/exception_notification.rb) - # where you can customize your configurations. - # https://github.com/smartinez87/exception_notification#rails def generate_exception_notification generate 'exception_notification:install' end - # Internal: Leftovers def leftovers end - # Internal: Setup Rails Config def generate_rails_config generate 'rails_config:install' end - # Internal: Setup devise def generate_devise_settings generate 'devise:install' gsub_file 'config/initializers/filter_parameter_logging.rb', /:password/, ':password, :password_confirmation' @@ -194,20 +165,16 @@ def generate_devise_settings end - # Internal: Generate devise model def generate_devise_model(model_name) generate "devise #{model_name} name:string" generate_devise_strong_parameters(model_name) remove_file 'config/locales/devise.en.yml' end - # Internal: Generate devise views def generate_devise_views - # generate "devise:views" directory 'app/views/devise', 'app/views/devise' end - # Internal: Generate Welcome Page def generate_welcome_page copy_file 'app/controllers/welcome_controller.rb', 'app/controllers/welcome_controller.rb' template 'app/views/welcome/index.html.haml.erb', 'app/views/welcome/index.html.haml', force: true @@ -234,12 +201,6 @@ def set_time_zone private - # Internal: Set action mailer hostname - # - # rail_env - rails env like development, text, production - # host - domain.dev, domain.com or example.com - # - # Returns nothing def action_mailer_host(rails_env, host) config = <<-RUBY @@ -250,25 +211,16 @@ def action_mailer_host(rails_env, host) configure_environment(rails_env, config) end - # Internal: Set configure environment - # - # rail_env - rails env like development, text, production - # config - config string which will add to rails_env file - # - # Return nothing def configure_environment(rails_env, config) inject_into_file("config/environments/#{rails_env}.rb", "\n\n #{config}", before: "\nend") end - # Setup strong params for devise def generate_devise_strong_parameters(model_name) create_sanitizer_lib(model_name) create_sanitizer_initializer(model_name) devise_parameter_sanitizer(model_name) end - - # Internal: Create devise ParameterSanitizer library def create_sanitizer_lib(model_name) create_file "lib/#{model_name.parameterize}_sanitizer.rb", <<-CODE class #{model_name.classify}::ParameterSanitizer < Devise::ParameterSanitizer @@ -280,7 +232,6 @@ def sign_up CODE end - # Internal: Create devise ParameterSanitizer library initializer def create_sanitizer_initializer(model_name) path = "#" path << "{Rails.application.root}" @@ -290,7 +241,6 @@ def create_sanitizer_initializer(model_name) CODE end - # Internal: Add devise_parameter_sanitizer method to app/controller/applications_controller.rb def devise_parameter_sanitizer(model_name) inject_into_file 'app/controllers/application_controller.rb', :after => 'protect_from_forgery with: :exception' do <<-CODE @@ -307,7 +257,6 @@ def devise_parameter_sanitizer end end - #Internal: Create namespace with dashboard resource in routes.rb def create_namespace_routing(namespace) inject_into_file 'config/routes.rb', after: "root to: 'welcome#index'" do <<-CODE @@ -318,13 +267,11 @@ def create_namespace_routing(namespace) end end - # Internal: Generate migration for add time_zone to User model def add_time_zone_to_user say 'Add time_zone to User model' generate 'migration AddTimeZoneToUser time_zone:string -s' end - # Internal: Add set_user_time_zone method to app/controller/applications_controller.rb def add_set_user_time_zone_method_to_application_controller say 'Add set_user_time_zone method to application controller' inject_into_file 'app/controllers/application_controller.rb', :after => 'protected' do <<-CODE @@ -343,4 +290,4 @@ def set_user_time_zone end end end -end +end \ No newline at end of file diff --git a/lib/cybele/generators/app_generator.rb b/lib/cybele/generators/app_generator.rb index 94aa610..c011f9a 100644 --- a/lib/cybele/generators/app_generator.rb +++ b/lib/cybele/generators/app_generator.rb @@ -1,28 +1,21 @@ require 'rails/generators' require 'rails/generators/rails/app/app_generator' -module Cybele #:nodoc:# +module Cybele - # Public: This allows you to override entire operations, like the creation of the - # Gemfile_new, README, or JavaScript files, without needing to know exactly - # what those operations do so you can create another template action. class AppGenerator < Rails::Generators::AppGenerator - # Internal: Default use postgresql class_option :database, :type => :string, :aliases => '-d', :default => 'postgresql', :desc => "Preconfigure for selected database (options: #{DATABASES.join('/')})" - # Internal: Default skip Test::Unit class_option :skip_test_unit, :type => :boolean, :aliases => '-T', :default => true, :desc => 'Skip Test::Unit files' - # Internal: Finish template def finish_template invoke :customization super end - # Internal: Customization template def customization invoke :customize_gemfile invoke :setup_database @@ -42,33 +35,28 @@ def customization invoke :setup_time_zone end - # Internal: Customize gemfile def customize_gemfile build :replace_gemfile bundle_command 'install --binstubs=bin/stubs' end - # Internal: Remove files don't need def remove_files_we_dont_need say 'Remove files we don\'t need' build :remove_readme_rdoc end - # Internal: Replace files def replace_files say 'Replace files' build :replace_erb_with_haml build :replace_database_yml end - # Internal: Install gems def install_gems say 'Install gems' say 'Install responder gem' build :install_responder_gem end - # Internal: Setup database def setup_database say 'Setting up database' @@ -79,13 +67,11 @@ def setup_database build :create_database end - # Internal: Ignore files and folder def gitignore_files_and_folders build :setup_gitignore_files build :setup_gitignore_folders end - # Internal: Setup up bootstrap, sass, coffee def setup_bootstrap_sass_coffee say 'Setup bootstrap' build :setup_asset_precompile @@ -94,7 +80,6 @@ def setup_bootstrap_sass_coffee build :convert_application_css_to_sass end - # Internal: Setup mail setting def configure_mail_setting say 'Setup mail settings' build :configure_action_mailer @@ -117,26 +102,22 @@ def setup_factory_girl build :generate_factory_girl end - # Internal: Setup simple_form def setup_simple_form say 'Generate simple form files' build :generate_simple_form end - # Internal: Setup exception notification def setup_exception_notification say 'Generate exception notification' say 'Do not forget to configure config/initializers/exception_notification.rb file' build :generate_exception_notification end - # Internal: Setup Rails Config def setup_rails_config say 'Generate rails config' build :generate_rails_config end - # Internal: Setup Devise def setup_devise say 'Generate devise' build :generate_devise_settings @@ -145,32 +126,26 @@ def setup_devise build :generate_devise_views end - # Internal: Setup Welcome Page def setup_welcome_page say 'Generate Welcome Page' build :generate_welcome_page end - def setup_hq_namespace say 'Generate hq namespace' build :generate_hq_namespace end - # Internal: Setup timezone per user def setup_time_zone say 'Setup time zone' build :set_time_zone end - - # Internal: Let's not: We'll bundle manually at the right spot. def run_bundle end protected - # Internal: We need get_builder class def get_builder_class Cybele::AppBuilder end diff --git a/lib/cybele/version.rb b/lib/cybele/version.rb index ed016b0..afdaa1e 100644 --- a/lib/cybele/version.rb +++ b/lib/cybele/version.rb @@ -1,4 +1,3 @@ -module Cybele #:nodoc: - # Public: Cybele version +module Cybele VERSION = '0.8.0' end