taskmapper-github 0.10.4 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  source "http://rubygems.org"
2
2
  gem "taskmapper", "~> 0.8"
3
- gem "octokit", "~> 1.9"
3
+ gem "octokit", :git => "git://github.com/ajonas04/octokit.git"
4
4
  group :development do
5
5
  gem "jeweler", "~> 1.6"
6
6
  gem "rspec", "~> 2.3"
data/Gemfile.lock CHANGED
@@ -1,56 +1,61 @@
1
+ GIT
2
+ remote: git://github.com/ajonas04/octokit.git
3
+ revision: 44633e89f77b0136cf496c6048bb751586f60b43
4
+ specs:
5
+ octokit (1.18.0)
6
+ addressable (~> 2.2)
7
+ faraday (~> 0.8)
8
+ faraday_middleware (~> 0.8)
9
+ hashie (~> 1.2)
10
+ multi_json (~> 1.3)
11
+
1
12
  GEM
2
13
  remote: http://rubygems.org/
3
14
  specs:
4
- activemodel (3.2.6)
5
- activesupport (= 3.2.6)
15
+ activemodel (3.2.11)
16
+ activesupport (= 3.2.11)
6
17
  builder (~> 3.0.0)
7
- activeresource (3.2.6)
8
- activemodel (= 3.2.6)
9
- activesupport (= 3.2.6)
10
- activesupport (3.2.6)
18
+ activeresource (3.2.11)
19
+ activemodel (= 3.2.11)
20
+ activesupport (= 3.2.11)
21
+ activesupport (3.2.11)
11
22
  i18n (~> 0.6)
12
23
  multi_json (~> 1.0)
13
- addressable (2.2.8)
14
- builder (3.0.0)
24
+ addressable (2.3.2)
25
+ builder (3.0.4)
15
26
  diff-lcs (1.1.3)
16
27
  fakeweb (1.3.0)
17
- faraday (0.8.1)
28
+ faraday (0.8.4)
18
29
  multipart-post (~> 1.1)
19
- faraday_middleware (0.8.8)
30
+ faraday_middleware (0.9.0)
20
31
  faraday (>= 0.7.4, < 0.9)
21
32
  git (1.2.5)
22
33
  hashie (1.2.0)
23
- i18n (0.6.0)
34
+ i18n (0.6.1)
24
35
  jeweler (1.8.4)
25
36
  bundler (~> 1.0)
26
37
  git (>= 1.2.5)
27
38
  rake
28
39
  rdoc
29
- json (1.7.3)
30
- multi_json (1.3.6)
40
+ json (1.7.6)
41
+ multi_json (1.5.0)
31
42
  multipart-post (1.1.5)
32
- octokit (1.9.1)
33
- addressable (~> 2.2)
34
- faraday (~> 0.8)
35
- faraday_middleware (~> 0.8)
36
- hashie (~> 1.2)
37
- multi_json (~> 1.3)
38
- rake (0.9.2.2)
43
+ rake (10.0.3)
39
44
  rcov (1.0.0)
40
45
  rdoc (3.12)
41
46
  json (~> 1.4)
42
- rspec (2.11.0)
43
- rspec-core (~> 2.11.0)
44
- rspec-expectations (~> 2.11.0)
45
- rspec-mocks (~> 2.11.0)
46
- rspec-core (2.11.0)
47
- rspec-expectations (2.11.1)
47
+ rspec (2.12.0)
48
+ rspec-core (~> 2.12.0)
49
+ rspec-expectations (~> 2.12.0)
50
+ rspec-mocks (~> 2.12.0)
51
+ rspec-core (2.12.2)
52
+ rspec-expectations (2.12.1)
48
53
  diff-lcs (~> 1.1.3)
49
- rspec-mocks (2.11.1)
50
- simplecov (0.6.4)
54
+ rspec-mocks (2.12.1)
55
+ simplecov (0.7.1)
51
56
  multi_json (~> 1.0)
52
- simplecov-html (~> 0.5.3)
53
- simplecov-html (0.5.3)
57
+ simplecov-html (~> 0.7.1)
58
+ simplecov-html (0.7.1)
54
59
  taskmapper (0.8.0)
55
60
  activeresource (~> 3.0)
56
61
  activesupport (~> 3.0)
@@ -62,7 +67,7 @@ PLATFORMS
62
67
  DEPENDENCIES
