Module: Nib

Defined in:
lib/nib.rb,
lib/nib/version.rb

Defined Under Namespace

Modules: Command, History, Options Classes: CheckForUpdate, CodeClimate, Console, Debug, Exec, Run, Setup, Shell, UnrecognizedHelp, Update

Constant Summary collapse

GEM_ROOT =
File.expand_path('../..', __FILE__)
VERSION =
File.read(File.expand_path('../../../VERSION', __FILE__)).freeze

Class Method Summary collapse

Class Method Details

.available_pluginsObject



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/nib.rb', line 29

def available_plugins
  Gem.find_files('nib*_plugin.rb').sort.map do |plugin_path|
    name = File.basename plugin_path, '_plugin.rb'

    require plugin_path

    next unless const_for(name).applies?

    plugin_base_path = plugin_path[0..-"/lib/#{name}_plugin.rb".length]

    "#{plugin_base_path}bin/#{name.tr('_', '-')}"
  end.compact
end

.const_for(name) ⇒ Object



43
44
45
# File 'lib/nib.rb', line 43

def const_for(name)
  Nib.const_get(name.split('_').map(&:capitalize).join('::'))
end

.load_default_config(command, file_name) ⇒ Object



47
48
49
# File 'lib/nib.rb', line 47

def load_default_config(command, file_name)
  File.read("#{GEM_ROOT}/config/commands/#{command}/#{file_name}")
end