unfuddler 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +9 -1
- data/VERSION +1 -1
- data/lib/unfuddler.rb +26 -11
- data/test/test_unfuddler.rb +27 -7
- metadata +5 -19
- data/unfuddler.gemspec +0 -63
data/README.md
CHANGED
@@ -2,6 +2,14 @@
|
|
2
2
|
|
3
3
|
Unfuddler is a simple Ruby API to Unfuddle's projects and tickets. Primarily made for [ticketmaster](http://github.com/Sirupsen/ticketmaster).
|
4
4
|
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
The easiest way to install Unfuddler is via RubyGems:
|
8
|
+
# gem install unfuddler
|
9
|
+
|
10
|
+
If you live on the edge, clone this repository and run:
|
11
|
+
# rake install
|
12
|
+
|
5
13
|
## Usage
|
6
14
|
|
7
15
|
First of all, authentiate with your information:
|
@@ -13,7 +21,7 @@ Now, find your project
|
|
13
21
|
Get ALL the tickets from this project, where the status is "new"
|
14
22
|
new_tickets = project.tickets(:status => "new")
|
15
23
|
|
16
|
-
Let's close the
|
24
|
+
Let's close the first of these tickets, with a resolution.
|
17
25
|
new_tickets.first.close!(:resolution => "fixed", :description => "I fixed it!")
|
18
26
|
|
19
27
|
## Note on Patches/Pull Requests
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.4
|
data/lib/unfuddler.rb
CHANGED
@@ -6,18 +6,17 @@
|
|
6
6
|
active_support/core_ext/hash
|
7
7
|
}.each {|lib| require lib}
|
8
8
|
|
9
|
-
|
10
9
|
module Unfuddler
|
11
10
|
class << self
|
12
11
|
attr_accessor :username, :password, :subdomain, :http
|
13
12
|
|
14
13
|
def authenticate(info)
|
15
|
-
@username, @password, @subdomain = info[:username], info[:password], info[:subdomain]
|
14
|
+
@username, @password, @subdomain = info[:username] || info["username"], info[:password] || info["password"], info[:subdomain] || info["subdomain"]
|
16
15
|
@http = Net::HTTP.new("#{@subdomain}.unfuddle.com", 80)
|
17
16
|
end
|
18
17
|
|
19
18
|
def request(type, url, data = nil)
|
20
|
-
request = eval("Net::HTTP::#{type.capitalize}").new("/api/v1/#{url}", {'Content-type' => "application/xml"})
|
19
|
+
request = eval("Net::HTTP::#{type.to_s.capitalize}").new("/api/v1/#{url}", {'Content-type' => "application/xml"})
|
21
20
|
request.basic_auth @username, @password
|
22
21
|
|
23
22
|
request.body = data if data
|
@@ -31,21 +30,36 @@ module Unfuddler
|
|
31
30
|
end
|
32
31
|
|
33
32
|
[:get, :put, :post, :delete].each do |method|
|
34
|
-
define_method(method) do |
|
33
|
+
define_method(method) do |*args|
|
34
|
+
# Ruby 1.8 fix, in 1.9 we could just do define.. do |url, data = nil|
|
35
|
+
url, data = args
|
35
36
|
request(method, url, data)
|
36
37
|
end
|
37
38
|
end
|
38
39
|
end
|
39
40
|
|
40
41
|
class Project < Hashie::Mash
|
41
|
-
def self.find
|
42
|
+
def self.find(name = nil)
|
42
43
|
projects = []
|
43
44
|
Unfuddler.get("projects.xml")["projects"].each do |project|
|
44
45
|
projects << Project.new(project)
|
45
46
|
end
|
47
|
+
|
48
|
+
if name
|
49
|
+
right_project = nil
|
50
|
+
projects.each do |project|
|
51
|
+
right_project = project if project.short_name == name.to_s
|
52
|
+
end
|
53
|
+
return right_project
|
54
|
+
end
|
55
|
+
|
46
56
|
projects
|
47
57
|
end
|
48
58
|
|
59
|
+
def self.[](name = nil)
|
60
|
+
self.find(name)
|
61
|
+
end
|
62
|
+
|
49
63
|
def tickets(argument = nil)
|
50
64
|
Ticket.find(self.id, argument)
|
51
65
|
end
|
@@ -109,14 +123,15 @@ module Unfuddler
|
|
109
123
|
|
110
124
|
[:closed!, :new!, :unaccepted!, :reassigned!, :reopened!, :accepted!, :resolved!].each do |method|
|
111
125
|
# Fix method names, e.g. #reassigned! => #reassign!
|
112
|
-
length = method[0..-3] if method == :closed!
|
113
|
-
length = method[0..-2] if [:new!, :resolved!].include?(method)
|
126
|
+
length = method.to_s[0..-3] if method == :closed!
|
127
|
+
length = method.to_s[0..-2] if [:new!, :resolved!].include?(method)
|
114
128
|
|
115
|
-
define_method((length || method[0..-4]) + "!") do |
|
116
|
-
name = method[0..-2] # No "!"
|
129
|
+
define_method((length || method.to_s[0..-4]) + "!") do |*args|
|
130
|
+
name = method.to_s[0..-2] # No "!"
|
117
131
|
update = {:status => name}
|
118
|
-
|
119
|
-
|
132
|
+
|
133
|
+
resolution = args.first
|
134
|
+
unless resolution.empty?
|
120
135
|
# The API wants resolution-description for a resolutions description,
|
121
136
|
# to make it more user-friendly, we convert this automatically
|
122
137
|
resolution[:"resolution-description"] = resolution.delete(:description)
|
data/test/test_unfuddler.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
3
|
class TestUnfuddler < Test::Unit::TestCase
|
4
|
-
context "an Unfuddler project
|
4
|
+
context "an Unfuddler project" do
|
5
5
|
setup do
|
6
6
|
Unfuddler.authenticate(:username => "", :password => "", :subdomain => "ticketmaster")
|
7
7
|
@project = Unfuddler::Project.find.first
|
@@ -11,6 +11,14 @@ class TestUnfuddler < Test::Unit::TestCase
|
|
11
11
|
assert @project.is_a?(Unfuddler::Project)
|
12
12
|
end
|
13
13
|
|
14
|
+
should "find a project with name Test" do
|
15
|
+
assert_instance_of Unfuddler::Project, Unfuddler::Project.find("testproject")
|
16
|
+
end
|
17
|
+
|
18
|
+
should "find a project with name Test" do
|
19
|
+
assert_instance_of Unfuddler::Project, Unfuddler::Project["testproject"]
|
20
|
+
end
|
21
|
+
|
14
22
|
should "have authentication information" do
|
15
23
|
assert Unfuddler.subdomain.is_a?(String)
|
16
24
|
assert Unfuddler.username.is_a?(String)
|
@@ -23,11 +31,23 @@ class TestUnfuddler < Test::Unit::TestCase
|
|
23
31
|
assert tickets.last.is_a?(Unfuddler::Ticket)
|
24
32
|
end
|
25
33
|
|
26
|
-
|
34
|
+
should "create a new ticket" do
|
35
|
+
assert @project.ticket.create(:priority => "3", :summary => "TestTicket", :description => "This is a description for a test ticket.").empty?
|
36
|
+
end
|
37
|
+
|
38
|
+
should "find tickets by summary and description" do
|
39
|
+
assert_instance_of Unfuddler::Ticket, @project.tickets.find(:summary => "TestTicket", :description => "This is a description for a test ticket.").first
|
40
|
+
end
|
41
|
+
|
42
|
+
context "with new ticket instance" do
|
27
43
|
setup do
|
28
44
|
@ticket = @project.tickets.last
|
29
45
|
end
|
30
46
|
|
47
|
+
should "have right summary" do
|
48
|
+
assert_equal "TestTicket", @ticket.summary
|
49
|
+
end
|
50
|
+
|
31
51
|
should "be a ticket" do
|
32
52
|
assert @ticket.is_a?(Unfuddler::Ticket)
|
33
53
|
end
|
@@ -36,14 +56,14 @@ class TestUnfuddler < Test::Unit::TestCase
|
|
36
56
|
assert @ticket.close!(:resolution => "fixed", :description => "Fixed it").empty?
|
37
57
|
end
|
38
58
|
|
39
|
-
should "
|
40
|
-
|
59
|
+
should "have new resolution description" do
|
60
|
+
assert_equal "Fixed it", @ticket.resolution_description
|
41
61
|
end
|
42
62
|
|
43
|
-
should "delete the last ticket" do
|
63
|
+
#should "delete the last ticket" do
|
44
64
|
# Should return an empty hash on success
|
45
|
-
|
46
|
-
end
|
65
|
+
# assert @ticket.delete.empty?
|
66
|
+
#end
|
47
67
|
end
|
48
68
|
end
|
49
69
|
end
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unfuddler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 25
|
5
4
|
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 0
|
8
7
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
8
|
+
- 4
|
9
|
+
version: 0.0.4
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Sirupsen
|
@@ -15,18 +14,16 @@ autorequire:
|
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date: 2010-
|
17
|
+
date: 2010-06-11 00:00:00 +02:00
|
19
18
|
default_executable:
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
22
21
|
name: shoulda
|
23
22
|
prerelease: false
|
24
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
24
|
requirements:
|
27
25
|
- - ">="
|
28
26
|
- !ruby/object:Gem::Version
|
29
|
-
hash: 3
|
30
27
|
segments:
|
31
28
|
- 0
|
32
29
|
version: "0"
|
@@ -36,11 +33,9 @@ dependencies:
|
|
36
33
|
name: hashie
|
37
34
|
prerelease: false
|
38
35
|
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
-
none: false
|
40
36
|
requirements:
|
41
37
|
- - ">="
|
42
38
|
- !ruby/object:Gem::Version
|
43
|
-
hash: 23
|
44
39
|
segments:
|
45
40
|
- 0
|
46
41
|
- 2
|
@@ -52,11 +47,9 @@ dependencies:
|
|
52
47
|
name: crack
|
53
48
|
prerelease: false
|
54
49
|
requirement: &id003 !ruby/object:Gem::Requirement
|
55
|
-
none: false
|
56
50
|
requirements:
|
57
51
|
- - ">="
|
58
52
|
- !ruby/object:Gem::Version
|
59
|
-
hash: 23
|
60
53
|
segments:
|
61
54
|
- 0
|
62
55
|
- 1
|
@@ -68,11 +61,9 @@ dependencies:
|
|
68
61
|
name: activesupport
|
69
62
|
prerelease: false
|
70
63
|
requirement: &id004 !ruby/object:Gem::Requirement
|
71
|
-
none: false
|
72
64
|
requirements:
|
73
65
|
- - ">="
|
74
66
|
- !ruby/object:Gem::Version
|
75
|
-
hash: 9
|
76
67
|
segments:
|
77
68
|
- 2
|
78
69
|
- 3
|
@@ -99,7 +90,6 @@ files:
|
|
99
90
|
- lib/unfuddler.rb
|
100
91
|
- test/helper.rb
|
101
92
|
- test/test_unfuddler.rb
|
102
|
-
- unfuddler.gemspec
|
103
93
|
has_rdoc: true
|
104
94
|
homepage: http://github.com/Sirupsen/unfuddler
|
105
95
|
licenses: []
|
@@ -110,30 +100,26 @@ rdoc_options:
|
|
110
100
|
require_paths:
|
111
101
|
- lib
|
112
102
|
required_ruby_version: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
103
|
requirements:
|
115
104
|
- - ">="
|
116
105
|
- !ruby/object:Gem::Version
|
117
|
-
hash: 3
|
118
106
|
segments:
|
119
107
|
- 0
|
120
108
|
version: "0"
|
121
109
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
|
-
none: false
|
123
110
|
requirements:
|
124
111
|
- - ">="
|
125
112
|
- !ruby/object:Gem::Version
|
126
|
-
hash: 3
|
127
113
|
segments:
|
128
114
|
- 0
|
129
115
|
version: "0"
|
130
116
|
requirements: []
|
131
117
|
|
132
118
|
rubyforge_project:
|
133
|
-
rubygems_version: 1.3.
|
119
|
+
rubygems_version: 1.3.6
|
134
120
|
signing_key:
|
135
121
|
specification_version: 3
|
136
122
|
summary: Provides a simple Ruby API to Unfuddle.
|
137
123
|
test_files:
|
138
|
-
- test/helper.rb
|
139
124
|
- test/test_unfuddler.rb
|
125
|
+
- test/helper.rb
|
data/unfuddler.gemspec
DELETED
@@ -1,63 +0,0 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
|
-
|
6
|
-
Gem::Specification.new do |s|
|
7
|
-
s.name = %q{unfuddler}
|
8
|
-
s.version = "0.0.3"
|
9
|
-
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Sirupsen"]
|
12
|
-
s.date = %q{2010-05-25}
|
13
|
-
s.description = %q{Provides a simple Ruby API to Unfuddle.}
|
14
|
-
s.email = %q{sirup@sirupsen.dk}
|
15
|
-
s.extra_rdoc_files = [
|
16
|
-
"LICENSE",
|
17
|
-
"README.md"
|
18
|
-
]
|
19
|
-
s.files = [
|
20
|
-
".document",
|
21
|
-
".gitignore",
|
22
|
-
"LICENSE",
|
23
|
-
"README.md",
|
24
|
-
"Rakefile",
|
25
|
-
"VERSION",
|
26
|
-
"lib/unfuddler.rb",
|
27
|
-
"test/helper.rb",
|
28
|
-
"test/test_unfuddler.rb",
|
29
|
-
"unfuddler.gemspec"
|
30
|
-
]
|
31
|
-
s.homepage = %q{http://github.com/Sirupsen/unfuddler}
|
32
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
33
|
-
s.require_paths = ["lib"]
|
34
|
-
s.rubygems_version = %q{1.3.7}
|
35
|
-
s.summary = %q{Provides a simple Ruby API to Unfuddle.}
|
36
|
-
s.test_files = [
|
37
|
-
"test/helper.rb",
|
38
|
-
"test/test_unfuddler.rb"
|
39
|
-
]
|
40
|
-
|
41
|
-
if s.respond_to? :specification_version then
|
42
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
43
|
-
s.specification_version = 3
|
44
|
-
|
45
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
46
|
-
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
47
|
-
s.add_runtime_dependency(%q<hashie>, [">= 0.2.0"])
|
48
|
-
s.add_runtime_dependency(%q<crack>, [">= 0.1.6"])
|
49
|
-
s.add_runtime_dependency(%q<activesupport>, [">= 2.3.5"])
|
50
|
-
else
|
51
|
-
s.add_dependency(%q<shoulda>, [">= 0"])
|
52
|
-
s.add_dependency(%q<hashie>, [">= 0.2.0"])
|
53
|
-
s.add_dependency(%q<crack>, [">= 0.1.6"])
|
54
|
-
s.add_dependency(%q<activesupport>, [">= 2.3.5"])
|
55
|
-
end
|
56
|
-
else
|
57
|
-
s.add_dependency(%q<shoulda>, [">= 0"])
|
58
|
-
s.add_dependency(%q<hashie>, [">= 0.2.0"])
|
59
|
-
s.add_dependency(%q<crack>, [">= 0.1.6"])
|
60
|
-
s.add_dependency(%q<activesupport>, [">= 2.3.5"])
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|