Module: EpubForge::Action::SharedActionInterface

Included in:
ThorAction
Defined in:
lib/action/thor_action.rb

Instance Method Summary collapse

Instance Method Details

#actions_lookupObject



4
5
6
7
8
9
10
# File 'lib/action/thor_action.rb', line 4

def actions_lookup
  if self == ThorAction
    @actions_lookup ||= ActionsLookup.new
  else
    ThorAction.actions_lookup
  end
end

#command_to_action_classesObject



29
30
31
32
33
34
35
# File 'lib/action/thor_action.rb', line 29

def command_to_action_classes
  if self == ThorAction
    @command_klass_lookup ||= {}
  else
    ThorAction.command_to_action_classes
  end
end

#desc(usage, description, options = {}) ⇒ Object

eventually replace description



43
44
45
46
# File 'lib/action/thor_action.rb', line 43

def desc( usage, description, options = {} )
  self.command_to_action_classes[usage] = self
  super( usage, description, options )
end

#description(str = nil) ⇒ Object



37
38
39
40
# File 'lib/action/thor_action.rb', line 37

def description( str = nil )
  @description = str if str
  @description
end

#include_standard_optionsObject



78
79
80
81
82
83
# File 'lib/action/thor_action.rb', line 78

def include_standard_options
  method_option :verbose, :type => :boolean, :default => false, :aliases => "-v"
  method_option :debug,   :type => :boolean, :default => false, :aliases => "--dbg"
  method_option :help,    :type => :boolean, :default => false, :aliases => "-h"
  method_option :project, :type => :string, :default => nil, :aliases => "--proj"
end

#keywords(*args) ⇒ Object

TODO: Get rid of this



49
50
51
52
53
54
55
56
57
# File 'lib/action/thor_action.rb', line 49

def keywords( *args )
  if args.epf_blank?
    @keywords ||= []
  else 
    @keywords = args.map(&:to_s)
  end
  
  @keywords
end

#project_not_requiredObject

Most actions require – nay, demand! – a project to act upon. Add the line ‘project_not_required’ to the class definition to keep it from failing out if it can’t find an existing project. Used for things like initializing new projects, or… my imagination fails me.



74
75
76
# File 'lib/action/thor_action.rb', line 74

def project_not_required
  @project_required = false
end

#project_required?Boolean

Returns:

  • (Boolean)


64
65
66
67
# File 'lib/action/thor_action.rb', line 64

def project_required?
  @project_required = true if @project_required.nil?
  @project_required
end

#register_action_subclass(klass) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/action/thor_action.rb', line 12

def register_action_subclass( klass )
  if self == ThorAction
    @subclasses ||= []
    @subclasses = (@subclasses + [klass]).uniq
  else
    ThorAction.register_action_subclass( klass )
  end
end

#subclassesObject



21
22
23
24
25
26
27
# File 'lib/action/thor_action.rb', line 21

def subclasses
  if self == ThorAction
    @subclasses
  else
    ThorAction.subclasses
  end
end

#usage(str = nil) ⇒ Object



59
60
61
62
# File 'lib/action/thor_action.rb', line 59

def usage( str = nil )
  @usage = str if str
  @usage
end