Class: Pv::BugTracker

Inherits:
Object show all
Defined in:
lib/pv/bug_tracker.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(with_username = nil, and_password = nil, and_project_id = nil) ⇒ BugTracker

Connect to Pivotal Tracker



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/pv/bug_tracker.rb', line 8

def initialize with_username=nil, and_password=nil, and_project_id=nil
  @username = with_username || Pv.config.username
  @password = and_password  || Pv.config.password
  @token = PivotalTracker::Client.token(username, password)

  @project = begin
    project_id = and_project_id || Pv.config.project_id
    PivotalTracker::Project.all.select { |p| p.id == project_id }.first if @token.present?
  end

  PivotalTracker::Client.use_ssl = true
end

Instance Attribute Details

#passwordObject (readonly)

Returns the value of attribute password.



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

def password
  @password
end

#projectObject (readonly)

Returns the value of attribute project.



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

def project
  @project
end

#tokenObject (readonly)

Returns the value of attribute token.



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

def token
  @token
end

#usernameObject (readonly)

Returns the value of attribute username.



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

def username
  @username
end

Instance Method Details

#connected?Boolean

Test whether we are connected.

Returns:

  • (Boolean)


22
23
24
# File 'lib/pv/bug_tracker.rb', line 22

def connected?
  @token.present?
end

#stories(by_user_name = nil) ⇒ Object

Find stories filtered by this username.



27
28
29
30
# File 'lib/pv/bug_tracker.rb', line 27

def stories by_user_name=nil
  user = by_user_name || Pv.config.name
  @project.stories.all(owned_by: user).reject { |s| s.current_state =~ /accepted|delivered/ }
end