Class: Commands::Base
- Inherits:
-
Object
- Object
- Commands::Base
- Defined in:
- lib/commands/base.rb
Instance Attribute Summary collapse
-
#input ⇒ Object
Returns the value of attribute input.
-
#options ⇒ Object
Returns the value of attribute options.
-
#output ⇒ Object
Returns the value of attribute output.
Instance Method Summary collapse
- #get(cmd) ⇒ Object
-
#initialize(input = STDIN, output = STDOUT, *args) ⇒ Base
constructor
A new instance of Base.
- #put(string, newline = true) ⇒ Object
- #run! ⇒ Object
- #sys(cmd) ⇒ Object
Constructor Details
#initialize(input = STDIN, output = STDOUT, *args) ⇒ Base
Returns a new instance of Base.
10 11 12 13 14 15 16 17 |
# File 'lib/commands/base.rb', line 10 def initialize(input=STDIN, output=STDOUT, *args) @input = input @output = output @options = {} parse_gitconfig parse_argv(*args) end |
Instance Attribute Details
#input ⇒ Object
Returns the value of attribute input.
8 9 10 |
# File 'lib/commands/base.rb', line 8 def input @input end |
#options ⇒ Object
Returns the value of attribute options.
8 9 10 |
# File 'lib/commands/base.rb', line 8 def @options end |
#output ⇒ Object
Returns the value of attribute output.
8 9 10 |
# File 'lib/commands/base.rb', line 8 def output @output end |
Instance Method Details
#get(cmd) ⇒ Object
28 29 30 31 |
# File 'lib/commands/base.rb', line 28 def get(cmd) put cmd if [:verbose] `#{cmd}` end |
#put(string, newline = true) ⇒ Object
19 20 21 |
# File 'lib/commands/base.rb', line 19 def put(string, newline=true) @output.print(newline ? string + "\n" : string) unless [:quiet] end |
#run! ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/commands/base.rb', line 33 def run! unless [:api_token] && [:project_id] put "Pivotal Tracker API Token and Project ID are required" return 1 end PivotalTracker::Client.token = [:api_token] PivotalTracker::Client.use_ssl = [:use_ssl] return 0 end |
#sys(cmd) ⇒ Object
23 24 25 26 |
# File 'lib/commands/base.rb', line 23 def sys(cmd) put cmd if [:verbose] system "#{cmd} > /dev/null 2>&1" end |