63
68
  fakeweb (~> 1.3)
64
69
  jeweler (~> 1.6)
65
- octokit (~> 1.9)
70
+ octokit!
66
71
  rcov (~> 1.0)
67
72
  rspec (~> 2.3)
68
73
  simplecov (~> 0.5)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.10.4
1
+ 0.11.0
@@ -6,16 +6,15 @@ module TaskMapper::Provider
6
6
  # versions of the ticket.
7
7
  #
8
8
  class Comment < TaskMapper::Provider::Base::Comment
9
- attr_accessor :prefix_options
10
9
 
11
10
  def initialize(*object)
12
11
  if object.first
13
12
  object = object.first
14
13
  unless object.is_a? Hash
15
14
  hash = {:id => object.id,
16
- :body => object.body,
17
- :created_at => object.created_at,
18
- :author => object.user.login}
15
+ :body => object.body,
16
+ :created_at => object.created_at,
17
+ :author => object.user.login}
19
18
  else
20
19
  hash = object
21
20
  end
@@ -28,19 +27,15 @@ module TaskMapper::Provider
28
27
  end
29
28
 
30
29
  def created_at
31
- @created_at ||= begin
32
- Time.parse(self[:created_at])
33
- rescue
34
- self[:created_at]
35
- end
30
+ Time.parse(self[:created_at])
31
+ rescue
32
+ self[:created_at]
36
33
  end
37
34
 
38
35
  def updated_at
39
- @updated_at ||= begin
40
- Time.parse(self[:updated_at])
41
- rescue
42
- self[:updated_at]
43
- end
36
+ Time.parse(self[:updated_at])
37
+ rescue
38
+ self[:updated_at]
44
39
  end
45
40
 
46
41
  # declare needed overloaded methods here
@@ -50,7 +45,8 @@ module TaskMapper::Provider
50
45
  end
51
46
 
52
47
  def self.find_all(project_id, ticket_id)
53
- TaskMapper::Provider::Github.api.issue_comments(project_id, ticket_id).collect do |comment|
48
+ current_time = Time.now.httpdate
49
+ Array(TaskMapper::Provider::Github.api.issue_comments(project_id, ticket_id, :since => current_time)).collect do |comment|
54
50
  comment.merge!(:project_id => project_id, :ticket_id => ticket_id)
55
51
  clean_body! comment
56
52
  self.new comment
@@ -58,10 +54,11 @@ module TaskMapper::Provider
58
54
  end
59
55
 
60
56
  def self.create(project_id, ticket_id, comment)
61
- comment = comment[:body]
62
- github_comment = TaskMapper::Provider::Github.api.add_comment(project_id, ticket_id, comment)
63
- github_comment.merge!(:project_id => project_id, :ticket_id => ticket_id)
64
- self.new github_comment
57
+ self.new github_comment(project_id, ticket_id, comment[:body]).merge!(:project_id => project_id, :ticket_id => ticket_id)
58
+ end
59
+
60
+ def self.github_comment(project_id, number, body)
61
+ TaskMapper::Provider::Github.api.add_comment(project_id, number, body)
65
62
  end
66
63
 
67
64
  # See https://www.kanbanpad.com/projects/31edb8d134e7967c1f0d#!xt-4f994f2101428900070759fd
@@ -74,8 +71,8 @@ module TaskMapper::Provider
74
71
  end
75
72
 
76
73
  private
77
- def update_comment(repo, number, comment, options = {})
78
- TaskMapper::Provider::Github.api.update_comment repo, number, comment, options
74
+ def update_comment(repo, number, comment)
75
+ TaskMapper::Provider::Github.api.update_comment repo, number, comment
79
76
  true
80
77
  end
81
78
 
@@ -6,7 +6,7 @@ module TaskMapper::Provider
6
6
  class << self
7
7
  attr_accessor :login, :api, :user_token
8
8
  end
9
-
9
+
10
10
  # This is for cases when you want to instantiate using TaskMapper::Provider::Github.new(auth)
11
11
  def self.new(auth = {})
12
12
  TaskMapper.new(:github, auth)
@@ -15,23 +15,17 @@ module TaskMapper::Provider
15
15
  # declare needed overloaded methods here
16
16
  def authorize(auth = {})
17
17
  @authentication ||= TaskMapper::Authenticator.new(auth)
