Class: ReactiveRuby::TestAppGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- ReactiveRuby::TestAppGenerator
- Defined in:
- lib/generators/reactive_ruby/test_app/test_app_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #clean_superfluous_files ⇒ Object
- #configure_opal_rspec ⇒ Object
- #configure_test_app ⇒ Object
- #generate_test_app ⇒ Object
- #remove_existing_app ⇒ Object
Class Method Details
.source_paths ⇒ Object
5 6 7 8 9 |
# File 'lib/generators/reactive_ruby/test_app/test_app_generator.rb', line 5 def self.source_paths paths = self.superclass.source_paths paths << File.('../templates', __FILE__) paths.flatten end |
Instance Method Details
#clean_superfluous_files ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/generators/reactive_ruby/test_app/test_app_generator.rb', line 43 def clean_superfluous_files inside test_app_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.rdoc' remove_file 'test' remove_file 'vendor' remove_file 'spec' end end |
#configure_opal_rspec ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/generators/reactive_ruby/test_app/test_app_generator.rb', line 60 def configure_opal_rspec inject_into_file "#{test_app_path}/config/application.rb", after: /class Application < Rails::Application/, verbose: true do %Q[ config.opal.method_missing = true config.opal.optimized_operators = true config.opal.arity_check = false config.opal.const_missing = true config.opal.dynamic_require_severity = :ignore config.opal.enable_specs = true config.opal.spec_location = 'spec-opal' ] end end |
#configure_test_app ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/generators/reactive_ruby/test_app/test_app_generator.rb', line 26 def configure_test_app template 'boot.rb.erb', "#{test_app_path}/config/boot.rb", force: true template 'test_application.rb.erb', "#{test_app_path}/config/application.rb", force: true template 'assets/javascripts/test_application.rb', "#{test_app_path}/app/assets/javascripts/application.rb", force: true template 'assets/javascripts/components.rb', "#{test_app_path}/app/views/components.rb", force: true template 'views/components/hello_world.rb', "#{test_app_path}/app/views/components/hello_world.rb", force: true template 'views/components/todo.rb', "#{test_app_path}/app/views/components/todo.rb", force: true template 'views/layouts/test_layout.html.erb', "#{test_app_path}/app/views/layouts/test_layout.html.erb", force: true template 'views/layouts/test_layout.html.erb', "#{test_app_path}/app/views/layouts/explicit_layout.html.erb", force: true end |
#generate_test_app ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/generators/reactive_ruby/test_app/test_app_generator.rb', line 15 def generate_test_app opts = .dup opts[:database] = 'sqlite3' if opts[:database].blank? opts[:force] = true opts[:skip_bundle] = true puts "Generating Test Rails Application..." invoke ::Rails::Generators::AppGenerator, [ File.(test_app_path, destination_root) ], opts end |
#remove_existing_app ⇒ Object
11 12 13 |
# File 'lib/generators/reactive_ruby/test_app/test_app_generator.rb', line 11 def remove_existing_app remove_dir(test_app_path) if File.directory?(test_app_path) end |