ticketmaster 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/NOTES ADDED
@@ -0,0 +1,18 @@
1
+ This needs a documentation for implementing Providers and some guidelines on Provider stuff.
2
+
3
+ Environment variables and config files
4
+ ~/.ticketmaster.yml
5
+
6
+
7
+ .ticketmaster.yml
8
+ default: lighthouse
9
+ lighthouse:
10
+ token: 67dc50b88ea1e339eb72ba0e2b90573b6453d805
11
+ account: ticketmaster
12
+ unfuddle:
13
+ username: xxx
14
+ password: xxx
15
+ subdomain: xxx
16
+
17
+
18
+
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.1.0
data/lib/console.rb ADDED
File without changes
data/lib/ticketmaster.rb CHANGED
@@ -3,20 +3,42 @@
3
3
  hashie
4
4
  }.each {|lib| require lib }
5
5
 
6
+ class TicketMaster
7
+ end
8
+
6
9
  %w{
7
10
  project
8
11
  ticket
9
12
  authenticator
10
- }.each {|lib| require 'ticketmaster/' + lib }
11
-
12
- module TicketMasterMod
13
- attr_reader :project, :client
13
+ provider
14
+ exception
15
+ }.each {|lib| require File.dirname(__FILE__) + '/ticketmaster/' + lib }
14
16
 
15
- def initialize(client, authentication = {})
16
- @project = Project::Finder.new(client, authentication)
17
- end
18
- end
19
17
 
18
+ # This is the TicketMaster class
19
+ #
20
20
  class TicketMaster
21
- include TicketMasterMod
21
+ attr_reader :provider
22
+
23
+ # This initializes the TicketMaster instance and prepares the provider
24
+ # If called without any arguments, it conveniently tries searching for the information in
25
+ # ~/.ticketmaster.yml
26
+ # See the documentation for more information on the format of that file.
27
+ #
28
+ # What it DOES NOT do is auto-require the provider...so make sure you have the providers required.
29
+ def initialize(system = nil, authentication = nil)
30
+ if system.nil?
31
+ require 'yaml'
32
+ data = YAML.load_file File.expand_path('~/.ticketmaster.yml')
33
+ system = data['default'] || data.first.first
34
+ authentication = data[system] if authentication.nil?
35
+ end
36
+ self.extend TicketMaster::Provider.const_get(system.to_s.capitalize)
37
+ authorize authentication
38
+ end
39
+
40
+ # Providers should over-write this method
41
+ def authorize(authentication = {})
42
+ raise TicketMaster::Exception.new("This method must be reimplemented in the provider")
43
+ end
22
44
  end
@@ -1,4 +1,2 @@
1
- module TicketMasterMod
2
- class Authenticator < Hashie::Mash
3
- end
1
+ class TicketMaster::Authenticator < Hashie::Mash
4
2
  end
