Class: Reviewr::CLI::Command

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

Direct Known Subclasses

Accept, Help, Request

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#argumentsObject

Returns the value of attribute arguments.



5
6
7
# File 'lib/reviewr/cli/command.rb', line 5

def arguments
  @arguments
end

#inputObject

Returns the value of attribute input.



5
6
7
# File 'lib/reviewr/cli/command.rb', line 5

def input
  @input
end

#outputObject

Returns the value of attribute output.



5
6
7
# File 'lib/reviewr/cli/command.rb', line 5

def output
  @output
end

#projectObject (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

#callObject



12
13
14
# File 'lib/reviewr/cli/command.rb', line 12

def call
  execute
end

#prompt_for_userObject



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