pivotal-tracker-api 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 684e9c41b85f26f2b945a3968a246697c93fe327
4
- data.tar.gz: c2d99f604a04bf0a75209bf1f01987889fd54c7b
3
+ metadata.gz: 359d263b3e317435d1e1e33d05364f5b7d29c0e6
4
+ data.tar.gz: cad7be8e004e74660c38a837edb8205e7cc0b203
5
5
  SHA512:
6
- metadata.gz: af4f339ec6457b278c4de4e0ac1990c8bf874585fd93b07a017f98cfd2acc1733e103d7d017d05d1bd614a5bace762044c7da29b59afb355b3cc424ff70894c0
7
- data.tar.gz: 01227146224d47e0ebfcd063983ed02b22019317d41940af42951f8352a516754f741b217b5ca4e1ae1eff768706e6341ee1054598692d6666c96ea53fbb90e9
6
+ metadata.gz: 540addcafdfd2583e43789a60cd87cb62332dab39f975cfeb11a2e15e9ac3946bda92101fa1be18b409e892961bf9a89116e28e5d85ecaedceb4c6dce4d7ad72
7
+ data.tar.gz: 5b216a4b8822e3f12fcb7761e8e9eff940591691f20a90fe6ac1abe313fab87d0e293b8e6fbe8f41be735829c38deb814741d1390ee6acb2d7148670f3d26c49
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
@@ -3,6 +3,25 @@ module Scorer
3
3
 
4
4
  attr_accessor :story, :project_id, :story_id, :id, :text, :author, :created_at, :updated_at
5
5
 
6
+ def self.fields
7
+ ['person', 'text', 'updated_at', 'id', 'created_at', 'story_id']
8
+ end
9
+
10
+ def self.parse_json_comments(json_comments, story)
11
+ comments = Array.new
12
+ json_comments.each do |comment|
13
+ comments << new({
14
+ id: comment[:id].to_i,
15
+ text: comment[:text],
16
+ author: Scorer::Person.parse_json_person(comment[:person]),
17
+ created_at: DateTime.parse(comment[:created_at].to_s).to_s,
18
+ updated_at: DateTime.parse(comment[:updated_at].to_s).to_s,
19
+ story: story
20
+ })
21
+ end
22
+ comments
23
+ end
24
+
6
25
  def initialize(attributes={})
7
26
  if attributes[:owner]
8
27
  self.story = attributes.delete(:owner)
@@ -100,6 +100,13 @@ class PivotalService
100
100
  Scorer::Client.put(api_url, updates)
101
101
  end
102
102
 
103
+ def comments(project_id, story, fields)
104
+ api_url = append_fields('/projects' + "/#{project_id}/stories/#{story.id}/comments", fields)
105
+ response = Scorer::Client.get_with_caching(api_url)
106
+ json_comments = JSON.parse(response, {:symbolize_names => true})
107
+ Scorer::Comment.parse_json_comments(json_comments, story)
108
+ end
109
+
103
110
  private
104
111
 
105
112
  def append_fields(api_url, fields)
@@ -39,7 +39,7 @@ module Scorer
39
39
  deadline: json_story[:deadline]
40
40
  })
41
41
 
42
- parsed_story.comments = parse_notes(json_story[:comments], json_story)
42
+ parsed_story.comments = get_story_comments(project_id, parsed_story)
43
43
  parsed_story.tasks = parse_tasks(json_story[:tasks], json_story)
44
44
  parsed_story.attachments = []
45
45
  parsed_story
@@ -53,21 +53,8 @@ module Scorer
53
53
  stories
54
54
  end
55
55
 
56
- def self.parse_notes(notes, story)
57
- comments = Array.new
58
- if notes
59
- notes.each do |note|
60
- comments << Scorer::Comment.new({
61
- id: note[:id].to_i,
62
- text: note[:text],
63
- author: note[:person_id],
64
- created_at: DateTime.parse(note[:created_at].to_s).to_s,
65
- updated_at: DateTime.parse(note[:updated_at].to_s).to_s,
66
- story: story
67
- })
68
- end
69
- end
70
- comments
56
+ def self.get_story_comments(project_id, story)
57
+ PivotalService.comments(project_id, story, Scorer::Comment.fields)
71
58
  end
72
59
 
73
60
  def self.parse_tasks(tasks, story)
@@ -2,11 +2,11 @@
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 0.1.1 ruby lib
5
+ # stub: pivotal-tracker-api 0.1.2 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "pivotal-tracker-api"
9
- s.version = "0.1.1"
9
+ s.version = "0.1.2"
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"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pivotal-tracker-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - jfox