@@ -0,0 +1,65 @@
1
+ module TicketMaster::Provider
2
+ # This is the Dummy Provider
3
+ #
4
+ # It doesn't really do anything, it exists in order to test the basic functionality of ticketmaster
5
+ # and to provide an example the basics of what is to be expected from the providers.
6
+ #
7
+ # Note that the initial provider name is a module rather than a class. TicketMaster.new
8
+ # extends on an instance-based fashion. If you would rather initialize using code that is
9
+ # closer to:
10
+ #
11
+ # TicketMaster::Provider::Dummy.new(authentication)
12
+ #
13
+ # You will have to do a little magic trick and define new on the provider as a wrapper
14
+ # around the TicketMaster.new call.
15
+ module Dummy
16
+ include TicketMaster::Provider::Base
17
+ @system = :dummy
18
+ # An example of what to do if you would like to do TicketMaster::Provider::Dummy.new(...)
19
+ # rather than TicketMaster.new(:dummy, ...)
20
+ def self.new(authentication = {})
21
+ TicketMaster.new(:dummy, authentication)
22
+ # maybe do some other stuff
23
+ end
24
+
25
+ # It returns all projects...
26
+ def projects(*options)
27
+ return Project.find(*options) if options.length > 0
28
+ [Project.new]
29
+ end
30
+
31
+ # It returns all tickets...
32
+ def tickets(*options)
33
+ return Ticket.find(*options) if options.length > 0
34
+ [Ticket.new]
35
+ end
36
+
37
+ # Returning a single ticket based on parameters or a Ticket class if no parameters given
38
+ #
39
+ # The later is for doing:
40
+ # ticketmaster.ticket.find(...)
41
+ # ticketmaster.tickets.create(...)
42
+ #
43
+ # It's semantically nicer to use ticketmaster.tickets.find ... but people do strange things...
44
+ def ticket(*options)
45
+ return Ticket.new(*options) if options.length > 0
46
+ TicketMaster::Provider::Dummy::Ticket
47
+ end
48
+
49
+ # Return a single project based on parameters or the Project class if no parameters given
50
+ #
51
+ # The later is for doing:
52
+ # ticketmaster.project.find(...)
53
+ # ticketmaster.tickets.create(...)
54
+ #
55
+ # (It's semantically nicer to use ticketmaster.projects.find ... but people do strange things)
56
+ def project(*options)
57
+ return Project.new(*options) if options.length > 0
58
+ TicketMaster::Provider::Dummy::Project
59
+ end
60
+ end
61
+ end
62
+
63
+ %w| project ticket |.each do |f|
64
+ require File.dirname(__FILE__) + '/' + f +'.rb'
65
+ end
@@ -0,0 +1,54 @@
1
+ module TicketMaster::Provider
2
+ module Dummy
3
+ # This is the Project class for the Dummy provider
4
+ class Project < TicketMaster::Provider::Base::Project
5
+ # This serves to find projects
6
+ # As noted in the Project class's documentation, we should try to accept these:
7
+ #
8
+ # * find(:all) - Returns an array of all projects
9
+ # * find(##) - Returns a project based on that id or some other primary (unique) attribute
10
+ # * find(:first, :summary => 'Project name') - Returns a project based on the project's attributes
11
+ # * find(:summary => 'Test Project') - Returns all projects based on the given attribute(s)
12
+ def self.find(*options)
13
+ first = options.shift
14
+ if first.nil? or first == :all
15
+ [Project.new]
16
+ elsif first == :first
17
+ Project.new(options.shift)
18
+ elsif first.is_a?(Hash)
19
+ [Project.new(first)]
20
+ end
21
+ end
22
+
23
+ # You should define @system and @system_data here.
24
+ # The data stuff is just to initialize fake data. In a real provider, you would use the API
25
+ # to grab the information and then initialize based on that info.
26
+ # @system_data would hold the API's model/instance for reference
27
+ def initialize(*options)
28
+ data = {:id => rand(1000).to_i, :name => 'Dummy', :description => 'Mock!-ing Bird',
29
+ :created_at => Time.now, :updated_at => Time.now}
30
+ @system = :dummy
31
+ super(data.merge(options.first || {}))
32
+ end
33
+
34
+ # Should return all of the project's tickets
35
+ def tickets(*options)
36
+ return Ticket.find(*options) if options.length > 0
37
+ [Ticket.new]
38
+ end
39
+
40
+ # Point it to the Dummy's Ticket class
41
+ def ticket(*options)
42
+ return Ticket.find(:first, options.first) if options.length > 0
43
+ Ticket
44
+ end
45
+
46
+ # Nothing to save so we always return true
47
+ # ...unless it's an odd numbered second on Friday the 13th. muhaha!
48
+ def save
49
+ time = Time.now
50
+ !(time.wday == 5 and time.day == 13 and time.to_i % 2 == 1)
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,54 @@
1
+ module TicketMaster::Provider
2
+ module Dummy
3
+ # The Dummy Provider's Ticket class
4
+ class Ticket < TicketMaster::Provider::Base::Ticket
5
+ @system = :dummy
6
+
7
+ # Find a ticket
8
+ #
9
+ # The implementation should be able to accept these cases if feasible:
10
+ #
11
+ # * find(:all) - Returns an array of all tickets
12
+ # * find(##) - Returns a project based on that id or some other primary (unique) attribute
13
+ # * find(:first, :summary => 'Ticket title') - Returns a ticket based on the ticket's attributes
14
+ # * find(:summary => 'Test Ticket') - Returns all tickets based on the given attributes
15
+ def self.find(*options)
16
+ first = options.shift
17
+ if first.nil? or first == :all
18
+ [Ticket.new]
19
+ elsif first == :first
20
+ Ticket.new(options.shift)
21
+ elsif first.is_a?(Hash)
22
+ [Ticket.new(first)]
23
+ end
24
+ end
25
+
26
+ # You don't need to define an initializer, this is only here to initialize dummy data
27
+ def initialize(*options)
28
+ data = {:id => rand(1000), :status => ['lol', 'rofl', 'lmao', 'lamo', 'haha', 'heh'][rand(6)],
29
+ :priority => rand(10), :summary => 'Tickets ticket ticket ticket', :resolution => false,
30
+ :created_at => Time.now, :updated_at => Time.now, :description => 'Ticket ticket ticket ticket laughing',
31
+ :assignee => 'lol-man'}
32
+ @system = :dummy
33
+ super(data.merge(options.first || {}))
34
+ end
35
+
36
+ # Nothing to save so we always return true
37
+ # ...unless it's the Ides of March and the second is divisible by three. muhaha!
38
+ def save
39
+ time = Time.now
40
+ !(time.wday == 15 and time.day == 3 and time.to_i % 3 == 0)
41
+ end
42
+
43
+ # Nothing to close, so we always return true
44
+ def close
45
+ true
46
+ end
47
+
48
+ # Nothing to destroy so we always return true
49
+ def destroy
50
+ true
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,2 @@
1
+ class TicketMaster::Exception < Exception
2
+ end
@@ -1,82 +1,87 @@
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.
1
+ module TicketMaster::Provider
2
+ module Base
3
+ # This is the base Project class for providers
5
4
  #
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<..>, ..]
5
+ # Providers should inherit this class and redefine the methods
6
+ #
7
+ # Each provider should have their own @system defined.
8
+ # For example, ticketmaster-unfuddle's @system is :unfuddle and ticketmaster-lighthouse's
9
+ # @system is :lighthouse.
11
10
  #
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.
11
+ # Methods that must be implemented by the provider
31
12
  #
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(..)
13
+ # * self.find
14
+ # * tickets
15
+ # * ticket
16
+ # * save
17
+ # * initialize
43
18
  #
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_pair do |method, expected_value|
56
- matches += 1 if object.send(method) == expected_value
57
- end
58
-
59
- matching_objects << object if matches == query.length
19
+ # Methods that would probably be okay if the provider left it alone:
20
+ #
21
+ # * self.create
22
+ #
23
+ # A provider should define as many attributes as feasibly possible. The list below are
24
+ # some guidelines as to what attributes are necessary, if your provider's api does not
25
+ # implement them, point it to an attribute that is close to it. (for example, a name
26
+ # can point to title. Remember to alias it in your class!)
27
+ #
28
+ # * id
29
+ # * name
30
+ # * created_at
31
+ # * updated_at
32
+ # * description
33
+ class Project < Hashie::Mash
34
+ attr_accessor :system, :system_data
35
+ # Find a project, or find more projects.
36
+ # You can also retrieve an array of all projects by not specifying any query.
37
+ #
38
+ # The implementation should be able to accept these cases if feasible:
39
+ #
40
+ # * find(:all) - Returns an array of all projects
41
+ # * find(##) - Returns a project based on that id or some other primary (unique) attribute
42
+ # * find(:first, :summary => 'Project name') - Returns a project based on the project's attributes
43
+ # * find(:summary => 'Test Project') - Returns all projects based on the given attribute(s)
44
+ def self.find(*options)
45
+ raise TicketMaster::Exception.new("This method must be reimplemented in the provider")
60
46
  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)
47
+
48
+ # Create a project.
49
+ # Basically, a .new and .save in the same call. The default method assumes it is passed a
50
+ # single hash with attribute information
51
+ def self.create(*options)
52
+ project = self.new(options.first)
53
+ project.save
54
+ project
55
+ end
56
+
57
+ # The initializer
58
+ def initialize(*options)
59
+ super(options.shift)
60
+ # do some other stuff
71
61
  end
72
62
 
73
- def find(query = nil, options = {})
74
- options[:authentication] = @authentication
75
- options[:client] = @client
76
- Project::find(query, options)
63
+ # Asks the provider's api for the tickets associated with the project,
64
+ # returns an array of Ticket objects.
65
+ def tickets(*options)
66
+ raise TicketMaster::Exception.new("This method must be reimplemented in the provider")
77
67
  end
78
68
 
79
- alias_method :[], :find
69
+ # Mainly here because it is more natural to do:
70
+ # project.ticket.create(..)
71
+ #
72
+ # Than
73
+ # project.tickets.create(..)
74
+ #
75
+ # returns a ticket object or ticket class that responds to .new and .create.
76
+ def ticket(*options)
77
+ raise TicketMaster::Exception.new("This method must be reimplemented in the provider")
78
+ end
79
+
80
+ # Save changes to this project
81
+ def save
82
+ raise TicketMaster::Exception.new("This method must be reimplemented in the provider")
83
+ end
84
+
80
85
  end
81
86
  end
82
87
  end
@@ -0,0 +1,68 @@
1
+ # This is the TicketMaster::Provider Module
2
+ #
3
+ # All provider classes will extend into this module.
4
+ # See the Dummy provider's code for some specifics on implementing a provider
5
+ #
6
+ # Currently, only Projects and Tickets are standardized in ticket master. Therefore,
7
+ # if your provider has other types--such as People/Members, Messages, Milestones, Notes,
8
+ # Tags, etc--you may implement it at your discretion. We are planning to eventually
9
+ # incorporate and standardize many of these into the overall provider. Keep on the look out for it!
10
+ #
11
+ # We are also planning on standardizing non-standard/provider-specific object models
12
+ module TicketMaster::Provider
13
+ module Base
14
+ # All providers must define this method.
15
+ # It doesn't *have* to do anything, it just has to be there. But since it's here, you don't
16
+ # have to worry about it as long as you "include TicketMaster::Provider::Base"
17
+ #
18
+ # If you need to do some additional things to initialize the instance, here is where you would put it
19
+ def authorize(authentication = {})
20
+ @authentication = TicketMaster::Authenticator.new(authentication)
21
+ end
22
+
23
+ # Providers should try to define this method
24
+ #
25
+ # It returns the project class for this provider, so that there can be calls such as
26
+ # ticketmaster.project.find :all
27
+ # ticketmaster.project(:id => 777, :name => 'Proj test')
28
+ #
29
+ # Should try to implement a find :first (or find with singular result) if given parameters
30
+ def project(*options)
31
+ return TicketMaster::Project.find(*options) if options.length > 0
32
+ TicketMaster::Project
33
+ end
34
+
35
+ # Providers should try to define this method
36
+ #
37
+ # It returns the ticket class for this provider, so that there can be calls such as
38
+ # ticketmaster.ticket.find :all
39
+ # ticketmaster.ticket(:id => 102, :title => 'Ticket')
40
+ #
41
+ # Don't confuse this with project.ticket.find(...) since that deals with tickets specific to a
42
+ # project. This is deals with tickets
43
+ #
44
+ # Should try to implement a find :first (or find with singular result) if given parameters
45
+ def ticket(*options)
46
+ return TicketMaster::Ticket.find(*options) if options.length > 0
47
+ TicketMaster::Ticket
48
+ end
49
+
50
+ # All providers should try to define this method.
51
+ #
52
+ # It returns all projects in an array
53
+ # Should try to implement a find :all if given parameters
54
+ def projects(*options)
55
+ []
56
+ end
57
+
58
+ # All providers should try to define this method
59
+ #
60
+ # It returns all tickets in an array.
61
+ # Should try to implement a find :all if given parameters
62
+ def tickets(*options)
63
+ []
64
+ end
65
+ end
66
+ end
67
+
68
+
@@ -1,27 +1,120 @@
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}
1
+ module TicketMaster::Provider
2
+ module Base
3
+ # The base ticket class for ticketmaster
4
+ # All providers should inherit this class
5
+ #
6
+ # The difference between the class methods and instance methods are that the instance
7
+ # methods should be treated as though they are called on a known ticket and the class
8
+ # methods act based on a blank slate (which means the info to find a specific ticket has
9
+ # to be passed in the parameters in the ticket)
10
+ #
11
+ # Methods that a provider must define:
12
+ #
13
+ # * self.find
14
+ # * close
15
+ # * save
16
+ # * destroy
17
+ #
18
+ # Methods that the provider should define if feasible:
19
+ #
20
+ # * reload!
21
+ # * initialize
22
+ #
23
+ # Methods that would probably be okay if the provider left it alone:
24
+ #
25
+ # * self.create
26
+ # * update
27
+ # * update!
28
+ #
29
+ # A provider should define as many attributes as feasibly possible. The list below are
30
+ # some guidelines as to what attributes are necessary, if your provider's api does not
31
+ # implement them, point it to an attribute that is close to it. (for example, a summary
32
+ # can point to title. and assignee might point to assigned_to. Remember to alias it in your class!)
33
+ #
34
+ # * id
35
+ # * status
36
+ # * priority
37
+ # * summary
38
+ # * resolution
39
+ # * created_at
40
+ # * updated_at
41
+ # * description
42
+ # * assignee
43
+ class Ticket < Hashie::Mash
44
+ @ignore_inspect = %w| system system_data |
45
+ @system = nil # The symbol for the provider.
46
+ @system_data = nil # The system info for the provider
47
+ attr_accessor :system, :system_data
48
+ # Find a ticket
49
+ #
50
+ # The implementation should be able to accept these cases if feasible:
51
+ #
52
+ # * find(:all) - Returns an array of all tickets
53
+ # * find(##) - Returns a project based on that id or some other primary (unique) attribute
54
+ # * find(:first, :summary => 'Ticket title') - Returns a ticket based on the ticket's attributes
55
+ # * find(:summary => 'Test Ticket') - Returns all tickets based on the given attributes
56
+ def self.find(*options)
57
+ raise TicketMaster::Exception.new("This method must be reimplemented in the provider")
58
+ end
59
+
60
+ # Create a ticket.
61
+ # Basically, a .new and .save in the same call. The default method assumes it is passed a
62
+ # single hash with attribute information
63
+ def self.create(*options)
64
+ ticket = self.new(options.first)
65
+ ticket.save
66
+ end
67
+
68
+ # Instantiate a new ticket (but don't save yet!)
69
+ # The default method assumes a single hash with all the parameters is passed to Ticket.new
70
+ def initialize(*options)
71
+ super(options.first)
72
+ # do some other stuff
18
73
  end
19
74
 
20
- def create(ticket_hash)
21
- ticket_hash.merge!(@system)
22
- ticket = TicketMasterMod::Ticket.new(ticket_hash)
23
- ticket.create
75
+ # Close this ticket
76
+ #
77
+ # On success it should return true, otherwise false
78
+ def close(*options)
79
+ raise TicketMaster::Exception.new("This method must be reimplemented in the provider")
80
+ end
81
+
82
+ # Save this ticket
83
+ # Expected return value of true (successful) or false (failure)
84
+ def save(*options)
85
+ raise TicketMaster::Exception.new("This method must be reimplemented in the provider")
86
+ end
87
+
88
+ # Reload this ticket
89
+ def reload!(*options)
90
+ raise TicketMaster::Exception.new("This method must be reimplemented in the provider")
91
+ end
92
+
93
+ # Delete this ticket
94
+ #
95
+ # If your provider doesn't have a delete or trash option for tickets:
96
+ # raise TicketMaster::Exception.new("Tickets can not be destroyed on SomeProviderAPI")
97
+ def destroy(*options)
98
+ raise TicketMaster::Exception.new("This method must be reimplemented in the provider")
24
99
  end
100
+
101
+ # Update a ticket and save
102
+ #
103
+ # The default assumes the options passed to it is a single hash with the attributes to update
104
+ def update!(*options)
105
+ update(options.first)
106
+ save
107
+ end
108
+
109
+ # Update a ticket's attributes, but no save
110
+ # Used when you need to do mass attribute assignment
111
+ def update(*options)
112
+ options.first.each do |k, v|
113
+ self.send(k + '=', v)
114
+ end
115
+ self
116
+ end
117
+
25
118
  end
