# coding: utf-8 # http://guides.rubyonrails.org/rails_application_templates.html # https://github.com/morizyun/rails4_template/blob/master/app_template.rb # https://github.com/search?q=rails%20template&source=c # # The method "insert_to_file" is defined by thor instead of rails # https://github.com/erikhuda/thor/blob/master/lib/thor/actions/inject_into_file.rb require 'bundler' require 'fileutils' def git_add_commit(msg, path = '.') git add: path raise "Failed to git add #{path.inspect} with exit code #{$?.inspect}" unless $? == 0 git commit: "-m '#{msg}'" raise "Failed to git commit #{msg.inspect} with exit code #{$?.inspect}" unless $? == 0 end def generate_with_git(arg) generate arg, '-f' git_add_commit "rails generate #{arg}" end def git_run(cmd) run cmd raise "Failed to run: #{cmd}" unless $? == 0 git_add_commit cmd end def download_file(dest, url) FileUtils.mkdir_p File.dirname(dest) git_run "curl #{url} -o #{dest}" end def git_rake(*args) git_run "bin/rake %s" % args.join(" ") end def uncomment(path, target) text = IO.binread(path) text.sub!(/\#\s*#{Regexp.escape(target)}/, target) IO.binwrite(path, text) end git :init unless ENV['SKIP_GIT_INIT'] =~ /true|yes|on|1/i git_add_commit "#{File.basename($PROGRAM_NAME)} #{ARGV.join(' ')}" if File.exist?('README.rdoc') && File.exist?('README.md') run 'mv README.rdoc README.md' git_add_commit "Rename README.rdoc to README.md" end ## Gemfile gem "twitter-bootstrap-rails" gem 'devise' # https://github.com/CanCanCommunity/cancancan gem 'cancancan' # https://github.com/brainspec/enumerize gem 'enumerize' gem "kaminari" # # https://github.com/brainspec/enumerize # gem 'enumerize' # https://github.com/sinsoku/pretty_validation # http://sinsoku.hatenablog.com/entry/2015/11/15/103924 gem 'pretty_validation', git: "https://github.com/akm/pretty_validation.git" # # https://github.com/sferik/rails_admin # gem 'rails_admin' unless ENV['DISABLE_RAILS_ADMIN'] =~ /true|yes|on|1/i # Use dotenv to load environment variables gem 'dotenv-rails', :require => 'dotenv/rails-now' gem_group :development, :test do gem "rspec" gem "rspec-rails" gem 'simplecov' , require: false gem 'simplecov-rcov', require: false gem "pry-rails" gem "pry-byebug" gem "pry-stack_explorer" gem "fuubar" gem "factory_girl" gem "factory_girl_rails" gem "annotate" gem "rails_best_practices" # https://github.com/flyerhzm/bullet gem 'bullet' end gem_group :development do gem "better_errors" gem 'binding_of_caller' end gem_group :test do gem 'rails-controller-testing' end git_add_commit 'Add gems to Gemfile' Bundler.with_clean_env do run 'bundle install' end git_add_commit 'bundle install' # set config/application.rb application do %q{ config.time_zone = 'Tokyo' config.active_record.default_timezone = :local config.i18n.default_locale = :ja config.generators do |g| # g.orm :mongoid g.test_framework :rspec g.factory_girl dir: 'spec/factories' # g.template_engine :haml end } end git_add_commit 'Add settings of timezone, locale and generators' # Rails Japanese locale download_file "config/locales/ja.yml", "https://raw.githubusercontent.com/svenfuchs/rails-i18n/master/rails/locale/ja.yml" ## rspec generate_with_git 'rspec:install' download_file ".rspec", "https://raw.githubusercontent.com/akm/rails_template/master/.rspec" uncomment('spec/rails_helper.rb', "Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }") git_add_commit 'Enable rb files under spec/support' ## simplecov insert_into_file 'spec/rails_helper.rb', <' #

<%= notice %>

#

<%= alert %>

# # EOS insert_into_file 'config/environments/development.rb', < 'bullets_account@jabber.org', # :password => 'bullets_password_for_jabber', # :receiver => 'your_account@jabber.org', # :show_online_status => true } Bullet.rails_logger = true # Bullet.honeybadger = true # Bullet.bugsnag = true # Bullet.airbrake = true # Bullet.rollbar = true # Bullet.add_footer = true # Bullet.stacktrace_includes = [ 'your_gem', 'your_middleware' ] # Bullet.stacktrace_excludes = [ 'their_gem', 'their_middleware' ] # Bullet.slack = { webhook_url: 'http://some.slack.url', foo: 'bar' } end EOS git_add_commit 'Add config for bullet' # ## rails_admin # unless ENV['DISABLE_RAILS_ADMIN'] =~ /true|yes|on|1/i # generate_with_git 'rails_admin:install' # download_file "config/locales/ja.rails_admin.yml", "https://raw.githubusercontent.com/starchow/rails_admin-i18n/master/locales/ja.yml" # end ## model_base_generators generate_with_git 'model_base:install' ## DB git_rake "db:create db:migrate" ## gitguard gem_group :development do # https://github.com/akm/gitguard gem 'gitguard' end generate_with_git "gitguard:install" ## The End git commit: "-m \"\[COMPLETE\] rails new with akm/rails_template\" --allow-empty "