confluence-soap 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 28dd7f0a8be54581855b39ba6d406cfc7e9c749b
4
+ data.tar.gz: 10dff918c2f03e4ccec12613e458d04975521fca
5
+ SHA512:
6
+ metadata.gz: 0fa5a0e5d0258fbf67c57a7e1a9621777e9693a9c1713a60d358ce09d9762a4a3a58e4110b67e9ace4660ee5fedf843873002ca5ef457f5727705a83364f6c5c
7
+ data.tar.gz: 00d47c5aace57ec6452045344cc60b368fb82e550a603062b5787071582438532e4075fbecb4a76ec14e1dc529a629c8b52d1755be56db12dc31ddf37463a7d2
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.0.0-p353
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source "https://rubygems.org"
2
+ gem 'savon'
3
+
4
+ group :development do
5
+ gem "bundler", "~> 1.0"
6
+ gem "jeweler", "~> 2.0.0"
7
+ gem "rdoc", "~> 3.12"
8
+ end
9
+
10
+ group :test do
11
+ gem "rspec", "~> 2.8.0"
12
+ gem "simplecov"
13
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,96 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ addressable (2.3.5)
5
+ akami (1.2.0)
6
+ gyoku (>= 0.4.0)
7
+ nokogiri (>= 1.4.0)
8
+ builder (3.2.2)
9
+ descendants_tracker (0.0.3)
10
+ diff-lcs (1.1.3)
11
+ docile (1.1.1)
12
+ faraday (0.9.0)
13
+ multipart-post (>= 1.2, < 3)
14
+ git (1.2.6)
15
+ github_api (0.11.1)
16
+ addressable (~> 2.3)
17
+ descendants_tracker (~> 0.0.1)
18
+ faraday (~> 0.8, < 0.10)
19
+ hashie (>= 1.2)
20
+ multi_json (>= 1.7.5, < 2.0)
21
+ nokogiri (~> 1.6.0)
22
+ oauth2
23
+ gyoku (1.1.1)
24
+ builder (>= 2.1.2)
25
+ hashie (2.0.5)
26
+ highline (1.6.20)
27
+ httpi (2.1.0)
28
+ rack
29
+ rubyntlm (~> 0.3.2)
30
+ jeweler (2.0.0)
31
+ builder
32
+ bundler (>= 1.0)
33
+ git (>= 1.2.5)
34
+ github_api
35
+ highline (>= 1.6.15)
36
+ nokogiri (>= 1.5.10)
37
+ rake
38
+ rdoc
39
+ json (1.8.1)
40
+ jwt (0.1.11)
41
+ multi_json (>= 1.5)
42
+ mime-types (1.25.1)
43
+ mini_portile (0.5.2)
44
+ multi_json (1.8.4)
45
+ multi_xml (0.5.5)
46
+ multipart-post (2.0.0)
47
+ nokogiri (1.6.1)
48
+ mini_portile (~> 0.5.0)
49
+ nori (2.3.0)
50
+ oauth2 (0.9.3)
51
+ faraday (>= 0.8, < 0.10)
52
+ jwt (~> 0.1.8)
53
+ multi_json (~> 1.3)
54
+ multi_xml (~> 0.5)
55
+ rack (~> 1.2)
56
+ rack (1.5.2)
57
+ rake (10.1.1)
58
+ rdoc (3.12.2)
59
+ json (~> 1.4)
60
+ rspec (2.8.0)
61
+ rspec-core (~> 2.8.0)
62
+ rspec-expectations (~> 2.8.0)
63
+ rspec-mocks (~> 2.8.0)
64
+ rspec-core (2.8.0)
65
+ rspec-expectations (2.8.0)
66
+ diff-lcs (~> 1.1.2)
67
+ rspec-mocks (2.8.0)
68
+ rubyntlm (0.3.4)
69
+ savon (2.3.3)
70
+ akami (~> 1.2.0)
71
+ builder (>= 2.1.2)
72
+ gyoku (~> 1.1.0)
73
+ httpi (~> 2.1.0)
74
+ nokogiri (>= 1.4.0)
75
+ nori (~> 2.3.0)
76
+ wasabi (~> 3.2.2)
77
+ simplecov (0.8.2)
78
+ docile (~> 1.1.0)
79
+ multi_json
80
+ simplecov-html (~> 0.8.0)
81
+ simplecov-html (0.8.0)
82
+ wasabi (3.2.3)
83
+ httpi (~> 2.0)
84
+ mime-types (< 2.0.0)
85
+ nokogiri (>= 1.4.0)
86
+
87
+ PLATFORMS
88
+ ruby
89
+
90
+ DEPENDENCIES
91
+ bundler (~> 1.0)
92
+ jeweler (~> 2.0.0)
93
+ rdoc (~> 3.12)
94
+ rspec (~> 2.8.0)
95
+ savon
96
+ simplecov
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2014 Ping Yu
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,19 @@
1
+ = confluence-soap
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to confluence-soap
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
9
+ * Fork the project.
10
+ * Start a feature/bugfix branch.
11
+ * Commit and push until you are happy with your contribution.
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * 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
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2014 Ping Yu. See LICENSE.txt for
18
+ further details.
19
+
data/Rakefile ADDED
@@ -0,0 +1,49 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "confluence-soap"
18
+ gem.homepage = "http://github.com/intridea/confluence-soap"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{ruby client for confluence soap API}
21
+ gem.description = %Q{}
22
+ gem.email = "ping@intridea.com", "eric@intridea.com"
23
+ gem.authors = ["Ping Yu", "Eric Himmelreich"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rspec/core'
29
+ require 'rspec/core/rake_task'
30
+ RSpec::Core::RakeTask.new(:spec) do |spec|
31
+ spec.pattern = FileList['spec/**/*_spec.rb']
32
+ end
33
+
34
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
35
+ spec.pattern = 'spec/**/*_spec.rb'
36
+ spec.rcov = true
37
+ end
38
+
39
+ task :default => :spec
40
+
41
+ require 'rdoc/task'
42
+ Rake::RDocTask.new do |rdoc|
43
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
44
+
45
+ rdoc.rdoc_dir = 'rdoc'
46
+ rdoc.title = "confluence-soap #{version}"
47
+ rdoc.rdoc_files.include('README*')
48
+ rdoc.rdoc_files.include('lib/**/*.rb')
49
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,62 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "confluence-soap"
8
+ s.version = "0.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Ping Yu", "Eric Himmelreich"]
12
+ s.date = "2014-01-22"
13
+ s.description = ""
14
+ s.email = ["ping@intridea.com", "eric@intridea.com"]
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".rspec",
22
+ ".ruby-version",
23
+ "Gemfile",
24
+ "Gemfile.lock",
25
+ "LICENSE.txt",
26
+ "README.rdoc",
27
+ "Rakefile",
28
+ "VERSION",
29
+ "confluence-soap.gemspec",
30
+ "lib/.DS_Store",
31
+ "lib/confluence-soap.rb",
32
+ "spec/confluence-soap_spec.rb",
33
+ "spec/spec_helper.rb"
34
+ ]
35
+ s.homepage = "http://github.com/intridea/confluence-soap"
36
+ s.licenses = ["MIT"]
37
+ s.require_paths = ["lib"]
38
+ s.rubygems_version = "2.0.14"
39
+ s.summary = "ruby client for confluence soap API"
40
+
41
+ if s.respond_to? :specification_version then
42
+ s.specification_version = 4
43
+
44
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
45
+ s.add_runtime_dependency(%q<savon>, [">= 0"])
46
+ s.add_development_dependency(%q<bundler>, ["~> 1.0"])
47
+ s.add_development_dependency(%q<jeweler>, ["~> 2.0.0"])
48
+ s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
49
+ else
50
+ s.add_dependency(%q<savon>, [">= 0"])
51
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
52
+ s.add_dependency(%q<jeweler>, ["~> 2.0.0"])
53
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
54
+ end
55
+ else
56
+ s.add_dependency(%q<savon>, [">= 0"])
57
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
58
+ s.add_dependency(%q<jeweler>, ["~> 2.0.0"])
59
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
60
+ end
61
+ end
62
+
data/lib/.DS_Store ADDED
Binary file
@@ -0,0 +1,56 @@
1
+ require 'savon'
2
+
3
+ class ConfluenceSoap
4
+ attr_reader :client, :token
5
+
6
+ Page = Struct.new(:content, :contentStatus, :title, :space, :parentId, :permissions)
7
+
8
+ def initialize url, user, password
9
+ @client = Savon.client(wsdl: url)
10
+ @token = login(user, password)
11
+ end
12
+
13
+ def login user, password
14
+ response = @client.call :login, message: {in0: user, in1: password}
15
+ @token = response.body[:login_response][:login_return]
16
+ end
17
+
18
+ def get_pages space
19
+ response = @client.call :get_pages, message: {in0: @token, in1: space}
20
+ parse_array_response :get_pages, response
21
+ end
22
+
23
+ def get_page page_id
24
+ response = @client.call :get_page, message: {in0: @token, in1: page_id}
25
+ parse_response :get_page, response
26
+ end
27
+
28
+ def get_children page_id
29
+ response = @client.call :get_children, message: {in0: @token, in1: page_id}
30
+ parse_array_response :get_children, response
31
+ end
32
+
33
+ def store_page page
34
+ response = @client.call :store_page, message: {in0: @token, in1: page.to_h}
35
+ parse_response :store_page, response
36
+ end
37
+
38
+ def search(term, criteria = {})
39
+ limit = criteria.delete(:limit) || 20
40
+ criteria = criteria.map { |k, v| {key: k, value: v} }
41
+ response =
42
+ @client.call(:search, message: {
43
+ in0: @token, in1: term, in2: {item: criteria}, in3: limit})
44
+ parse_array_response :search, response
45
+ end
46
+
47
+ private
48
+
49
+ def parse_array_response method, response
50
+ parse_response(method, response)["#{method}_return".to_sym]
51
+ end
52
+
53
+ def parse_response method, response
54
+ response.body["#{method}_response".to_sym]["#{method}_return".to_sym]
55
+ end
56
+ end
@@ -0,0 +1,113 @@
1
+ require 'spec_helper'
2
+
3
+ describe ConfluenceSoap do
4
+ let (:url) {'http://example.com?wsdl'}
5
+ subject {ConfluenceSoap.new(url, 'user', 'password')}
6
+
7
+ describe 'Page' do
8
+ ConfluenceSoap::Page.new.to_h
9
+ end
10
+
11
+ describe '#initialize' do
12
+ it 'should create a savon soap client with url provided' do
13
+ Savon.should_receive(:client).with(wsdl: url)
14
+ ConfluenceSoap.any_instance.should_receive(:login)
15
+
16
+ subject
17
+ end
18
+ end
19
+
20
+ describe '#login' do
21
+ before (:each) do
22
+ Savon::Client.any_instance.should_receive(:call).twice
23
+ .with(:login, message: {in0: 'user', in1: 'password'})
24
+ .and_return(double(:response, body: {login_response: {login_return: 'token'}}))
25
+ end
26
+
27
+ it 'should login with savon client' do
28
+
29
+ subject.login('user', 'password')
30
+ end
31
+
32
+ it 'should store the login token' do
33
+ subject.login('user', 'password')
34
+
35
+ subject.token.should == 'token'
36
+ end
37
+ end
38
+
39
+ describe '#get_pages' do
40
+ let(:space) { 'SpaceName' }
41
+ before (:each) do
42
+ 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
+ end
47
+
48
+ it 'should return the pages in the space' do
49
+ subject.get_pages(space).should == []
50
+ end
51
+ end
52
+
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
61
+
62
+ it 'should return the page' do
63
+ subject.get_page page_id
64
+ end
65
+ end
66
+
67
+ describe '#get_children' do
68
+ before (:each) do
69
+ ConfluenceSoap.any_instance.stub(:login).and_return('token')
70
+ subject.client.should_receive(:call)
71
+ .with(:get_children, message: {in0: 'token', in1: 'page_id'})
72
+ .and_return(double(:response, body: {get_children_response: {get_children_return: {get_children_return: []}}}))
73
+ end
74
+
75
+ it 'should return array of child pages' do
76
+ subject.get_children('page_id').should == []
77
+ end
78
+ end
79
+
80
+ describe '#store_page' do
81
+ let(:page) do
82
+ ConfluenceSoap::Page.new('test', 'current', 'Testing API ', 'Space Name',
83
+ 'parent_id', 0)
84
+ end
85
+
86
+ before (:each) do
87
+ ConfluenceSoap.any_instance.stub(:login).and_return('token')
88
+ subject.client.should_receive(:call)
89
+ .with(:store_page, message: {in0: 'token', in1: page.to_h})
90
+ .and_return(double(:response, body: {store_page_response: {store_page_return: {}}}))
91
+ end
92
+
93
+ it 'should store page with savon' do
94
+ subject.store_page(page)
95
+ end
96
+ end
97
+
98
+ describe '#search' do
99
+ let(:term) { 'search term' }
100
+ let(:criteria) { {item: [{key: :spaceKey, value: 'SpaceName'}]} }
101
+ before (:each) do
102
+ ConfluenceSoap.any_instance.stub(:login).and_return('token')
103
+ subject.client.should_receive(:call)
104
+ .with(:search,
105
+ message: {in0: 'token', in1: term, in2: criteria, in3: 20})
106
+ .and_return(double(:response, body: {search_response: {search_return: {search_return: []}}}))
107
+ end
108
+
109
+ it 'should search with savon' do
110
+ subject.search(term, spaceKey: 'SpaceName').should == []
111
+ end
112
+ end
113
+ end
@@ -0,0 +1,12 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'confluence-soap'
5
+
6
+ # Requires supporting files with custom matchers and macros, etc,
7
+ # in ./support/ and its subdirectories.
8
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
+
10
+ RSpec.configure do |config|
11
+
12
+ end
metadata ADDED
@@ -0,0 +1,118 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: confluence-soap
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ping Yu
8
+ - Eric Himmelreich
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-01-22 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: savon
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - '>='
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - '>='
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: bundler
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ~>
33
+ - !ruby/object:Gem::Version
34
+ version: '1.0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ~>
40
+ - !ruby/object:Gem::Version
41
+ version: '1.0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: jeweler
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ~>
47
+ - !ruby/object:Gem::Version
48
+ version: 2.0.0
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ~>
54
+ - !ruby/object:Gem::Version
55
+ version: 2.0.0
56
+ - !ruby/object:Gem::Dependency
57
+ name: rdoc
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ~>
61
+ - !ruby/object:Gem::Version
62
+ version: '3.12'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: '3.12'
70
+ description: ''
71
+ email:
72
+ - ping@intridea.com
73
+ - eric@intridea.com
74
+ executables: []
75
+ extensions: []
76
+ extra_rdoc_files:
77
+ - LICENSE.txt
78
+ - README.rdoc
79
+ files:
80
+ - .document
81
+ - .rspec
82
+ - .ruby-version
83
+ - Gemfile
84
+ - Gemfile.lock
85
+ - LICENSE.txt
86
+ - README.rdoc
87
+ - Rakefile
88
+ - VERSION
89
+ - confluence-soap.gemspec
90
+ - lib/.DS_Store
91
+ - lib/confluence-soap.rb
92
+ - spec/confluence-soap_spec.rb
93
+ - spec/spec_helper.rb
94
+ homepage: http://github.com/intridea/confluence-soap
95
+ licenses:
96
+ - MIT
97
+ metadata: {}
98
+ post_install_message:
99
+ rdoc_options: []
100
+ require_paths:
101
+ - lib
102
+ required_ruby_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - '>='
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ required_rubygems_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ requirements: []
113
+ rubyforge_project:
114
+ rubygems_version: 2.1.11
115
+ signing_key:
116
+ specification_version: 4
117
+ summary: ruby client for confluence soap API
118
+ test_files: []