Class: BootstrapAssets::Generators::InstallGenerator

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

Instance Method Summary collapse

Instance Method Details

#add_assetsObject



41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/generators/bootstrap_assets/install/install_generator.rb', line 41

def add_assets
  text = "@import \"twitter/bootstrap/bootstrap\";\n// Set the correct sprite paths\n@iconSpritePath: asset-path('twitter/bootstrap/glyphicons-halflings.png');\n@iconWhiteSpritePath: asset-path('twitter/bootstrap/glyphicons-halflings-white.png');\n"

  add_bootstrap_file 'vendor/assets/stylesheets/twitter/bootstrap.css.less', text
  add_bootstrap_file 'vendor/assets/stylesheets/twitter/responsive.css.less', '@import "twitter/bootstrap/responsive";'
  add_bootstrap_file 'vendor/assets/javascripts/twitter/bootstrap.js', '//=require_directory "./bootstrap"'
end

#download_assetsObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/generators/bootstrap_assets/install/install_generator.rb', line 11

def download_assets
  plugins = %w(alert button carousel collapse dropdown modal popover scrollspy tab tooltip transition typeahead)
  less = %w(accordion alerts bootstrap breadcrumbs button-groups buttons carousel close code component-animations dropdowns forms grid hero-unit labels-badges layouts mixins modals navbar navs pager pagination popovers progress-bars reset responsive-767px-max responsive-768px-979px responsive-1200px-min responsive-navbar responsive-utilities responsive scaffolding sprites tables thumbnails tooltip type utilities variables wells)
  images = %w(glyphicons-halflings-white glyphicons-halflings)


  js_path = 'vendor/assets/javascripts/twitter/bootstrap'
  less_path = 'vendor/assets/stylesheets/twitter/bootstrap'
  img_path =  'vendor/assets/images/twitter/bootstrap'

  FileUtils.mkdir_p(js_path)
  FileUtils.mkdir_p(less_path)
  FileUtils.mkdir_p(img_path)

  plugins.each do |plugin|
    filename = "bootstrap-#{plugin}.js"
    download("https://raw.github.com/twitter/bootstrap/master/js/#{filename}", "#{js_path}/#{filename}")
  end

  less.each do |l|
    filename = "#{l}.less"
    download("https://raw.github.com/twitter/bootstrap/master/less/#{filename}", "#{less_path}/#{filename}")
  end

  images.each do |image|
    filename = "#{image}.png"
    download("https://github.com/twitter/bootstrap/raw/master/img/#{filename}", "#{img_path}/#{filename}")
  end
end