Class: Turbo::Generator

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.say_step(message) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/turbo/generator.rb', line 16

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



12
13
14
# File 'lib/turbo/generator.rb', line 12

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

Instance Method Details

#create_gitignoreObject



44
45
46
# File 'lib/turbo/generator.rb', line 44

def create_gitignore
  template "gitignore", ".gitignore"
end

#create_rootObject



36
37
38
39
40
41
42
# File 'lib/turbo/generator.rb', line 36

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



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/turbo/generator.rb', line 48

def create_tests_or_specs
  directory test_path
  empty_directory dummy_path
  empty_directory File.join(dummy_path, 'config')
  empty_directory File.join(dummy_path, 'db')
  empty_directory File.join(dummy_path, 'log')
  empty_directory File.join(dummy_path, 'public')
  template 'dummy/routes.rb',    File.join(dummy_path, 'config', 'routes.rb')
  template 'dummy/database.yml', File.join(dummy_path, 'config', 'database.yml')
  template 'dummy/schema.rb',    File.join(dummy_path, 'db', 'schema.rb')
  create_file                    File.join(dummy_path, 'public', 'favicon.ico')
  create_file                    File.join(dummy_path, 'log', '.gitignore') do
    '*.log'
  end
end

#initialize_git_repoObject



64
65
66
67
68
# File 'lib/turbo/generator.rb', line 64

def initialize_git_repo
  run 'git init'
  run 'git add .'
  run 'git commit -am "initial commit"'
end