ticketmaster-github 0.3.1 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/provider/comment.rb +6 -15
- data/lib/provider/github.rb +13 -15
- data/lib/provider/project.rb +40 -58
- data/lib/provider/ticket.rb +67 -77
- data/lib/ticketmaster-github.rb +1 -6
- data/spec/comment_spec.rb +6 -19
- data/spec/factories/comment.rb +2 -2
- data/spec/factories/issue.rb +2 -2
- data/spec/factories/repository.rb +2 -2
- data/spec/project_spec.rb +16 -28
- data/spec/spec_helper.rb +3 -3
- data/spec/ticket_spec.rb +29 -45
- data/ticketmaster-github.gemspec +34 -38
- metadata +11 -15
- data/.gitignore +0 -25
- data/lib/github/github.rb +0 -28
data/Rakefile
CHANGED
@@ -11,7 +11,7 @@ begin
|
|
11
11
|
gem.homepage = "http://github.com/kiafaldorius/ticketmaster-github"
|
12
12
|
gem.authors = ["HybridGroup"]
|
13
13
|
gem.add_development_dependency "rspec", ">= 1.2.9"
|
14
|
-
gem.add_dependency "
|
14
|
+
gem.add_dependency "octokit"
|
15
15
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
16
16
|
end
|
17
17
|
Jeweler::GemcutterTasks.new
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.4.1
|
data/lib/provider/comment.rb
CHANGED
@@ -7,7 +7,6 @@ module TicketMaster::Provider
|
|
7
7
|
#
|
8
8
|
class Comment < TicketMaster::Provider::Base::Comment
|
9
9
|
attr_accessor :prefix_options
|
10
|
-
API = GithubComment
|
11
10
|
|
12
11
|
def initialize(*options)
|
13
12
|
if options.first.is_a? Hash
|
@@ -37,23 +36,15 @@ module TicketMaster::Provider
|
|
37
36
|
end
|
38
37
|
|
39
38
|
# declare needed overloaded methods here
|
40
|
-
|
41
|
-
|
39
|
+
|
40
|
+
def self.find(project_id, ticket_id)
|
41
|
+
TicketMaster::Provider::Github.api.issue_comments("#{TicketMaster::Provider::Github.login}/#{project_id}", ticket_id).collect { |comment| self.new comment }
|
42
42
|
end
|
43
|
-
|
44
|
-
def self.find_by_attributes(project_id, ticket_id, attributes = {})
|
45
|
-
warn "Github API only gets all comments"
|
46
|
-
self::API.find_all(Project.find(:first, [project_id]), ticket_id).collect {|comment| self.new comment, project_id, ticket_id}
|
47
|
-
end
|
48
|
-
|
49
|
-
def self.search(project_id, ticket_id, options = {}, limit = 1000)
|
50
|
-
warn "This method is not supported by Github's API"
|
51
|
-
end
|
52
|
-
|
43
|
+
|
53
44
|
def self.create(project_id, ticket_id, comment)
|
54
|
-
|
45
|
+
self.new TicketMaster::Provider::Github.api.add_comment("#{TicketMaster::Provider::Github.login}/#{project_id}", ticket_id, comment)
|
55
46
|
end
|
56
|
-
|
47
|
+
|
57
48
|
end
|
58
49
|
end
|
59
50
|
end
|
data/lib/provider/github.rb
CHANGED
@@ -2,11 +2,9 @@ module TicketMaster::Provider
|
|
2
2
|
# This is the Github Provider for ticketmaster
|
3
3
|
module Github
|
4
4
|
include TicketMaster::Provider::Base
|
5
|
-
PROJECT_API = Octopi::Repository
|
6
|
-
ISSUE_API = Octopi::Issue
|
7
5
|
|
8
6
|
class << self
|
9
|
-
attr_accessor :login
|
7
|
+
attr_accessor :login, :api
|
10
8
|
end
|
11
9
|
|
12
10
|
# This is for cases when you want to instantiate using TicketMaster::Provider::Github.new(auth)
|
@@ -22,31 +20,31 @@ module TicketMaster::Provider
|
|
22
20
|
raise TicketMaster::Exception.new('Please provide at least a username')
|
23
21
|
elsif auth.token.blank?
|
24
22
|
TicketMaster::Provider::Github.login = auth.login || auth.username
|
25
|
-
|
23
|
+
TicketMaster::Provider::Github.api = Octokit.client(:login => auth.login)
|
26
24
|
else
|
27
25
|
TicketMaster::Provider::Github.login = auth.login || auth.username
|
28
|
-
|
29
|
-
Octopi::Api.api.token = auth.token
|
30
|
-
Octopi::Api.api.login = auth.login || auth.username
|
26
|
+
TicketMaster::Provider::Github.api = Octokit.client(:login => auth.login, :token => auth.token)
|
31
27
|
end
|
32
28
|
end
|
33
29
|
|
34
30
|
def projects(*options)
|
35
31
|
if options.empty?
|
36
|
-
|
37
|
-
elsif
|
38
|
-
options.collect{|name| Project.
|
32
|
+
Project.find_all(options)
|
33
|
+
elsif options.first.is_a? Array
|
34
|
+
options.first.collect { |name| Project.find_by_id(name) }
|
35
|
+
elsif options.first.is_a? Hash
|
36
|
+
Project.find_by_attributes(options.first)
|
39
37
|
end
|
40
38
|
end
|
41
|
-
|
42
|
-
def project(*
|
43
|
-
unless
|
44
|
-
Project.
|
39
|
+
|
40
|
+
def project(*project)
|
41
|
+
unless project.empty?
|
42
|
+
Project.find_by_id(project.first)
|
45
43
|
else
|
46
44
|
super
|
47
45
|
end
|
48
46
|
end
|
49
|
-
|
47
|
+
|
50
48
|
end
|
51
49
|
end
|
52
50
|
|
data/lib/provider/project.rb
CHANGED
@@ -4,57 +4,29 @@ module TicketMaster::Provider
|
|
4
4
|
#
|
5
5
|
#
|
6
6
|
class Project < TicketMaster::Provider::Base::Project
|
7
|
-
attr_accessor :prefix_options, :name, :user
|
8
7
|
|
9
|
-
API = Octopi::Repository
|
10
8
|
# declare needed overloaded methods here
|
11
|
-
|
12
|
-
def initialize(*object)
|
9
|
+
def initialize(*object)
|
13
10
|
if object.first
|
14
11
|
object = object.first
|
15
|
-
@system_data = {:client => object}
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
'actions' => object.actions,
|
28
|
-
'score' => object.score,
|
29
|
-
'language' => object.language,
|
30
|
-
'followers' => object.followers,
|
31
|
-
'type' => object.type,
|
32
|
-
'username' => object.username,
|
33
|
-
'id' => object.name,
|
34
|
-
'pushed' => object.pushed,
|
35
|
-
'created' => object.created}
|
36
|
-
|
37
|
-
@name = object.name
|
38
|
-
@user = object.username
|
39
|
-
super hash
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def self.search(options = {}, limit = 100)
|
44
|
-
raise "Please supply arguments for search" if options.blank?
|
45
|
-
if options.is_a? Hash
|
46
|
-
r = self.new self::API.find(options)
|
47
|
-
[] << r
|
48
|
-
else
|
49
|
-
self::API.find_all(options)[0...limit].collect { |repo| self.new repo }
|
50
|
-
end
|
12
|
+
@system_data = {:client => object}
|
13
|
+
unless object.is_a? Hash
|
14
|
+
hash = {:description => object.description,
|
15
|
+
:created_at => object.created_at,
|
16
|
+
:name => object.name,
|
17
|
+
:id => object.name,
|
18
|
+
:owner => object.owner}
|
19
|
+
else
|
20
|
+
hash = object
|
21
|
+
end
|
22
|
+
super hash
|
23
|
+
end
|
51
24
|
end
|
52
|
-
|
53
|
-
def
|
54
|
-
|
55
|
-
self.new self::API.find({:user => TicketMaster::Provider::Github.login, :repo => id})
|
25
|
+
|
26
|
+
def id
|
27
|
+
self[:name]
|
56
28
|
end
|
57
|
-
|
29
|
+
|
58
30
|
# copy from this.copy(that) copies that into this
|
59
31
|
def copy(project)
|
60
32
|
project.tickets.each do |ticket|
|
@@ -65,26 +37,36 @@ module TicketMaster::Provider
|
|
65
37
|
end
|
66
38
|
end
|
67
39
|
end
|
68
|
-
|
69
|
-
def
|
70
|
-
|
71
|
-
#return api if options.length == 0 and symbol == :first
|
72
|
-
api.find(*options)
|
73
|
-
end
|
40
|
+
|
41
|
+
def self.find_by_attributes(attributes = {})
|
42
|
+
search_by_attribute(find_all, attributes).collect { |project| self.new project }
|
74
43
|
end
|
75
44
|
|
76
|
-
def
|
77
|
-
TicketMaster::Provider::Github
|
45
|
+
def self.find_by_id(id)
|
46
|
+
self.new TicketMaster::Provider::Github.api.repository("#{TicketMaster::Provider::Github.login}/#{id}")
|
78
47
|
end
|
79
|
-
|
48
|
+
|
49
|
+
def self.find_all(*options)
|
50
|
+
TicketMaster::Provider::Github.api.repositories(TicketMaster::Provider::Github.login).collect { |repository|
|
51
|
+
self.new repository }
|
52
|
+
end
|
53
|
+
|
80
54
|
def tickets(*options)
|
81
|
-
|
55
|
+
TicketMaster::Provider::Github::Ticket.find(self.id, options)
|
56
|
+
end
|
57
|
+
|
58
|
+
def ticket(*options)
|
59
|
+
unless options.empty?
|
60
|
+
TicketMaster::Provider::Github::Ticket.find_by_id(self.id, options.first)
|
61
|
+
else
|
62
|
+
TicketMaster::Provider::Github::Ticket
|
63
|
+
end
|
82
64
|
end
|
83
|
-
|
65
|
+
|
84
66
|
def ticket!(*options)
|
85
|
-
TicketMaster::Provider::Github::Ticket.open(
|
67
|
+
TicketMaster::Provider::Github::Ticket.open(self.id, options.first)
|
86
68
|
end
|
87
|
-
|
88
69
|
end
|
70
|
+
|
89
71
|
end
|
90
72
|
end
|
data/lib/provider/ticket.rb
CHANGED
@@ -6,103 +6,93 @@ module TicketMaster::Provider
|
|
6
6
|
|
7
7
|
@@allowed_states = %w{open close}
|
8
8
|
attr_accessor :prefix_options
|
9
|
-
API = Octopi::Issue
|
10
9
|
# declare needed overloaded methods here
|
11
10
|
|
12
|
-
def initialize(*object)
|
11
|
+
def initialize(*object)
|
12
|
+
project_id = object.shift
|
13
13
|
if object.first
|
14
14
|
object = object.first
|
15
|
-
@system_data = {:client => object}
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
else
|
36
|
-
hash = object
|
37
|
-
end
|
15
|
+
@system_data = {:client => object}
|
16
|
+
unless object.is_a? Hash
|
17
|
+
hash = {:title => object.title,
|
18
|
+
:created_at => object.created_at,
|
19
|
+
:updated_at => object.updated_at,
|
20
|
+
:number => object.number,
|
21
|
+
:user => object.user,
|
22
|
+
:id => object.number,
|
23
|
+
:state => object.state,
|
24
|
+
:html_url => object.html_url,
|
25
|
+
:position => object.position,
|
26
|
+
:description => object.body,
|
27
|
+
:project_id => project_id}
|
28
|
+
else
|
29
|
+
object.merge!(:project_id => project_id)
|
30
|
+
hash = object
|
31
|
+
end
|
32
|
+
super hash
|
33
|
+
end
|
34
|
+
end
|
38
35
|
|
39
|
-
|
40
|
-
|
36
|
+
def id
|
37
|
+
self[:number]
|
41
38
|
end
|
42
|
-
|
43
|
-
def self.find_by_id(project_id,
|
44
|
-
|
39
|
+
|
40
|
+
def self.find_by_id(project_id, number)
|
41
|
+
self.new(project_id, TicketMaster::Provider::Github.api.issue("#{TicketMaster::Provider::Github.login}/#{project_id}", number))
|
45
42
|
end
|
46
|
-
|
43
|
+
|
44
|
+
def self.find(project_id, *options)
|
45
|
+
if options.first.empty?
|
46
|
+
self.find_all(project_id)
|
47
|
+
elsif options[0].first.is_a? Array
|
48
|
+
options.first.collect { |number| self.find_by_id(project_id, number) }
|
49
|
+
elsif options[0].first.is_a? Hash
|
50
|
+
self.find_by_attributes(project_id, options[0].first)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
47
54
|
def self.find_by_attributes(project_id, attributes = {})
|
48
|
-
|
49
|
-
issues
|
50
|
-
if attributes[:state].nil?
|
51
|
-
attributes[:state] = 'open'
|
52
|
-
issues += self::API.find_all(build_attributes(project_id, attributes))
|
53
|
-
attributes[:state] = 'closed'
|
54
|
-
begin
|
55
|
-
issues += self::API.find_all(build_attributes(project_id, attributes))
|
56
|
-
rescue APICache::TimeoutError
|
57
|
-
warn "Unable to fetch closed issues due to timeout"
|
58
|
-
end
|
59
|
-
else
|
60
|
-
issues = self::API.find_all(build_attributes(project_id, attributes))
|
61
|
-
end
|
62
|
-
issues.collect { |issue| self.new issue }
|
55
|
+
issues = self.find_all(project_id)
|
56
|
+
search_by_attribute(issues, attributes)
|
63
57
|
end
|
64
|
-
|
65
|
-
def self.
|
66
|
-
|
67
|
-
|
58
|
+
|
59
|
+
def self.find_all(project_id)
|
60
|
+
issues = []
|
61
|
+
issues += TicketMaster::Provider::Github.api.issues("#{TicketMaster::Provider::Github.login}/#{project_id}")
|
62
|
+
state = 'closed'
|
63
|
+
issues += TicketMaster::Provider::Github.api.issues("#{TicketMaster::Provider::Github.login}/#{project_id}", state)
|
64
|
+
issues.collect { |issue| Ticket.new(project_id, issue) }
|
68
65
|
end
|
69
|
-
|
66
|
+
|
70
67
|
def self.open(project_id, *options)
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
self.find(project_id, :all).last
|
75
|
-
end
|
68
|
+
body = options.first.delete(:body)
|
69
|
+
title = options.first.delete(:title)
|
70
|
+
TicketMaster::Provider::Github.api.create_issue("#{TicketMaster::Provider::Github.login}/#{project_id}", title, body, options.first)
|
76
71
|
end
|
77
|
-
|
78
|
-
def
|
79
|
-
|
72
|
+
|
73
|
+
def save
|
74
|
+
t = Ticket.find_by_id(project_id, number)
|
75
|
+
return false if t.title == title and t.body == body
|
76
|
+
Ticket.new(project_id, TicketMaster::Provider::Github.api.update_issue("#{TicketMaster::Provider::Github.login}/#{project_id}", number, title, body))
|
77
|
+
true
|
80
78
|
end
|
81
|
-
|
79
|
+
|
82
80
|
def reopen
|
83
|
-
|
81
|
+
Ticket.new(project_id, TicketMaster::Provider::Github.api.reopen_issue("#{TicketMaster::Provider::Github.login}/#{project_id}", number))
|
84
82
|
end
|
85
|
-
|
86
|
-
def
|
87
|
-
|
88
|
-
|
89
|
-
return false if t.title == title and t.body == body
|
90
|
-
|
91
|
-
t.title = title
|
92
|
-
t.body = body
|
93
|
-
t.save
|
94
|
-
|
95
|
-
true
|
83
|
+
|
84
|
+
def close
|
85
|
+
Ticket.new(project_id, TicketMaster::Provider::Github.api.close_issue("#{TicketMaster::Provider::Github.login}/#{project_id}", number))
|
96
86
|
end
|
97
|
-
|
87
|
+
|
98
88
|
def comments
|
99
|
-
|
89
|
+
Comment.find(project_id, number)
|
100
90
|
end
|
101
|
-
|
91
|
+
|
102
92
|
def comment!(comment)
|
103
|
-
|
93
|
+
Comment.create(project_id, number, comment)
|
104
94
|
end
|
105
|
-
|
95
|
+
|
106
96
|
end
|
107
97
|
end
|
108
98
|
end
|
data/lib/ticketmaster-github.rb
CHANGED
@@ -1,10 +1,5 @@
|
|
1
1
|
#require YOUR_PROVIDER_API
|
2
|
-
require '
|
3
|
-
require 'httparty'
|
4
|
-
|
5
|
-
%w{ github }.each do |f|
|
6
|
-
require File.dirname(__FILE__) + '/github/' + f + '.rb';
|
7
|
-
end
|
2
|
+
require 'octokit'
|
8
3
|
|
9
4
|
%w{ github ticket project comment }.each do |f|
|
10
5
|
require File.dirname(__FILE__) + '/provider/' + f + '.rb';
|
data/spec/comment_spec.rb
CHANGED
@@ -1,32 +1,19 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
2
|
|
3
3
|
describe "Ticketmaster::Provider::Github::Comment" do
|
4
|
-
before(:all) do
|
5
|
-
@github = TicketMaster.new(:github, {:login => 'juanespinosa', :token => 'asdfghk'})
|
6
|
-
@klass = TicketMaster::Provider::Github::Comment
|
7
|
-
@api = TicketMaster::Provider::Github::GithubComment
|
8
|
-
@repository = Factory.build(:repository)
|
9
|
-
end
|
10
4
|
|
11
5
|
before(:each) do
|
12
|
-
|
13
|
-
|
14
|
-
@
|
15
|
-
@comment = Factory.build(:comment)
|
16
|
-
@comments = [@comment]
|
17
|
-
Octopi::Repository.stub!(:find_all).and_return([@repository])
|
6
|
+
@github = TicketMaster.new(:github, {:login => 'cored', :token => 'kdkdkd'})
|
7
|
+
@klass = TicketMaster::Provider::Github::Comment
|
8
|
+
@api = Octokit::Client
|
18
9
|
end
|
19
10
|
|
20
11
|
it "should be able to load all comments" do
|
21
|
-
|
22
|
-
@ticket.comments.should be_an_instance_of(Array)
|
23
|
-
@ticket.comments.first.should be_an_instance_of(@klass)
|
12
|
+
pending
|
24
13
|
end
|
25
14
|
|
26
15
|
it "should be able to create a new comment" do
|
27
|
-
|
28
|
-
@comment = @ticket.comment!("A new comment")
|
29
|
-
@comment.should be_an_instance_of(@klass)
|
16
|
+
pending
|
30
17
|
end
|
31
18
|
|
32
|
-
end
|
19
|
+
end
|
data/spec/factories/comment.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
Factory.define :comment
|
1
|
+
Factory.define :comment do |p|
|
2
2
|
p.body 'Body message'
|
3
3
|
p.id '335287'
|
4
4
|
p.created_at '2010/07/30 13:50:42'
|
5
5
|
p.updated_at '2010/07/30 13:50:42'
|
6
6
|
p.user 'juanespinosa'
|
7
|
-
end
|
7
|
+
end
|
data/spec/factories/issue.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Factory.define :issue
|
1
|
+
Factory.define :issue do |p|
|
2
2
|
p.repository 'test-juange'
|
3
3
|
p.user 'juanespinosa'
|
4
4
|
p.updated_at ''
|
@@ -10,4 +10,4 @@ Factory.define :issue, :class => Octopi::Issue do |p|
|
|
10
10
|
p.labels ''
|
11
11
|
p.state 'open'
|
12
12
|
p.created_at ''
|
13
|
-
end
|
13
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
Factory.define :repository
|
1
|
+
Factory.define :repository do |p|
|
2
2
|
p.description ''
|
3
3
|
p.url ''
|
4
4
|
p.forks ''
|
@@ -19,4 +19,4 @@ Factory.define :repository, :class => Octopi::Repository do |p|
|
|
19
19
|
p.id ''
|
20
20
|
p.pushed ''
|
21
21
|
p.created ''
|
22
|
-
end
|
22
|
+
end
|
data/spec/project_spec.rb
CHANGED
@@ -3,54 +3,42 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
3
3
|
describe "Ticketmaster::Provider::Github::Project" do
|
4
4
|
|
5
5
|
before(:all) do
|
6
|
-
@repo_name = "
|
6
|
+
@repo_name = "jquery-mobile"
|
7
7
|
@klass = TicketMaster::Provider::Github::Project
|
8
8
|
end
|
9
9
|
|
10
10
|
before(:each) do
|
11
|
-
@
|
12
|
-
@repositories = [@repository]
|
13
|
-
@github = TicketMaster.new(:github, {:login => 'juanespinosa', :token => 'asdfghk'})
|
11
|
+
@github = TicketMaster.new(:github, {:login => 'jquery' })
|
14
12
|
end
|
15
13
|
|
16
14
|
it "should be able to load all projects" do
|
17
|
-
|
18
|
-
|
15
|
+
@github.projects.should be_an_instance_of(Array)
|
16
|
+
@github.projects.first.should be_an_instance_of(@klass)
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should be able to load all projects based on an array of name(id)" do
|
20
|
+
projects = @github.projects([@repo_name])
|
19
21
|
projects.should be_an_instance_of(Array)
|
20
22
|
projects.first.should be_an_instance_of(@klass)
|
23
|
+
projects.first.id.should == @repo_name
|
21
24
|
end
|
22
|
-
|
25
|
+
|
23
26
|
it "should be able to find by name(id)" do
|
24
|
-
Octopi::Repository.stub!(:find).and_return(@repository)
|
25
27
|
p = @github.project(@repo_name)
|
26
28
|
p.should be_an_instance_of(@klass)
|
27
29
|
p.name.should be_eql(@repo_name)
|
28
30
|
end
|
29
|
-
|
30
|
-
it "should be able to find by name(id) with find method" do
|
31
|
-
Octopi::Repository.stub!(:find).and_return(@repository)
|
31
|
+
|
32
|
+
it "should be able to find by name(id) with the find method" do
|
32
33
|
p = @github.project.find(@repo_name)
|
33
34
|
p.should be_an_instance_of(@klass)
|
34
35
|
p.name.should be_eql(@repo_name)
|
35
36
|
end
|
36
37
|
|
37
|
-
it "should be able to
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
p.first.should be_an_instance_of(@klass)
|
42
|
-
end
|
43
|
-
|
44
|
-
it "should be able to find by attributes(name and repo)" do
|
45
|
-
Octopi::Repository.stub!(:find).and_return(@repository)
|
46
|
-
p = @github.project.find(:first, {:user => 'juanespinosa', :repo => 'test-juange'})
|
47
|
-
p.should be_an_instance_of(@klass)
|
48
|
-
end
|
49
|
-
|
50
|
-
it "should be able to find repos in an array" do
|
51
|
-
Octopi::Repository.stub!(:find_all).and_return(@repositories)
|
52
|
-
p = @github.project.find(:all, ['test-juange', 'ticketmaster'])
|
53
|
-
p.should be_an_instance_of(Array)
|
38
|
+
it "should be able to find by attributes" do
|
39
|
+
projects = @github.projects(:name => @repo_name)
|
40
|
+
projects.should be_an_instance_of(Array)
|
41
|
+
projects.first.id.should be_eql(@repo_name)
|
54
42
|
end
|
55
43
|
end
|
56
44
|
|
data/spec/spec_helper.rb
CHANGED
@@ -2,11 +2,11 @@ $LOAD_PATH.unshift(File.dirname(__FILE__))
|
|
2
2
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
3
|
|
4
4
|
require 'rubygems'
|
5
|
-
require 'ticketmaster'
|
6
|
-
require 'ticketmaster-github'
|
7
5
|
require 'spec'
|
8
6
|
require 'factory_girl'
|
7
|
+
require 'ticketmaster'
|
8
|
+
require 'ticketmaster-github'
|
9
9
|
|
10
10
|
Dir["#{File.dirname(__FILE__)}/factories/*.rb"].each {|f| require f}
|
11
11
|
Spec::Runner.configure do |config|
|
12
|
-
end
|
12
|
+
end
|
data/spec/ticket_spec.rb
CHANGED
@@ -1,65 +1,49 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
2
|
|
3
3
|
describe "Ticketmaster::Provider::Github::Ticket" do
|
4
|
-
before(:
|
5
|
-
@github =
|
4
|
+
before(:each) do
|
5
|
+
@github = TicketMaster.new(:github, {:login => 'jquery'})
|
6
|
+
@project = @github.project('jquery-mobile')
|
7
|
+
@ticket_id = 1
|
8
|
+
@ticket = {:body => 'Creating a ticket from API', :title => 'Ticket for jquery', :number => 1}
|
6
9
|
@klass = TicketMaster::Provider::Github::Ticket
|
7
|
-
@api =
|
10
|
+
@api = Octokit::Client
|
8
11
|
end
|
9
12
|
|
10
|
-
|
11
|
-
@
|
12
|
-
@project
|
13
|
-
@ticket = Factory.build(:issue)
|
14
|
-
@tickets = [@ticket]
|
15
|
-
@ticket.stub_chain(:repository, :name).and_return(@ticket.repository)
|
13
|
+
it "should be able to load all tickets" do
|
14
|
+
@project.tickets.should be_an_instance_of(Array)
|
15
|
+
@project.tickets.first.should be_an_instance_of(@klass)
|
16
16
|
end
|
17
17
|
|
18
|
-
it "should be able to load
|
19
|
-
@
|
20
|
-
tickets = @project.tickets
|
18
|
+
it "should be able to load tickets from an array of ids" do
|
19
|
+
tickets = @project.tickets([@ticket_id])
|
21
20
|
tickets.should be_an_instance_of(Array)
|
22
21
|
tickets.first.should be_an_instance_of(@klass)
|
23
22
|
end
|
24
23
|
|
25
|
-
it "should be able to
|
26
|
-
@
|
27
|
-
|
28
|
-
|
29
|
-
@tickets.first.should be_an_instance_of(@klass)
|
30
|
-
@tickets.first.number.should == @ticket_id
|
31
|
-
end
|
32
|
-
|
33
|
-
it "should be able to find a single ticket based on number attribute" do
|
34
|
-
@api.stub!(:find).and_return(@ticket)
|
35
|
-
@ticket = @project.tickets({:number => @ticket_id})
|
36
|
-
@ticket.should be_an_instance_of(@klass)
|
24
|
+
it "should be able to find tickets based on attributes" do
|
25
|
+
tickets = @project.tickets(:number => @ticket_id)
|
26
|
+
tickets.should be_an_instance_of(Array)
|
27
|
+
tickets.first.should be_an_instance_of(@klass)
|
37
28
|
end
|
38
29
|
|
39
30
|
it "should find a ticket by id(number)" do
|
40
|
-
@
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
it "should be able to open a new ticket" do
|
45
|
-
@api.stub!(:open).and_return(@ticket)
|
46
|
-
tick = @project.ticket!({:body => "new ticket", :title => "New"})
|
47
|
-
tick.should be_an_instance_of(@klass)
|
31
|
+
ticket = @project.ticket(@ticket_id)
|
32
|
+
ticket.should be_an_instance_of(@klass)
|
33
|
+
ticket.title.should be_eql('Move Ajax Test to Core')
|
48
34
|
end
|
49
35
|
|
36
|
+
it "should be able to open a new ticket"
|
37
|
+
|
50
38
|
it "should be able to update a existing ticket" do
|
51
|
-
@
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
it "should be able to close a ticket" do
|
57
|
-
@api.stub_chain(:find, :close!).and_return(@ticket)
|
58
|
-
@klass.new.close.should be_an_instance_of(@klass)
|
39
|
+
@api.stub!('issue').and_return(@ticket)
|
40
|
+
tick = @project.ticket(@ticket_id)
|
41
|
+
tick.stub!('save').and_return(true)
|
42
|
+
tick.title = 'hello'
|
43
|
+
tick.save.should be_eql(true)
|
59
44
|
end
|
60
45
|
|
61
|
-
it "should be able to reopen a ticket"
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
end
|
46
|
+
it "should be able to reopen a ticket"
|
47
|
+
|
48
|
+
it "should be able to close a ticket"
|
49
|
+
end
|
data/ticketmaster-github.gemspec
CHANGED
@@ -1,75 +1,71 @@
|
|
1
1
|
# Generated by jeweler
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{ticketmaster-github}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.4.1"
|
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-
|
12
|
+
s.date = %q{2011-04-07}
|
13
13
|
s.description = %q{This provides an interface with github through the ticketmaster gem.}
|
14
14
|
s.email = %q{hong.quach@abigfisch.com}
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"LICENSE",
|
17
|
-
|
17
|
+
"README.md"
|
18
18
|
]
|
19
19
|
s.files = [
|
20
20
|
".document",
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
"spec/ticketmaster-github_spec.rb",
|
41
|
-
"ticketmaster-github.gemspec"
|
21
|
+
"LICENSE",
|
22
|
+
"README.md",
|
23
|
+
"Rakefile",
|
24
|
+
"VERSION",
|
25
|
+
"lib/provider/comment.rb",
|
26
|
+
"lib/provider/github.rb",
|
27
|
+
"lib/provider/project.rb",
|
28
|
+
"lib/provider/ticket.rb",
|
29
|
+
"lib/ticketmaster-github.rb",
|
30
|
+
"spec/comment_spec.rb",
|
31
|
+
"spec/factories/comment.rb",
|
32
|
+
"spec/factories/issue.rb",
|
33
|
+
"spec/factories/repository.rb",
|
34
|
+
"spec/project_spec.rb",
|
35
|
+
"spec/spec.opts",
|
36
|
+
"spec/spec_helper.rb",
|
37
|
+
"spec/ticket_spec.rb",
|
38
|
+
"spec/ticketmaster-github_spec.rb",
|
39
|
+
"ticketmaster-github.gemspec"
|
42
40
|
]
|
43
41
|
s.homepage = %q{http://github.com/kiafaldorius/ticketmaster-github}
|
44
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
45
42
|
s.require_paths = ["lib"]
|
46
|
-
s.rubygems_version = %q{1.
|
43
|
+
s.rubygems_version = %q{1.6.1}
|
47
44
|
s.summary = %q{The github provider for ticketmaster}
|
48
45
|
s.test_files = [
|
49
46
|
"spec/comment_spec.rb",
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
47
|
+
"spec/factories/comment.rb",
|
48
|
+
"spec/factories/issue.rb",
|
49
|
+
"spec/factories/repository.rb",
|
50
|
+
"spec/project_spec.rb",
|
51
|
+
"spec/spec_helper.rb",
|
52
|
+
"spec/ticket_spec.rb",
|
53
|
+
"spec/ticketmaster-github_spec.rb"
|
57
54
|
]
|
58
55
|
|
59
56
|
if s.respond_to? :specification_version then
|
60
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
61
57
|
s.specification_version = 3
|
62
58
|
|
63
59
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
64
60
|
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
65
|
-
s.add_runtime_dependency(%q<
|
61
|
+
s.add_runtime_dependency(%q<octokit>, [">= 0"])
|
66
62
|
else
|
67
63
|
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
68
|
-
s.add_dependency(%q<
|
64
|
+
s.add_dependency(%q<octokit>, [">= 0"])
|
69
65
|
end
|
70
66
|
else
|
71
67
|
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
72
|
-
s.add_dependency(%q<
|
68
|
+
s.add_dependency(%q<octokit>, [">= 0"])
|
73
69
|
end
|
74
70
|
end
|
75
71
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ticketmaster-github
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 13
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 4
|
9
9
|
- 1
|
10
|
-
version: 0.
|
10
|
+
version: 0.4.1
|
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-
|
18
|
+
date: 2011-04-07 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -35,19 +35,17 @@ dependencies:
|
|
35
35
|
type: :development
|
36
36
|
version_requirements: *id001
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
|
-
name:
|
38
|
+
name: octokit
|
39
39
|
prerelease: false
|
40
40
|
requirement: &id002 !ruby/object:Gem::Requirement
|
41
41
|
none: false
|
42
42
|
requirements:
|
43
43
|
- - ">="
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
hash:
|
45
|
+
hash: 3
|
46
46
|
segments:
|
47
47
|
- 0
|
48
|
-
|
49
|
-
- 0
|
50
|
-
version: 0.3.0
|
48
|
+
version: "0"
|
51
49
|
type: :runtime
|
52
50
|
version_requirements: *id002
|
53
51
|
description: This provides an interface with github through the ticketmaster gem.
|
@@ -61,12 +59,10 @@ extra_rdoc_files:
|
|
61
59
|
- README.md
|
62
60
|
files:
|
63
61
|
- .document
|
64
|
-
- .gitignore
|
65
62
|
- LICENSE
|
66
63
|
- README.md
|
67
64
|
- Rakefile
|
68
65
|
- VERSION
|
69
|
-
- lib/github/github.rb
|
70
66
|
- lib/provider/comment.rb
|
71
67
|
- lib/provider/github.rb
|
72
68
|
- lib/provider/project.rb
|
@@ -87,8 +83,8 @@ homepage: http://github.com/kiafaldorius/ticketmaster-github
|
|
87
83
|
licenses: []
|
88
84
|
|
89
85
|
post_install_message:
|
90
|
-
rdoc_options:
|
91
|
-
|
86
|
+
rdoc_options: []
|
87
|
+
|
92
88
|
require_paths:
|
93
89
|
- lib
|
94
90
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -112,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
108
|
requirements: []
|
113
109
|
|
114
110
|
rubyforge_project:
|
115
|
-
rubygems_version: 1.
|
111
|
+
rubygems_version: 1.6.1
|
116
112
|
signing_key:
|
117
113
|
specification_version: 3
|
118
114
|
summary: The github provider for ticketmaster
|
data/.gitignore
DELETED
data/lib/github/github.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
module TicketMaster::Provider
|
2
|
-
module Github
|
3
|
-
|
4
|
-
class GithubComment
|
5
|
-
include HTTParty
|
6
|
-
URI = 'http://github.com/api/v2/json'
|
7
|
-
attr_accessor :gravatar_id, :created_at, :body, :updated_at, :id, :user
|
8
|
-
|
9
|
-
base_uri "http://github.com/api/v2/json"
|
10
|
-
|
11
|
-
def self.find_all(repo, number)
|
12
|
-
HTTParty.get("#{URI}/issues/comments/#{repo.username}/#{repo.name}/#{number}", :query => auth_params).parsed_response['comments']
|
13
|
-
end
|
14
|
-
|
15
|
-
def self.create(repo, number, comment)
|
16
|
-
HTTParty.post("#{secure}/issues/comment/#{repo.username}/#{repo.name}/#{number}", :query => auth_params, :body => {:comment => comment}).parsed_response['comment']
|
17
|
-
end
|
18
|
-
|
19
|
-
def self.auth_params
|
20
|
-
{:login => Octopi::Api.api.login, :token => Octopi::Api.api.token}
|
21
|
-
end
|
22
|
-
|
23
|
-
def self.secure
|
24
|
-
URI.gsub('http','https')
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|