confluencer 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/confluencer.gemspec +3 -1
- data/lib/confluence/session.rb +23 -9
- data/spec/confluence/page_spec.rb +1 -1
- data/spec/confluence/session_spec.rb +32 -0
- data/spec/spec_helper.rb +11 -4
- metadata +4 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.6
|
data/confluencer.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
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.6"
|
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"]
|
@@ -37,6 +37,7 @@ Gem::Specification.new do |s|
|
|
37
37
|
"script/console_init.rb",
|
38
38
|
"spec/confluence.yaml.example",
|
39
39
|
"spec/confluence/page_spec.rb",
|
40
|
+
"spec/confluence/session_spec.rb",
|
40
41
|
"spec/confluencer_spec.rb",
|
41
42
|
"spec/spec.opts",
|
42
43
|
"spec/spec_helper.rb"
|
@@ -48,6 +49,7 @@ Gem::Specification.new do |s|
|
|
48
49
|
s.summary = %q{Useful classes to manage Confluence.}
|
49
50
|
s.test_files = [
|
50
51
|
"spec/confluence/page_spec.rb",
|
52
|
+
"spec/confluence/session_spec.rb",
|
51
53
|
"spec/confluencer_spec.rb",
|
52
54
|
"spec/spec_helper.rb"
|
53
55
|
]
|
data/lib/confluence/session.rb
CHANGED
@@ -3,7 +3,7 @@ module Confluence
|
|
3
3
|
attr_reader :client
|
4
4
|
|
5
5
|
def token
|
6
|
-
client.token
|
6
|
+
client.token if client
|
7
7
|
end
|
8
8
|
|
9
9
|
def initialize(arguments = {})
|
@@ -18,17 +18,31 @@ module Confluence
|
|
18
18
|
@client.login(arguments[:username], arguments[:password])
|
19
19
|
end
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
Confluence::Record::client = @client
|
21
|
+
# set client for records
|
22
|
+
Confluence::Record::client = @client
|
24
23
|
|
25
|
-
|
24
|
+
if block_given?
|
25
|
+
begin
|
26
|
+
yield @client
|
27
|
+
rescue RuntimeError => e
|
28
|
+
# strip non-message part of java exception message
|
29
|
+
raise e.message.split(":").last.strip
|
30
|
+
end
|
26
31
|
|
27
|
-
|
28
|
-
rescue RuntimeError => e
|
29
|
-
# strip non-message part of java exception message
|
30
|
-
raise e.message.split(":").last.strip
|
32
|
+
self.destroy
|
31
33
|
end
|
32
34
|
end
|
35
|
+
|
36
|
+
def destroy
|
37
|
+
# invalidate the token
|
38
|
+
client.logout
|
39
|
+
|
40
|
+
# client and token is not valid anymore
|
41
|
+
@client = nil
|
42
|
+
@token = nil
|
43
|
+
|
44
|
+
# reset client for records
|
45
|
+
Confluence::Record::client = nil
|
46
|
+
end
|
33
47
|
end
|
34
48
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
2
|
+
|
3
|
+
describe Confluence::Session do
|
4
|
+
include ConfigurationHelperMethods
|
5
|
+
|
6
|
+
it "should log into Confluence and have valid token" do
|
7
|
+
session = Confluence::Session.new config
|
8
|
+
|
9
|
+
session.client.should_not be_nil
|
10
|
+
session.token.should_not be_nil
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should log out of Confluence and invalidate token" do
|
14
|
+
session = Confluence::Session.new config
|
15
|
+
|
16
|
+
# destroy session
|
17
|
+
session.destroy
|
18
|
+
|
19
|
+
session.client.should be_nil
|
20
|
+
session.token.should be_nil
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should yield the client and log out of Confluence if a block is given" do
|
24
|
+
session = Confluence::Session.new(config) do |client|
|
25
|
+
client.should_not be_nil
|
26
|
+
client.token.should_not be_nil
|
27
|
+
end
|
28
|
+
|
29
|
+
session.client.should be_nil
|
30
|
+
session.token.should be_nil
|
31
|
+
end
|
32
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -9,16 +9,23 @@ require 'yaml'
|
|
9
9
|
Spec::Runner.configure do |config|
|
10
10
|
end
|
11
11
|
|
12
|
-
module
|
12
|
+
module ConfigurationHelperMethods
|
13
13
|
def config
|
14
14
|
# load configuration
|
15
15
|
@config ||= YAML.load(File.open(File.join(File.dirname(__FILE__), 'confluence.yaml')))[:test]
|
16
16
|
end
|
17
|
+
end
|
18
|
+
|
19
|
+
module SessionHelperMethods
|
20
|
+
include ConfigurationHelperMethods
|
17
21
|
|
18
22
|
def new_session
|
19
|
-
|
20
|
-
|
21
|
-
yield
|
23
|
+
if block_given?
|
24
|
+
# initialize session and yield
|
25
|
+
Confluence::Session.new config { yield }
|
26
|
+
else
|
27
|
+
# initialize session and return
|
28
|
+
Confluence::Session.new config
|
22
29
|
end
|
23
30
|
end
|
24
31
|
end
|
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
|
+
- 6
|
9
|
+
version: 0.2.6
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Gabor Ratky
|
@@ -61,6 +61,7 @@ files:
|
|
61
61
|
- script/console_init.rb
|
62
62
|
- spec/confluence.yaml.example
|
63
63
|
- spec/confluence/page_spec.rb
|
64
|
+
- spec/confluence/session_spec.rb
|
64
65
|
- spec/confluencer_spec.rb
|
65
66
|
- spec/spec.opts
|
66
67
|
- spec/spec_helper.rb
|
@@ -96,5 +97,6 @@ specification_version: 3
|
|
96
97
|
summary: Useful classes to manage Confluence.
|
97
98
|
test_files:
|
98
99
|
- spec/confluence/page_spec.rb
|
100
|
+
- spec/confluence/session_spec.rb
|
99
101
|
- spec/confluencer_spec.rb
|
100
102
|
- spec/spec_helper.rb
|