Class: Reviewr::CLI::Command
- Inherits:
-
Object
- Object
- Reviewr::CLI::Command
- Defined in:
- lib/reviewr/cli/command.rb
Instance Attribute Summary collapse
-
#arguments ⇒ Object
Returns the value of attribute arguments.
-
#input ⇒ Object
Returns the value of attribute input.
-
#output ⇒ Object
Returns the value of attribute output.
-
#project ⇒ Object
readonly
Returns the value of attribute project.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(project, input = STDIN, output = STDOUT) ⇒ Command
constructor
A new instance of Command.
- #prompt_for_user ⇒ Object
- #read_template(name) ⇒ Object
Constructor Details
#initialize(project, input = STDIN, output = STDOUT) ⇒ Command
Returns a new instance of Command.
7 8 9 10 |
# File 'lib/reviewr/cli/command.rb', line 7 def initialize(project, input = STDIN, output = STDOUT) @project = project @input, @output = input, output end |
Instance Attribute Details
#arguments ⇒ Object
Returns the value of attribute arguments.
5 6 7 |
# File 'lib/reviewr/cli/command.rb', line 5 def arguments @arguments end |
#input ⇒ Object
Returns the value of attribute input.
5 6 7 |
# File 'lib/reviewr/cli/command.rb', line 5 def input @input end |
#output ⇒ Object
Returns the value of attribute output.
5 6 7 |
# File 'lib/reviewr/cli/command.rb', line 5 def output @output end |
#project ⇒ Object (readonly)
Returns the value of attribute project.
4 5 6 |
# File 'lib/reviewr/cli/command.rb', line 4 def project @project end |
Instance Method Details
#call ⇒ Object
12 13 14 |
# File 'lib/reviewr/cli/command.rb', line 12 def call execute end |
#prompt_for_user ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/reviewr/cli/command.rb', line 16 def prompt_for_user output.print("Email (default #{project.user_email}): ") email = input.gets.chomp project.user_email = email unless email.empty? output.print("Email password: ") no_echo(input) do project.email_password = input.gets.chomp end output.print("\n") output.print("Remote repository (default origin): ") repo = input.gets.chomp project.remote_repo = repo unless repo.empty? end |
#read_template(name) ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/reviewr/cli/command.rb', line 32 def read_template(name) @templates ||= {} @templates[name] ||= ERB.new(File.read(File.join(File.dirname(__FILE__), '..', 'templates', name))) @templates[name].result(binding) end |