Module: Firestarter
- Defined in:
- lib/firestarter.rb,
lib/firestarter/version.rb
Constant Summary collapse
- ARB =
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # PREPARE TO TWEAK
"ActiveRecord::Base\n"- M =
'app/models/'- E =
"\n"- CO =
"config/"- V =
'app/views/'- C =
'app/controllers/'- VERSION =
"0.0.1"
Instance Method Summary collapse
- #add_carrierwave_assets ⇒ Object
- #add_gem(gem_name, options = nil) ⇒ Object
- #add_gems(gem_list, options = nil) ⇒ Object
-
#add_to_model(model_name, text) ⇒ Object
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # EDIT MODELS.
- #add_to_model_header(model_name, text) ⇒ Object
- #dont_generate_css ⇒ Object
- #generate_admin(path) ⇒ Object
-
#install_cucumber ⇒ Object
BDD SUITE.
-
#install_devise ⇒ Object
AUTHENTICATION.
- #install_gems ⇒ Object
-
#install_jquery ⇒ Object
JAVASCRIPTS.
- #remove_useless_files ⇒ Object
- #start_admin ⇒ Object
- #start_database ⇒ Object
- #start_git ⇒ Object
-
#use_rspec_generators ⇒ Object
TEST.
Instance Method Details
#add_carrierwave_assets ⇒ Object
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/firestarter.rb', line 151 def add_carrierwave_assets generate :model, "asset file:string asset_type:string asset_id:integer" run "rails generate uploader Asset" inject_into_file M+'asset.rb', " mount_uploader :file, AssetUploader"+E, :after => ARB files_allowed = " def extension_white_list ; %w(jpg jpeg gif png) ; end "+E inject_into_file 'app/uploaders/asset_uploader.rb', files_allowed, :after => "CarrierWave::Uploader::Base\n" image_magick = " include CarrierWave::RMagick"+E image_magick += " process :resize_to_fit [800,800]"+E image_magick += " version :thumb do"+E image_magick += " process :resize_to_fill => [200,200]"+E image_magick += " end"+E inject_into_file 'app/uploaders/asset_uploader.rb', image_magick, :after => "CarrierWave::Uploader::Base\n" end |
#add_gem(gem_name, options = nil) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/firestarter.rb', line 18 def add_gem(gem_name, =nil) gem_line = " gem '#{gem_name}'" if gem_line += ", '#{options[:version]}'" if [:version] gem_line += ", :group => :#{options[:group]}" if [:group] end gem_line += E inject_into_file "Gemfile", gem_line, :after => "source 'http://rubygems.org'\n" end |
#add_gems(gem_list, options = nil) ⇒ Object
28 29 30 31 32 |
# File 'lib/firestarter.rb', line 28 def add_gems(gem_list, =nil) gem_list.each do |gem_name| add_gem(gem_name, ) end end |
#add_to_model(model_name, text) ⇒ Object
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # EDIT MODELS
86 87 88 |
# File 'lib/firestarter.rb', line 86 def add_to_model(model_name, text) inject_into_file M+"#{model_name}.rb", " #{text}"+E, :after => ARB end |
#add_to_model_header(model_name, text) ⇒ Object
90 91 92 |
# File 'lib/firestarter.rb', line 90 def add_to_model_header(model_name, text) inject_into_file M+"#{model_name}.rb", " #{text}"+E, :after => "class " end |
#dont_generate_css ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/firestarter.rb', line 10 def dont_generate_css initializer 'generators.rb', " Rails.application.config.generators do |g|\n g.stylesheets false\n end\n" end |
#generate_admin(path) ⇒ Object
114 115 116 117 118 119 |
# File 'lib/firestarter.rb', line 114 def generate_admin(path) # run "rails g web_app_theme:themed #{path} --engine=haml" # run "rails g controller #{path.split('/').join('::')} index show new edit create update" # inject_into_file CO+'routes.rb', "resources :#{path.split('/')[1].pluralize}", :after => "\n namespace :admin do\n" run "rails g active_admin:resource #{path}" end |
#install_cucumber ⇒ Object
BDD SUITE
73 74 75 |
# File 'lib/firestarter.rb', line 73 def install_cucumber generate "cucumber:install --capybara#{' --rspec' if recipes.include?('rspec')}#{' -D' unless recipes.include?('activerecord')}" end |
#install_devise ⇒ Object
AUTHENTICATION
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/firestarter.rb', line 55 def install_devise generate 'devise:install' case template['orm'] when 'mongo_mapper' gem 'mm-devise' gsub_file 'config/intializers/devise.rb', 'devise/orm/active_record', 'devise/orm/mongo_mapper_active_model' when 'mongoid' gsub_file 'config/intializers/devise.rb', 'devise/orm/active_record', 'devise/orm/mongoid' when 'active_record' # Nothing to do end generate 'devise user' generate 'devise user:views' end |
#install_gems ⇒ Object
34 35 36 |
# File 'lib/firestarter.rb', line 34 def install_gems run('bundle install') end |
#install_jquery ⇒ Object
JAVASCRIPTS
40 41 42 |
# File 'lib/firestarter.rb', line 40 def install_jquery run "rails generate jquery:install --ui" end |
#remove_useless_files ⇒ Object
2 3 4 5 6 7 8 |
# File 'lib/firestarter.rb', line 2 def remove_useless_files run "rm README" run "rm public/index.html" run "rm public/favicon.ico" run "rm public/robots.txt" run "rm -f public/javascripts/*" end |
#start_admin ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/firestarter.rb', line 100 def start_admin # Default Routes routes = " namespace :admin do\n end\n\n root :to => \"products#index\"\n APP\n inject_into_file CO+'routes.rb', routes, :after => \"Cartmen::Application.routes.draw do\\n\"\n\n run \"rails g active_admin:install\"\n run \"rake db:migrate\"\nend\n" |
#start_database ⇒ Object
94 95 96 97 98 |
# File 'lib/firestarter.rb', line 94 def start_database run "rake db:drop" run "rake db:create" run "rake db:migrate" end |
#start_git ⇒ Object
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/firestarter.rb', line 129 def start_git # Git run 'git init' run "rm .gitignore" file ".gitignore", " .DS_Store\n log/*.log\n tmp/**/*\n config/database.yml\n assets/*\n .idea\n .generators\n *.swp\n END\n\n run \"cp config/database.yml config/database.yml.model\"\n\n run 'git add .'\n run 'git commit -am \"Another brand new app\"'\nend\n" |
#use_rspec_generators ⇒ Object
TEST
47 48 49 50 51 |
# File 'lib/firestarter.rb', line 47 def use_rspec_generators inject_into_file "config/initializers/generators.rb", :after => "Rails.application.config.generators do |g|\n" do " g.test_framework = :rspec\n" end end |