track-r 1.6.1 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.textile CHANGED
@@ -6,8 +6,8 @@ level using Ruby.
6
6
  h2. Installation
7
7
 
8
8
  <pre><code>
9
- $ gem sources -a http://gems.github.com (you only have to do this once)
10
- $ sudo gem install jfgomez86-track-r
9
+ $ gem sources -a http://gemcutter.org (you only have to do this once) *New*
10
+ $ sudo gem install track-r
11
11
  </code></pre>
12
12
 
13
13
  h2. Usage
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.6.1
1
+ 1.7.0
data/lib/track-r.rb CHANGED
@@ -2,6 +2,7 @@ $:.unshift(File.dirname(__FILE__))
2
2
  require File.join(File.dirname(__FILE__), '/../config/environment.rb')
3
3
  require 'track-r/project'
4
4
  require 'track-r/story'
5
+ require 'track-r/comment'
5
6
  require 'track-r/token'
6
7
  require 'track-r/tracker'
7
8
  require 'cgi'
@@ -0,0 +1,22 @@
1
+ class Comment
2
+ attr_accessor :id, :text, :author, :noted_at, :story_id, :project_id, :token
3
+
4
+ def initialize(options = {})
5
+ @token = options[:token].to_s
6
+ @project_id = options[:project_id]
7
+ @story_id = options[:story_id]
8
+ @comment = Hpricot(options[:comment])
9
+ build_comment
10
+ end
11
+
12
+ private
13
+
14
+ def build_comment
15
+ if @comment
16
+ @id = @comment.at('id').inner_html.chomp unless @comment.at('id').nil?
17
+ @text = @comment.at('text').inner_html.chomp unless @comment.at('text').nil?
18
+ @author = @comment.at('author').inner_html.chomp unless @comment.at('author').nil?
19
+ @noted_at = @comment.at('noted_at').inner_html.chomp unless @comment.at('noted_at').nil?
20
+ end
21
+ end
22
+ end
data/lib/track-r/story.rb CHANGED
@@ -2,7 +2,7 @@
2
2
  class Story
3
3
  attr_accessor :story_type, :estimate, :current_state,
4
4
  :description, :name, :requested_by, :owned_by, :created_at, :accepted_at,
5
- :labels, :project_id
5
+ :labels, :project_id, :comments
6
6
 
7
7
  attr_reader :id, :url
8
8
 
@@ -37,6 +37,7 @@ class Story
37
37
  @created_at = @story.at('created_at').inner_html unless @story.at('created_at').nil?
38
38
  @accepted_at = @story.at('accepted_at').inner_html unless @story.at('accepted_at').nil?
39
39
  @labels = @story.at('labels').inner_html unless @story.at('labels').nil?
40
+ @comments ||= build_comments(@story.at('notes').inner_html) unless @story.at('notes').nil?
40
41
  end
41
42
 
42
43
  # TODO: Test this method
@@ -75,6 +76,10 @@ class Story
75
76
 
76
77
  protected
77
78
 
79
+ def build_comments(xml_comments)
80
+ (Hpricot(xml_comments)/:note).map {|comment| Comment.new(:comment => comment.to_s, :project_id => @project_id, :token => @token, :story_id => @id)}
81
+ end
82
+
78
83
  def to_param
79
84
  query_string = attributes.map { |key, value| "story[#{key}]=#{CGI::escape(value)}" unless value.nil?}.compact.join('&')
80
85
  end
data/track-r.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{track-r}
5
- s.version = "1.6.1"
5
+ s.version = "1.7.0"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Jose Felix Gomez"]
@@ -21,6 +21,7 @@ Gem::Specification.new do |s|
21
21
  "config/environment.rb",
22
22
  "config/gems.yml",
23
23
  "lib/track-r.rb",
24
+ "lib/track-r/comment.rb",
24
25
  "lib/track-r/project.rb",
25
26
  "lib/track-r/story.rb",
26
27
  "lib/track-r/token.rb",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: track-r
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.1
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jose Felix Gomez
@@ -30,6 +30,7 @@ files:
30
30
  - config/environment.rb
31
31
  - config/gems.yml
32
32
  - lib/track-r.rb
33
+ - lib/track-r/comment.rb
33
34
  - lib/track-r/project.rb
34
35
  - lib/track-r/story.rb
35
36
  - lib/track-r/token.rb