Class: Therapist
- Inherits:
-
Thor
- Object
- Thor
- Therapist
- Defined in:
- lib/therapist.rb
Instance Method Summary collapse
- #fetch ⇒ Object
-
#initialize(args = [], options = {}, config = {}) ⇒ Therapist
constructor
A new instance of Therapist.
- #list ⇒ Object
- #show(number) ⇒ Object
Constructor Details
#initialize(args = [], options = {}, config = {}) ⇒ Therapist
Returns a new instance of Therapist.
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/therapist.rb', line 12 def initialize(args = [], ={}, config={}) git = Git.open(Dir.pwd) origin_url = git.remote('origin').url origin_url =~ /git@github\.com:(.*)\/(.*)\.git/ @username = $1 @repository = $2 @out = $stdout super end |
Instance Method Details
#fetch ⇒ Object
67 68 69 |
# File 'lib/therapist.rb', line 67 def fetch fetch_issues end |
#list ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/therapist.rb', line 27 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 |
#show(number) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/therapist.rb', line 36 def show(number) number.gsub!('#', '') fetch_issue(number) unless issue_file(number).exist? issue = YAML.load(issue_file(number).read)['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 "="*80 @out.puts issue['body'] fetch_issue_comments(number) unless issue_comments_file(number).exist? comments = YAML.load(issue_comments_file(number).read)['comments'] @out.puts @out.puts "Comments:" comments.each do |comment| @out.puts "="*80 @out.puts "#{comment['user']} wrote on #{comment['created_at']}" @out.puts "="*80 @out.puts comment['body'] @out.puts end end |