Sha256: f7f36a5a0b2b6dc0ea44005988a1de19f4b15f88615f098d67212e801aff721f

Contents?: true

Size: 1.32 KB

Versions: 2

Compression:

Stored size: 1.32 KB

Contents

require 'rails/generators'

class TestAppGenerator < Rails::Generators::Base
  source_root File.expand_path("../../../../support", __FILE__)
  
  def run_config_generator
    generate "browse_everything:config"
  end
  
  def inject_css
    copy_file "../internal/app/assets/stylesheets/application.css", "app/assets/stylesheets/application.css.scss"
    remove_file "app/assets/stylesheets/application.css"
    insert_into_file "app/assets/stylesheets/application.css.scss", :after => '*/' do
      %{\n\n@import "browse_everything"}
    end
  end

  def inject_javascript
    insert_into_file "app/assets/javascripts/application.js", :after => '//= require_tree .' do
      "\n//= require browse_everything"
    end
  end

  def inject_application
    insert_into_file "config/application.rb", :after => 'Rails::Application' do
      "\nconfig.autoload_paths+=[File.join(Rails.root,'../../lib')]"
    end
  end

  def inject_routes
    insert_into_file "config/routes.rb", :after => ".draw do" do
      %{

  root :to => "file_handler#index"
  post '/file', :to => "file_handler#update"
      }
    end
  end

  def create_test_route
    copy_file "app/controllers/file_handler_controller.rb", "app/controllers/file_handler_controller.rb"
    copy_file "app/views/file_handler/index.html.erb", "app/views/file_handler/index.html.erb"
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
browse-everything-0.4.1 spec/support/lib/generators/test_app_generator.rb
browse-everything-0.4.0 spec/support/lib/generators/test_app_generator.rb