Class: Decidim::Generators::DummyGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Decidim::Generators::DummyGenerator
- Defined in:
- lib/generators/decidim/dummy_generator.rb
Overview
Generates a dummy test Rails app for the given library folder. It uses the ‘AppGenerator` class to actually generate the Rails app, so this generator only sets the path and some flags.
The Rails app will be installed with some flags to disable git, tests, Gemfile and other options. Refer to the ‘create_dummy_app` method to see all the flags passed to the `AppGenerator` class, which is the one that actually generates the Rails app.
Remember that, because of how generators work, actions are executed based on the definition order of the public methods.
Instance Method Summary collapse
- #cleanup ⇒ Object
- #create_dummy_app ⇒ Object
- #decidim_dev ⇒ Object
- #source_paths ⇒ Object
- #test_env ⇒ Object
Instance Method Details
#cleanup ⇒ Object
34 35 36 |
# File 'lib/generators/decidim/dummy_generator.rb', line 34 def cleanup remove_directory_if_exists(dummy_app_path) end |
#create_dummy_app ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/generators/decidim/dummy_generator.rb', line 38 def create_dummy_app Decidim::Generators::AppGenerator.start [ dummy_app_path, "--path", "../..", "--app_const_base=DummyApplication", "--recreate_db", "--skip_gemfile=#{[:skip_gemfile]}", "--demo" ] end |
#decidim_dev ⇒ Object
50 51 52 53 54 55 56 57 |
# File 'lib/generators/decidim/dummy_generator.rb', line 50 def decidim_dev # TODO: Remove these after PhantomJS updates WebKit version (see YML and # initializer comments) template "autoprefixer.yml", "#{dummy_app_path}/config/autoprefixer.yml" template "autoprefixer_initializer.rb", "#{dummy_app_path}/config/initializers/autoprefixer.rb" template "no_animations.rb", "#{dummy_app_path}/app/middleware/no_animations.rb" end |
#source_paths ⇒ Object
28 29 30 31 32 |
# File 'lib/generators/decidim/dummy_generator.rb', line 28 def source_paths [ File.("templates", __dir__) ] end |
#test_env ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/generators/decidim/dummy_generator.rb', line 59 def test_env gsub_file "#{dummy_app_path}/config/environments/test.rb", /allow_forgery_protection = (.*)/, "allow_forgery_protection = true" inject_into_file "#{dummy_app_path}/config/environments/test.rb", after: "allow_forgery_protection = true\n" do <<~RUBY.gsub(/^ *\|/, "") | | # Inject middleware to disable CSS animations | config.middleware.use NoAnimations | RUBY end end |