26
119
  end
27
120
  end
data/spec/spec.opts ADDED
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,10 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'ticketmaster.rb'
4
+ require 'ticketmaster/dummy/dummy.rb'
5
+ require 'spec'
6
+ require 'spec/autorun'
7
+
8
+ Spec::Runner.configure do |config|
9
+
10
+ end
@@ -0,0 +1,58 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ # This can also act as an example test or test skeleton for your provider.
4
+ # Just replace the Dummy in @project_class and @ticket_class
5
+ # Also, remember to mock or stub any API calls
6
+ describe "Ticketmaster" do
7
+ before(:each) do
8
+ @ticketmaster = TicketMaster.new(:dummy)
9
+ @project_class = TicketMaster::Provider::Dummy::Project
10
+ @ticket_class = TicketMaster::Provider::Dummy::Ticket
11
+ end
12
+
13
+ # Essentially just a sanity check on the include since .new always returns the object's instance
14
+ it "should be able to instantiate a new instance" do
15
+ @ticketmaster.should be_an_instance_of TicketMaster
16
+ @ticketmaster.should be_a_kind_of TicketMaster::Provider::Dummy
17
+ end
18
+
19
+ it "should be able to load projects" do
20
+ @ticketmaster.projects.should be_an_instance_of Array
21
+ @ticketmaster.projects.first.should be_an_instance_of @project_class
22
+ @ticketmaster.projects.first.description.should == "Mock!-ing Bird"
23
+ @ticketmaster.projects(:id => 555).should be_an_instance_of Array
24
+ @ticketmaster.projects(:id => 555).first.should be_an_instance_of @project_class
25
+ @ticketmaster.projects(:id => 555).first.id.should == 555
26
+
27
+ @ticketmaster.project.should == @project_class
28
+ @ticketmaster.project(:name => "Whack whack what?").should be_an_instance_of @project_class
29
+ @ticketmaster.project(:name => "Whack whack what?").name.should == "Whack whack what?"
30
+ @ticketmaster.project.find(:first, :description => "Shocking Dirb").should be_an_instance_of @project_class
31
+ @ticketmaster.project.find(:first, :description => "Shocking Dirb").description.should == "Shocking Dirb"
32
+ end
33
+
34
+ it "should be able to do project stuff" do
35
+ info = {:id => 777, :name => "Tiket Name c", :description => "that c thinks the k is trying to steal it's identity"}
36
+ @ticketmaster.project.create(info).should be_an_instance_of @project_class
37
+ @ticketmaster.project.new(info).should be_an_instance_of @project_class
38
+ @ticketmaster.project.create(info).id.should == 777
39
+ @ticketmaster.project.new(info).id.should == 777
40
+
41
+ @ticketmaster.projects.first.save.should == true
42
+ end
43
+
44
+ it "should be able to load tickets" do
45
+ project = @ticketmaster.projects.first
46
+ project.tickets.should be_an_instance_of Array
47
+ project.tickets.first.should be_an_instance_of @ticket_class
48
+ project.tickets(:id => 999).should be_an_instance_of Array
49
+ project.tickets(:id => 999).first.should be_an_instance_of @ticket_class
50
+ project.tickets(:id => 999).first.id.should == 999
51
+
52
+ project.ticket.should == TicketMaster::Provider::Dummy::Ticket
53
+ project.ticket(:id => 888).should be_an_instance_of @ticket_class
54
+ project.ticket(:id => 888).id.should == 888
55
+ project.ticket.find(:first, :id => 888).should be_an_instance_of @ticket_class
56
+ project.ticket.find(:first, :id => 888).id.should == 888
57
+ end
58
+ end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ticketmaster
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 27
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
- - 0
8
8
  - 1
