confluence-soap 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 69c70a9833f7aa57fa636ef35557cac026f35b98
4
- data.tar.gz: f4ff292c2bb73668555fe00569d0d4fd6cc0d782
3
+ metadata.gz: 05235a53aeb95b8019306a7550602d9177d84407
4
+ data.tar.gz: 9db7f2a153e4b1ab49a38fedcf580d271efa453c
5
5
  SHA512:
6
- metadata.gz: fc77609b9558fa7239f55c01941b89c41f243ae0e8b8085a1d797e506912a52381fdb3ce02fec9064bffb5f203c06ba50d9f840400a0089069c396923681fad8
7
- data.tar.gz: 1c24c6eb42d207f04133ab6565038c61a0512ae73b78a92111dc0e10aae99e0a440e537c72353726246cd58cbd24b4b811c3dc5531caf5d9fbb0a7a79395a366
6
+ metadata.gz: 2d6e0c7787d416a1fdbbfafd015936221b37f49a503dc68e2fad905bfa6e3914875bb9b2b1f0a900e2b97b3e4e8db3c9cf32399c8e833da24179e23acb5e5cce
7
+ data.tar.gz: a679505d6e4380d034075115ee506073df8a1e116c60573dfb2d02d04cc18f873a5367677df90f01800e2330cf145d166dd6867c16d556bffcea6bd69964f5df
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.4
1
+ 0.0.5
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "confluence-soap"
8
- s.version = "0.0.4"
8
+ s.version = "0.0.5"
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"]
@@ -34,34 +34,36 @@ class ConfluenceSoap
34
34
  end
35
35
 
36
36
  def get_pages space
37
- response = @client.call :get_pages, message: {in0: @token, in1: space}
37
+ response = @client.call :get_pages, auth_message({in1: space})
38
38
  pages = parse_array_response :get_pages, response
39
39
  pages.map { |page| Page.from_hash(page) }
40
40
  end
41
41
 
42
42
  def get_page page_id
43
- response = @client.call :get_page, message: {in0: @token, in1: page_id}
43
+ response = @client.call :get_page, auth_message({in1: page_id})
44
44
  Page.from_hash parse_response :get_page, response
45
45
  end
46
46
 
47
47
  def get_children page_id
48
- response = @client.call :get_children, message: {in0: @token, in1: page_id}
48
+ response = @client.call :get_children, auth_message({in1: page_id})
49
49
  pages = parse_array_response :get_children, response
50
50
  pages.map { |page| Page.from_hash(page) }
51
51
  end
52
52
 
53
53
  def store_page page
54
- response = @client.call :store_page, message: {in0: @token, in1: page.to_soap}
54
+ response = @client.call :store_page, auth_message({in1: page.to_soap})
55
55
  Page.from_hash parse_response :store_page, response
56
56
  end
57
57
 
58
58
  def update_page page
59
- response = @client.call :update_page, message: {in0: @token, in1: page.to_soap, in2: {minorEdit: true}}
59
+ response =
60
+ @client.call(:update_page,
61
+ auth_message({in1: page.to_soap, in2: {minorEdit: true} }))
60
62
  Page.from_hash parse_response :update_page, response
61
63
  end
62
64
 
63
65
  def remove_page page_id
64
- response = @client.call :remove_page, message: {in0: @token, in1: page_id}
66
+ response = @client.call :remove_page, auth_message({in1: page_id})
65
67
  Page.from_hash parse_response :remove_page, response
66
68
  end
67
69
 
@@ -69,15 +71,29 @@ class ConfluenceSoap
69
71
  limit = criteria.delete(:limit) || 20
70
72
  criteria = criteria.map { |k, v| {key: k, value: v} }
71
73
  response =
72
- @client.call(:search, message: {
73
- in0: @token, in1: term, in2: {item: criteria}, in3: limit})
74
+ @client.call(:search,
75
+ auth_message({in1: term, in2: {item: criteria}, in3: limit}))
74
76
  pages = parse_array_response :search, response
75
77
  pages.map { |page| Page.from_hash(page) }
76
78
  end
77
79
 
78
- def has_user user
80
+ def add_label_by_name(label, page_id)
81
+ response =
82
+ @client.call(:add_label_by_name, auth_message({in1: label, in2: page_id}))
83
+
84
+ parse_response(:add_label_by_name, response)
85
+ end
86
+
87
+ def remove_label_by_name(label, page_id)
79
88
  response =
80
- @client.call(:has_user, message: { in0: @token, in1: user })
89
+ @client.call(:remove_label_by_name,
90
+ auth_message({in1: label, in2: page_id}))
91
+
92
+ parse_response(:remove_label_by_name, response)
93
+ end
94
+
95
+ def has_user user
96
+ response = @client.call(:has_user, auth_message({in1: user}))
81
97
  parse_response(:has_user, response)
