pivotal-tracker-api 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cbfb334bb577e14833146540ec08e68f8dc26cca
4
- data.tar.gz: dc59ed6076a4899c0b09458865c99aee9982d381
3
+ metadata.gz: 0b104677712cae09b437565df220315ae88480d0
4
+ data.tar.gz: 92f8ff95cc3783d225490b0b53a0a42bcb6420f1
5
5
  SHA512:
6
- metadata.gz: 4b689d03586d7eed80ffb25444b47192adb4a5371c65b79710971805331f178d10bb092207f3800ecacf93b1fc006ae9ce67034636f2941bb78c7282b826b672
7
- data.tar.gz: 9f959cc0af6ce48c3acde9785a10ad268bad1b82c3ee1376cf428b0f91636152bc6f99d14e8ce2c22f951b117004b06d38a8e93397063a113988c02e306aac60
6
+ metadata.gz: 7e0fd85f353763e431780593df56b051e5c021b59474f45aedb0fbfc7c3babb2245efff89501fbbfc395d997798807a5456aca5aaf12d1220c9d04185fe97fe2
7
+ data.tar.gz: 602e9a5acacb5429c59adf434d050266ff3428027dedb8b1a0c2be8e45ff718e318ab8a4ed9493fc3fadd5612cfae38b97d382301ed6fc462ee2520a9515ecf1
data/README.md CHANGED
@@ -3,62 +3,100 @@ pivotal-tracker-api
3
3
 
4
4
  A Pivotal Tracker API gem that can be used to interface with the Pivotal Tracker API v5.
5
5
 
