Class: RoCommands::Base

Inherits:
Thor
  • Object
show all
Includes:
Bash, Thor::Actions
Defined in:
lib/ro_commands/base.rb

Class Method Summary collapse

Methods included from Bash

#_bash, #add_time, #bash, #bash_capture, #bash_capture_array, #bash_lines, #bash_per, #bash_system, #bundle_exec, #err, err, #handle_path, #kernel_system, out, #out, #status, status

Class Method Details

.describe(action, item, shortcut_item) ⇒ Object



96
97
98
# File 'lib/ro_commands/base.rb', line 96

def describe(action, item, shortcut_item)
  "#{action} #{item}"
end

.inherited(sub) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/ro_commands/base.rb', line 54

def inherited(sub)
  sub.class_eval do
    class << self
      def get_source_root
        file_path = ::File.join(RoCommands.lib, name.split("::").map(&:uncamelize).join("/"))
        dir_path = ::File.dirname file_path
        template_path = File.join(dir_path, "templates")
      end
    end

    source_root(get_source_root)
  end
end

.method_added(method) ⇒ Object



79
80
81
82
83
84
# File 'lib/ro_commands/base.rb', line 79

def method_added(method)
  super
  unless method.match(%r{drb_})
    meths << method
  end
end

.methsObject



86
87
88
89
90
# File 'lib/ro_commands/base.rb', line 86

def meths
  @meths.flatten! if @meths.respond_to?(:flatten!)
  @meths.uniq! if @meths.respond_to?(:uniq!)
  @meths ||= []
end

.start(given_args = ARGV, config = {}) ⇒ Object



68
69
70
71
72
73
74
75
76
77
# File 'lib/ro_commands/base.rb', line 68

def start(given_args=ARGV, config={})
  given_args.flatten!
  opt = given_args.extract_options!
  if opt and opt[:pwd]
    Dir.chdir opt[:pwd]
    Out.out("Current working path is #{opt[:pwd]}")
  end
  given_args = given_args - [{pwd: opt[:pwd]}]
  super
end

.usage(meth_name) ⇒ Object



92
93
94
# File 'lib/ro_commands/base.rb', line 92

def usage(meth_name)
  "#{name.split("::")[-1].uncamelize} #{meth_name}"
end