Sha256: af477ef1476a9d5dcdebeea4ec66c21e8de10643e2fca6d05a7814632e701271

Contents?: true

Size: 1.32 KB

Versions: 7

Compression:

Stored size: 1.32 KB

Contents

require_relative 'install_generator_base'
module Hyperloop
  class  InstallMuiGenerator < Rails::Generators::Base

    desc "Adds the bits you need for the MUI framework"

    class_option 'no-build', type: :boolean

    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

    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

    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

    def run_yarn
      yarn 'muicss'
    end

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

    def add_sample_component
      create_file 'app/hyperloop/components/mui_sampler.rb' do
        <<-RUBY
class MuiSampler < Hyperloop::Component
  render(DIV) do
    Mui::Appbar()
    Mui::Container() do
      Mui::Button(color: :primary) { 'button' }
    end
  end
end
        RUBY
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
hyperloop-0.99.6 lib/generators/hyperloop/install_mui_generator.rb
hyperloop-0.99.5 lib/generators/hyperloop/install_mui_generator.rb
hyperloop-0.99.4 lib/generators/hyperloop/install_mui_generator.rb
hyperloop-0.99.3 lib/generators/hyperloop/install_mui_generator.rb
hyperloop-0.99.2 lib/generators/hyperloop/install_mui_generator.rb
hyperloop-0.99.1 lib/generators/hyperloop/install_mui_generator.rb
hyperloop-0.99.0 lib/generators/hyperloop/install_mui_generator.rb