82
98
  end
83
99
 
@@ -98,6 +114,10 @@ class ConfluenceSoap
98
114
  parse_response(method, response)["#{method}_return".to_sym] || []
99
115
  end
100
116
 
117
+ def auth_message(params = {})
118
+ {message: {in0: @token}.merge(params)}
119
+ end
120
+
101
121
  def parse_response method, response
102
122
  response.body["#{method}_response".to_sym]["#{method}_return".to_sym]
103
123
  end
@@ -36,126 +36,149 @@ describe ConfluenceSoap do
36
36
  end
37
37
  end
38
38
 
39
- describe '#get_pages' do
40
- let(:space) { 'SpaceName' }
41
- before (:each) do
39
+ describe 'with an authenticated user' do
40
+ before(:each) do
42
41
  ConfluenceSoap.any_instance.stub(:login).and_return('token')
43
- subject.client.should_receive(:call)
44
- .with(:get_pages, message: {in0: 'token', in1: space})
45
- .and_return(double(:response, body: {get_pages_response: {get_pages_return: {get_pages_return: []}}}))
46
42
  end
47
43
 
48
- it 'should return the pages in the space' do
49
- subject.get_pages(space).should == []
50
- end
51
- end
44
+ describe '#get_pages' do
45
+ let(:space) { 'SpaceName' }
46
+ before (:each) do
52
47
 
53
- describe '#get_page' do
54
- let(:page_id) { '123456' }
55
- before (:each) do
56
- ConfluenceSoap.any_instance.stub(:login).and_return('token')
57
- subject.client.should_receive(:call)
58
- .with(:get_page, message: {in0: 'token', in1: page_id})
59
- .and_return(double(:response, body: {get_page_response: {get_page_return: {}}}))
60
- end
48
+ subject.client.should_receive(:call)
49
+ .with(:get_pages, message: {in0: 'token', in1: space})
50
+ .and_return(double(:response, body: {get_pages_response: {get_pages_return: {get_pages_return: []}}}))
51
+ end
61
52
 
62
- it 'should return the page' do
63
- subject.get_page page_id
53
+ it 'should return the pages in the space' do
54
+ subject.get_pages(space).should == []
55
+ end
64
56
  end
65
- end
66
57
 
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
58
+ describe '#get_page' do
59
+ let(:page_id) { '123456' }
60
+ before (:each) do
61
+ subject.client.should_receive(:call)
62
+ .with(:get_page, message: {in0: 'token', in1: page_id})
63
+ .and_return(double(:response, body: {get_page_response: {get_page_return: {}}}))
64
+ end
75
65
 
76
- it 'should return the page' do
77
- subject.remove_page page_id
78
- end
79
- end
80
- describe '#get_children' do
81
- before (:each) do
82
- ConfluenceSoap.any_instance.stub(:login).and_return('token')
83
- subject.client.should_receive(:call)
84
- .with(:get_children, message: {in0: 'token', in1: 'page_id'})
85
- .and_return(double(:response, body: {get_children_response: {get_children_return: {get_children_return: []}}}))
66
+ it 'should return the page' do
67
+ subject.get_page page_id
68
+ end
86
69
  end
87
70
 
88
- it 'should return array of child pages' do
89
- subject.get_children('page_id').should == []
90
- end
91
- end
71
+ describe '#get_page' do
72
+ let(:page_id) { '123456' }
73
+ before (:each) do
74
+ subject.client.should_receive(:call)
75
+ .with(:remove_page, message: {in0: 'token', in1: page_id})
76
+ .and_return(double(:response, body: {remove_page_response: {remove_page_return: {}}}))
77
+ end
92
78
 
93
- describe '#store_page' do
94
- let(:page) do
95
- ConfluenceSoap::Page.from_hash({content: 'test', title: 'Testing API ', space: 'Space Name',
96
- parent_id: 'parent_id', permissions: 0})
79
+ it 'should return the page' do
80
+ subject.remove_page page_id
81
+ end
97
82
  end
83
+ describe '#get_children' do
84
+ before (:each) do
85
+ subject.client.should_receive(:call)
86
+ .with(:get_children, message: {in0: 'token', in1: 'page_id'})
87
+ .and_return(double(:response, body: {get_children_response: {get_children_return: {get_children_return: []}}}))
88
+ end
98
89
 
99
- before (:each) do
100
- ConfluenceSoap.any_instance.stub(:login).and_return('token')
101
- subject.client.should_receive(:call)
102
- .with(:store_page, message: {in0: 'token', in1: {content: 'test', title: 'Testing API ',
103
- space: 'Space Name', parent_id: 'parent_id', permissions: 0}})
104
- .and_return(double(:response, body: {store_page_response: {store_page_return: {}}}))
90
+ it 'should return array of child pages' do
91
+ subject.get_children('page_id').should == []
92
+ end
105
93
  end
