ticketmaster-kanbanpad 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.5
1
+ 0.1.6
@@ -55,7 +55,8 @@ module KanbanpadAPI
55
55
  #
56
56
 
57
57
  class Project < Base
58
- def tasks(options = {})
58
+
59
+ def self.tickets(slug, options = {})
59
60
  Task.find(:all, :params => options.update(:project_id => slug, :backlog => 'yes', :finished => 'yes'))
60
61
  end
61
62
 
@@ -70,7 +71,7 @@ module KanbanpadAPI
70
71
 
71
72
  class Task < Base
72
73
  self.site += 'projects/:project_id/'
73
-
74
+
74
75
  def self.finished(project_id, options = {})
75
76
  find(:all, :params => options.merge(:slug => project_id), :from => :finished)
76
77
  end
@@ -3,7 +3,7 @@ module TicketMaster::Provider
3
3
 
4
4
  module Kanbanpad
5
5
  include TicketMaster::Provider::Base
6
- TICKET_API = KanbanpadAPI::Task
6
+ TICKET_API = KanbanpadAPI::Task
7
7
  PROJECT_API = KanbanpadAPI::Project
8
8
 
9
9
  # This is for cases when you want to instantiate using TicketMaster::Provider::Kanbanpad.new(auth)
@@ -20,6 +20,6 @@ module TicketMaster::Provider
20
20
  end
21
21
  ::KanbanpadAPI.authenticate((auth.username.blank? ? auth.email : auth.username), (auth.password.blank? ? auth.token : auth.password))
22
22
  end
23
-
23
+
24
24
  end
25
25
  end
@@ -38,7 +38,37 @@ module TicketMaster::Provider
38
38
  end
39
39
  end
40
40
 
41
-
41
+ # TODO: Needs refactor
42
+ def tickets(*options)
43
+ if options.empty?
44
+ collect_all_tickets
45
+ elsif options.first.is_a? Array
46
+ collect_all_tickets.select do |ticket|
47
+ if options.first.any? {|id| id == ticket.id }
48
+ ticket
49
+ end
50
+ end
51
+ elsif options.first.is_a? Hash
52
+ collect_all_tickets.select do |ticket|
53
+ options.first.inject(true) do |memo, kv|
54
+ break unless memo
55
+ key, value = kv
56
+ begin
57
+ memo &= ticket.send(key) == value
58
+ rescue NoMethodError
59
+ memo = false
60
+ end
61
+ memo
62
+ end
63
+ end
64
+ end
65
+ end
66
+
67
+ private
68
+ def collect_all_tickets
69
+ API.tickets(id).collect { |ticket| Ticket.new ticket }
70
+ end
71
+
42
72
  end
43
73
  end
44
74
  end
@@ -17,10 +17,6 @@ module TicketMaster::Provider
17
17
  self.assigned_to.first
18
18
  end
19
19
 
20
- def project_id
21
- self.project_slug
22
- end
23
-
24
20
  def created_at
25
21
  if self[:created_at].blank?
26
22
  Time.parse('2010-03-25 3:06:34') #kanbanpad used to not track the created_at
@@ -33,6 +29,20 @@ module TicketMaster::Provider
33
29
  end
34
30
  end
35
31
 
32
+ def self.find_by_id(project_id, id)
33
+ self.search(project_id, {'id' => id}).first
34
+ end
35
+
36
+ def self.find_by_attributes(project_id, attributes = {})
37
+ self.search(project_id, attributes)
38
+ end
39
+
40
+ def self.search(project_id, options = {}, limit = 1000)
41
+ tickets = API.find(:all, :params => {:project_id => project_id, :backlog => 'yes', :finished => 'yes'}).collect do |ticket|
42
+ self.new ticket
43
+ end
44
+ end
45
+
36
46
  def updated_at
37
47
  if self[:updated_at].blank?
38
48
  Time.parse('2010-03-25 3:06:34') #kanbanpad used to not track the updated_at
