Class: Therapy
- Inherits:
-
Object
- Object
- Therapy
- Defined in:
- lib/therapy.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#repository ⇒ Object
Returns the value of attribute repository.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
- #fetch ⇒ Object
-
#initialize ⇒ Therapy
constructor
A new instance of Therapy.
- #list ⇒ Object
- #open_issues ⇒ Object
- #show(number) ⇒ Object
Constructor Details
#initialize ⇒ Therapy
Returns a new instance of Therapy.
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/therapy.rb', line 6 def initialize() @git = Git.open(Dir.pwd) @config = Git.global_config origin_url = @git.remote('origin').url origin_url =~ /git@github\.com:(.*)\/(.*)\.git/ @username = $1 @repository = $2 @out = $stdout end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
5 6 7 |
# File 'lib/therapy.rb', line 5 def config @config end |
#repository ⇒ Object
Returns the value of attribute repository.
5 6 7 |
# File 'lib/therapy.rb', line 5 def repository @repository end |
#username ⇒ Object
Returns the value of attribute username.
5 6 7 |
# File 'lib/therapy.rb', line 5 def username @username end |
Instance Method Details
#fetch ⇒ Object
42 43 44 |
# File 'lib/therapy.rb', line 42 def fetch fetch_issues end |
#list ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/therapy.rb', line 19 def list fetch_issues unless File.exist?(open_issues_file) open_issues.each do |issue| @out.puts "##{issue['number'].to_s.ljust 3} #{issue['state'].rjust 6}: #{issue['title']}" end end |
#open_issues ⇒ Object
46 47 48 |
# File 'lib/therapy.rb', line 46 def open_issues YAML.load(File.read(open_issues_file))['issues'] end |
#show(number) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/therapy.rb', line 27 def show(number) fetch_issue(number) unless File.exist?(issue_file(number)) issue = YAML.load(File.read(issue_file(number)))['issue'] @out.puts "##{issue['number']} #{issue['state']}: #{issue['title']}" @out.puts @out.puts "user : #{issue['user']}" @out.puts "created: #{issue['created_at']}" @out.puts "updated: #{issue['updated_at']}" @out.puts "votes : #{issue['votes']}" @out.puts @out.puts issue['body'] end |