pivotal-tracker 0.2.2 → 0.3.0

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.2
1
+ 0.3.0
@@ -23,19 +23,17 @@ module PivotalTracker
23
23
 
24
24
  def self.encode_options(options)
25
25
  return nil if !options.is_a?(Hash) || options.empty?
26
-
27
- options_string = []
28
- options_string << "limit=#{options.delete(:limit)}" if options[:limit]
29
- options_string << "offset=#{options.delete(:offset)}" if options[:offset]
30
-
31
- filters = []
32
- options.each do |key, value|
33
- values = value.is_a?(Array) ? value.map {|x| CGI.escape(x) }.join(',') : CGI.escape(value)
34
- filters << "#{key}%3A#{values}" # %3A => :
26
+ options_strings = []
27
+ # remove options which are not filters, and encode them as such
28
+ [:limit, :offset].each do |o|
29
+ options_strings << "#{CGI.escape(o.to_s)}=#{CGI.escape(options.delete(o))}" if options[o]
35
30
  end
36
- options_string << "filter=#{filters.join('%20')}" unless filters.empty? # %20 => &amp;
37
-
38
- return "?#{options_string.join('&')}"
31
+ # assume remaining key-value pairs describe filters, and encode them as such.
32
+ filters_string = options.map do |key, value|
33
+ [value].flatten.map {|v| "#{CGI.escape(key.to_s)}%3A#{CGI.escape(v)}"}.join('&filter=')
34
+ end
35
+ options_strings << "filter=#{filters_string}" unless filters_string.empty?
36
+ return "?#{options_strings.join('&')}"
39
37
  end
40
38
 
41
39
  end
@@ -9,12 +9,13 @@ module PivotalTracker
9
9
  end
10
10
 
11
11
  def token(username, password, method='post')
12
+ return @token if @token
12
13
  response = if method == 'post'
13
14
  RestClient.post 'https://www.pivotaltracker.com/services/v3/tokens/active', :username => username, :password => password
14
15
  else
15
16
  RestClient.get "https://#{username}:#{password}@www.pivotaltracker.com/services/v3/tokens/active"
16
17
  end
17
- @token ||= Nokogiri::XML(response.body).search('guid').inner_html
18
+ @token= Nokogiri::XML(response.body).search('guid').inner_html
18
19
  end
19
20
 
20
21
  # this is your connection for the entire module
@@ -17,6 +17,7 @@ module PivotalTracker
17
17
 
18
18
  def find(param, options={})
19
19
  return all(options) if param == :all
20
+ return @target.find(param, @owner.id) if @target.respond_to?("find")
20
21
  return proxy_found(options).detect { |document| document.id == param }
21
22
  end
22
23
 
@@ -9,6 +9,16 @@ module PivotalTracker
9
9
  stories.each { |s| s.project_id = project.id }
10
10
  return stories
11
11
  end
12
+
13
+ def find(param, project_id)
14
+ begin
15
+ story = parse(Client.connection["/projects/#{project_id}/stories/#{param}"].get)
16
+ story.project_id = project_id
17
+ rescue RestClient::ExceptionWithResponse
18
+ story = nil
19
+ end
20
+ return story
21
+ end
12
22
  end
13
23
 
14
24
  tag "story"
@@ -42,6 +42,7 @@ module PivotalTracker
42
42
  xml.complete "#{complete}"
43
43
  }
44
44
  end
45
+ return builder.to_xml
45
46
  end
46
47
 
47
48
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{pivotal-tracker}
8
- s.version = "0.2.2"
8
+ s.version = "0.3.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Justin Smestad", "Josh Nichols", "Terence Lee"]
12
- s.date = %q{2010-09-20}
12
+ s.date = %q{2010-11-04}
13
13
  s.email = %q{justin.smestad@gmail.com}
14
14
  s.extra_rdoc_files = [
15
15
  "LICENSE",
metadata CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 2
9
- - 2
10
- version: 0.2.2
8
+ - 3
9
+ - 0
10
+ version: 0.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Justin Smestad
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2010-09-20 00:00:00 -06:00
20
+ date: 2010-11-04 00:00:00 -06:00
21
21
  default_executable:
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency