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", "# NOTE: The Assetfile will eventually be replaced with an asset-pipeline\n# compatible API. This is mostly important so that plugins can easily\n# inject into the pipeline.\n#\n# Depending on demand and how the API shakes out, we may retain the\n# Assetfile API but pull in the information from the Rails API.\n\ninput \"app/assets\"\noutput \"public\"\n\nmatch \"*.js\" do\nconcat \"application.js\"\nend\n\nmatch \"*.css\" do\nconcat \"application.css\"\nend\n\n# copy any remaining files\nconcat\n".strip_heredoc
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'", "# Pick the frameworks you want:\nrequire \"active_record/railtie\"\nrequire \"action_controller/railtie\"\nrequire \"action_mailer/railtie\"\nrequire \"active_resource/railtie\"\nrequire \"rails/test_unit/railtie\"\n".strip_heredoc
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