confluence-client 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY +6 -0
- data/README.rdoc +29 -6
- data/lib/confluence-client/version.rb +1 -1
- data/lib/confluence-client.rb +71 -10
- metadata +4 -4
data/HISTORY
CHANGED
data/README.rdoc
CHANGED
@@ -4,10 +4,33 @@
|
|
4
4
|
|
5
5
|
Confluence::Client.new(url) do |confluence|
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
7
|
+
if confluence.login(user, pass)
|
8
|
+
|
9
|
+
# Was last API call successful?
|
10
|
+
confluence.ok?
|
11
|
+
|
12
|
+
# Print error message if error on last API call.
|
13
|
+
puts confluence.error if confluence.error?
|
14
|
+
|
15
|
+
space = confluence.get_space('foo')
|
16
|
+
if space
|
17
|
+
puts "found space: #{space.inspect}"
|
18
|
+
else
|
19
|
+
space = confluence.add_space( 'foo', 'space name', 'space description' )
|
20
|
+
if space
|
21
|
+
puts "created space: #{space.inspect}"
|
22
|
+
else
|
23
|
+
puts "unable to create space: #{c.error}"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
if confluence.remove_space('foo')
|
28
|
+
puts 'removed space'
|
29
|
+
else
|
30
|
+
puts "unable to remove space: #{c.error}"
|
31
|
+
end
|
32
|
+
|
33
|
+
confluence.logout
|
34
|
+
end
|
35
|
+
|
13
36
|
end
|
data/lib/confluence-client.rb
CHANGED
@@ -7,12 +7,35 @@ module Confluence # :nodoc:
|
|
7
7
|
#
|
8
8
|
# Confluence::Client.new(url) do |confluence|
|
9
9
|
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
10
|
+
# if confluence.login(user, pass)
|
11
|
+
#
|
12
|
+
# # Was last API call successful?
|
13
|
+
# confluence.ok?
|
14
|
+
#
|
15
|
+
# # Print error message if error on last API call.
|
16
|
+
# puts confluence.error if confluence.error?
|
17
|
+
#
|
18
|
+
# space = confluence.get_space('foo')
|
19
|
+
# if space
|
20
|
+
# puts "found space: #{space.inspect}"
|
21
|
+
# else
|
22
|
+
# space = confluence.add_space( 'foo', 'space name', 'space description' )
|
23
|
+
# if space
|
24
|
+
# puts "created space: #{space.inspect}"
|
25
|
+
# else
|
26
|
+
# puts "unable to create space: #{c.error}"
|
27
|
+
# end
|
28
|
+
# end
|
29
|
+
#
|
30
|
+
# if confluence.remove_space('foo')
|
31
|
+
# puts 'removed space'
|
32
|
+
# else
|
33
|
+
# puts "unable to remove space: #{c.error}"
|
34
|
+
# end
|
35
|
+
#
|
36
|
+
# confluence.logout
|
37
|
+
# end
|
38
|
+
#
|
16
39
|
# end
|
17
40
|
class Client
|
18
41
|
|
@@ -40,11 +63,33 @@ module Confluence # :nodoc:
|
|
40
63
|
yield self if block_given?
|
41
64
|
end
|
42
65
|
|
66
|
+
# Create Confluence space. Returns space or nil.
|
67
|
+
#
|
68
|
+
# Params:
|
69
|
+
# +key+:: Key for space.
|
70
|
+
# +name+:: Name of space.
|
71
|
+
# +description+:: Description for space.
|
72
|
+
def add_space(key, name, description)
|
73
|
+
space = addSpace( { 'key' => key, 'name' => name, 'description' => description } )
|
74
|
+
return space if ok?
|
75
|
+
nil
|
76
|
+
end
|
77
|
+
|
43
78
|
# Was there an error on the last request?
|
44
79
|
def error?
|
45
80
|
!ok?
|
46
81
|
end
|
47
82
|
|
83
|
+
# Return Confluence space or nil.
|
84
|
+
#
|
85
|
+
# Params:
|
86
|
+
# +key+:: Confluence key for space.
|
87
|
+
def get_space(key)
|
88
|
+
space = getSpace(key)
|
89
|
+
return space if ok?
|
90
|
+
nil
|
91
|
+
end
|
92
|
+
|
48
93
|
# Login to the Confluence XML/RPC API.
|
49
94
|
def login(user, password)
|
50
95
|
raise ArgumentError if user.nil? || password.nil?
|
@@ -53,9 +98,9 @@ module Confluence # :nodoc:
|
|
53
98
|
@token = @confluence.login(@user, @password)
|
54
99
|
@error = nil
|
55
100
|
rescue XMLRPC::FaultException => e
|
56
|
-
@error = e.faultString
|
101
|
+
@error = tidy_exception( e.faultString )
|
57
102
|
rescue => e
|
58
|
-
@error = e.message
|
103
|
+
@error = tidy_exception( e.message )
|
59
104
|
end
|
60
105
|
return ok?
|
61
106
|
end
|
@@ -69,9 +114,9 @@ module Confluence # :nodoc:
|
|
69
114
|
@error = nil
|
70
115
|
return @confluence.send( method_name, *( [@token] + args ) )
|
71
116
|
rescue XMLRPC::FaultException => e
|
72
|
-
@error = e.faultString
|
117
|
+
@error = tidy_exception( e.faultString )
|
73
118
|
rescue Exception => e
|
74
|
-
@error = e.message
|
119
|
+
@error = tidy_exception( e.message )
|
75
120
|
end
|
76
121
|
return ok?
|
77
122
|
end
|
@@ -81,6 +126,22 @@ module Confluence # :nodoc:
|
|
81
126
|
@error.nil?
|
82
127
|
end
|
83
128
|
|
129
|
+
# Remove Confluence space. Returns boolean.
|
130
|
+
#
|
131
|
+
# Params:
|
132
|
+
# +key+:: Confluence key for space to remove.
|
133
|
+
def remove_space(key)
|
134
|
+
return removeSpace(key)
|
135
|
+
end
|
136
|
+
|
137
|
+
# Make the Confluence exceptions more readable.
|
138
|
+
#
|
139
|
+
# Params:
|
140
|
+
# +txt+:: Exception text to clean up.
|
141
|
+
def tidy_exception(txt)
|
142
|
+
txt.gsub!( /^java.lang.Exception: com.atlassian.confluence.rpc.RemoteException:\s+/, '' )
|
143
|
+
end
|
144
|
+
|
84
145
|
end # class Client
|
85
146
|
end # module Confluence
|
86
147
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: confluence-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,12 +9,12 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-04-
|
12
|
+
date: 2011-04-04 00:00:00.000000000 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rspec
|
17
|
-
requirement: &
|
17
|
+
requirement: &2158439060 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,7 +22,7 @@ dependencies:
|
|
22
22
|
version: 2.5.0
|
23
23
|
type: :development
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *2158439060
|
26
26
|
description: Ruby client for the Confluence XML::RPC API
|
27
27
|
email:
|
28
28
|
- blair.christensen@gmail.com
|