Class: Rake::Pipeline::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/rake/pipeline/install/install_generator.rb

Instance Method Summary collapse

Instance Method Details

#add_assetfileObject

TODO: Support asset-pipeline like API


38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/generators/rake/pipeline/install/install_generator.rb', line 38

def add_assetfile
  create_file "Assetfile", <<-RUBY.strip_heredoc
    # NOTE: The Assetfile will eventually be replaced with an asset-pipeline
    # compatible API. This is mostly important so that plugins can easily
    # inject into the pipeline.
    #
    # Depending on demand and how the API shakes out, we may retain the
    # Assetfile API but pull in the information from the Rails API.

    input "app/assets"
    output "public"

    match "*.js" do
      concat "application.js"
    end

    match "*.css" do
      concat "application.css"
    end

    # copy any remaining files
    concat
  RUBY
end

#disable_asset_pipeline_configObject

TODO: Support sprockets API


20
21
22
23
24
25
# File 'lib/generators/rake/pipeline/install/install_generator.rb', line 20

def disable_asset_pipeline_config
  regex = /^\n?\s*#.*\n\s*(#\s*)?config\.assets.*\n/
  gsub_file app, regex, ''
  gsub_file Rails.root.join("config/environments/development.rb"), regex, ''
  gsub_file Rails.root.join("config/environments/production.rb"), regex, ''
end

#disable_asset_pipeline_railtieObject


7
8
9
10
11
12
13
14
15
16
17
# File 'lib/generators/rake/pipeline/install/install_generator.rb', line 7

def disable_asset_pipeline_railtie
  say_status :config, "Updating configuration to remove asset pipeline"
  gsub_file app, "require 'rails/all'", <<-RUBY.strip_heredoc
    # Pick the frameworks you want:
    require "active_record/railtie"
    require "action_controller/railtie"
    require "action_mailer/railtie"
    require "active_resource/railtie"
    require "rails/test_unit/railtie"
  RUBY
end

#enable_assets_in_developmentObject


33
34
35
# File 'lib/generators/rake/pipeline/install/install_generator.rb', line 33

def enable_assets_in_development
  gsub_file "config/environments/development.rb", /^end/, "\n  config.rake_pipeline_enabled = true\nend"
end

#remove_assets_groupObject


27
28
29
30
31
# File 'lib/generators/rake/pipeline/install/install_generator.rb', line 27

def remove_assets_group
  regex = /^\n(#.*\n)+group :assets.*\n(.*\n)*?end\n/

  gsub_file "Gemfile", regex, ''
end