class MiddlemanEmberScaffold::Generators::Scaffold

Public Class Methods

source_root() click to toggle source
# File lib/middleman_ember_scaffold/generators/scaffold.rb, line 5
def self.source_root
  File.expand_path(File.dirname(__FILE__), "../template")
end

Public Instance Methods

scaffold(*args) click to toggle source
# File lib/middleman_ember_scaffold/generators/scaffold.rb, line 10
def scaffold(*args)
  destination_root=args[0]
  src = File.expand_path(File.join(File.dirname(__FILE__), "../template"))
  directory(src, destination_root)
  Dir.chdir(destination_root)
  run_bundle
  bundle_command('exec middleman build')
end

Private Instance Methods

bundle_command(command) click to toggle source

steal bundle command from rails app generator

# File lib/middleman_ember_scaffold/generators/scaffold.rb, line 23
def bundle_command(command)
  say_status :run, "bundle #{command}"

  # We are going to shell out rather than invoking Bundler::CLI.new(command)
  # because `mes new` loads the Thor gem and on the other hand bundler uses
  # its own vendored Thor, which could be a different version. Running both
  # things in the same process is a recipe for a night with paracetamol.
  #
  # We use backticks and #print here instead of vanilla #system because it
  # is easier to silence stdout in the existing test suite this way. The
  # end-user gets the bundler commands called anyway, so no big deal.
  #
  # We unset temporary bundler variables to load proper bundler and Gemfile.
  #
  # Thanks to James Tucker for the Gem tricks involved in this call.
  _bundle_command = Gem.bin_path('bundler', 'bundle')

  require 'bundler'
  Bundler.with_clean_env do
    print `"#{Gem.ruby}" "#{_bundle_command}" #{command}`
  end
end
run_bundle() click to toggle source
# File lib/middleman_ember_scaffold/generators/scaffold.rb, line 46
def run_bundle
  bundle_command('install')
end