Class: Playit::Command
- Inherits:
-
Object
- Object
- Playit::Command
- Defined in:
- lib/playit/command.rb
Class Method Summary collapse
- .bootstrap(operation) ⇒ Object
-
.configure ⇒ Object
Edit the configuration in an editor.
- .delegate(command, major, minor) ⇒ Object
- .execute(*args) ⇒ Object
- .metadata(operation) ⇒ Object
- .overview ⇒ Object
- .topics ⇒ Object
- .usage ⇒ Object
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 |
.configure ⇒ Object
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 |
.overview ⇒ Object
63 64 65 |
# File 'lib/playit/command.rb', line 63 def overview puts usage end |
.topics ⇒ Object
89 90 91 |
# File 'lib/playit/command.rb', line 89 def topics Playit::Services::Governance.topics end |
.usage ⇒ Object
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 |