Class: MultiEngine

Inherits:
Thor::Group
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/multi_engine.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.say_step(message) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'lib/multi_engine.rb', line 20

def self.say_step(message)
  @step = (@step || 0) + 1
  class_eval <<-METHOD, __FILE__, __LINE__ + 1
    def step_#{@step}
      #{"puts" if @step > 1}
      say_status "STEP #{@step}", #{message.inspect}
    end
  METHOD
end

.source_rootObject



16
17
18
# File 'lib/multi_engine.rb', line 16

def self.source_root
  @_source_root ||= File.expand_path('../templates', __FILE__)
end

Instance Method Details

#change_gitignoreObject



65
66
67
# File 'lib/multi_engine.rb', line 65

def change_gitignore
  template "gitignore", ".gitignore"
end

#create_rootObject



53
54
55
56
57
58
59
# File 'lib/multi_engine.rb', line 53

def create_root
  self.destination_root = File.expand_path(path, destination_root)
  set_accessors!

  directory "root", "."
  FileUtils.cd(destination_root)
end

#create_tests_or_specsObject



61
62
63
# File 'lib/multi_engine.rb', line 61

def create_tests_or_specs
  directory test_path
end

#invoke_rails_app_generatorsObject



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/multi_engine.rb', line 69

def invoke_rails_app_generators
  say "Vendoring Rails applications at #{test_path}/dummy-apps"
  types.each do |type|
    say "Creating #{type} apps"
    self.current_type = type
    orms.each do |orm|
      self.current_orm = translate(orm) 
      
      say "Creating #{type} dummy Rails app with #{orm_name}", :green
      # say "Location: #{dummy_app_path}"
      command = "rails new #{app_args.join(' ')} -f" # force overwrite
      say command

      exec_command command

      #invoke Rails::Generators::AppGenerator, app_args

      say "Configuring Rails app"
      change_config_files

      # say "Removing unneeded files"
      remove_uneeded_rails_files
          
      send orm_config_method if respond_to?(orm_config_method)

      say "Configuring testing framework for #{orm_name}"      
      set_orm_helpers

      ensure_app_class_name
      
      FileUtils.cd(destination_root)
    end
  end
end