Class: Birdwatcher::Command

Defined Under Namespace

Classes: Error, InvalidMetadataError, MetadataNotSetError

Constant Summary collapse

ARGUMENT_SEPARATOR =
" ".freeze

Constants included from Birdwatcher::Concerns::Concurrency

Birdwatcher::Concerns::Concurrency::DEFAULT_THREAD_POOL_SIZE

Constants included from Birdwatcher::Concerns::Core

Birdwatcher::Concerns::Core::DATA_DIRECTORY

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Birdwatcher::Concerns::Concurrency

included, #thread_pool

Methods included from Birdwatcher::Concerns::Persistence

included, #save_status, #save_user

Methods included from Birdwatcher::Concerns::Presentation

included, #make_status_summary_output, #make_url_summary_output, #make_user_details_output, #make_user_summary_output, #output_status_summary, #output_user_details, #output_user_summary, #page_text

Methods included from Birdwatcher::Concerns::Outputting

#confirm, #error, #fatal, included, #info, #line_separator, #newline, #output, #output_formatted, #task, #warn

Methods included from Birdwatcher::Concerns::Util

#escape_html, #excerpt, included, #number_to_human_size, #parse_time, #pluralize, #strip_control_characters, #strip_html, #suppress_output, #suppress_warnings, #time_ago_in_words, #unescape_html

Methods included from Birdwatcher::Concerns::Core

#console, #current_workspace, #current_workspace=, #database, included, #klout_client, #read_data_file, #twitter_client

Instance Attribute Details

#argumentsObject (readonly)

Returns the value of attribute arguments.



9
10
11
# File 'lib/birdwatcher/command.rb', line 9

def arguments
  @arguments
end

Class Method Details

.auto_completionObject



41
42
43
# File 'lib/birdwatcher/command.rb', line 41

def self.auto_completion
  []
end

.auto_completion_stringsObject



37
38
39
# File 'lib/birdwatcher/command.rb', line 37

def self.auto_completion_strings
  (meta[:names] + auto_completion).uniq
end

.descendantsObject



29
30
31
# File 'lib/birdwatcher/command.rb', line 29

def self.descendants
  ObjectSpace.each_object(Class).select { |klass| klass < self }
end

.detailed_usageObject



27
# File 'lib/birdwatcher/command.rb', line 27

def self.detailed_usage; end

.has_name?(name) ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/birdwatcher/command.rb', line 33

def self.has_name?(name)
  meta[:names].include?(name)
end

.metaObject



18
19
20
# File 'lib/birdwatcher/command.rb', line 18

def self.meta
  @meta || fail(MetadataNotSetError, "Metadata has not been set")
end

.meta=(meta) ⇒ Object



22
23
24
25
# File 'lib/birdwatcher/command.rb', line 22

def self.meta=(meta)
  (meta)
  @meta = meta
end

Instance Method Details

#execute(argument_line) ⇒ Object



45
46
47
48
49
50
51
# File 'lib/birdwatcher/command.rb', line 45

def execute(argument_line)
  @arguments = argument_line.to_s.split(ARGUMENT_SEPARATOR).map { |a| a.to_s.strip }
  run
rescue => e
  error("#{e.class}".bold + ": #{e.message}")
  puts e.backtrace.join("\n")
end