18
- auth = @authentication
19
- login = auth.login || auth.username
20
- if auth.login.blank? and auth.username.blank?
18
+ login = @authentication.login || @authentication.username
19
+ if login.blank?
21
20
  raise TaskMapper::Exception.new('Please provide at least a username')
22
- elsif auth.token
23
- TaskMapper::Provider::Github.login = login
24
- TaskMapper::Provider::Github.user_token = auth.token
25
- TaskMapper::Provider::Github.api = Octokit::Client.new(:login => login, :token => auth.token)
26
- elsif auth.password
27
- TaskMapper::Provider::Github.login = login
28
- TaskMapper::Provider::Github.user_token = auth.token
29
- TaskMapper::Provider::Github.api = Octokit::Client.new(:login => login, :password => auth.password)
21
+ elsif @authentication.token
22
+ TaskMapper::Provider::Github.api = Octokit::Client.new(:login => login, :token => @authentication.token)
23
+ elsif @authentication.password
24
+ TaskMapper::Provider::Github.api = Octokit::Client.new(:login => login, :password => @authentication.password)
30
25
  else
31
- TaskMapper::Provider::Github.login = login
32
- TaskMapper::Provider::Github.user_token = nil
33
26
  TaskMapper::Provider::Github.api = Octokit::Client.new(:login => login)
34
27
  end
28
+ TaskMapper::Provider::Github.login = login
35
29
  end
36
30
 
37
31
  def valid?
@@ -1,22 +1,20 @@
1
1
  module TaskMapper::Provider
2
2
  module Github
3
3
  # Ticket class for taskmapper-github
4
-
4
+
5
5
  class Ticket < TaskMapper::Provider::Base::Ticket
6
-
7
- @@allowed_states = %w{open close}
8
- attr_accessor :prefix_options
6
+
9
7
  # declare needed overloaded methods here
10
-
8
+
11
9
  def initialize(*object)
12
10
  if object.first
13
11
  object = object.first
14
12
  unless object.is_a? Hash
15
13
  hash = {:id => object.number,
16
- :status => object.state,
17
- :description => object.body,
18
- :user => object.user,
19
- :project_id => object.project_id}
14
+ :status => object.state,
15
+ :description => object.body,
16
+ :user => object.user,
17
+ :project_id => object.project_id}
20
18
  else
21
19
  hash = object
22
20
  end
@@ -35,21 +33,21 @@ module TaskMapper::Provider
35
33
  def description
36
34
  self.body
37
35
  end
38
-
36
+
39
37
  def description=(val)
40
38
  self.body = val
41
39
  end
42
-
40
+
43
41
  def author
44
- self.user.respond_to?('login') ? self.user.login : self.user
42
+ github_user
45
43
  end
46
44
 
47
45
  def requestor
48
- self.user.respond_to?('login') ? self.user.login : self.user
46
+ github_user
49
47
  end
50
48
 
51
49
  def assignee
52
- self.user.respond_to?('login') ? self.user.login : self.user
50
+ github_user
53
51
  end
54
52
 
55
53
  def self.find_by_id(project_id, number)
@@ -64,9 +62,10 @@ module TaskMapper::Provider
64
62
  end
65
63
 
66
64
  def self.find_all(project_id)
65
+ current_time = Time.now.httpdate
67
66
  issues = []
68
- issues += TaskMapper::Provider::Github.api.issues(project_id)
69
- issues += TaskMapper::Provider::Github.api.issues(project_id, {:state => "closed"})
67
+ issues = Array(TaskMapper::Provider::Github.api.issues(project_id, :since => current_time))
68
+ issues += TaskMapper::Provider::Github.api.issues(project_id, {:state => "closed"}) unless issues.empty?
70
69
  issues.collect do |issue|
71
70
  issue.merge!(:project_id => project_id)
72
71
  Ticket.new issue
@@ -114,6 +113,11 @@ module TaskMapper::Provider
114
113
  def comment!(attributes)
115
114
  Comment.create(project_id, number, attributes)
116
115
  end
116
+
117
+ private
118
+ def github_user
119
+ self.user.login || self.user
120
+ end
117
121
  end
118
122
  end
119
123
  end
@@ -1,4 +1,4 @@
1
- #require YOUR_PROVIDER_API
1
+ require 'bundler/setup'
2
2
  require 'octokit'
