ticketmaster-codaset 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm 1.8.7@ticketmaster-codaset --create
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'ticketmaster', '0.5.2'
4
+ gem 'oauth2'
5
+
6
+ group :development do
7
+ gem "rspec", "1.3.0"
8
+ gem "bundler", "~> 1.0.0"
9
+ gem "jeweler", "~> 1.5.1"
10
+ gem "rcov", ">= 0"
11
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,48 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ activemodel (3.0.3)
5
+ activesupport (= 3.0.3)
6
+ builder (~> 2.1.2)
7
+ i18n (~> 0.4)
8
+ activeresource (3.0.3)
9
+ activemodel (= 3.0.3)
10
+ activesupport (= 3.0.3)
11
+ activesupport (3.0.3)
12
+ addressable (2.2.2)
13
+ builder (2.1.2)
14
+ faraday (0.5.4)
15
+ addressable (~> 2.2.2)
16
+ multipart-post (~> 1.1.0)
17
+ rack (>= 1.1.0, < 2)
18
+ git (1.2.5)
19
+ hashie (0.3.0)
20
+ i18n (0.5.0)
21
+ jeweler (1.5.2)
22
+ bundler (~> 1.0.0)
23
+ git (>= 1.2.5)
24
+ rake
25
+ multi_json (0.0.5)
26
+ multipart-post (1.1.0)
27
+ oauth2 (0.1.0)
28
+ faraday (~> 0.5.0)
29
+ multi_json (~> 0.0.4)
30
+ rack (1.2.1)
31
+ rake (0.8.7)
32
+ rcov (0.9.9)
33
+ rspec (1.3.0)
34
+ ticketmaster (0.5.2)
35
+ activeresource (>= 2.3.2)
36
+ activesupport (>= 2.3.2)
37
+ hashie (<= 0.3.0)
38
+
39
+ PLATFORMS
40
+ ruby
41
+
42
+ DEPENDENCIES
43
+ bundler (~> 1.0.0)
44
+ jeweler (~> 1.5.1)
45
+ oauth2
46
+ rcov
47
+ rspec (= 1.3.0)
48
+ ticketmaster (= 0.5.2)
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 anymoto
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,63 @@
1
+ # ticketmaster-codaset
2
+
3
+ This is a provider for [ticketmaster](http://ticketrb.com). It provides interoperability with [Codaset](http://www.codaset.com).
4
+
5
+ # Usage and Examples
6
+
7
+ First we have to instantiate a new ticketmaster instance:
8
+ codaset = TicketMaster.new(:codaset, {:username => "foo", :password => "bar", :client_id => "your_client_id", :client_secret => "your_client_secret"})
9
+
10
+ If you do not pass in username, password, client id and client secret you won't get any information.
11
+
12
+ == Finding Projects
13
+
14
+ You can find your own projects by doing:
15
+
16
+ projects = codaset.projects # Will return all your projects
17
+ projects = codaset.projects(['project1', 'project2']) # You must use your projects identifier
18
+ project = codaset.project('your_project') # Also use project identifier in here
19
+
20
+ == Finding Tickets
21
+
22
+ tickets = project.tickets # All open issues
23
+ ticket = project.ticket(<ticket_number>)
24
+
25
+ == Open Tickets
26
+
27
+ ticket = project.ticket!({:title=> "New ticket", :description=> "Body for the very new ticket"})
28
+
29
+ = Update a ticket
30
+
31
+ ticket.title = "New title"
32
+ ticket.description = "New Description"
33
+ ticket.save
34
+
35
+ ## Requirements
36
+
37
+ * rubygems (obviously)
38
+ * ticketmaster gem (latest version preferred)
39
+ * jeweler gem (only if you want to repackage and develop)
40
+ * OAuth2 gem
41
+
42
+ The ticketmaster gem and OAuth2 gem should automatically be installed during the installation of these gems if it is not already installed.
43
+
44
+ ## Other Notes
45
+
46
+ Since this and the ticketmaster gem is still primarily a work-in-progress, minor changes may be incompatible with previous versions. Please be careful about using and updating this gem in production.
47
+
48
+ If you see or find any issues, feel free to open up an issue report.
49
+
50
+
51
+ ## Note on Patches/Pull Requests
52
+
53
+ * Fork the project.
54
+ * Make your feature addition or bug fix.
55
+ * Add tests for it. This is important so I don't break it in a
56
+ future version unintentionally.
57
+ * Commit, do not mess with rakefile, version, or history.
58
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
59
+ * Send me a pull request. Bonus points for topic branches.
60
+
61
+ ## Copyright
62
+
63
+ Copyright (c) 2010 [Hybrid Group](http://hybridgroup.com). See LICENSE for details.
data/README.rdoc ADDED
@@ -0,0 +1,19 @@
1
+ = ticketmaster-codaset
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to ticketmaster-codaset
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
9
+ * Fork the project
10
+ * Start a feature/bugfix branch
11
+ * Commit and push until you are happy with your contribution
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2010 anymoto. See LICENSE.txt for
18
+ further details.
19
+
data/Rakefile ADDED
@@ -0,0 +1,32 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'rake'
11
+
12
+ require 'jeweler'
13
+ Jeweler::Tasks.new do |gem|
14
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
15
+ gem.name = "ticketmaster-codaset"
16
+ gem.homepage = "http://github.com/hybridgroup/ticketmaster-codaset"
17
+ gem.license = "MIT"
18
+ gem.summary = %Q{The codaset provider for ticketmaster}
19
+ gem.description = %Q{Allows ticketmaster to interact with Your System.}
20
+ gem.email = "ana@hybridgroup.com"
21
+ gem.authors = ["anymoto"]
22
+ gem.add_development_dependency "rspec", ">= 1.2.9"
23
+ gem.add_dependency "ticketmaster", ">= 0.3.0"
24
+ gem.add_dependency "activesupport", ">= 2.3.0"
25
+ gem.add_dependency "activeresource", ">= 2.3.0"
26
+ end
27
+ Jeweler::RubygemsDotOrgTasks.new
28
+
29
+ require 'spec/rake/spectask'
30
+ Spec::Rake::SpecTask.new do |t|
31
+ t.spec_files = FileList['spec/**/*_spec.rb']
32
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1 @@
1
+ *.DS_Store
@@ -0,0 +1,225 @@
1
+ require 'rubygems'
2
+ require 'active_support'
3
+ require 'active_resource'
4
+ require 'oauth2'
5
+ require 'net/https'
6
+
7
+ # Ruby lib for working with the Codaset API's JSON interface.
8
+
9
+ # This library is a small wrapper around the REST interface. You should read the docs at
10
+ # http://api.codaset.com
11
+ #
12
+
13
+
14
+ module CodasetAPI
15
+
16
+ class Error < StandardError; end
17
+ class << self
18
+ attr_accessor :client_id, :client_secret, :site, :username, :password, :host_format, :domain_format, :protocol, :token
19
+ attr_reader :account
20
+
21
+ def authenticate(username, password, client_id, client_secret)
22
+ @username = username
23
+ @password = password
24
+ @client_id = client_id
25
+ @client_secret = client_secret
26
+ @site = 'https://api.codaset.com'
27
+
28
+ self::Base.user = username
29
+ self::Base.password = password
30
+ self::Base.site = @site
31
+
32
+ self.token = access_token(self)
33
+
34
+ end
35
+
36
+ # Sets the account name, and updates all the resources with the new domain.
37
+ def account=(name)
38
+ resources.each do |klass|
39
+ klass.site = klass.site_format % (host_format % [protocol, domain_format, name])
40
+ end
41
+ @account = name
42
+ end
43
+
44
+ # Gets the OAuth2's access token
45
+ def access_token(master)
46
+ @auth_url = '/authorization/token'
47
+ consumer = OAuth2::Client.new(master.client_id,
48
+ master.client_secret,
49
+ {:site =>
50
+ {:url => master.site,
51
+ :ssl => {:verify => OpenSSL::SSL::VERIFY_NONE,
52
+ :ca_file => nil
53
+ }
54
+ },
55
+ :authorize_url => @auth_url,
56
+ :parse_json => true})
57
+
58
+ response = consumer.request(:post, @auth_url, {:grant_type => 'password',
59
+ :client_id => master.client_id,
60
+ :client_secret => master.client_secret,
61
+ :username => master.username,
62
+ :password => master.password},
63
+ 'Content-Type' => 'application/x-www-form-urlencoded')
64
+
65
+ OAuth2::AccessToken.new(consumer, response['access_token']).token
66
+
67
+ end
68
+
69
+ # Sets the OAuth2's access token, and updates the headers in the resources
70
+ def token=(value)
71
+ resources.each do |klass|
72
+ klass.headers['Authorization'] = 'OAuth ' + value.to_s
73
+ end
74
+ @token = value
75
+ end
76
+
77
+ def resources
78
+ @resources ||= []
79
+ end
80
+
81
+ end
82
+
83
+ self.host_format = '%s://%s/%s'
84
+ self.domain_format = 'api.codaset.com'
85
+ self.protocol = 'https'
86
+
87
+
88
+ class Base < ActiveResource::Base
89
+
90
+ self.format = :json
91
+ self.site = 'https://api.codaset.com'
92
+
93
+ def self.inherited(base)
94
+ CodasetAPI.resources << base
95
+ class << base
96
+ attr_accessor :site_format
97
+ end
98
+ base.site_format = '%s'
99
+ super
100
+ end
101
+
102
+ end
103
+
104
+ # Find projects
105
+ #
106
+ # CodasetAPI::Project.find(:all) # find all projects for the current account.
107
+ # CodasetAPI::Project.find('my-project') # find individual project by slug
108
+ #
109
+ # Creating a Project
110
+ #
111
+ # project = CodasetAPI::Project.new(:name => 'Ninja Whammy Jammy')
112
+ # project.save
113
+ # # => true
114
+ #
115
+ #
116
+ # Updating a Project
117
+ #
118
+ # project = CodasetAPI::Project.find('my-project')
119
+ # project.name = "Codaset Issues"
120
+ # project.public = false
121
+ # project.save
122
+ #
123
+ # Finding tickets
124
+ #
125
+ # project = CodasetAPI::Project.find('my-project')
126
+ # project.tickets
127
+ #
128
+
129
+ class Project < Base
130
+
131
+ #begin monkey patches
132
+ def self.element_path(id, prefix_options = {}, query_options = nil)
133
+ prefix_options, query_options = split_options(prefix_options) if query_options.nil?
134
+ "#{prefix(prefix_options)}#{URI.escape id.to_s}.#{format.extension}#{query_string(query_options)}"
135
+ end
136
+
137
+ def element_path(options = nil)
138
+ self.class.element_path(self.slug, options)
139
+ end
140
+
141
+ def encode(options={})
142
+ val = []
143
+ attributes.each_pair do |key, value|
144
+ val << "values[#{URI.escape key}]=#{URI.escape value}" rescue nil
145
+ end
146
+ val.join('&')
147
+ end
148
+
149
+ def update
150
+ connection.put(element_path(prefix_options) + '?' + encode, nil, self.class.headers).tap do |response|
151
+ load_attributes_from_response(response)
152
+ end
153
+ end
154
+
155
+ def create
156
+ connection.post(collection_path + '?' + encode, nil, self.class.headers).tap do |response|
157
+ self.id = id_from_response(response)
158
+ load_attributes_from_response(response)
159
+ end
160
+ end
161
+
162
+ #end monkey patches
163
+
164
+ def tickets(options = {})
165
+ puts 'tickets (codaset-api)'
166
+ Ticket.find(:all, :params => options.update(:slug => slug))
167
+ end
168
+
169
+ def id
170
+ @attributes['slug']
171
+ end
172
+
173
+ end
174
+
175
+ # Find tickets
176
+ #
177
+ # CodasetAPI::Ticket.find(:all, :params => { :project_id => 44 })
178
+ # CodasetAPI::Ticket.find(:all, :params => { :project_id => 44, :q => "status:closed" })
179
+ #
180
+ # project = CodasetAPI::Project.find(44)
181
+ # project.tickets
182
+ # project.tickets(:q => "status:closed")
183
+ # project.tickets(:params => {:status => 'closed'})
184
+ #
185
+ #
186
+ #
187
+
188
+ class Ticket < Base
189
+ self.site_format << '/:slug/'
190
+
191
+ #begin monkey patches
192
+ def self.element_path(id, prefix_options = {}, query_options = nil)
193
+ prefix_options, query_options = split_options(prefix_options) if query_options.nil?
194
+ "#{prefix(prefix_options)}#{collection_name}/#{URI.escape id.to_s}#{query_string(query_options)}"
195
+ end
196
+
197
+ def element_path(options = nil)
198
+ self.class.element_path(self.id, options)
199
+ end
200
+
201
+ def encode(options={})
202
+ val = []
203
+ attributes.each_pair do |key, value|
204
+ val << "values[#{URI.escape key}]=#{URI.escape value}" rescue nil
205
+ end
206
+ val.join('&')
207
+ end
208
+
209
+ def update
210
+ connection.put(element_path(prefix_options) + '?' + encode, nil, self.class.headers).tap do |response|
211
+ load_attributes_from_response(response)
212
+ end
213
+ end
214
+
215
+ def create
216
+ connection.post(collection_path + '?' + encode, nil, self.class.headers).tap do |response|
217
+ self.id = id_from_response(response)
218
+ load_attributes_from_response(response)
219
+ end
220
+ end
221
+
222
+ #end monkey patches
223
+ end
224
+
225
+ end
@@ -0,0 +1,32 @@
1
+ module TicketMaster::Provider
2
+ # This is the Codaset Provider for ticketmaster
3
+ module Codaset
4
+ include TicketMaster::Provider::Base
5
+ TICKET_API = Codaset::Ticket # The class to access the api's tickets
6
+ PROJECT_API = Codaset::Project # The class to access the api's projects
7
+
8
+ # This is for cases when you want to instantiate using TicketMaster::Provider::Codaset.new(auth)
9
+ def self.new(auth = {})
10
+ TicketMaster.new(:codaset, auth)
11
+ end
12
+
13
+ # Providers must define an authorize method. This is used to initialize and set authentication
14
+ # parameters to access the API
15
+
16
+ # Client Id and Client Secret: get these values once you register your app on http://api.codaset.com/apps
17
+ def authorize(auth = {})
18
+ @authentication ||= TicketMaster::Authenticator.new(auth)
19
+ auth = @authentication
20
+ if auth.username.nil? or auth.password.nil? or auth.client_id.nil? or auth.client_secret.nil?
21
+ raise "Please provide username, password, client id and client secret"
22
+ end
23
+ CodasetAPI.account = auth.username
24
+ CodasetAPI.authenticate(auth.username, auth.password, auth.client_id, auth.client_secret)
25
+ end
26
+
27
+ # declare needed overloaded methods here
28
+
29
+ end
30
+ end
31
+
32
+
@@ -0,0 +1,14 @@
1
+ module TicketMaster::Provider
2
+ module Codaset
3
+ # The comment class for ticketmaster-codaset
4
+ #
5
+ # Do any mapping between Ticketmaster and your system's comment model here
6
+ # versions of the ticket.
7
+ #
8
+ # Not supported by Codaset API
9
+ class Comment < TicketMaster::Provider::Base::Comment
10
+ # declare needed overloaded methods here
11
+
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,65 @@
1
+ module TicketMaster::Provider
2
+ module Codaset
3
+ # Project class for ticketmaster-codaset
4
+ #
5
+ #
6
+ class Project < TicketMaster::Provider::Base::Project
7
+ API = CodasetAPI::Project # The class to access the api's projects
8
+ # declare needed overloaded methods here
9
+
10
+ def created_at
11
+ @created_at ||= self[:created_at] ? Time.parse(self[:created_at]) : nil
12
+ end
13
+
14
+ def updated_at
15
+ @updated_at ||= self[:updated_at] ? Time.parse(self[:updated_at]) : nil
16
+ end
17
+
18
+ def initialize(*options)
19
+ super(*options)
20
+ end
21
+
22
+ def id
23
+ self[:slug]
24
+ end
25
+
26
+ def name
27
+ self[:title]
28
+ end
29
+
30
+ def ticket!(*options)
31
+ options[0].merge!(:slug => slug) if options.first.is_a?(Hash)
32
+ provider_parent(self.class)::Ticket.create(*options)
33
+ end
34
+
35
+ def tickets(*options)
36
+ begin
37
+ if options.first.is_a? Hash
38
+ #options[0].merge!(:params => {:slug => slug})
39
+ super(*options)
40
+ elsif options.empty?
41
+ tickets = CodasetAPI::Ticket.find(:all, :params => {:slug => slug}).collect { |ticket| TicketMaster::Provider::Codaset::Ticket.new ticket }
42
+ else
43
+ super(*options)
44
+ end
45
+ rescue
46
+ []
47
+ end
48
+ end
49
+
50
+ # copy from this.copy(that) copies that into this
51
+ def copy(project)
52
+ project.tickets.each do |ticket|
53
+ copy_ticket = self.ticket!(:title => ticket.title, :description => ticket.description)
54
+ ticket.comments.each do |comment|
55
+ copy_ticket.comment!(:body => comment.body)
56
+ sleep 1
57
+ end
58
+ end
59
+ end
60
+
61
+ end
62
+ end
63
+ end
64
+
65
+
@@ -0,0 +1,107 @@
1
+ module TicketMaster::Provider
2
+ module Codaset
3
+ # Ticket class for ticketmaster-codaset
4
+ # * project_id (prefix_options[:project_id])
5
+
6
+ API = CodasetAPI::Ticket # The class to access the api's tickets
7
+
8
+ class Ticket < TicketMaster::Provider::Base::Ticket
9
+ attr_accessor :prefix_options
10
+
11
+ # declare needed overloaded methods here
12
+
13
+ def initialize(*object)
14
+ if object.first
15
+ object = object.first
16
+ @system_data = {:client => object}
17
+ unless object.is_a? Hash
18
+ hash = {:id => object.id,
19
+ :title => object.title,
20
+ :description => object.description,
21
+ :status => object.state,
22
+ :priority => object.custom_data.Priority,
23
+ :assignee => object.assigned_to.title,
24
+ :requestor => object.reported_by.title}
25
+ else
26
+ hash = object
27
+ end
28
+ super hash
29
+ end
30
+ end
31
+
32
+ def self.create(*options)
33
+ issue = API.new(options.first.merge!(:state => 'new'))
34
+ ticket = self.new issue
35
+ issue.save
36
+ ticket
37
+ end
38
+
39
+ def self.find_by_id(project_id, id)
40
+ self.search(project_id, {'id' => id}).first
41
+ end
42
+
43
+ def self.search(project_id, options = {}, limit = 1000)
44
+ tickets = API.find(:all, :params => {:slug => project_id}).collect { |ticket| self.new ticket}
45
+ search_by_attribute(tickets, options, limit)
46
+ end
47
+
48
+ def self.find_by_attributes(project_id, attributes = {})
49
+ self.search(project_id, attributes)
50
+ end
51
+
52
+ def created_at
53
+ @created_at ||= self[:created_at] ? Time.parse(self[:created_at]) : nil
54
+ end
55
+
56
+ def updated_at
57
+ @updated_at ||= self[:updated_at] ? Time.parse(self[:updated_at]) : nil
58
+ end
59
+
60
+ def id
61
+ self[:id].to_i
62
+ end
63
+
64
+ def status
65
+ self[:status]
66
+ end
67
+
68
+ def priority
69
+ self[:priority]
70
+ end
71
+
72
+ def title
73
+ self[:title]
74
+ end
75
+
76
+ def description
77
+ self[:description]
78
+ end
79
+
80
+ def assignee
81
+ self[:assignee]
82
+ end
83
+
84
+ def requestor
85
+ self[:requestor]
86
+ end
87
+
88
+ def comments
89
+ warn 'Comments not supported. Perhaps you should leave feedback to request it?'
90
+ []
91
+ end
92
+
93
+ #TODO?
94
+ def comment
95
+ warn 'Comments not supported. Perhaps you should leave feedback to request it?'
96
+ nil
97
+ end
98
+
99
+ #TODO?
100
+ def comment!
101
+ warn 'Comments not supported. Perhaps you should leave feedback to request it?'
102
+ []
103
+ end
104
+
105
+ end
106
+ end
107
+ end
@@ -0,0 +1,5 @@
1
+ require File.dirname(__FILE__) + '/codaset/codaset-api'
2
+
3
+ %w{ codaset ticket project comment }.each do |f|
4
+ require File.dirname(__FILE__) + '/provider/' + f + '.rb';
5
+ end
@@ -0,0 +1,5 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Ticketmaster::Provider::Yoursystem::Comment" do
4
+ it "should have specs for comments"
5
+ end
@@ -0,0 +1 @@
1
+ {"created_at":"2011-01-10T05:42:33Z","title":"My project","fork_count":0,"updated_at":"2011-01-10T05:42:40Z","ticket_count":3,"default_branch":"master","externally_forked_from":null,"bookmark_count":0,"description":"This is my first project","url":"http://codaset.com/anymoto/my-project","last_pushed_at":null,"forked_from":null,"state":"public","disk_usage":null,"slug":"my-project"}
@@ -0,0 +1,2 @@
1
+ {"created_at":"2011-01-11T05:42:33Z","title":"New project","fork_count":0,"updated_at":"2011-01-11T05:42:40Z","ticket_count":0,"default_branch":"master","externally_forked_from":null,"bookmark_count":0,"description":"This is a new
2
+ project","url":"http://codaset.com/anymoto/new-project","last_pushed_at":null,"forked_from":null,"state":"public","disk_usage":null,"slug":"new-project"}
@@ -0,0 +1 @@
1
+ {"custom_data":{"Priority":"Medium","Type":"Bug"},"created_at":"2011-01-12T07:27:21Z","title":"Another ticket","reported_by":{"title":"anymoto","last_name":null,"first_name":null,"url":"http://codaset.com/anymoto","gravatar_id":"b64b0e826e9f1ed95c333b58b7d1d90a","login":"anymoto"},"updated_at":"2011-01-12T19:28:33Z","votes":0,"url":"http://codaset.com/anymoto/my-project/tickets/4","description":"this is a new description","comments":{"count":0},"milestone":null,"state":"new","updated_by":{"title":"anymoto","last_name":null,"first_name":null,"url":"http://codaset.com/anymoto","gravatar_id":"b64b0e826e9f1ed95c333b58b7d1d90a","login":"anymoto"},"assigned_to":{"title":"anymoto","last_name":null,"first_name":null,"url":"http://codaset.com/anymoto","gravatar_id":"b64b0e826e9f1ed95c333b58b7d1d90a","login":"anymoto"},"id":4}
@@ -0,0 +1,2 @@
1
+ [{"created_at":"2011-01-10T05:42:33Z","title":"My project","fork_count":0,"updated_at":"2011-01-10T05:42:40Z","ticket_count":0,"default_branch":"master","externally_forked_from":null,"bookmark_count":0,"description":"This is my first project","url":"http://codaset.com/anymoto/my-project","last_pushed_at":null,"forked_from":null,"state":"public","disk_usage":null,"slug":"my-project"},{"created_at":"2011-01-03T19:46:36Z","title":"Second project","fork_count":0,"updated_at":"2011-01-07T18:06:53Z","ticket_count":0,"default_branch":"master","externally_forked_from":null,"bookmark_count":0,"description":"This is my second
2
+ project","url":"http://codaset.com/anymoto/second-project","last_pushed_at":null,"forked_from":null,"state":"public","disk_usage":null,"slug":"second-project"},{"created_at":"2010-12-27T17:49:02Z","title":"My third project","fork_count":0,"updated_at":"2011-01-11T19:30:33Z","ticket_count":3,"default_branch":"master","externally_forked_from":null,"bookmark_count":0,"description":"This is my third project","url":"http://codaset.com/anymoto/third-project","last_pushed_at":null,"forked_from":null,"state":"public","disk_usage":null,"slug":"third-project"}]
@@ -0,0 +1 @@
1
+ {"custom_data":{"Priority":"Medium","Type":"Bug"},"created_at":"2011-01-03T07:27:21Z","title":"First ticket 1","reported_by":{"title":"anymoto","last_name":null,"first_name":null,"url":"http://codaset.com/anymoto","gravatar_id":"b64b0e826e9f1ed95c333b58b7d1d90a","login":"anymoto"},"updated_at":"2011-01-11T19:28:33Z","votes":0,"url":"http://codaset.com/anymoto/my-project/tickets/1","description":"this is a ticket created on tuesday","comments":{"count":0},"milestone":null,"state":"new","updated_by":{"title":"anymoto","last_name":null,"first_name":null,"url":"http://codaset.com/anymoto","gravatar_id":"b64b0e826e9f1ed95c333b58b7d1d90a","login":"anymoto"},"assigned_to":{"title":"anymoto","last_name":null,"first_name":null,"url":"http://codaset.com/anymoto","gravatar_id":"b64b0e826e9f1ed95c333b58b7d1d90a","login":"anymoto"},"id":1}
@@ -0,0 +1 @@
1
+ [{"custom_data":{"Priority":"Medium","Type":"Bug"},"created_at":"2011-01-11T19:30:32Z","title":"First ticket","reported_by":{"title":"anymoto","last_name":null,"first_name":null,"url":"http://codaset.com/anymoto","gravatar_id":"b64b0e826e9f1ed95c333b58b7d1d90a","login":"anymoto"},"updated_at":"2011-01-11T19:30:32Z","votes":0,"url":"http://codaset.com/anymoto/my-project/tickets/1","description":"this is a ticket created on tuesday","comments":{"count":0},"milestone":null,"state":"new","updated_by":null,"assigned_to":{"title":"anymoto","last_name":null,"first_name":null,"url":"http://codaset.com/anymoto","gravatar_id":"b64b0e826e9f1ed95c333b58b7d1d90a","login":"anymoto"},"id":1},{"custom_data":{"Priority":"Medium","Type":"Bug"},"created_at":"2011-01-03T07:27:21Z","title":"Second ticket","reported_by":{"title":"anymoto","last_name":null,"first_name":null,"url":"http://codaset.com/anymoto","gravatar_id":"b64b0e826e9f1ed95c333b58b7d1d90a","login":"anymoto"},"updated_at":"2011-01-11T19:28:33Z","votes":0,"url":"http://codaset.com/anymoto/my-project/tickets/2","description":"this is a ticket created on wednesday","comments":{"count":0},"milestone":null,"state":"new","updated_by":{"title":"anymoto","last_name":null,"first_name":null,"url":"http://codaset.com/anymoto","gravatar_id":"b64b0e826e9f1ed95c333b58b7d1d90a","login":"anymoto"},"assigned_to":{"title":"anymoto","last_name":null,"first_name":null,"url":"http://codaset.com/anymoto","gravatar_id":"b64b0e826e9f1ed95c333b58b7d1d90a","login":"anymoto"},"id":1},{"custom_data":{"Priority":"Medium","Type":"Bug"},"created_at":"2011-01-10T06:26:53Z","title":"Third ticket","reported_by":{"title":"anymoto","last_name":null,"first_name":null,"url":"http://codaset.com/anymoto","gravatar_id":"b64b0e826e9f1ed95c333b58b7d1d90a","login":"anymoto"},"updated_at":"2011-01-10T06:26:53Z","votes":0,"url":"http://codaset.com/anymoto/my-project/tickets/3","description":"a new ticket on monday","comments":{"count":0},"milestone":null,"state":"new","updated_by":null,"assigned_to":{"title":"anymoto","last_name":null,"first_name":null,"url":"http://codaset.com/anymoto","gravatar_id":"b64b0e826e9f1ed95c333b58b7d1d90a","login":"anymoto"},"id":3}]
@@ -0,0 +1,71 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Ticketmaster::Provider::Codaset::Project" do
4
+ before(:all) do
5
+ headers_get = {'Authorization' => 'OAuth 01234567890abcdef', 'Accept' => 'application/json'}
6
+ headers = {'Authorization' => 'OAuth 01234567890abcdef', 'Content-Type' => 'application/json'}
7
+ @project_id = 'my-project'
8
+ ActiveResource::HttpMock.respond_to do |mock|
9
+ mock.get '/anymoto/projects.json', headers_get, fixture_for('projects'), 200
10
+ mock.get '/anymoto/my-project.json', headers_get, fixture_for('my-project'), 200
11
+ mock.post '/anymoto/projects.json?values[name]=New%20project', headers, '', 201
12
+ mock.put '/anymoto/my-project.json?values[slug]=my-project&values[title]=My%20project&values[default_branch]=master&values[url]=http://codaset.com/anymoto/my-project&values[description]=This%20is%20my%20first%20project&values[state]=public', headers, '', 200
13
+ mock.delete '/anymoto/my-project.json', headers, '', 200
14
+ end
15
+
16
+ stubs = Faraday::Adapter::Test::Stubs.new do |stub|
17
+ #ACCESS_TOKEN = { "access_token" => "01234567890abcdef", "refresh_token" => "01234567890abcdef", "expires_in" => 1209600, "username" => "anymoto" }
18
+ stub.post('/authorization/token') { [200, {}, ACCESS_TOKEN.to_json] }
19
+ end
20
+
21
+ new_method = Faraday::Connection.method(:new)
22
+ Faraday::Connection.stub(:new) do |*args|
23
+ connection = new_method.call(*args) do |builder|
24
+ builder.adapter :test, stubs
25
+ end
26
+ end
27
+
28
+ @ticketmaster = TicketMaster.new(:codaset, {:username => 'anymoto', :password => '000000', :client_id => '07f16ec71c324ab053885212ad65a6cc', :client_secret => '442fe0b16ff1143602e89ea923cbabc50'})
29
+ @klass = TicketMaster::Provider::Codaset::Project
30
+ end
31
+
32
+ it "should be able to load all projects" do
33
+ @ticketmaster.projects.should be_an_instance_of(Array)
34
+ @ticketmaster.projects.first.should be_an_instance_of(@klass)
35
+ end
36
+
37
+ it "should be able to load projects from an array of ids" do
38
+ @projects = @ticketmaster.projects([@project_id])
39
+ @projects.should be_an_instance_of(Array)
40
+ @projects.first.should be_an_instance_of(@klass)
41
+ @projects.first.id.should == @project_id
42
+ end
43
+
44
+ it "should be able to load all projects from attributes" do
45
+ @projects = @ticketmaster.projects(:id => @project_id)
46
+ @projects.should be_an_instance_of(Array)
47
+ @projects.first.should be_an_instance_of(@klass)
48
+ @projects.first.id.should == @project_id
49
+ end
50
+
51
+ it "should be able to find a project" do
52
+ @ticketmaster.project.should == @klass
53
+ @ticketmaster.project.find(@project_id).should be_an_instance_of(@klass)
54
+ end
55
+
56
+ it "should be able to find a project by identifier" do
57
+ @ticketmaster.project(@project_id).should be_an_instance_of(@klass)
58
+ @ticketmaster.project(@project_id).id.should == @project_id
59
+ end
60
+
61
+ it "should be able to update and save a project" do
62
+ @project = @ticketmaster.project(@project_id)
63
+ @project.update!(:short_name => 'some new name').should == true
64
+ end
65
+
66
+ it "should be able to create a project" do
67
+ @project = @ticketmaster.project.create(:name => 'New project')
68
+ @project.should be_an_instance_of(@klass)
69
+ end
70
+
71
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1,5 @@
1
+ --colour
2
+ --format progress
3
+ --loadby mtime
4
+ --reverse
5
+
@@ -0,0 +1,10 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'rubygems'
4
+ require 'spec'
5
+ require 'ticketmaster'
6
+ require 'ticketmaster-codaset'
7
+
8
+ def fixture_for(name)
9
+ File.read(File.dirname(__FILE__) + '/fixtures/' + name + '.json')
10
+ end
@@ -0,0 +1,22 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Ticketmaster::Provider::Codaset" do
4
+ it "should be able to instantiate a new instance" do
5
+
6
+ stubs = Faraday::Adapter::Test::Stubs.new do |stub|
7
+ ACCESS_TOKEN = { "access_token" => "01234567890abcdef", "refresh_token" => "01234567890abcdef", "expires_in" => 1209600, "username" => "anymoto" }
8
+ stub.post('/authorization/token') { [200, {}, ACCESS_TOKEN.to_json] }
9
+ end
10
+
11
+ new_method = Faraday::Connection.method(:new)
12
+ Faraday::Connection.stub(:new) do |*args|
13
+ connection = new_method.call(*args) do |builder|
14
+ builder.adapter :test, stubs
15
+ end
16
+ end
17
+
18
+ @ticketmaster = TicketMaster.new(:codaset, {:username => 'anymoto', :password => '000000', :client_id => '07f16ec7', :client_secret => '442fe0b16'})
19
+ @ticketmaster.should be_an_instance_of(TicketMaster)
20
+ @ticketmaster.should be_a_kind_of(TicketMaster::Provider::Codaset)
21
+ end
22
+ end
@@ -0,0 +1,80 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Ticketmaster::Provider::Codaset::Ticket" do
4
+ before(:all) do
5
+ headers_get = {'Authorization' => 'OAuth 01234567890abcdef', 'Accept' => 'application/json'}
6
+ headers = {'Authorization' => 'OAuth 01234567890abcdef', 'Content-Type' => 'application/json'}
7
+ @project_id = 'my-project'
8
+ ActiveResource::HttpMock.respond_to do |mock|
9
+ mock.get '/anymoto/my-project.json', headers_get, fixture_for('my-project'), 200
10
+ mock.get '/anymoto/my-project/tickets.json', headers_get, fixture_for('tickets'), 200
11
+ mock.get '/anymoto/my-project/tickets/1.json', headers_get, fixture_for('tickets/1'), 200
12
+ mock.put '/anymoto/my-project/tickets/1?values[title]=First%20ticket&values[description]=new%20ticket%20description', headers, '', 200
13
+ mock.post '/anymoto/my-project/tickets.json?values[title]=Ticket%20%2312&values[description]=Body&values[state]=new', headers, fixture_for('new-ticket'), 200
14
+ end
15
+
16
+ stubs = Faraday::Adapter::Test::Stubs.new do |stub|
17
+ #ACCESS_TOKEN = { "access_token" => "01234567890abcdef", "refresh_token" => "01234567890abcdef", "expires_in" => 1209600, "username" => "anymoto" }
18
+ stub.post('/authorization/token') { [200, {}, ACCESS_TOKEN.to_json] }
19
+ end
20
+
21
+ new_method = Faraday::Connection.method(:new)
22
+ Faraday::Connection.stub(:new) do |*args|
23
+ connection = new_method.call(*args) do |builder|
24
+ builder.adapter :test, stubs
25
+ end
26
+ end
27
+
28
+ @ticketmaster = TicketMaster.new(:codaset, {:username => 'anymoto', :password => '000000', :client_id => '07f16ec71c324ab053885212ad65a6cc', :client_secret => '442fe0b16ff1143602e89ea923cbabc50'})
29
+ @project = @ticketmaster.project(@project_id)
30
+ @klass = TicketMaster::Provider::Codaset::Ticket
31
+ end
32
+
33
+ it "should be able to load all tickets" do
34
+ @project.tickets.should be_an_instance_of(Array)
35
+ @project.tickets.first.should be_an_instance_of(@klass)
36
+ end
37
+
38
+ it "should be able to load all tickets based on an array of ids" do
39
+ @tickets = @project.tickets([1])
40
+ @tickets.should be_an_instance_of(Array)
41
+ @tickets.first.should be_an_instance_of(@klass)
42
+ @tickets.first.id.should == 1
43
+ end
44
+
45
+ it "should be able to load all tickets based on attributes" do
46
+ @tickets = @project.tickets(:id => 1)
47
+ @tickets.should be_an_instance_of(Array)
48
+ @tickets.first.should be_an_instance_of(@klass)
49
+ @tickets.first.id.should == 1
50
+ end
51
+
52
+ it "should return the ticket class" do
53
+ @project.ticket.should == @klass
54
+ end
55
+
56
+ it "should be able to load a single ticket" do
57
+ @ticket = @project.ticket(1)
58
+ @ticket.should be_an_instance_of(@klass)
59
+ @ticket.id.should == 1
60
+ end
61
+
62
+ it "should be able to load a single ticket based on attributes" do
63
+ @ticket = @project.ticket(:id => 1)
64
+ @ticket.should be_an_instance_of(@klass)
65
+ @ticket.id.should == 1
66
+ end
67
+
68
+ it "should be able to update and save a ticket" do
69
+ @ticket = @project.ticket(1)
70
+ @ticket.description = 'new ticket description'
71
+ @ticket.save.should == true
72
+ end
73
+
74
+ it "should be able to create a ticket" do
75
+ @ticket = @project.ticket!(:title => 'Ticket #12', :description => 'Body')
76
+ @ticket.should be_an_instance_of(@klass)
77
+ end
78
+
79
+ end
80
+
metadata ADDED
@@ -0,0 +1,256 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ticketmaster-codaset
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - anymoto
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-01-17 00:00:00 -06:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ prerelease: false
23
+ name: ticketmaster
24
+ type: :runtime
25
+ version_requirements: &id001 !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - "="
29
+ - !ruby/object:Gem::Version
30
+ hash: 15
31
+ segments:
32
+ - 0
33
+ - 5
34
+ - 2
35
+ version: 0.5.2
36
+ requirement: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ prerelease: false
39
+ name: oauth2
40
+ type: :runtime
41
+ version_requirements: &id002 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ hash: 3
47
+ segments:
48
+ - 0
49
+ version: "0"
50
+ requirement: *id002
51
+ - !ruby/object:Gem::Dependency
52
+ prerelease: false
53
+ name: rspec
54
+ type: :development
55
+ version_requirements: &id003 !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - "="
59
+ - !ruby/object:Gem::Version
60
+ hash: 27
61
+ segments:
62
+ - 1
63
+ - 3
64
+ - 0
65
+ version: 1.3.0
66
+ requirement: *id003
67
+ - !ruby/object:Gem::Dependency
68
+ prerelease: false
69
+ name: bundler
70
+ type: :development
71
+ version_requirements: &id004 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ~>
75
+ - !ruby/object:Gem::Version
76
+ hash: 23
77
+ segments:
78
+ - 1
79
+ - 0
80
+ - 0
81
+ version: 1.0.0
82
+ requirement: *id004
83
+ - !ruby/object:Gem::Dependency
84
+ prerelease: false
85
+ name: jeweler
86
+ type: :development
87
+ version_requirements: &id005 !ruby/object:Gem::Requirement
88
+ none: false
89
+ requirements:
90
+ - - ~>
91
+ - !ruby/object:Gem::Version
92
+ hash: 1
93
+ segments:
94
+ - 1
95
+ - 5
96
+ - 1
97
+ version: 1.5.1
98
+ requirement: *id005
99
+ - !ruby/object:Gem::Dependency
100
+ prerelease: false
101
+ name: rcov
102
+ type: :development
103
+ version_requirements: &id006 !ruby/object:Gem::Requirement
104
+ none: false
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ hash: 3
109
+ segments:
110
+ - 0
111
+ version: "0"
112
+ requirement: *id006
113
+ - !ruby/object:Gem::Dependency
114
+ prerelease: false
115
+ name: rspec
116
+ type: :development
117
+ version_requirements: &id007 !ruby/object:Gem::Requirement
118
+ none: false
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ hash: 13
123
+ segments:
124
+ - 1
125
+ - 2
126
+ - 9
127
+ version: 1.2.9
128
+ requirement: *id007
129
+ - !ruby/object:Gem::Dependency
130
+ prerelease: false
131
+ name: ticketmaster
132
+ type: :runtime
133
+ version_requirements: &id008 !ruby/object:Gem::Requirement
134
+ none: false
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ hash: 19
139
+ segments:
140
+ - 0
141
+ - 3
142
+ - 0
143
+ version: 0.3.0
144
+ requirement: *id008
145
+ - !ruby/object:Gem::Dependency
146
+ prerelease: false
147
+ name: activesupport
148
+ type: :runtime
149
+ version_requirements: &id009 !ruby/object:Gem::Requirement
150
+ none: false
151
+ requirements:
152
+ - - ">="
153
+ - !ruby/object:Gem::Version
154
+ hash: 3
155
+ segments:
156
+ - 2
157
+ - 3
158
+ - 0
159
+ version: 2.3.0
160
+ requirement: *id009
161
+ - !ruby/object:Gem::Dependency
162
+ prerelease: false
163
+ name: activeresource
164
+ type: :runtime
165
+ version_requirements: &id010 !ruby/object:Gem::Requirement
166
+ none: false
167
+ requirements:
168
+ - - ">="
169
+ - !ruby/object:Gem::Version
170
+ hash: 3
171
+ segments:
172
+ - 2
173
+ - 3
174
+ - 0
175
+ version: 2.3.0
176
+ requirement: *id010
177
+ description: Allows ticketmaster to interact with Your System.
178
+ email: ana@hybridgroup.com
179
+ executables: []
180
+
181
+ extensions: []
182
+
183
+ extra_rdoc_files:
184
+ - LICENSE.txt
185
+ - README.md
186
+ - README.rdoc
187
+ files:
188
+ - .document
189
+ - .rspec
190
+ - .rvmrc
191
+ - Gemfile
192
+ - Gemfile.lock
193
+ - LICENSE.txt
194
+ - README.md
195
+ - README.rdoc
196
+ - Rakefile
197
+ - VERSION
198
+ - lib/codaset/.gitignore
199
+ - lib/codaset/codaset-api.rb
200
+ - lib/provider/codaset.rb
201
+ - lib/provider/comment.rb
202
+ - lib/provider/project.rb
203
+ - lib/provider/ticket.rb
204
+ - lib/ticketmaster-codaset.rb
205
+ - spec/comments_spec.rb
206
+ - spec/fixtures/my-project.json
207
+ - spec/fixtures/new-project.json
208
+ - spec/fixtures/new-ticket.json
209
+ - spec/fixtures/projects.json
210
+ - spec/fixtures/tickets.json
211
+ - spec/fixtures/tickets/1.json
212
+ - spec/projects_spec.rb
213
+ - spec/spec.opts
214
+ - spec/spec_helper.rb
215
+ - spec/ticketmaster-codaset_spec.rb
216
+ - spec/tickets_spec.rb
217
+ has_rdoc: true
218
+ homepage: http://github.com/hybridgroup/ticketmaster-codaset
219
+ licenses:
220
+ - MIT
221
+ post_install_message:
222
+ rdoc_options: []
223
+
224
+ require_paths:
225
+ - lib
226
+ required_ruby_version: !ruby/object:Gem::Requirement
227
+ none: false
228
+ requirements:
229
+ - - ">="
230
+ - !ruby/object:Gem::Version
231
+ hash: 3
232
+ segments:
233
+ - 0
234
+ version: "0"
235
+ required_rubygems_version: !ruby/object:Gem::Requirement
236
+ none: false
237
+ requirements:
238
+ - - ">="
239
+ - !ruby/object:Gem::Version
240
+ hash: 3
241
+ segments:
242
+ - 0
243
+ version: "0"
244
+ requirements: []
245
+
246
+ rubyforge_project:
247
+ rubygems_version: 1.4.2
248
+ signing_key:
249
+ specification_version: 3
250
+ summary: The codaset provider for ticketmaster
251
+ test_files:
252
+ - spec/comments_spec.rb
253
+ - spec/projects_spec.rb
254
+ - spec/spec_helper.rb
255
+ - spec/ticketmaster-codaset_spec.rb
256
+ - spec/tickets_spec.rb