Class: Hyperloop::InstallMuiGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Thor::Group
- Rails::Generators::Base
- Hyperloop::InstallMuiGenerator
- Defined in:
- lib/generators/hyperloop/install_mui_generator.rb
Instance Method Summary collapse
- #add_sample_component ⇒ Object
- #add_style_sheet_pack_tag ⇒ Object
- #add_to_manifests ⇒ Object
- #build_webpack ⇒ Object
- #insure_yarn_loaded ⇒ Object
- #run_yarn ⇒ Object
Instance Method Details
#add_sample_component ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/generators/hyperloop/install_mui_generator.rb', line 37 def add_sample_component create_file 'app/hyperloop/components/mui_sampler.rb' do "class MuiSampler < Hyperloop::Component\n render(DIV) do\nMui::Appbar()\nMui::Container() do\n Mui::Button(color: :primary) { 'button' }\nend\n end\nend\n RUBY\n end\nend\n" |
#add_style_sheet_pack_tag ⇒ Object
23 24 25 26 27 |
# File 'lib/generators/hyperloop/install_mui_generator.rb', line 23 def add_style_sheet_pack_tag inject_into_file 'app/views/layouts/application.html.erb', after: /stylesheet_link_tag.*$/ do "\n <%= stylesheet_pack_tag 'application' %>\n" end end |
#add_to_manifests ⇒ Object
18 19 20 21 |
# File 'lib/generators/hyperloop/install_mui_generator.rb', line 18 def add_to_manifests add_to_manifest('client_and_server.js') { "Mui = require('muicss/react');\n" } add_to_manifest('application.scss') { "@import '~muicss/lib/sass/mui'\n" } end |
#build_webpack ⇒ Object
33 34 35 |
# File 'lib/generators/hyperloop/install_mui_generator.rb', line 33 def build_webpack system('bin/webpack') unless ['no-build'] end |
#insure_yarn_loaded ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/generators/hyperloop/install_mui_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_yarn ⇒ Object
29 30 31 |
# File 'lib/generators/hyperloop/install_mui_generator.rb', line 29 def run_yarn yarn 'muicss' end |