Module: CLIForge

Extended by:
AutoloadConvention
Defined in:
lib/cli_forge/autoload_convention.rb,
lib/cli_forge.rb,
lib/cli_forge/version.rb

Overview

Autoload Convention

We adhere to a strict convention for the constants in this library:

‘Camel::Caps::BasedConstants` map to their underscore variants of `camel/caps/based_constants`.

Each autoloadable parent module/class only needs to to ‘extend` the `AutoloadConvention` to bootstrap this behavior.

Defined Under Namespace

Modules: AutoloadConvention, EmbeddedCommands Classes: BinCommand, CommandSet, Configuration, DefaultConfiguration, Runner

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Methods included from AutoloadConvention

const_missing

Class Method Details

.caller_path(stack_line) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/cli_forge.rb', line 24

def self.caller_path(stack_line)
  return unless stack_line
  stack_path = stack_line.split(":").first
  return if stack_path =~ /^\(.*\)$/

  File.expand_path(File.dirname(stack_path))
end

.guess_bin_nameObject



20
21
22
# File 'lib/cli_forge.rb', line 20

def self.guess_bin_name
  File.basename($0)
end

.start(bin_name = nil, &block) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/cli_forge.rb', line 6

def self.start(bin_name=nil, &block)
  config = CLIForge::DefaultConfiguration.new

  config.search_paths  = Array(caller_path(caller.first))
  config.search_paths += ENV["PATH"].split(":")
  config.search_paths.uniq!

  block.call(config) if block

  config.bin_name ||= bin_name || guess_bin_name

  CLIForge::Runner.new(config).start(ARGV)
end