confluence-soap 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/confluence-soap.gemspec +2 -2
- data/lib/confluence-soap.rb +27 -18
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5dd3ae54fb12362a0f0e89e5d5d01451edd1519f
|
4
|
+
data.tar.gz: 30d78f9164051adceb7759a9b307de247be9ea57
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d4a364b0a3962ae83c3034544155c2532632f6e0bc0f47d6896a6d8cf9897c16d0c3d78e5d27bcd4744987b9fa9b1463542715120d65d8d98622df7ef65995e
|
7
|
+
data.tar.gz: 8791722d3061ebbe9015cf6594b3302d7715b6e8d789b0f991d363f214f9e035b3fe9ebcd2e25973ddf8cf7366fd58195946a921ac8216445b6bea9ed8cb8094
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.8
|
data/confluence-soap.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "confluence-soap"
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.8"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Ping Yu", "Eric Himmelreich"]
|
12
|
-
s.date = "2014-01-
|
12
|
+
s.date = "2014-01-29"
|
13
13
|
s.description = ""
|
14
14
|
s.email = ["ping@intridea.com", "eric@intridea.com"]
|
15
15
|
s.extra_rdoc_files = [
|
data/lib/confluence-soap.rb
CHANGED
@@ -3,20 +3,26 @@ require 'savon'
|
|
3
3
|
class ConfluenceSoap
|
4
4
|
attr_reader :client, :token, :user
|
5
5
|
|
6
|
-
Page = Struct.new(:content, :content_status, :created, :creator, :current,
|
7
|
-
:
|
8
|
-
|
9
|
-
|
6
|
+
Page = Struct.new(:content, :content_status, :created, :creator, :current,
|
7
|
+
:home_page, :id, :modified, :modifier, :parent_id,
|
8
|
+
:permissions, :space, :title, :url, :version) do
|
9
|
+
|
10
|
+
def self.from_hash(h)
|
11
|
+
values =
|
12
|
+
h.values_at(*Page.members.map { |m| m.to_sym })
|
13
|
+
.map { |v| v.is_a?(Hash) ? v[:value] || '' : v }
|
14
|
+
|
10
15
|
self.new *values
|
11
16
|
end
|
12
17
|
|
13
|
-
SKIPPED_KEYS = [:content_status, :created, :creator, :current, :home_page,
|
18
|
+
SKIPPED_KEYS = [:content_status, :created, :creator, :current, :home_page,
|
19
|
+
:modified, :modifier, :url]
|
14
20
|
def to_soap
|
15
|
-
to_h.reject {|k,v| v.nil? || SKIPPED_KEYS.include?(k)}
|
21
|
+
to_h.reject { |k, v| v.nil? || SKIPPED_KEYS.include?(k) }
|
16
22
|
end
|
17
23
|
end
|
18
24
|
|
19
|
-
def initialize
|
25
|
+
def initialize(url, user, password)
|
20
26
|
@user = user
|
21
27
|
@password = password
|
22
28
|
@client = Savon.client(wsdl: url) do
|
@@ -25,7 +31,7 @@ class ConfluenceSoap
|
|
25
31
|
@token = login(user, password)
|
26
32
|
end
|
27
33
|
|
28
|
-
def login
|
34
|
+
def login(user, password)
|
29
35
|
response = @client.call :login, message: {in0: user, in1: password}
|
30
36
|
@token = response.body[:login_response][:login_return]
|
31
37
|
end
|
@@ -34,36 +40,36 @@ class ConfluenceSoap
|
|
34
40
|
@client.call :logout, message: {in0: @token} if @token
|
35
41
|
end
|
36
42
|
|
37
|
-
def get_pages
|
43
|
+
def get_pages(space)
|
38
44
|
response = @client.call :get_pages, auth_message({in1: space})
|
39
45
|
pages = parse_array_response :get_pages, response
|
40
46
|
pages.map { |page| Page.from_hash(page) }
|
41
47
|
end
|
42
48
|
|
43
|
-
def get_page
|
49
|
+
def get_page(page_id)
|
44
50
|
response = @client.call :get_page, auth_message({in1: page_id})
|
45
51
|
Page.from_hash parse_response :get_page, response
|
46
52
|
end
|
47
53
|
|
48
|
-
def get_children
|
54
|
+
def get_children(page_id)
|
49
55
|
response = @client.call :get_children, auth_message({in1: page_id})
|
50
56
|
pages = parse_array_response :get_children, response
|
51
57
|
pages.map { |page| Page.from_hash(page) }
|
52
58
|
end
|
53
59
|
|
54
|
-
def store_page
|
60
|
+
def store_page(page)
|
55
61
|
response = @client.call :store_page, auth_message({in1: page.to_soap})
|
56
62
|
Page.from_hash parse_response :store_page, response
|
57
63
|
end
|
58
64
|
|
59
|
-
def update_page
|
65
|
+
def update_page(page)
|
60
66
|
response =
|
61
67
|
@client.call(:update_page,
|
62
68
|
auth_message({in1: page.to_soap, in2: {minorEdit: true} }))
|
63
69
|
Page.from_hash parse_response :update_page, response
|
64
70
|
end
|
65
71
|
|
66
|
-
def remove_page
|
72
|
+
def remove_page(page_id)
|
67
73
|
response = @client.call :remove_page, auth_message({in1: page_id})
|
68
74
|
Page.from_hash parse_response :remove_page, response
|
69
75
|
end
|
@@ -93,12 +99,12 @@ class ConfluenceSoap
|
|
93
99
|
parse_response(:remove_label_by_name, response)
|
94
100
|
end
|
95
101
|
|
96
|
-
def has_user
|
102
|
+
def has_user(user)
|
97
103
|
response = @client.call(:has_user, auth_message({in1: user}))
|
98
104
|
parse_response(:has_user, response)
|
99
105
|
end
|
100
106
|
|
101
|
-
def execute
|
107
|
+
def execute(&block)
|
102
108
|
yield self
|
103
109
|
rescue Savon::SOAPFault => e
|
104
110
|
if e.to_hash[:fault][:faultstring] =~ /InvalidSessionException/
|
@@ -115,8 +121,11 @@ class ConfluenceSoap
|
|
115
121
|
login(@user, @password)
|
116
122
|
end
|
117
123
|
|
118
|
-
def parse_array_response
|
119
|
-
|
124
|
+
def parse_array_response(method, response)
|
125
|
+
parsed_response =
|
126
|
+
parse_response(method, response)["#{method}_return".to_sym] || []
|
127
|
+
|
128
|
+
parsed_response.respond_to?(:to_hash) ? [parsed_response] : parsed_response
|
120
129
|
end
|
121
130
|
|
122
131
|
def auth_message(params = {})
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: confluence-soap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ping Yu
|
@@ -110,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
110
110
|
version: '0'
|
111
111
|
requirements: []
|
112
112
|
rubyforge_project:
|
113
|
-
rubygems_version: 2.
|
113
|
+
rubygems_version: 2.0.14
|
114
114
|
signing_key:
|
115
115
|
specification_version: 4
|
116
116
|
summary: ruby client for confluence soap API
|