Module: Stratagem::Generators::InstallBase
- Included in:
- InstallGenerator
- Defined in:
- lib/generators/stratagem/install/install_base.rb
Instance Method Summary collapse
- #append_yml(m, *filenames) ⇒ Object
- #create_all(m = self) ⇒ Object
- #create_config(m) ⇒ Object
- #create_database(m) ⇒ Object
- #create_scripts(m) ⇒ Object
- #create_tasks(m) ⇒ Object
Instance Method Details
#append_yml(m, *filenames) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/generators/stratagem/install/install_base.rb', line 32 def append_yml(m, *filenames) filenames.each do |filename| if (File.exists?("config/#{filename}")) unless File.read("config/#{filename}").include? 'stratagem:' m.gsub_file "config/#{filename}", /^test:.*\n/, "test: &test\n" m.gsub_file "config/#{filename}", /\z/, "\nstratagem:\n <<: *test" puts " force config/#{filename}" end end end end |
#create_all(m = self) ⇒ Object
4 5 6 7 8 9 |
# File 'lib/generators/stratagem/install/install_base.rb', line 4 def create_all(m=self) create_scripts(m) create_config(m) create_tasks(m) create_database(m) end |
#create_config(m) ⇒ Object
20 21 22 |
# File 'lib/generators/stratagem/install/install_base.rb', line 20 def create_config(m) m.template 'environments/stratagem.rb.erb', 'config/environments/stratagem.rb' end |
#create_database(m) ⇒ Object
28 29 30 |
# File 'lib/generators/stratagem/install/install_base.rb', line 28 def create_database(m) append_yml(m, 'mongoid.yml', 'database.yml', 'workling.yml') end |
#create_scripts(m) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/generators/stratagem/install/install_base.rb', line 11 def create_scripts(m) m.template('script/stratagem', 'script/stratagem', ) begin chmod 'script/stratagem', 0755 rescue puts "ERROR: #{$!.}" end end |
#create_tasks(m) ⇒ Object
24 25 26 |
# File 'lib/generators/stratagem/install/install_base.rb', line 24 def create_tasks(m) m.template 'tasks/stratagem.rake', 'lib/tasks/stratagem.rake' end |