106
94
 
107
- it 'should store page with savon' do
108
- subject.store_page(page)
109
- end
110
- end
95
+ describe '#store_page' do
96
+ let(:page) do
97
+ ConfluenceSoap::Page.from_hash({content: 'test', title: 'Testing API ', space: 'Space Name',
98
+ parent_id: 'parent_id', permissions: 0})
99
+ end
111
100
 
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
101
+ before (:each) do
102
+ subject.client.should_receive(:call)
103
+ .with(:store_page, message: {in0: 'token', in1: {content: 'test', title: 'Testing API ',
104
+ space: 'Space Name', parent_id: 'parent_id', permissions: 0}})
105
+ .and_return(double(:response, body: {store_page_response: {store_page_return: {}}}))
106
+ end
117
107
 
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', parent_id: 'parent_id', permissions: 0},
123
- in2: {minorEdit: true}})
124
- .and_return(double(:response, body: {update_page_response: {update_page_return: {}}}))
108
+ it 'should store page with savon' do
109
+ subject.store_page(page)
110
+ end
125
111
  end
126
112
 
127
- it 'should store page with savon' do
128
- subject.update_page(page)
113
+ describe '#update_page' do
114
+ let(:page) do
115
+ ConfluenceSoap::Page.from_hash({content: 'test', title: 'Testing API ', space: 'Space Name',
116
+ parent_id: 'parent_id', permissions: 0})
117
+ end
118
+
119
+ before (:each) do
120
+ subject.client.should_receive(:call)
121
+ .with(:update_page, message: {in0: 'token', in1: {content: 'test', title: 'Testing API ',
122
+ space: 'Space Name', parent_id: '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
129
130
  end
130
- end
131
131
 
132
- describe '#search' do
133
- let(:term) { 'search term' }
134
- let(:criteria) { {item: [{key: :space_key, value: 'SpaceName'}]} }
135
- before (:each) do
136
- ConfluenceSoap.any_instance.stub(:login).and_return('token')
137
- subject.client.should_receive(:call)
138
- .with(:search,
139
- message: {in0: 'token', in1: term, in2: criteria, in3: 20})
140
- .and_return(double(:response, body: {search_response: {search_return: {search_return: []}}}))
132
+ describe '#search' do
133
+ let(:term) { 'search term' }
134
+ let(:criteria) { {item: [{key: :space_key, value: 'SpaceName'}]} }
135
+ before (:each) do
136
+ subject.client.should_receive(:call)
137
+ .with(:search,
138
+ message: {in0: 'token', in1: term, in2: criteria, in3: 20})
139
+ .and_return(double(:response, body: {search_response: {search_return: {search_return: []}}}))
140
+ end
141
+
142
+ it 'should search with savon' do
143
+ subject.search(term, space_key: 'SpaceName').should == []
144
+ end
141
145
  end
142
146
 
143
- it 'should search with savon' do
144
- subject.search(term, space_key: 'SpaceName').should == []
147
+ describe '#add_label_by_name' do
148
+ before(:each) do
149
+ subject.client.should_receive(:call)
150
+ .with(:add_label_by_name, message: {in0: 'token', in1: 'faq', in2: 1})
151
+ .and_return(double(:response, body: {add_label_by_name_response: {add_label_by_name_return: true}}))
152
+ end
153
+
154
+ it 'should add a label to the page' do
155
+ subject.add_label_by_name('faq', 1).should == true
156
+ end
145
157
  end
146
- end
147
158
 
148
- describe '#execute' do
149
- before (:each) do
150
- ConfluenceSoap.any_instance.stub(:login).and_return('token')
151
- subject.should_receive(:login)
159
+ describe '#remove_label_by_name' do
160
+ before(:each) do
161
+ subject.client.should_receive(:call)
162
+ .with(:remove_label_by_name, message: {in0: 'token', in1: 'faq', in2: 1})
163
+ .and_return(double(:response, body: {remove_label_by_name_response: {remove_label_by_name_return: true}}))
164
+ end
165
+
166
+ it 'should remove a label from the page' do
167
+ subject.remove_label_by_name('faq', 1).should == true
168
+ end
152
169
  end
153
170
 
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
171
+ describe '#execute' do
172
+ before (:each) do
173
+ subject.should_receive(:login)
174
+ end
175
+
176
+ it 'should reconnect when session is invalid' do
177
+ Savon::SOAPFault.any_instance.stub(:to_hash).and_return({fault: {faultstring: 'InvalidSessionException'}})
178
+ ex = Savon::SOAPFault.new nil, nil
179
+ subject.execute do |x|
180
+ raise ex if x.is_a? ConfluenceSoap
181
+ end
159
182
  end
160
183
  end
161
184
  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
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ping Yu