9
- version: 0.0.1
9
+ - 0
10
+ version: 0.1.0
10
11
  platform: ruby
11
12
  authors:
12
13
  - Sirupsen
@@ -15,16 +16,18 @@ autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
18
 
18
- date: 2010-06-12 00:00:00 +02:00
19
+ date: 2010-06-22 00:00:00 +02:00
19
20
  default_executable: ticket
20
21
  dependencies:
21
22
  - !ruby/object:Gem::Dependency
22
23
  name: hashie
23
24
  prerelease: false
24
25
  requirement: &id001 !ruby/object:Gem::Requirement
26
+ none: false
25
27
  requirements:
26
28
  - - ">="
27
29
  - !ruby/object:Gem::Version
30
+ hash: 3
28
31
  segments:
29
32
  - 0
30
33
  version: "0"
@@ -34,9 +37,11 @@ dependencies:
34
37
  name: shoulda
35
38
  prerelease: false
36
39
  requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
37
41
  requirements:
38
42
  - - ">="
39
43
  - !ruby/object:Gem::Version
44
+ hash: 3
40
45
  segments:
41
46
  - 0
42
47
  version: "0"
@@ -55,17 +60,26 @@ files:
55
60
  - .document
56
61
  - .gitignore
57
62
  - LICENSE
63
+ - NOTES
58
64
  - README.md
59
65
  - Rakefile
60
66
  - VERSION
61
67
  - bin/ticket
68
+ - lib/console.rb
62
69
  - lib/ticketmaster.rb
63
70
  - lib/ticketmaster/authenticator.rb
71
+ - lib/ticketmaster/dummy/dummy.rb
72
+ - lib/ticketmaster/dummy/project.rb
73
+ - lib/ticketmaster/dummy/ticket.rb
74
+ - lib/ticketmaster/exception.rb
64
75
  - lib/ticketmaster/project.rb
76
+ - lib/ticketmaster/provider.rb
65
77
  - lib/ticketmaster/ticket.rb
78
+ - spec/spec.opts
79
+ - spec/spec_helper.rb
80
+ - spec/ticketmaster_spec.rb
66
81
  - test/helper.rb
67
82
  - test/test_ticketmaster.rb
68
- - test/test_unfuddler.rb
69
83
  has_rdoc: true
70
84
  homepage: http://ticketrb.com
71
85
  licenses: []
@@ -76,27 +90,32 @@ rdoc_options:
76
90
  require_paths:
77
91
  - lib
78
92
  required_ruby_version: !ruby/object:Gem::Requirement
93
+ none: false
79
94
  requirements:
80
95
  - - ">="
81
96
  - !ruby/object:Gem::Version
97
+ hash: 3
82
98
  segments:
83
99
  - 0
84
100
  version: "0"
85
101
  required_rubygems_version: !ruby/object:Gem::Requirement
102
+ none: false
86
103
  requirements:
87
104
  - - ">="
88
105
  - !ruby/object:Gem::Version
106
+ hash: 3
89
107
  segments:
90
108
  - 0
91
109
  version: "0"
92
110
  requirements: []
93
111
 
94
112
  rubyforge_project:
95
- rubygems_version: 1.3.6
113
+ rubygems_version: 1.3.7
96
114
  signing_key:
97
115
  specification_version: 3
98
116
  summary: Ticketmaster provides a universal API to trouble ticket and project management systems.
99
117
  test_files:
100
- - test/test_unfuddler.rb
118
+ - spec/spec_helper.rb
119
+ - spec/ticketmaster_spec.rb
101
120
  - test/test_ticketmaster.rb
102
121
  - test/helper.rb
@@ -1,75 +0,0 @@
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