confluence-soap 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/Gemfile.lock +5 -0
- data/LICENSE.txt +1 -1
- data/{README.rdoc → README.md} +8 -6
- data/VERSION +1 -1
- data/lib/confluence-soap.rb +38 -7
- data/spec/confluence-soap_spec.rb +37 -3
- metadata +18 -5
- data/lib/.DS_Store +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: faa98e76adbdb9a7a9ae872be7ba356b280989f4
|
4
|
+
data.tar.gz: 67c6bacca0f5dcf9bf85ecdb19a20182d9240764
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a67efcc7f12ea2ad22230c7244dba08a83d193044e91043b5f48ab339145f75f817b896d036c37d8e8a384e8030a0da2e4461b5cc64da34ccce689b63dd6a08f
|
7
|
+
data.tar.gz: 57d04949ed82713889656e05aa6b4952fc5f429f70cac6959a90bda7deb6cd8ddf209f004a00072df4add1596eb0e7063b3557a49bfb2c1e3d7592895178253f
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,6 +1,9 @@
|
|
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)
|
4
7
|
addressable (2.3.5)
|
5
8
|
akami (1.2.0)
|
6
9
|
gyoku (>= 0.4.0)
|
@@ -27,6 +30,7 @@ GEM
|
|
27
30
|
httpi (2.1.0)
|
28
31
|
rack
|
29
32
|
rubyntlm (~> 0.3.2)
|
33
|
+
i18n (0.6.9)
|
30
34
|
jeweler (2.0.0)
|
31
35
|
builder
|
32
36
|
bundler (>= 1.0)
|
@@ -88,6 +92,7 @@ PLATFORMS
|
|
88
92
|
ruby
|
89
93
|
|
90
94
|
DEPENDENCIES
|
95
|
+
activesupport
|
91
96
|
bundler (~> 1.0)
|
92
97
|
jeweler (~> 2.0.0)
|
93
98
|
rdoc (~> 3.12)
|
data/LICENSE.txt
CHANGED
data/{README.rdoc → README.md}
RENAMED
@@ -1,9 +1,11 @@
|
|
1
|
-
|
1
|
+
confluence-soap
|
2
|
+
===============
|
2
3
|
|
3
|
-
|
4
|
+
Ruby client for Confluence's SOAP API
|
5
|
+
http://<confluence-install>/rpc/soap-axis/confluenceservice-v2?wsdl
|
6
|
+
|
7
|
+
## Contributing to confluence-soap
|
4
8
|
|
5
|
-
== Contributing to confluence-soap
|
6
|
-
|
7
9
|
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
8
10
|
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
9
11
|
* Fork the project.
|
@@ -12,8 +14,8 @@ Description goes here.
|
|
12
14
|
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
15
|
* 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.
|
14
16
|
|
15
|
-
|
17
|
+
### Copyright
|
16
18
|
|
17
|
-
Copyright (c) 2014
|
19
|
+
Copyright (c) 2014 Intridea. See LICENSE.txt for
|
18
20
|
further details.
|
19
21
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.2
|
data/lib/confluence-soap.rb
CHANGED
@@ -1,9 +1,23 @@
|
|
1
1
|
require 'savon'
|
2
|
+
require 'active_support/core_ext/string'
|
2
3
|
|
3
4
|
class ConfluenceSoap
|
4
5
|
attr_reader :client, :token
|
5
6
|
|
6
|
-
Page = Struct.new(:content, :
|
7
|
+
Page = Struct.new(:content, :content_status, :created, :creator, :current, :home_page, :id,
|
8
|
+
:modified, :modifier, :parent_id, :permissions, :space, :title, :url, :version) do
|
9
|
+
def self.from_hash h
|
10
|
+
self.new *h.values_at(*Page.members.map {|m|m.to_sym})
|
11
|
+
end
|
12
|
+
|
13
|
+
SKIPPED_KEYS = [:content_status, :created, :creator, :current, :home_page, :modified, :modifier, :url]
|
14
|
+
def to_soap
|
15
|
+
to_h.inject({}) do |hash, (k,v)|
|
16
|
+
hash[k.to_s.camelize(:lower).to_sym] = v unless (v.nil? || SKIPPED_KEYS.include?(k))
|
17
|
+
hash
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
7
21
|
|
8
22
|
def initialize url, user, password
|
9
23
|
@client = Savon.client(wsdl: url)
|
@@ -15,24 +29,40 @@ class ConfluenceSoap
|
|
15
29
|
@token = response.body[:login_response][:login_return]
|
16
30
|
end
|
17
31
|
|
32
|
+
def logout
|
33
|
+
@client.call :logout, message: {in0: @token} if @token
|
34
|
+
end
|
35
|
+
|
18
36
|
def get_pages space
|
19
37
|
response = @client.call :get_pages, message: {in0: @token, in1: space}
|
20
|
-
parse_array_response :get_pages, response
|
38
|
+
pages = parse_array_response :get_pages, response
|
39
|
+
pages.map { |page| Page.from_hash(page) }
|
21
40
|
end
|
22
41
|
|
23
42
|
def get_page page_id
|
24
43
|
response = @client.call :get_page, message: {in0: @token, in1: page_id}
|
25
|
-
parse_response :get_page, response
|
44
|
+
Page.from_hash parse_response :get_page, response
|
26
45
|
end
|
27
46
|
|
28
47
|
def get_children page_id
|
29
48
|
response = @client.call :get_children, message: {in0: @token, in1: page_id}
|
30
|
-
parse_array_response :get_children, response
|
49
|
+
pages = parse_array_response :get_children, response
|
50
|
+
pages.map { |page| Page.from_hash(page) }
|
31
51
|
end
|
32
52
|
|
33
53
|
def store_page page
|
34
|
-
response = @client.call :store_page, message: {in0: @token, in1: page.
|
35
|
-
parse_response :store_page, response
|
54
|
+
response = @client.call :store_page, message: {in0: @token, in1: page.to_soap}
|
55
|
+
Page.from_hash parse_response :store_page, response
|
56
|
+
end
|
57
|
+
|
58
|
+
def update_page page
|
59
|
+
response = @client.call :update_page, message: {in0: @token, in1: page.to_soap, in2: {minorEdit: true}}
|
60
|
+
Page.from_hash parse_response :update_page, response
|
61
|
+
end
|
62
|
+
|
63
|
+
def remove_page page_id
|
64
|
+
response = @client.call :remove_page, message: {in0: @token, in1: page_id}
|
65
|
+
Page.from_hash parse_response :remove_page, response
|
36
66
|
end
|
37
67
|
|
38
68
|
def search(term, criteria = {})
|
@@ -41,7 +71,8 @@ class ConfluenceSoap
|
|
41
71
|
response =
|
42
72
|
@client.call(:search, message: {
|
43
73
|
in0: @token, in1: term, in2: {item: criteria}, in3: limit})
|
44
|
-
parse_array_response :search, response
|
74
|
+
pages = parse_array_response :search, response
|
75
|
+
pages.map { |page| Page.from_hash(page) }
|
45
76
|
end
|
46
77
|
|
47
78
|
private
|
@@ -64,6 +64,19 @@ describe ConfluenceSoap do
|
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
|
+
describe '#get_page' do
|
68
|
+
let(:page_id) { '123456' }
|
69
|
+
before (:each) do
|
70
|
+
ConfluenceSoap.any_instance.stub(:login).and_return('token')
|
71
|
+
subject.client.should_receive(:call)
|
72
|
+
.with(:remove_page, message: {in0: 'token', in1: page_id})
|
73
|
+
.and_return(double(:response, body: {remove_page_response: {remove_page_return: {}}}))
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'should return the page' do
|
77
|
+
subject.remove_page page_id
|
78
|
+
end
|
79
|
+
end
|
67
80
|
describe '#get_children' do
|
68
81
|
before (:each) do
|
69
82
|
ConfluenceSoap.any_instance.stub(:login).and_return('token')
|
@@ -79,14 +92,15 @@ describe ConfluenceSoap do
|
|
79
92
|
|
80
93
|
describe '#store_page' do
|
81
94
|
let(:page) do
|
82
|
-
ConfluenceSoap::Page.
|
83
|
-
|
95
|
+
ConfluenceSoap::Page.from_hash({content: 'test', title: 'Testing API ', space: 'Space Name',
|
96
|
+
parent_id: 'parent_id', permissions: 0})
|
84
97
|
end
|
85
98
|
|
86
99
|
before (:each) do
|
87
100
|
ConfluenceSoap.any_instance.stub(:login).and_return('token')
|
88
101
|
subject.client.should_receive(:call)
|
89
|
-
.with(:store_page, message: {in0: 'token', in1:
|
102
|
+
.with(:store_page, message: {in0: 'token', in1: {content: 'test', title: 'Testing API ',
|
103
|
+
space: 'Space Name', parentId: 'parent_id', permissions: 0}})
|
90
104
|
.and_return(double(:response, body: {store_page_response: {store_page_return: {}}}))
|
91
105
|
end
|
92
106
|
|
@@ -95,6 +109,26 @@ describe ConfluenceSoap do
|
|
95
109
|
end
|
96
110
|
end
|
97
111
|
|
112
|
+
describe '#update_page' do
|
113
|
+
let(:page) do
|
114
|
+
ConfluenceSoap::Page.from_hash({content: 'test', title: 'Testing API ', space: 'Space Name',
|
115
|
+
parent_id: 'parent_id', permissions: 0})
|
116
|
+
end
|
117
|
+
|
118
|
+
before (:each) do
|
119
|
+
ConfluenceSoap.any_instance.stub(:login).and_return('token')
|
120
|
+
subject.client.should_receive(:call)
|
121
|
+
.with(:update_page, message: {in0: 'token', in1: {content: 'test', title: 'Testing API ',
|
122
|
+
space: 'Space Name', parentId: 'parent_id', permissions: 0},
|
123
|
+
in2: {minorEdit: true}})
|
124
|
+
.and_return(double(:response, body: {update_page_response: {update_page_return: {}}}))
|
125
|
+
end
|
126
|
+
|
127
|
+
it 'should store page with savon' do
|
128
|
+
subject.update_page(page)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
98
132
|
describe '#search' do
|
99
133
|
let(:term) { 'search term' }
|
100
134
|
let(:criteria) { {item: [{key: :spaceKey, value: 'SpaceName'}]} }
|
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.2
|
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-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: savon
|
@@ -25,6 +25,20 @@ 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'
|
28
42
|
- !ruby/object:Gem::Dependency
|
29
43
|
name: bundler
|
30
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -75,7 +89,7 @@ executables: []
|
|
75
89
|
extensions: []
|
76
90
|
extra_rdoc_files:
|
77
91
|
- LICENSE.txt
|
78
|
-
- README.
|
92
|
+
- README.md
|
79
93
|
files:
|
80
94
|
- .document
|
81
95
|
- .rspec
|
@@ -83,11 +97,10 @@ files:
|
|
83
97
|
- Gemfile
|
84
98
|
- Gemfile.lock
|
85
99
|
- LICENSE.txt
|
86
|
-
- README.
|
100
|
+
- README.md
|
87
101
|
- Rakefile
|
88
102
|
- VERSION
|
89
103
|
- confluence-soap.gemspec
|
90
|
-
- lib/.DS_Store
|
91
104
|
- lib/confluence-soap.rb
|
92
105
|
- spec/confluence-soap_spec.rb
|
93
106
|
- spec/spec_helper.rb
|
data/lib/.DS_Store
DELETED
Binary file
|