Class: NpmPipeline::Generators::BrunchGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/npm_pipeline/brunch_generator.rb

Instance Method Summary collapse

Instance Method Details

#create_brunch_configObject



13
14
15
# File 'lib/generators/npm_pipeline/brunch_generator.rb', line 13

def create_brunch_config
  template 'brunch-config.js', 'brunch-config.js'
end

#create_package_jsonObject



9
10
11
# File 'lib/generators/npm_pipeline/brunch_generator.rb', line 9

def create_package_json
  template 'package.json', 'package.json'
end

#create_sample_brunch_cssObject



24
25
26
27
# File 'lib/generators/npm_pipeline/brunch_generator.rb', line 24

def create_sample_brunch_css
  create_file 'app/brunch/example.css',
    %(html:before { content: 'Brunch assets added successfully! Edit app/brunch/example.css or remove it.'; display: block; padding: 20px; background: #ffc; color: #111; position: fixed; top: 16px; right: 16px; max-width: 600px; z-index: 10000; font-family: sans-serif; font-size: 14px; line-height: 1.6; }\n)
end

#create_sample_brunch_jsObject



29
30
31
32
# File 'lib/generators/npm_pipeline/brunch_generator.rb', line 29

def create_sample_brunch_js
  create_file 'app/brunch/example.js',
    "alert('Brunch works!')"
end

#update_assetsObject



17
18
19
20
21
22
# File 'lib/generators/npm_pipeline/brunch_generator.rb', line 17

def update_assets
  append_to_file 'app/assets/stylesheets/application.css',
    "/*\n *= require brunch/app\n */\n"
  append_to_file 'app/assets/javascripts/application.js',
    "//= require brunch/app\n"
end

#update_gitignoreObject



34
35
36
37
38
39
# File 'lib/generators/npm_pipeline/brunch_generator.rb', line 34

def update_gitignore
  append_to_file '.gitignore',
    "\n/node_modules" +
    "\n/vendor/assets/stylesheets/brunch" +
    "\n/vendor/assets/javascripts/brunch\n"
end