@@ -0,0 +1 @@
1
+ [{"assigned_to":[],"created_at":"2011-02-21T19:13:22Z","title":"Testing provider","updated_at":"2011-02-21T22:48:15Z","urgent":false,"id":"4d62b952faf6426596000061","step_id":null,"note":null,"wip":true,"project_slug":"ef74c392a173ea994328","finished":true,"backlog":false},{"assigned_to":[],"created_at":"2011-02-21T22:53:59Z","title":"Checking tasks creation","updated_at":"2011-02-21T22:57:56Z","urgent":false,"id":"4d62ed07c0847f51ea000009","step_id":null,"note":null,"wip":false,"project_slug":"ef74c392a173ea994328","finished":true,"backlog":false}]
data/spec/tickets_spec.rb CHANGED
@@ -7,6 +7,7 @@ describe "Ticketmaster::Provider::Kanbanpad::Ticket" do
7
7
  ActiveResource::HttpMock.respond_to do |mock|
8
8
  mock.get '/api/v1/projects/be74b643b64e3dc79aa0.json', wheaders, fixture_for('projects/be74b643b64e3dc79aa0'), 200
9
9
  mock.get '/api/v1/projects/be74b643b64e3dc79aa0/tasks.json', wheaders, fixture_for('tasks'), 200
10
+ mock.get '/api/v1/projects/be74b643b64e3dc79aa0/tasks.json?backlog=yes&finished=yes', wheaders, fixture_for('tasks'), 200
10
11
  mock.get '/api/v1/projects/be74b643b64e3dc79aa0/tasks/4cd428c496f0734eef000007.json', wheaders, fixture_for('tasks/4cd428c496f0734eef000007'), 200
11
12
  end
12
13
  @project_id = 'be74b643b64e3dc79aa0'
@@ -29,14 +30,14 @@ describe "Ticketmaster::Provider::Kanbanpad::Ticket" do
29
30
  @tickets = @project.tickets([@ticket_id])
30
31
  @tickets.should be_an_instance_of(Array)
31
32
  @tickets.first.should be_an_instance_of(@klass)
32
- @tickets.first.id.should == @ticket_id
33
+ @tickets.first.id.should == '4cd428c496f0734eef000007'
33
34
  end
34
35
 
35
36
  it "should be able to load all tickets based on attributes" do
36
37
  @tickets = @project.tickets(:id => @ticket_id)
37
38
  @tickets.should be_an_instance_of(Array)
38
39
  @tickets.first.should be_an_instance_of(@klass)
39
- @tickets.first.id.should == @ticket_id
40
+ @tickets.first.id.should == '4cd428c496f0734eef000007'
40
41
  end
41
42
 
42
43
  it "should return the ticket class" do
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ticketmaster-kanbanpad}
8
- s.version = "0.1.5"
8
+ s.version = "0.1.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["HybridGroup"]
12
- s.date = %q{2011-02-01}
12
+ s.date = %q{2011-02-23}
13
13
  s.description = %q{Allows ticketmaster to interact with kanbanpad.}
14
14
  s.email = %q{sonia@hybridgroup.com}
15
15
  s.extra_rdoc_files = [
@@ -29,6 +29,7 @@ Gem::Specification.new do |s|
29
29
  "lib/ticketmaster-kanbanpad.rb",
30
30
  "rakefile",
31
31
  "spec/comments_spec.rb",
32
+ "spec/fixtures/all.json",
32
33
  "spec/fixtures/projects.json",
33
34
  "spec/fixtures/projects.xml",
34
35
  "spec/fixtures/projects/be74b643b64e3dc79aa0.json",
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ticketmaster-kanbanpad
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 5
10
- version: 0.1.5
9
+ - 6
10
+ version: 0.1.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - HybridGroup
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-02-01 00:00:00 -08:00
18
+ date: 2011-02-23 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -56,6 +56,7 @@ files:
56
56
  - lib/ticketmaster-kanbanpad.rb
57
57
  - rakefile
58
58
  - spec/comments_spec.rb
59
+ - spec/fixtures/all.json
59
60
  - spec/fixtures/projects.json
60
61
  - spec/fixtures/projects.xml
61
62
  - spec/fixtures/projects/be74b643b64e3dc79aa0.json