Class: Bones::App::Plugins

Inherits:
Command show all
Defined in:
lib/bones/app/plugins.rb

Constant Summary

Constants inherited from Command

Command::DEFAULT_SKELETON

Constants included from Colors

Colors::COLORS

Instance Attribute Summary

Attributes inherited from Command

#config, #stderr, #stdout

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Command

#in_directory, inherited, #initialize, #mrbones_dir, #name, #output_dir, #parse, #repository, #skeleton_dir, #standard_options, standard_options, #verbose?

Methods included from Colors

#colorize, #colorize?

Constructor Details

This class inherits a constructor from Bones::App::Command

Class Method Details

.initialize_pluginsObject



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

def self.initialize_plugins
  synopsis 'bones plugins [options]'

  summary 'list available Mr Bones plugins'

  description <<-__
Parse the installed gems and then search for Mr Bones plugins related to
those gems. Passing in the 'all' flag will show plugins even if the related
gems are not installed.
  __

  option('-a', '--all', 'Show all plugins.', lambda { |_| config[:all] = true })
  option(standard_options[:colorize])
end

Instance Method Details

#all?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/bones/app/plugins.rb', line 43

def all?
  config[:all]
end

#runObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/bones/app/plugins.rb', line 20

def run
  stdout.write 'Looking up avaialble Mr Bones plugins ... '
  stdout.flush
  plugins = find_bones_plugins
  stdout.puts 'done!'
  stdout.puts

  if all?
    plugins.each { |name, version| show_plugin(name, version) }
  else
    gemspecs = find_gemspecs
    plugins.each { |name, version|
      gemspecs.each { |gem_name, gem_version|
        next unless name.downcase == gem_name.downcase
        next if version && version != gem_version
        show_plugin(name, version)
      }
    }
  end

  stdout.puts
end

#show_plugin(name, version) ⇒ Object



47
48
49
50
51
52
# File 'lib/bones/app/plugins.rb', line 47

def show_plugin( name, version )
  name = "bones-#{name}"
  name << "-#{version}" if version

  stdout.puts("  [%s]  %s" % [installed?(name) ? colorize('installed', :green) : colorize('available', :cyan), name])
end