Class: Gaku::DummyGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/gaku/dummy/dummy_generator.rb

Constant Summary collapse

PASSTHROUGH_OPTIONS =
[
  :skip_active_record, :skip_javascript, :javascript, :quiet, :pretend, :force, :skip
]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#lib_nameObject (readonly)

Returns the value of attribute lib_name.



59
60
61
# File 'lib/generators/gaku/dummy/dummy_generator.rb', line 59

def lib_name
  @lib_name
end

Class Method Details

.source_pathsObject



9
10
11
12
13
# File 'lib/generators/gaku/dummy/dummy_generator.rb', line 9

def self.source_paths
  paths = superclass.source_paths
  paths << File.expand_path('../templates', __FILE__)
  paths.flatten
end

Instance Method Details

#clean_upObject



15
16
17
# File 'lib/generators/gaku/dummy/dummy_generator.rb', line 15

def clean_up
  remove_directory_if_exists(dummy_path)
end

#generate_test_dummyObject



23
24
25
26
27
28
29
30
# File 'lib/generators/gaku/dummy/dummy_generator.rb', line 23

def generate_test_dummy
  opts = (options || {}).slice(*PASSTHROUGH_OPTIONS)
  opts[:force] = true
  opts[:skip_bundle] = true
  opts[:old_style_hash] = true
  puts 'Generating dummy Rails application...'
  invoke Rails::Generators::AppGenerator, [File.expand_path(dummy_path, destination_root)], opts
end

#test_dummy_cleanObject



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/generators/gaku/dummy/dummy_generator.rb', line 42

def test_dummy_clean
  inside dummy_path do
    remove_file '.gitignore'
    remove_file 'doc'
    remove_file 'Gemfile'
    remove_file 'lib/tasks'
    remove_file 'app/assets/images/rails.png'
    remove_file 'app/assets/javascripts/application.js'
    remove_file 'public/index.html'
    remove_file 'public/robots.txt'
    remove_file 'README'
    remove_file 'test'
    remove_file 'vendor'
    remove_file 'spec'
  end
end

#test_dummy_configObject



32
33
34
35
36
37
38
39
40
# File 'lib/generators/gaku/dummy/dummy_generator.rb', line 32

def test_dummy_config
  @lib_name = options[:lib_name]

  template 'rails/database.yml', "#{dummy_path}/config/database.yml", force: true
  template 'rails/boot.rb', "#{dummy_path}/config/boot.rb", force: true
  template 'rails/application.rb', "#{dummy_path}/config/application.rb", force: true
  template 'rails/routes.rb', "#{dummy_path}/config/routes.rb", force: true
  template 'rails/script/rails', "#{dummy_path}/spec/dummy/script/rails", force: true
end