Class: Therapy

Inherits:
Object
  • Object
show all
Defined in:
lib/therapy.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTherapy

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

#configObject

Returns the value of attribute config.



5
6
7
# File 'lib/therapy.rb', line 5

def config
  @config
end

#repositoryObject

Returns the value of attribute repository.



5
6
7
# File 'lib/therapy.rb', line 5

def repository
  @repository
end

#usernameObject

Returns the value of attribute username.



5
6
7
# File 'lib/therapy.rb', line 5

def username
  @username
end

Instance Method Details

#fetchObject



42
43
44
# File 'lib/therapy.rb', line 42

def fetch
  fetch_issues
end

#listObject



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_issuesObject



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