Sha256: 89b746124829123cd92f428476826ed67badb90b6e95c80bc619f831f3ed5606

Contents?: true

Size: 1.45 KB

Versions: 11

Compression:

Stored size: 1.45 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"
  get '/main', :to => "file_handler#main"
  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/main.html.erb", "app/views/file_handler/main.html.erb"
    copy_file "app/views/file_handler/index.html.erb", "app/views/file_handler/index.html.erb"
  end

end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
browse-everything-0.6.3 spec/support/lib/generators/test_app_generator.rb
browse-everything-0.6.2 spec/support/lib/generators/test_app_generator.rb
browse-everything-0.6.1 spec/support/lib/generators/test_app_generator.rb
browse-everything-0.6.0 spec/support/lib/generators/test_app_generator.rb
browse-everything-0.5.2 spec/support/lib/generators/test_app_generator.rb
browse-everything-0.5.1 spec/support/lib/generators/test_app_generator.rb
browse-everything-0.5.0 spec/support/lib/generators/test_app_generator.rb
browse-everything-0.4.5 spec/support/lib/generators/test_app_generator.rb
browse-everything-0.4.4 spec/support/lib/generators/test_app_generator.rb
browse-everything-0.4.3 spec/support/lib/generators/test_app_generator.rb
browse-everything-0.4.2 spec/support/lib/generators/test_app_generator.rb