Class: T3::Generators::BootstrapGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
GeneratorHelper
Defined in:
lib/generators/t3/bootstrap_generator.rb

Instance Method Summary collapse

Instance Method Details

#create_directoriesObject



11
12
13
14
15
16
# File 'lib/generators/t3/bootstrap_generator.rb', line 11

def create_directories
  components.each do |c|
    empty_directory "#{install_path}/#{c}"
    create_file "#{install_path}/#{c}/.gitkeep" unless options[:skip_git]
  end
end

#inject_t3Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/generators/t3/bootstrap_generator.rb', line 18

def inject_t3
  requires = "//= require t3\n"

  requires += components.map { |dir|
    "//= require_tree ./#{dir}"
  }.join("\n") + "\n"

  inject_into_file "#{install_path}/application.js", requires,
    before: '//= require_tree .'

  # If //= require_tree . does not exist, inject at the bottom
  # (Thor ensures that the content is not injected more than once)
  inject_into_file "#{install_path}/application.js", requires,
    before: %r{\z}
end