ticketmaster 0.0.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
+ README.md
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Hybrid Group
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,129 @@
1
+ # ticketmaster
2
+
3
+ ticketmaster is a Gem which eases communication with various project and ticket management systems by providing a consistent Ruby API.
4
+
5
+ ticketmaster let's you "remap" a system into the consistent ticketmaster API, easily. For instance the description of an issue/ticket, might be named **description** in one system, and **problem-description** somewhere else. Via ticketmaster, this would always be called **description**. The ticketmaster remaps makes it easy for you to integrate different kinds of ticket systems, into your own system. You don't have to take care of all the different kinds of systems, and their different APIs. ticketmaster handles all this *for* you, so you can focus on making your application awesome.
6
+
7
+ ## Installation
8
+
9
+ ticketmaster is a Gem, so we can easily install it by using RubyGems:
10
+
11
+ gem install ticketmaster
12
+
13
+ ticketmaster depends on [Hashie](http://github.com/intridea/hashie), which is an amazing library which makes converting objects to hashes, and the other way around, a joy. It should be installed automatically whenever installing ticketmaster.
14
+
15
+ ### Finding and installing a provider
16
+
17
+ ticketmaster by itself won't do too much. You may want to install a provider, to retrieve a list of available providers issue the following command:
18
+
19
+ gem search ticketmaster
20
+
21
+ You could then install for instance ticketmaster-unfuddle:
22
+
23
+ gem install ticketmaster-unfuddle
24
+
25
+ ## TODO
26
+
27
+ * Find ticket by property
28
+ * Load login information from local file
29
+
30
+ ## Usage
31
+
32
+ **Note** Subject to change.
33
+
34
+ First, we instance a new class with the right set of options. In this example, we are authenticating with Unfuddle. As Unfuddle is a closed system, it is *required* that you authenticate with a user to a subdomain, and so we do:
35
+ unfuddle = TicketMaster.new(:unfuddle, {:username => "john", :password => "seekrit", :subdomain => "ticketmaster"})
36
+
37
+ Now we can use our instance with the right settings, to find a project. Let's go ahead and grab "testproject":
38
+ project = unfuddle.project["testproject"]
39
+
40
+ Which is a shortcut for:
41
+ project = unfuddle.project.find "testproject"
42
+
43
+ Which is a shortcut for:
44
+ project = unfuddle.project.find :name => "testproject"
45
+
46
+ Meaning you could also find a project by description or any other property, like this:
47
+ project = unfuddle.project.find :description => "Testproject's description"
48
+
49
+ Let's create a ticket with our project instance, unfuddle requires these three properties in order to create a ticket:
50
+ project.ticket.create(:priority => 3, :summary => "Test", :description => "Hello World")
51
+
52
+ Let's play with tickets. First we go ahead and grab ticket 22:
53
+ ticket = project.tickets(:id => 22)
54
+
55
+ We're working on this ticket right now, so let's go ahead and change the status
56
+ ticket.status = :in_progress
57
+
58
+ Other valid ticket statuses are:
59
+ :closed, :accepted, :resolved
60
+
61
+ For the fun of it, we'll change the description as well, and then save the ticket.
62
+ ticket.description = "Changed description to something else!"
63
+ ticket.save
64
+
65
+ The issue was solved, let's make it official by closing the ticket with the appropriate resolution:
66
+ ticket.close(:resolution => "fixed", :description => "Fixed issue by doing x")
67
+
68
+ ## Support
69
+
70
+ Currently ticketmaster supports the following systems:
71
+
72
+ ### Unfuddle (Alpha)
73
+
74
+ To use Unfuddle with ticketmaster, install it:
75
+ gem install ticketmaster-unfuddle
76
+
77
+ Then simply require it, and you are good to use Unfuddle with ticketmaster!
78
+ require 'ticketmaster'
79
+ require 'ticketmaster-unfuddle'
80
+ unfuddle = TicketMaster.new(:unfuddle, {:username => "..", :password => "..", :subdomain => ".."})
81
+
82
+ ## Creating a provider
83
+ Creating a provider consists of three steps:
84
+
85
+ * Create the ticketmaster provider (a.k.a. the remap)
86
+ * Release it to RubyGems
87
+ * Send an email to sirup@sirupsen.dk telling me about the awesome provider you created so we can fit it onto the list!
88
+
89
+ ### Create the ticketmaster provider
90
+ Almost all APIs are different. And so are their Ruby providers. ticketmaster attempts to create an universal API for all ticket and project management systems, and thus we need to map the functionality to the ticketmaster API. This is the providers job. It is the glue between ticketmaster, and the ticket management's API. Usually, your provider would rely on another library for the raw HTTP interaction. For instance, [ticketmaster-unfuddle](http://github.com/hybridgroup/ticketmaster-unfuddle) depends on [Unfuddler](http://github.com/hybridgroup/unfuddler) in order to interact with the Unfuddle API. Look at it like this:
91
+
92
+ **ticketmaster** -> **Provider** -> *(Ruby library)* -> **Site's API**
93
+
94
+ Provider being the "glue" between the site's API and ticketmaster. Ruby library is "optional" (though higly recommended as mentioned), thus it is in parantheses.
95
+
96
+ An example of a provider could be [ticketmaster-unfuddle](http://github.com/hybridgroup/ticketmaster-unfuddle), an example of a Ruby library would be [Unfuddler](http://github.com/hybridgroup/unfuddler).
97
+
98
+ For now, look at [ticketmaster-unfuddle](http://github.com/hybridgroup/ticketmaster-unfuddle) as an example on how to create a provider. More detailed documentation on this matter will be available soon.
99
+
100
+ ### Release it
101
+ It would be an advantage for everyone, if you would host your provider on Github. Afterwards, simply release it to RubyGems.org, the name of the provider Gem should follow this simple naming rule:
102
+
103
+ ticketmaster-<provider's name>
104
+
105
+ For instance for a Github provider:
106
+
107
+ ticketmaster-github
108
+
109
+ This makes it easy for people to install a provider, simply by issuing:
110
+
111
+ gem search ticketmaster
112
+
113
+ They should be presented a nice list of all available providers.
114
+
115
+ After releasing, throw me an email at sirup@sirupsen.dk telling me about your awesome provider, and I'll throw it on the list of supported systems!
116
+
117
+ ## Note on Patches/Pull Requests
118
+
119
+ * Fork the project.
120
+ * Make your feature addition or bug fix.
121
+ * Add tests for it. This is important so I don't break it in a
122
+ future version unintentionally.
123
+ * Commit, do not mess with rakefile, version, or history.
124
+ (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)
125
+ * Send me a pull request. Bonus points for topic branches.
126
+
127
+ ## Copyright
128
+
129
+ Copyright (c) 2010 [Hybrid Group](http://hybridgroup.com). See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,53 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "ticketmaster"
8
+ gem.summary = %Q{Ticketmaster provides a universal API to trouble ticket and project management systems.}
9
+ gem.description = %Q{Ticketmaster provides a universal API to trouble ticket and project management systems.}
10
+ gem.email = "simon@hybridgroup.com"
11
+ gem.homepage = "http://ticketrb.com"
12
+ gem.authors = ["Sirupsen", "deadprogrammer"]
13
+ gem.add_dependency "hashie", ">= 0"
14
+ gem.add_development_dependency "shoulda", ">= 0"
15
+ end
16
+ Jeweler::GemcutterTasks.new
17
+ rescue LoadError
18
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
19
+ end
20
+
21
+ require 'rake/testtask'
22
+ Rake::TestTask.new(:test) do |test|
23
+ test.libs << 'lib' << 'test'
24
+ test.pattern = 'test/**/test_*.rb'
25
+ test.verbose = true
26
+ end
27
+
28
+ begin
29
+ require 'rcov/rcovtask'
30
+ Rcov::RcovTask.new do |test|
31
+ test.libs << 'test'
32
+ test.pattern = 'test/**/test_*.rb'
33
+ test.verbose = true
34
+ end
35
+ rescue LoadError
36
+ task :rcov do
37
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
38
+ end
39
+ end
40
+
41
+ task :test => :check_dependencies
42
+
43
+ task :default => :test
44
+
45
+ require 'rake/rdoctask'
46
+ Rake::RDocTask.new do |rdoc|
47
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
48
+
49
+ rdoc.rdoc_dir = 'rdoc'
50
+ rdoc.title = "ticketmaster #{version}"
51
+ rdoc.rdoc_files.include('README*')
52
+ rdoc.rdoc_files.include('lib/**/*.rb')
53
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.0
data/bin/ticket ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ puts "ticket commands will go thru here..."
4
+ puts "EXAMPLE:"
5
+ puts "ticket list"
6
+ puts "ticket close 127 \"This is done\""
7
+ puts "ticket open \"what a problem we have here\""
@@ -0,0 +1,22 @@
1
+ %w{
2
+ rubygems
3
+ hashie
4
+ }.each {|lib| require lib }
5
+
6
+ %w{
7
+ project
8
+ ticket
9
+ authenticator
10
+ }.each {|lib| require 'ticketmaster/' + lib }
11
+
12
+ module TicketMasterMod
13
+ attr_reader :project, :client
14
+
15
+ def initialize(client, authentication = {})
16
+ @project = Project::Finder.new(client, authentication)
17
+ end
18
+ end
19
+
20
+ class TicketMaster
21
+ include TicketMasterMod
22
+ end
@@ -0,0 +1,4 @@
1
+ module TicketMasterMod
2
+ class Authenticator < Hashie::Mash
3
+ end
4
+ end
@@ -0,0 +1,82 @@
1
+ module TicketMasterMod
2
+ class Project < Hashie::Mash
3
+ # Find a project, or find more projects. You can also retrieve an array of all
4
+ # projects by not specifying any query.
5
+ #
6
+ # unfuddle = TicketMaster.new(:unfuddle, {:username => "..", :password => "..", :subdomain => ".."})
7
+ # unfuddle.project.find("ticketmaster")
8
+ # #=> TicketMasterMod::Project<#name = "ticketmaster", ..>
9
+ # unfuddle.project.find
10
+ # #=> [TicketMasterMod::Project<..>, TicketMasterMod::Project<..>, ..]
11
+ #
12
+ def self.find(query = nil, options = {})
13
+ # Asks the client for the projects, should return an array of
14
+ # project objects.
15
+ projects = TicketMasterMod.const_get(options[:client].to_s.capitalize)::Project.find(query, options)
16
+
17
+ if query
18
+ query = {:name => query} if query.is_a?(String)
19
+
20
+ # For some reason #tickets find ability messes up if we use a class method.
21
+ # Thus I decided to go for an instance method.
22
+ return Project.new.search(query, projects)
23
+ end
24
+
25
+ # No query, so we just go ahead and return the array of projects
26
+ projects
27
+ end
28
+
29
+ # Asks the client for the tickets associated with the project,
30
+ # returns an array of Ticket objects.
31
+ #
32
+ # project.tickets
33
+ # #=> [TicketMasterMod::Ticket<...>, TicketMasterMod::Ticket<...>, ..]
34
+ def tickets(query = {})
35
+ tickets = TicketMasterMod.const_get(self.system.capitalize)::Project.tickets(self)
36
+ return search(query, tickets) unless query.empty?
37
+
38
+ tickets
39
+ end
40
+
41
+ # Mainly here because it is more natural to do:
42
+ # project.ticket.create(..)
43
+ #
44
+ # Than
45
+ # project.tickets.create(..)
46
+ def ticket
47
+ TicketMasterMod::Ticket::Creator.new(self)
48
+ end
49
+
50
+ def search(query, objects)
51
+ matching_objects = []
52
+
53
+ objects.each do |object|
54
+ matches = 0
55
+ query.each do |query, expected_value|
56
+ matches += 1 if object.send(query) == expected_value
57
+ end
58
+
59
+ matching_objects << object if matches == query.length
60
+ end
61
+
62
+ # Raw object versus array with one entry
63
+ return matching_objects.first if matching_objects.length == 1
64
+ matching_objects
65
+ end
66
+
67
+ class Finder
68
+ def initialize(client, authentication)
69
+ @client = client
70
+ @authentication = Authenticator.new(authentication)
71
+ end
72
+
73
+ def find(query = nil, options = {})
74
+ options[:authentication] = @authentication
75
+ options[:client] = @client
76
+ Project::find(query, options)
77
+ end
78
+
79
+ alias_method :[], :find
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,27 @@
1
+ module TicketMasterMod
2
+ class Ticket < Hashie::Mash
3
+ def create
4
+ TicketMasterMod.const_get((self.system || self.project.system).to_s.capitalize)::Ticket.create(self)
5
+ end
6
+
7
+ def close(resolution = {})
8
+ TicketMasterMod.const_get(self.system.to_s.capitalize)::Ticket.close(self, resolution)
9
+ end
10
+
11
+ def save
12
+ TicketMasterMod.const_get(self.system.to_s.capitalize)::Ticket.save(self)
13
+ end
14
+
15
+ class Creator
16
+ def initialize(system)
17
+ @system = {:project => system}
18
+ end
19
+
20
+ def create(ticket_hash)
21
+ ticket_hash.merge!(@system)
22
+ ticket = TicketMasterMod::Ticket.new(ticket_hash)
23
+ ticket.create
24
+ end
25
+ end
26
+ end
27
+ end
data/test/helper.rb ADDED
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
7
+ require 'ticketmaster'
8
+
9
+ class Test::Unit::TestCase
10
+ end
@@ -0,0 +1,4 @@
1
+ require 'helper'
2
+
3
+ class TestTicketmaster < Test::Unit::TestCase
4
+ end
@@ -0,0 +1,75 @@
1
+ require 'helper'
2
+ require 'ticketmaster-unfuddle'
3
+
4
+ class TestTicketmaster < Test::Unit::TestCase
5
+ context "Unfuddle" do
6
+ setup do
7
+ @unfuddle = TicketMaster.new(:unfuddle, {:username => "", :password => "", :subdomain => "ticketmaster"})
8
+ @project = @unfuddle.project.find.first
9
+ end
10
+
11
+ should "find testproject" do
12
+ project = @unfuddle.project.find(:name => "testproject")
13
+
14
+ assert_instance_of TicketMasterMod::Project, project
15
+ assert_equal "testproject", project.name
16
+
17
+ #method 2
18
+ project = @unfuddle.project.find("testproject")
19
+
20
+ assert_instance_of TicketMasterMod::Project, project
21
+ assert_equal "testproject", project.name
22
+
23
+ #method 3
24
+ project = @unfuddle.project["testproject"]
25
+
26
+ assert_instance_of TicketMasterMod::Project, project
27
+ assert_equal "testproject", project.name
28
+ end
29
+
30
+ context "project instance" do
31
+ should "find a project" do
32
+ assert_instance_of TicketMasterMod::Project, @project
33
+ end
34
+
35
+ should "find a bunch of tickets" do
36
+ @project.tickets
37
+ end
38
+
39
+ should "find new tickets" do
40
+ tickets = @project.tickets(:status => "new")
41
+
42
+ tickets.each do |ticket|
43
+ assert_equal "new", ticket.status
44
+ end
45
+ end
46
+
47
+ should "find ticket with id 1" do
48
+ ticket = @project.tickets(:id => 1)
49
+
50
+ assert_equal 1, ticket.id
51
+ end
52
+
53
+ should "create a ticket" do
54
+ assert @project.ticket.create(:priority => 3, :summary => "Test", :description => "Hello World from TicketMaster::Unfuddle").empty?
55
+ end
56
+
57
+ should "change ticket property" do
58
+ ticket = @project.tickets.last
59
+ ticket.description = "Edited description"
60
+ assert ticket.save.empty?
61
+
62
+ ticket = @project.tickets.last
63
+ assert_equal "Edited description", ticket.description
64
+ end
65
+
66
+ should "close the last ticket with a resolution" do
67
+ ticket = @project.tickets.last
68
+ assert ticket.close(:resolution => "fixed", :description => "Fixed issue").empty?
69
+
70
+ ticket = @project.tickets.last
71
+ assert_equal "fixed", ticket.resolution
72
+ end
73
+ end
74
+ end
75
+ end
metadata ADDED
@@ -0,0 +1,111 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ticketmaster
3
+ version: !ruby/object:Gem::Version
4
+ hash: 31
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 0
10
+ version: 0.0.0
11
+ platform: ruby
12
+ authors:
13
+ - Sirupsen
14
+ - deadprogrammer
15
+ autorequire:
16
+ bindir: bin
17
+ cert_chain: []
18
+
19
+ date: 2010-06-07 00:00:00 +02:00
20
+ default_executable: ticket
21
+ dependencies:
22
+ - !ruby/object:Gem::Dependency
23
+ name: hashie
24
+ prerelease: false
25
+ requirement: &id001 !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ hash: 3
31
+ segments:
32
+ - 0
33
+ version: "0"
34
+ type: :runtime
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: shoulda
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ hash: 3
45
+ segments:
46
+ - 0
47
+ version: "0"
48
+ type: :development
49
+ version_requirements: *id002
50
+ description: Ticketmaster provides a universal API to trouble ticket and project management systems.
51
+ email: simon@hybridgroup.com
52
+ executables:
53
+ - ticket
54
+ extensions: []
55
+
56
+ extra_rdoc_files:
57
+ - LICENSE
58
+ - README.md
59
+ files:
60
+ - .document
61
+ - .gitignore
62
+ - LICENSE
63
+ - README.md
64
+ - Rakefile
65
+ - VERSION
66
+ - bin/ticket
67
+ - lib/ticketmaster.rb
68
+ - lib/ticketmaster/authenticator.rb
69
+ - lib/ticketmaster/project.rb
70
+ - lib/ticketmaster/ticket.rb
71
+ - test/helper.rb
72
+ - test/test_ticketmaster.rb
73
+ - test/test_unfuddler.rb
74
+ has_rdoc: true
75
+ homepage: http://ticketrb.com
76
+ licenses: []
77
+
78
+ post_install_message:
79
+ rdoc_options:
80
+ - --charset=UTF-8
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ hash: 3
89
+ segments:
90
+ - 0
91
+ version: "0"
92
+ required_rubygems_version: !ruby/object:Gem::Requirement
93
+ none: false
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ hash: 3
98
+ segments:
99
+ - 0
100
+ version: "0"
101
+ requirements: []
102
+
103
+ rubyforge_project:
104
+ rubygems_version: 1.3.7
105
+ signing_key:
106
+ specification_version: 3
107
+ summary: Ticketmaster provides a universal API to trouble ticket and project management systems.
108
+ test_files:
109
+ - test/test_unfuddler.rb
110
+ - test/test_ticketmaster.rb
111
+ - test/helper.rb