6
+ [![Gem](https://img.shields.io/gem/v/pivotal-tracker-api.svg?maxAge=2592000)]() [![Gem](https://img.shields.io/gem/dtv/pivotal-tracker-api.svg?maxAge=2592000)]()
7
+
6
8
  ### Basic Example
7
9
 
8
10
  ```ruby
9
- # Use your personal Pivotal token
10
- def set_token
11
- # This will set the @token in the Client class. Class caching must be enabled for the token to persist.
12
- # config.cache_classes = true
13
- PivotalAPI::Service.set_token(your_token_here)
14
- end
11
+ # Use your personal pivotal token
12
+ PivotalAPI::Service.set_token A_PIVOTAL_TOKEN
15
13
  ```
16
14
 
17
15
  ```ruby
18
16
  # Authenticate a user using email / pass
19
- def get_user_token
20
- email = params[:email]
21
- pass = params[:pass]
22
- # This will set the @token in the Client class. Class caching must be enabled for the token to persist.
23
- # config.cache_classes = true
24
- token = PivotalAPI::Client.token(email, pass)
25
- # do something with the token
26
- end
17
+ @me = PivotalAPI::Me.retrieve('USERNAME', 'PASSWORD')
18
+ # Note: PivotalAPI::Me.retrieve will automatically set the api token so there is no need to use PivotalAPI::Service.set_token if you use PivotalAPI::Me.retrieve to login
19
+ ```
20
+
21
+ ```ruby
22
+ # If you login using PivotalAPI::Me.retrieve, you can simply ask your Me object for your projects.
23
+ @projects = @me.projects
24
+
25
+ # If you set your personal pivotal token manually using PivotalAPI::Service.set_token, you can get your projects using the following.
26
+ @projects = PivotalAPI::Projects.retrieve()
27
+ ```
28
+
29
+ ```ruby
30
+ # To get a specific project, use the following.
31
+ @project = PivotalAPI::Project.retrieve(PROJECT_ID)
32
+ ```
33
+
34
+ ```ruby
35
+ # Get a project's stories, this will return an array of PivotalAPI::Story instance's
36
+ @stories = @project.stories
37
+ ```
38
+
39
+ ```ruby
40
+ # Get a specific story for a project, this will return a PivotalAPI::Story instance
41
+ @story = @project.story(STORY_ID)
42
+ ```
43
+
44
+ ```ruby
45
+ # Get a story's comments, this will return an array of PivotalAPI::Comment instance's
46
+ @comments = @story.comments
47
+ ```
48
+
49
+ ```ruby
50
+ # Get a story's owners, this will return an array of PivotalAPI::Person instance's
51
+ @owners = @story.owners
52
+ ```
53
+
54
+ ```ruby
55
+ # Get a story's followers, this will return an array of PivotalAPI::Person instance's
56
+ @followers = @story.followers
57
+ ```
58
+
59
+ ```ruby
60
+ # Get a story's tasks, this will return an array of PivotalAPI::Task instance's
61
+ @tasks = @story.tasks
62
+ ```
63
+
64
+ ```ruby
65
+ # Get a story's transitions, this will return an array of PivotalAPI::StoryTransition instance's
66
+ @transitions = @story.transitions
67
+ ```
68
+
69
+ ```ruby
70
+ # Get a story's cycle time details, this will return ana array of PivotalAPI::CycleTimeDetails instance's
71
+ @cycle_time_details = @story.cycle_time_details
72
+ ```
73
+
74
+ ```ruby
75
+ # Get a project's activity, this will return an array of PivotalAPI::Activity instance's
76
+ @stories = @project.activity
27
77
  ```
28
78
 
29
79
  ```ruby
30
- # Get all of the users Projects
31
- def projects
32
- @projects = PivotalAPI::Service.all_projects(PivotalAPI::Project.fields)
33
- end
80
+ # Get a project's iterations, this will return an array of PivotalAPI::Iteration instance's
81
+ @iterations = @project.iterations
34
82
  ```
35
83
 
36
84
  ```ruby
37
- # Get only 1 of the users Projects
38
- def project
39
- @project = PivotalAPI::Service.one_project(params[:project_id], PivotalAPI::Project.fields)
40
- end
85
+ # Get a project's current iteration
86
+ @iteration = @project.current_iteration
41
87
  ```
42
88
 
43
89
  ```ruby
44
- # Get a Projects Stories by a specific Label
45
- def stories_by_label
46
- project_label = params[:project_label]
47
- @project_label = CGI.escape(project_label) if project_label
48
- @stories = PivotalAPI::Service.all_stories(@project_label, @project, PivotalAPI::Story.fields) if @project_label
49
- end
90
+ # Get a project's next iteration
91
+ @iteration = @project.next_iteration
50
92
  ```
51
93
 
52
94
  ```ruby
53
- # Get an Iteration and it's Stories
54
- def get_iteration
55
- @project_id = params[:project_id]
56
- @iteration = PivotalAPI::Service.iterations(@project_id, 'current')
57
- @stories = @iteration.stories
58
- end
95
+ # Get a project's previous iteration
96
+ @iteration = @project.previous_iteration
59
97
  ```
60
98
 
61
- For additional infomation on how to interface with this gem and use it to communicate with the Pivotal Tracker API v5 see the [PivotalAPI::Service](https://github.com/atljeremy/pivotal-tracker-api/blob/master/lib/pivotal-tracker-api/pivotal_service.rb) class.
99
+ For additional infomation on how to interface with this gem and use it to communicate with the Pivotal Tracker API v5 see the [PivotalAPI::Service](https://github.com/atljeremy/pivotal-tracker-api/blob/master/lib/pivotal-tracker-api/service.rb) class and the [Service Tests](https://github.com/atljeremy/pivotal-tracker-api/blob/master/test/test_service.rb).
62
100
 
63
101
  ### Contributing to pivotal-tracker-api
64
102
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.0.1
@@ -106,22 +106,46 @@ module PivotalAPI
106
106
  def hours
107
107
  return 0 if transitions.nil?
108
108
  duration_hrs = 0
109
- started = nil
110
- transitions.each do |transition|
109
+ prev_transition = nil
110
+ transitions.reverse.each do |transition|
111
111
  case transition.state
112
112
  when 'started'
113
- started = Time.parse(transition.occurred_at.to_s)
113
+ prev_transition = transition
114
114
  when 'finished'
115
- duration_hrs += hours_between(started, Time.parse(transition.occurred_at.to_s)) if started
115
+ if prev_transition
116
+ start_time = Time.parse(prev_transition.occurred_at.to_s)
117
+ end_time = Time.parse(transition.occurred_at.to_s)
118
+ puts "finished: start_time: #{start_time} - end_time: #{end_time}"
119
+ duration_hrs += hours_between(start_time, end_time)
120
+ end
121
+ prev_transition = transition
122
+ when 'delivered'
123
+ if prev_transition
124
+ start_time = Time.parse(prev_transition.occurred_at.to_s)
125
+ end_time = Time.parse(transition.occurred_at.to_s)
126
+ puts "delivered: start_time: #{start_time} - end_time: #{end_time}"
127
+ duration_hrs += hours_between(start_time, end_time)
128
+ end
129
+ prev_transition = transition
130
+ when 'rejected'
131
+ if prev_transition
132
+ start_time = Time.parse(prev_transition.occurred_at.to_s)
133
+ end_time = Time.parse(transition.occurred_at.to_s)
134
+ puts "rejected: start_time: #{start_time} - end_time: #{end_time}"
135
+ duration_hrs += hours_between(start_time, end_time)
136
+ end
137
+ prev_transition = transition
138
+ when 'accepted'
139
+ if prev_transition
140
+ start_time = Time.parse(prev_transition.occurred_at.to_s)
141
+ end_time = Time.parse(transition.occurred_at.to_s)
142
+ puts "accepted: start_time: #{start_time} - end_time: #{end_time}"
143
+ duration_hrs += hours_between(start_time, end_time)
144
+ end
145
+ prev_transition = transition
116
146
  end
117
147
  end
118
148
 
119
- if current_state == 'accepted'
120
- duration_hrs += hours_between(started, Time.parse(accepted_at.to_s))
121
- elsif current_state != 'accepted' && started
122
- duration_hrs += hours_between(started, Time.now)
123
- end
124
-
125
149
  duration_hrs
126
150
  end
127
151
 
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: pivotal-tracker-api 1.0.0 ruby lib
5
+ # stub: pivotal-tracker-api 1.0.1 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "pivotal-tracker-api"
9
- s.version = "1.0.0"
9
+ s.version = "1.0.1"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["jfox"]
14
- s.date = "2016-08-23"
14
+ s.date = "2016-08-24"
15
15
  s.description = "A ruby gem to communicate with the Picotal Tracker API v5"
16
16
  s.email = "atljeremy@me.com"
17
17
  s.extra_rdoc_files = [
@@ -19,7 +19,10 @@ class TestService < Test::Unit::TestCase
19
19
  # iteration = project.iterations.first
20
20
  # iteration.stories.each do |story|
21
21
  # puts "------------------"
22
- # puts "Story: #{story.name} - status: #{story.current_state} - overdue: #{story.overdue?}"
22
+ # puts "Story: #{story.name}\n
23
+ # status: #{story.current_state}\n
24
+ # overdue: #{story.overdue?}\n
25
+ # hours: #{story.hours}"
23
26
  # puts "------------------"
24
27
  # end
25
28
  #
@@ -136,15 +136,14 @@ class TestActivity < Test::Unit::TestCase
136
136
  kind: "label"
137
137
  }],
138
138
  transitions: [{
139
- state: "started",
139
+ state: "accepted",
140
140
  story_id: 1,
141
141
  project_id: 2,
142
142
  project_version: 3,
143
- occurred_at: "2016-08-17T11:03:53-04:00",
143
+ occurred_at: "2016-08-19T11:04:53-04:00",
144
144
  performed_by_id: 4,
145
145
  kind: "some-kind"
146
- },
147
- {
146
+ },{
148
147
  state: "finished",
149
148
  story_id: 1,
150
149
  project_id: 2,
@@ -152,13 +151,12 @@ class TestActivity < Test::Unit::TestCase
152
151
  occurred_at: "2016-08-19T11:03:53-04:00",
153
152
  performed_by_id: 4,
154
153
  kind: "some-kind"
155
- },
156
- {
157
- state: "accepted",
154
+ },{
155
+ state: "started",
158
156
  story_id: 1,
159
157
  project_id: 2,
160
158
  project_version: 3,
161
- occurred_at: "2016-08-19T11:03:53-04:00",
159
+ occurred_at: "2016-08-17T11:03:53-04:00",
162
160
  performed_by_id: 4,
163
161
  kind: "some-kind"
164
162
  }]
@@ -276,7 +274,7 @@ class TestActivity < Test::Unit::TestCase
276
274
  end
277
275
 
278
276
  should "have valid transitions" do
279
- assert_equal("started", @story.transitions[0].state)
277
+ assert_equal("accepted", @story.transitions[0].state)
280
278
  end
281
279
 
282
280
  should "have a valid task_ids" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pivotal-tracker-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - jfox
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-23 00:00:00.000000000 Z
11
+ date: 2016-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client