3
3
  require 'active_support/core_ext/string'
4
4
  require 'net/http'
data/spec/ticket_spec.rb CHANGED
@@ -9,7 +9,7 @@ describe TaskMapper::Provider::Github::Ticket do
9
9
 
10
10
  describe "Retrieving tickets" do
11
11
  before(:each) do
12
- stub_get('https://taskmapper-user:Tm123456@api.github.com/orgs/2hf/repos', 'org_repos.json')
12
+ stub_get('https://taskmapper-user:Tm123456@api.github.com/orgs/2hf/repos?since', 'org_repos.json')
13
13
  stub_get('https://taskmapper-user:Tm123456@api.github.com/repos/taskmapper-user/tmtest-repo/issues/1', 'issues/1.json')
14
14
  stub_get('https://taskmapper-user:Tm123456@api.github.com/repos/taskmapper-user/tmtest-repo/issues', 'issues.json')
15
15
  stub_get('https://taskmapper-user:Tm123456@api.github.com/repos/taskmapper-user/tmtest-repo/issues?state=closed', 'issues.json')
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "taskmapper-github"
8
- s.version = "0.10.4"
8
+ s.version = "0.11.0"
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 = "2012-12-01"
12
+ s.date = "2013-01-23"
13
13
  s.description = "This provides an interface with github through the taskmapper gem."
14
14
  s.email = "hong.quach@abigfisch.com"
15
15
  s.extra_rdoc_files = [
@@ -64,7 +64,7 @@ Gem::Specification.new do |s|
64
64
 
65
65
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
66
66
  s.add_runtime_dependency(%q<taskmapper>, ["~> 0.8"])
67
- s.add_runtime_dependency(%q<octokit>, ["~> 1.9"])
67
+ s.add_runtime_dependency(%q<octokit>, [">= 0"])
68
68
  s.add_development_dependency(%q<jeweler>, ["~> 1.6"])
69
69
  s.add_development_dependency(%q<rspec>, ["~> 2.3"])
70
70
  s.add_development_dependency(%q<fakeweb>, ["~> 1.3"])
@@ -72,7 +72,7 @@ Gem::Specification.new do |s|
72
72
  s.add_development_dependency(%q<rcov>, ["~> 1.0"])
73
73
  else
74
74
  s.add_dependency(%q<taskmapper>, ["~> 0.8"])
75
- s.add_dependency(%q<octokit>, ["~> 1.9"])
75
+ s.add_dependency(%q<octokit>, [">= 0"])
76
76
  s.add_dependency(%q<jeweler>, ["~> 1.6"])
77
77
  s.add_dependency(%q<rspec>, ["~> 2.3"])
78
78
  s.add_dependency(%q<fakeweb>, ["~> 1.3"])
@@ -81,7 +81,7 @@ Gem::Specification.new do |s|
81
81
  end
82
82
  else
83
83
  s.add_dependency(%q<taskmapper>, ["~> 0.8"])
84
- s.add_dependency(%q<octokit>, ["~> 1.9"])
84
+ s.add_dependency(%q<octokit>, [">= 0"])
85
85
  s.add_dependency(%q<jeweler>, ["~> 1.6"])
86
86
  s.add_dependency(%q<rspec>, ["~> 2.3"])
87
87
  s.add_dependency(%q<fakeweb>, ["~> 1.3"])
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: taskmapper-github
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.4
4
+ version: 0.11.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-01 00:00:00.000000000 Z
12
+ date: 2013-01-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: taskmapper
@@ -32,17 +32,17 @@ dependencies:
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  none: false
34
34
  requirements:
35
- - - ~>
35
+ - - ! '>='
36
36
  - !ruby/object:Gem::Version
37
- version: '1.9'
37
+ version: '0'
38
38
  type: :runtime
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
- - - ~>
43
+ - - ! '>='
44
44
  - !ruby/object:Gem::Version
45
- version: '1.9'
45
+ version: '0'
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: jeweler
48
48
  requirement: !ruby/object:Gem::Requirement
@@ -181,7 +181,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
181
181
  version: '0'
182
182
  segments:
183
183
  - 0
184
- hash: -366567343
184
+ hash: 4124351922753570818
185
185
  required_rubygems_version: !ruby/object:Gem::Requirement
186
186
  none: false
187
187
  requirements: