Class: Hyperloop::InstallMuiGenerator

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

Instance Method Summary collapse

Instance Method Details

#add_sample_componentObject



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_tagObject



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_manifestsObject



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_webpackObject



33
34
35
# File 'lib/generators/hyperloop/install_mui_generator.rb', line 33

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_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_yarnObject



29
30
31
# File 'lib/generators/hyperloop/install_mui_generator.rb', line 29

def run_yarn
  yarn 'muicss'
end