confluence-soap 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +0 -1
- data/Gemfile.lock +0 -5
- data/README.md +11 -1
- data/VERSION +1 -1
- data/lib/confluence-soap.rb +23 -7
- data/spec/confluence-soap_spec.rb +19 -4
- metadata +2 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b45379fdb6d8fc2681a17d2409d79b31181950cc
|
4
|
+
data.tar.gz: 0fbae6f9db31ace9c3a205e84646d5c0a35a95d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e93da27f1d2c8c5a7ed27d3097ac93f335dbbf9e4ab95f8ba4bdd974f7ec7b21e15709c75d9f3357a2b378bd6356c1c34e88f7678d441da1a802abdbfd8c7b7
|
7
|
+
data.tar.gz: 9311e48598ffbf0b5e7822c840329d673d6f43e57cf832b39f70fe7b86e0ee7c7cdcd52a5ba21567348bc874269354248568411a5276c37263131117147add80
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,9 +1,6 @@
|
|
1
1
|
GEM
|
2
2
|
remote: https://rubygems.org/
|
3
3
|
specs:
|
4
|
-
activesupport (3.2.16)
|
5
|
-
i18n (~> 0.6, >= 0.6.4)
|
6
|
-
multi_json (~> 1.0)
|
7
4
|
addressable (2.3.5)
|
8
5
|
akami (1.2.0)
|
9
6
|
gyoku (>= 0.4.0)
|
@@ -30,7 +27,6 @@ GEM
|
|
30
27
|
httpi (2.1.0)
|
31
28
|
rack
|
32
29
|
rubyntlm (~> 0.3.2)
|
33
|
-
i18n (0.6.9)
|
34
30
|
jeweler (2.0.0)
|
35
31
|
builder
|
36
32
|
bundler (>= 1.0)
|
@@ -92,7 +88,6 @@ PLATFORMS
|
|
92
88
|
ruby
|
93
89
|
|
94
90
|
DEPENDENCIES
|
95
|
-
activesupport
|
96
91
|
bundler (~> 1.0)
|
97
92
|
jeweler (~> 2.0.0)
|
98
93
|
rdoc (~> 3.12)
|
data/README.md
CHANGED
@@ -2,7 +2,8 @@ confluence-soap
|
|
2
2
|
===============
|
3
3
|
|
4
4
|
Ruby client for Confluence's SOAP API
|
5
|
-
|
5
|
+
|
6
|
+
http://<confluence-install>/rpc/soap-axis/confluenceservice-v2?wsdl
|
6
7
|
|
7
8
|
## Contributing to confluence-soap
|
8
9
|
|
@@ -14,6 +15,15 @@ http://<confluence-install>/rpc/soap-axis/confluenceservice-v2?wsdl
|
|
14
15
|
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
15
16
|
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
16
17
|
|
18
|
+
### Credits
|
19
|
+
=======
|
20
|
+
[Ping Yu](https://github.com/pyu10055)
|
21
|
+
|
22
|
+
[Eric Himmelreich](https://github.com/rawsyntax)
|
23
|
+
|
24
|
+
[Intridea](http://www.intridea.com)
|
25
|
+
|
26
|
+
|
17
27
|
### Copyright
|
18
28
|
|
19
29
|
Copyright (c) 2014 Intridea. See LICENSE.txt for
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.3
|
data/lib/confluence-soap.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
require 'savon'
|
2
|
-
require 'active_support/core_ext/string'
|
3
2
|
|
4
3
|
class ConfluenceSoap
|
5
|
-
attr_reader :client, :token
|
4
|
+
attr_reader :client, :token, :user
|
6
5
|
|
7
6
|
Page = Struct.new(:content, :content_status, :created, :creator, :current, :home_page, :id,
|
8
7
|
:modified, :modifier, :parent_id, :permissions, :space, :title, :url, :version) do
|
@@ -12,15 +11,16 @@ class ConfluenceSoap
|
|
12
11
|
|
13
12
|
SKIPPED_KEYS = [:content_status, :created, :creator, :current, :home_page, :modified, :modifier, :url]
|
14
13
|
def to_soap
|
15
|
-
to_h.
|
16
|
-
hash[k.to_s.camelize(:lower).to_sym] = v unless (v.nil? || SKIPPED_KEYS.include?(k))
|
17
|
-
hash
|
18
|
-
end
|
14
|
+
to_h.reject {|k,v| v.nil? || SKIPPED_KEYS.include?(k)}
|
19
15
|
end
|
20
16
|
end
|
21
17
|
|
22
18
|
def initialize url, user, password
|
23
|
-
@
|
19
|
+
@user = user
|
20
|
+
@password = password
|
21
|
+
@client = Savon.client(wsdl: url) do
|
22
|
+
convert_request_keys_to :lower_camelcase
|
23
|
+
end
|
24
24
|
@token = login(user, password)
|
25
25
|
end
|
26
26
|
|
@@ -75,7 +75,23 @@ class ConfluenceSoap
|
|
75
75
|
pages.map { |page| Page.from_hash(page) }
|
76
76
|
end
|
77
77
|
|
78
|
+
def has_user user
|
79
|
+
response =
|
80
|
+
@client.call(:has_user, message: { in0: @token, in1: user })
|
81
|
+
parse_response(:has_user, response)
|
82
|
+
end
|
83
|
+
|
84
|
+
def execute &block
|
85
|
+
yield self
|
86
|
+
rescue Savon::SOAPFault => e
|
87
|
+
reconnect if e.to_hash[:fault][:faultstring] =~ /InvalidSessionException/
|
88
|
+
yield e
|
89
|
+
end
|
90
|
+
|
78
91
|
private
|
92
|
+
def reconnect
|
93
|
+
login(@user, @password)
|
94
|
+
end
|
79
95
|
|
80
96
|
def parse_array_response method, response
|
81
97
|
parse_response(method, response)["#{method}_return".to_sym]
|
@@ -100,7 +100,7 @@ describe ConfluenceSoap do
|
|
100
100
|
ConfluenceSoap.any_instance.stub(:login).and_return('token')
|
101
101
|
subject.client.should_receive(:call)
|
102
102
|
.with(:store_page, message: {in0: 'token', in1: {content: 'test', title: 'Testing API ',
|
103
|
-
space: 'Space Name',
|
103
|
+
space: 'Space Name', parent_id: 'parent_id', permissions: 0}})
|
104
104
|
.and_return(double(:response, body: {store_page_response: {store_page_return: {}}}))
|
105
105
|
end
|
106
106
|
|
@@ -119,7 +119,7 @@ describe ConfluenceSoap do
|
|
119
119
|
ConfluenceSoap.any_instance.stub(:login).and_return('token')
|
120
120
|
subject.client.should_receive(:call)
|
121
121
|
.with(:update_page, message: {in0: 'token', in1: {content: 'test', title: 'Testing API ',
|
122
|
-
space: 'Space Name',
|
122
|
+
space: 'Space Name', parent_id: 'parent_id', permissions: 0},
|
123
123
|
in2: {minorEdit: true}})
|
124
124
|
.and_return(double(:response, body: {update_page_response: {update_page_return: {}}}))
|
125
125
|
end
|
@@ -131,7 +131,7 @@ describe ConfluenceSoap do
|
|
131
131
|
|
132
132
|
describe '#search' do
|
133
133
|
let(:term) { 'search term' }
|
134
|
-
let(:criteria) { {item: [{key: :
|
134
|
+
let(:criteria) { {item: [{key: :space_key, value: 'SpaceName'}]} }
|
135
135
|
before (:each) do
|
136
136
|
ConfluenceSoap.any_instance.stub(:login).and_return('token')
|
137
137
|
subject.client.should_receive(:call)
|
@@ -141,7 +141,22 @@ describe ConfluenceSoap do
|
|
141
141
|
end
|
142
142
|
|
143
143
|
it 'should search with savon' do
|
144
|
-
subject.search(term,
|
144
|
+
subject.search(term, space_key: 'SpaceName').should == []
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
describe '#execute' do
|
149
|
+
before (:each) do
|
150
|
+
ConfluenceSoap.any_instance.stub(:login).and_return('token')
|
151
|
+
subject.should_receive(:login)
|
152
|
+
end
|
153
|
+
|
154
|
+
it 'should reconnect when session is invalid' do
|
155
|
+
Savon::SOAPFault.any_instance.stub(:to_hash).and_return({fault: {faultstring: 'InvalidSessionException'}})
|
156
|
+
ex = Savon::SOAPFault.new nil, nil
|
157
|
+
subject.execute do |x|
|
158
|
+
raise ex if x.is_a? ConfluenceSoap
|
159
|
+
end
|
145
160
|
end
|
146
161
|
end
|
147
162
|
end
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ping Yu
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-01-
|
12
|
+
date: 2014-01-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: savon
|
@@ -25,20 +25,6 @@ dependencies:
|
|
25
25
|
- - '>='
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '0'
|
28
|
-
- !ruby/object:Gem::Dependency
|
29
|
-
name: activesupport
|
30
|
-
requirement: !ruby/object:Gem::Requirement
|
31
|
-
requirements:
|
32
|
-
- - '>='
|
33
|
-
- !ruby/object:Gem::Version
|
34
|
-
version: '0'
|
35
|
-
type: :runtime
|
36
|
-
prerelease: false
|
37
|
-
version_requirements: !ruby/object:Gem::Requirement
|
38
|
-
requirements:
|
39
|
-
- - '>='
|
40
|
-
- !ruby/object:Gem::Version
|
41
|
-
version: '0'
|
42
28
|
- !ruby/object:Gem::Dependency
|
43
29
|
name: bundler
|
44
30
|
requirement: !ruby/object:Gem::Requirement
|