Class: Playit::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/playit/command.rb

Class Method Summary collapse

Class Method Details

.bootstrap(operation) ⇒ Object



82
83
84
85
86
87
# File 'lib/playit/command.rb', line 82

def bootstrap(operation)
  return Playit::Services::Bootstrap.init if operation == 'init'
  return Playit::Services::Bootstrap.stop if operation == 'stop'

  "Invalid operation #{operation} for bootstrap service"
end

.configureObject

Edit the configuration in an editor



59
60
61
# File 'lib/playit/command.rb', line 59

def configure
  puts "Playit! #{Platform.edit(Playit.config.file)}"
end

.delegate(command, major, minor) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/playit/command.rb', line 43

def delegate command, major, minor

  return configure          if command == 'configure'
  return bootstrap(major)   if command == 'bootstrap'
  return (major)    if command == 'meta'
  return topics             if command == 'topics'
  return status             if command == 'status'
  return overview           if command == 'help'

  return overview

end

.execute(*args) ⇒ Object



34
35
36
37
38
39
40
41
# File 'lib/playit/command.rb', line 34

def execute(*args)
  command = args.shift
  major = args.shift
  minor = args.empty? ? nil : args.join(' ')

  return overview unless command
  delegate(command, major, minor)
end

.metadata(operation) ⇒ Object



74
75
76
77
78
79
80
# File 'lib/playit/command.rb', line 74

def (operation)
  return Playit::Services::Metadata.start if operation == 'start'
  return Playit::Services::Metadata.stop if operation == 'stop'
  return Playit::Services::Metadata.restart if operation == 'restart'

  "Invalid operation #{operation} for metadata service"
end

.overviewObject



63
64
65
# File 'lib/playit/command.rb', line 63

def overview
  puts usage
end

.topicsObject



89
90
91
# File 'lib/playit/command.rb', line 89

def topics
  Playit::Services::Governance.topics
end

.usageObject



67
68
69
70
71
72
# File 'lib/playit/command.rb', line 67

def usage
  File.readlines(__FILE__).
  grep(/^##.*/).
  map { |line| line.chomp[3..-1] }.
  join("\n")
end