Class: Hyperloop::InstallBootstrapGenerator

Inherits:
Rails::Generators::Base show all
Defined in:
lib/generators/hyperloop/install_bootstrap_generator.rb

Instance Method Summary collapse

Instance Method Details

#add_sample_componentObject



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/generators/hyperloop/install_bootstrap_generator.rb', line 46

def add_sample_component
  create_file 'app/hyperloop/components/bs_sampler.rb' do
    "class BsSampler < Hyperloop::Component\n  render(DIV) do\nBS::Grid() do\n  BS::Row(class: \"show-grid\") do\n    BS::Col(xs: 12, md: 8) do\n      CODE { \"BS::Col(xs: 12, md: 8)\" }\n    end\n    BS::Col(xs: 6, md: 4) do\n      CODE { \"BS::Col(xs: 6, md: 4)\" }\n    end\n  end\n  BS::Row() do\n    BS::Alert(bsStyle: \"warning\") do\n      STRONG { \"Holy guacamole!\" }\n      SPAN { \" Best check yo self, you're not looking too good.\" }\n    end\n  end\nend\n  end\nend\n    RUBY\n  end\nend\n"

#add_style_sheet_pack_tagObject



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/generators/hyperloop/install_bootstrap_generator.rb', line 24

def add_style_sheet_pack_tag
  inject_into_file 'app/views/layouts/application.html.erb', after: /stylesheet_link_tag.*$/ do
    "\n<!-- Latest compiled and minified CSS -->\n<link rel=\"stylesheet\" href=\"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css\" integrity=\"sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u\" crossorigin=\"anonymous\">\n\n<!-- Optional theme -->\n<link rel=\"stylesheet\" href=\"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css\" integrity=\"sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp\" crossorigin=\"anonymous\">\n    JAVASCRIPT\n  end\nend\n"

#add_to_manifestsObject



18
19
20
21
22
# File 'lib/generators/hyperloop/install_bootstrap_generator.rb', line 18

def add_to_manifests
  add_to_manifest 'client_and_server.js' do
    "BS = require('react-bootstrap');\n"
  end
end

#build_webpackObject



42
43
44
# File 'lib/generators/hyperloop/install_bootstrap_generator.rb', line 42

def build_webpack
  system('bin/webpack') unless options['no-build']
end

#insure_yarn_loadedObject



9
10
11
12
13
14
15
16
# File 'lib/generators/hyperloop/install_bootstrap_generator.rb', line 9

def insure_yarn_loaded
  begin
    yarn_version = `yarn --version`
    raise Errno::ENOENT if yarn_version.blank?
  rescue Errno::ENOENT
    raise Thor::Error.new("please insure the yarn command is available if using webpacker")
  end
end

#run_yarnObject



37
38
39
40
# File 'lib/generators/hyperloop/install_bootstrap_generator.rb', line 37

def run_yarn
  yarn 'react-bootstrap'
  yarn 'bootstrap@3'
end