confluencer 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/VERSION +1 -1
- data/confluencer.gemspec +6 -3
- data/lib/confluence/page.rb +18 -4
- data/spec/confluence.yaml.example +7 -0
- data/spec/confluence/page_spec.rb +78 -0
- data/spec/confluencer_spec.rb +0 -2
- data/spec/spec_helper.rb +16 -0
- metadata +6 -3
data/.gitignore
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.4
|
data/confluencer.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{confluencer}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Gabor Ratky"]
|
12
|
-
s.date = %q{2010-05-
|
12
|
+
s.date = %q{2010-05-06}
|
13
13
|
s.description = %q{ActiveRecord-like classes to access Confluence through XMLRPC.}
|
14
14
|
s.email = %q{rgabo@rgabostyle.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -35,6 +35,8 @@ Gem::Specification.new do |s|
|
|
35
35
|
"lib/confluencer.rb",
|
36
36
|
"script/console",
|
37
37
|
"script/console_init.rb",
|
38
|
+
"spec/confluence.yaml.example",
|
39
|
+
"spec/confluence/page_spec.rb",
|
38
40
|
"spec/confluencer_spec.rb",
|
39
41
|
"spec/spec.opts",
|
40
42
|
"spec/spec_helper.rb"
|
@@ -45,7 +47,8 @@ Gem::Specification.new do |s|
|
|
45
47
|
s.rubygems_version = %q{1.3.6}
|
46
48
|
s.summary = %q{Useful classes to manage Confluence.}
|
47
49
|
s.test_files = [
|
48
|
-
"spec/
|
50
|
+
"spec/confluence/page_spec.rb",
|
51
|
+
"spec/confluencer_spec.rb",
|
49
52
|
"spec/spec_helper.rb"
|
50
53
|
]
|
51
54
|
|
data/lib/confluence/page.rb
CHANGED
@@ -4,14 +4,22 @@ module Confluence
|
|
4
4
|
record_attr_accessor :parentId => :parent_id
|
5
5
|
record_attr_accessor :space
|
6
6
|
record_attr_accessor :title, :creator, :modifier, :content
|
7
|
-
record_attr_accessor :created, :modified
|
7
|
+
record_attr_accessor :created, :modified, :version
|
8
8
|
record_attr_accessor :url
|
9
9
|
|
10
10
|
def children
|
11
|
-
client.getChildren(page_id)
|
11
|
+
children = client.getChildren(page_id)
|
12
|
+
children.collect { |child| Page.find_by_id(child["id"]) } if children
|
12
13
|
end
|
13
14
|
|
14
15
|
def store
|
16
|
+
# check for existing page
|
17
|
+
existing_page = Page.find_by_id(page_id)
|
18
|
+
|
19
|
+
# take version from existing page if available
|
20
|
+
self.version = existing_page.version if existing_page
|
21
|
+
|
22
|
+
# reinitialize page after storing it
|
15
23
|
initialize(client.storePage(attributes))
|
16
24
|
end
|
17
25
|
|
@@ -20,11 +28,17 @@ module Confluence
|
|
20
28
|
end
|
21
29
|
|
22
30
|
def self.find_by_id(page_id)
|
23
|
-
|
31
|
+
begin
|
32
|
+
self.new(client.getPage(page_id))
|
33
|
+
rescue RuntimeError
|
34
|
+
end
|
24
35
|
end
|
25
36
|
|
26
37
|
def self.find_by_title(space, title)
|
27
|
-
|
38
|
+
begin
|
39
|
+
self.new(client.getPage(space, title))
|
40
|
+
rescue RuntimeError
|
41
|
+
end
|
28
42
|
end
|
29
43
|
end
|
30
44
|
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
module PageHelperMethods
|
4
|
+
include SessionHelperMethods
|
5
|
+
|
6
|
+
def create_test_page
|
7
|
+
Confluence::Page.new :space => config[:space], :title => config[:page_title], :content => "foobar"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe Confluence::Page do
|
12
|
+
include PageHelperMethods
|
13
|
+
|
14
|
+
after :each do
|
15
|
+
new_session do
|
16
|
+
begin
|
17
|
+
# check whether we need to remove the test page
|
18
|
+
test_page = Confluence::Page.find_by_title config[:space], config[:page_title]
|
19
|
+
test_page.remove if test_page
|
20
|
+
rescue RuntimeError
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should add a new page in Confluence" do
|
26
|
+
page = nil
|
27
|
+
|
28
|
+
new_session do
|
29
|
+
# initialize test page
|
30
|
+
page = create_test_page
|
31
|
+
|
32
|
+
# page_id should be nil
|
33
|
+
page.page_id.should be_nil
|
34
|
+
|
35
|
+
# store page
|
36
|
+
page.store
|
37
|
+
|
38
|
+
# check page_id
|
39
|
+
page.page_id.should_not be_nil
|
40
|
+
end
|
41
|
+
|
42
|
+
# initialize new session
|
43
|
+
new_session do
|
44
|
+
# find page by id
|
45
|
+
new_page = Confluence::Page.find_by_id page.page_id
|
46
|
+
|
47
|
+
# assert page
|
48
|
+
new_page.should_not be_nil
|
49
|
+
new_page.title.should == page.title
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should update an existing page in Confluence" do
|
54
|
+
page = nil
|
55
|
+
|
56
|
+
new_session do
|
57
|
+
# initialize test page
|
58
|
+
page = create_test_page
|
59
|
+
|
60
|
+
# store page
|
61
|
+
page.store
|
62
|
+
end
|
63
|
+
|
64
|
+
new_session do
|
65
|
+
# create test page with same id but updated content
|
66
|
+
updated_page = create_test_page
|
67
|
+
updated_page.page_id = page.page_id
|
68
|
+
updated_page.content = "updated content"
|
69
|
+
|
70
|
+
# store page
|
71
|
+
updated_page.store
|
72
|
+
|
73
|
+
# assert version
|
74
|
+
updated_page.version.should > page.version
|
75
|
+
updated_page.content.should == "updated content"
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
data/spec/confluencer_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,9 +1,25 @@
|
|
1
1
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
2
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
|
+
|
3
4
|
require 'confluencer'
|
4
5
|
require 'spec'
|
5
6
|
require 'spec/autorun'
|
7
|
+
require 'yaml'
|
6
8
|
|
7
9
|
Spec::Runner.configure do |config|
|
10
|
+
end
|
11
|
+
|
12
|
+
module SessionHelperMethods
|
13
|
+
def config
|
14
|
+
# load configuration
|
15
|
+
@config ||= YAML.load(File.open(File.join(File.dirname(__FILE__), 'confluence.yaml')))[:test]
|
16
|
+
end
|
8
17
|
|
18
|
+
def new_session
|
19
|
+
# initialize session and yield if block given
|
20
|
+
Confluence::Session.new config do
|
21
|
+
yield if block_given?
|
22
|
+
end
|
23
|
+
end
|
9
24
|
end
|
25
|
+
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
version: 0.2.
|
8
|
+
- 4
|
9
|
+
version: 0.2.4
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Gabor Ratky
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-05-
|
17
|
+
date: 2010-05-06 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -59,6 +59,8 @@ files:
|
|
59
59
|
- lib/confluencer.rb
|
60
60
|
- script/console
|
61
61
|
- script/console_init.rb
|
62
|
+
- spec/confluence.yaml.example
|
63
|
+
- spec/confluence/page_spec.rb
|
62
64
|
- spec/confluencer_spec.rb
|
63
65
|
- spec/spec.opts
|
64
66
|
- spec/spec_helper.rb
|
@@ -93,5 +95,6 @@ signing_key:
|
|
93
95
|
specification_version: 3
|
94
96
|
summary: Useful classes to manage Confluence.
|
95
97
|
test_files:
|
98
|
+
- spec/confluence/page_spec.rb
|
96
99
|
- spec/confluencer_spec.rb
|
97
100
|
- spec/spec_helper.rb
|