class Gaku::DummyGenerator
Constants
- PASSTHROUGH_OPTIONS
Attributes
lib_name[R]
Public Class Methods
source_paths()
click to toggle source
# 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
Public Instance Methods
clean_up()
click to toggle source
# File lib/generators/gaku/dummy/dummy_generator.rb, line 15 def clean_up remove_directory_if_exists(dummy_path) end
generate_test_dummy()
click to toggle source
# 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_clean()
click to toggle source
# 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_config()
click to toggle source
# 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
Protected Instance Methods
application_definition()
click to toggle source
# File lib/generators/gaku/dummy/dummy_generator.rb, line 71 def application_definition @application_definition ||= begin dummy_application_path = File.expand_path("#{dummy_path}/config/application.rb", destination_root) unless options[:pretend] || !File.exist?(dummy_application_path) contents = File.read(dummy_application_path) contents[(contents.index("module #{module_name}"))..-1] end end end
Also aliased as: store_application_definition!
camelized()
click to toggle source
# File lib/generators/gaku/dummy/dummy_generator.rb, line 84 def camelized @camelized ||= name.gsub(/\W/, '_').squeeze('_').camelize end
dummy_path()
click to toggle source
# File lib/generators/gaku/dummy/dummy_generator.rb, line 63 def dummy_path ENV['DUMMY_PATH'] || 'spec/dummy' end
gemfile_path()
click to toggle source
# File lib/generators/gaku/dummy/dummy_generator.rb, line 92 def gemfile_path version_file = File.expand_path('../../Versionfile', Dir.pwd) if File.exist?(version_file) '../../../../Gemfile' else '../../../../../Gemfile' end end
module_name()
click to toggle source
# File lib/generators/gaku/dummy/dummy_generator.rb, line 67 def module_name 'Dummy' end
remove_directory_if_exists(path)
click to toggle source
# File lib/generators/gaku/dummy/dummy_generator.rb, line 88 def remove_directory_if_exists(path) remove_dir(path) if File.directory?(path) end