module Nrb::Commands::ScriptGenerator

This module adds the :path_or_folder_name required argument, and some helper flags like: –init-repo, –bundle-install, –local.

Private Instance Methods

add_local_path(text) click to toggle source
# File lib/nrb/commands/concerns/script_generator.rb, line 49
def add_local_path(text)
  local_gem_path = Pathname.new(File.expand_path('../../../..', __dir__))
  target_path    = Pathname.new(target)
  relative_path  = local_gem_path.relative_path_from(target_path)
  text << ", path: '#{relative_path}'"
end
name() click to toggle source
# File lib/nrb/commands/concerns/script_generator.rb, line 39
def name
  File.basename(path_or_folder_name)
end
nrb_gem() click to toggle source
# File lib/nrb/commands/concerns/script_generator.rb, line 43
def nrb_gem
  text = "gem 'nrb', '#{Nrb::VERSION}'"
  add_local_path(text) if options[:local]
  text
end
silent_command(command) click to toggle source
# File lib/nrb/commands/concerns/script_generator.rb, line 31
def silent_command(command)
  Nrb::Utils.silently { run command }
end
target(final = nil) click to toggle source
# File lib/nrb/commands/concerns/script_generator.rb, line 35
def target(final = nil)
  File.join(File.expand_path(path_or_folder_name), final.to_s)
end
try_loud_command(command) click to toggle source
# File lib/nrb/commands/concerns/script_generator.rb, line 27
def try_loud_command(command)
  opts[:verbose] ? run(command) : silent_command(command)
end