confluencer 0.1.4 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +1 -1
- data/Rakefile +2 -3
- data/VERSION +1 -1
- data/confluencer.gems +1 -1
- data/confluencer.gemspec +6 -16
- data/lib/confluence/client.rb +2 -2
- data/lib/confluence/record.rb +6 -5
- data/lib/confluence/session.rb +34 -0
- data/lib/confluencer.rb +2 -5
- data/script/console +0 -3
- metadata +8 -29
- data/bin/confluencer +0 -8
- data/bin/confluencer-bookmarks +0 -8
- data/config/confluencer.yaml.example +0 -7
- data/lib/confluencer/app.rb +0 -61
- data/lib/confluencer/bookmarks.rb +0 -72
- data/script/console_client.rb +0 -9
- data/templates/webpage.erb +0 -9
data/LICENSE
CHANGED
data/Rakefile
CHANGED
@@ -5,13 +5,12 @@ begin
|
|
5
5
|
require 'jeweler'
|
6
6
|
Jeweler::Tasks.new do |gem|
|
7
7
|
gem.name = "confluencer"
|
8
|
-
gem.summary = %Q{Useful
|
9
|
-
gem.description = %Q{ActiveRecord-like classes
|
8
|
+
gem.summary = %Q{Useful classes to manage Confluence.}
|
9
|
+
gem.description = %Q{ActiveRecord-like classes to access Confluence through XMLRPC.}
|
10
10
|
gem.email = "rgabo@rgabostyle.com"
|
11
11
|
gem.homepage = "http://github.com/rgabo/confluencer"
|
12
12
|
gem.authors = ["Gabor Ratky"]
|
13
13
|
gem.add_development_dependency "rspec", ">= 1.3.0"
|
14
|
-
gem.add_runtime_dependency "thor", ">= 0.13.4"
|
15
14
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
16
15
|
end
|
17
16
|
Jeweler::GemcutterTasks.new
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1
|
1
|
+
0.2.1
|
data/confluencer.gems
CHANGED
data/confluencer.gemspec
CHANGED
@@ -5,14 +5,13 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{confluencer}
|
8
|
-
s.version = "0.1
|
8
|
+
s.version = "0.2.1"
|
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-
|
13
|
-
s.description = %q{ActiveRecord-like classes
|
12
|
+
s.date = %q{2010-05-05}
|
13
|
+
s.description = %q{ActiveRecord-like classes to access Confluence through XMLRPC.}
|
14
14
|
s.email = %q{rgabo@rgabostyle.com}
|
15
|
-
s.executables = ["confluencer", "confluencer-bookmarks"]
|
16
15
|
s.extra_rdoc_files = [
|
17
16
|
"LICENSE",
|
18
17
|
"README.rdoc"
|
@@ -25,9 +24,6 @@ Gem::Specification.new do |s|
|
|
25
24
|
"README.rdoc",
|
26
25
|
"Rakefile",
|
27
26
|
"VERSION",
|
28
|
-
"bin/confluencer",
|
29
|
-
"bin/confluencer-bookmarks",
|
30
|
-
"config/confluencer.yaml.example",
|
31
27
|
"confluencer.gems",
|
32
28
|
"confluencer.gemspec",
|
33
29
|
"lib/confluence/blog_entry.rb",
|
@@ -35,22 +31,19 @@ Gem::Specification.new do |s|
|
|
35
31
|
"lib/confluence/client.rb",
|
36
32
|
"lib/confluence/page.rb",
|
37
33
|
"lib/confluence/record.rb",
|
34
|
+
"lib/confluence/session.rb",
|
38
35
|
"lib/confluencer.rb",
|
39
|
-
"lib/confluencer/app.rb",
|
40
|
-
"lib/confluencer/bookmarks.rb",
|
41
36
|
"script/console",
|
42
|
-
"script/console_client.rb",
|
43
37
|
"script/console_init.rb",
|
44
38
|
"spec/confluencer_spec.rb",
|
45
39
|
"spec/spec.opts",
|
46
|
-
"spec/spec_helper.rb"
|
47
|
-
"templates/webpage.erb"
|
40
|
+
"spec/spec_helper.rb"
|
48
41
|
]
|
49
42
|
s.homepage = %q{http://github.com/rgabo/confluencer}
|
50
43
|
s.rdoc_options = ["--charset=UTF-8"]
|
51
44
|
s.require_paths = ["lib"]
|
52
45
|
s.rubygems_version = %q{1.3.6}
|
53
|
-
s.summary = %q{Useful
|
46
|
+
s.summary = %q{Useful classes to manage Confluence.}
|
54
47
|
s.test_files = [
|
55
48
|
"spec/confluencer_spec.rb",
|
56
49
|
"spec/spec_helper.rb"
|
@@ -62,14 +55,11 @@ Gem::Specification.new do |s|
|
|
62
55
|
|
63
56
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
64
57
|
s.add_development_dependency(%q<rspec>, [">= 1.3.0"])
|
65
|
-
s.add_runtime_dependency(%q<thor>, [">= 0.13.4"])
|
66
58
|
else
|
67
59
|
s.add_dependency(%q<rspec>, [">= 1.3.0"])
|
68
|
-
s.add_dependency(%q<thor>, [">= 0.13.4"])
|
69
60
|
end
|
70
61
|
else
|
71
62
|
s.add_dependency(%q<rspec>, [">= 1.3.0"])
|
72
|
-
s.add_dependency(%q<thor>, [">= 0.13.4"])
|
73
63
|
end
|
74
64
|
end
|
75
65
|
|
data/lib/confluence/client.rb
CHANGED
@@ -10,7 +10,7 @@ require 'ruby-debug'
|
|
10
10
|
#
|
11
11
|
# Usage:
|
12
12
|
#
|
13
|
-
# client = Confluence::Client.new("http://confluence.atlassian.com")
|
13
|
+
# client = Confluence::Client.new(:url => "http://confluence.atlassian.com")
|
14
14
|
# client.login("user", "password")
|
15
15
|
# puts client.getSpaces()
|
16
16
|
#
|
@@ -31,7 +31,7 @@ module Confluence
|
|
31
31
|
@token = options[:token]
|
32
32
|
end
|
33
33
|
|
34
|
-
def
|
34
|
+
def has_token?
|
35
35
|
!@token.nil?
|
36
36
|
end
|
37
37
|
|
data/lib/confluence/record.rb
CHANGED
@@ -60,17 +60,18 @@ module Confluence
|
|
60
60
|
end
|
61
61
|
|
62
62
|
@@client = nil
|
63
|
+
|
64
|
+
def self.client
|
65
|
+
raise "Confluence client is unavailable. Did you forget to use Confluence::Session.new?" unless @@client
|
66
|
+
@@client
|
67
|
+
end
|
63
68
|
|
64
69
|
def self.client=(client)
|
65
70
|
@@client = client
|
66
71
|
end
|
67
72
|
|
68
|
-
def self.client
|
69
|
-
@@client
|
70
|
-
end
|
71
|
-
|
72
73
|
def client
|
73
|
-
|
74
|
+
Record.client
|
74
75
|
end
|
75
76
|
end
|
76
77
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Confluence
|
2
|
+
class Session
|
3
|
+
attr_reader :client
|
4
|
+
|
5
|
+
def token
|
6
|
+
client.token
|
7
|
+
end
|
8
|
+
|
9
|
+
def initialize(arguments = {}, &block)
|
10
|
+
raise ArgumentError, "Required argument 'url' is missing." unless arguments.key? :url
|
11
|
+
|
12
|
+
@client = Client.new(arguments)
|
13
|
+
|
14
|
+
unless @client.has_token?
|
15
|
+
raise ArgumentError, "Required argument 'username' is missing." unless arguments.key? :username
|
16
|
+
raise ArgumentError, "Required argument 'password' is missing." unless arguments.key? :password
|
17
|
+
|
18
|
+
@client.login(arguments[:username], arguments[:password])
|
19
|
+
end
|
20
|
+
|
21
|
+
begin
|
22
|
+
# set client for records
|
23
|
+
Confluence::Record::client = @client
|
24
|
+
|
25
|
+
block.call(@client) if block
|
26
|
+
|
27
|
+
Confluence::Record::client = nil
|
28
|
+
rescue RuntimeError => e
|
29
|
+
# strip non-message part of java exception message
|
30
|
+
raise e.message.split(":").last.strip
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/confluencer.rb
CHANGED
@@ -5,12 +5,9 @@ require 'rubygems'
|
|
5
5
|
require 'thor'
|
6
6
|
|
7
7
|
require 'confluence/client'
|
8
|
+
require 'confluence/session'
|
9
|
+
|
8
10
|
require 'confluence/record'
|
9
11
|
require 'confluence/page'
|
10
12
|
require 'confluence/bookmark'
|
11
13
|
require 'confluence/blog_entry'
|
12
|
-
|
13
|
-
module Confluencer
|
14
|
-
autoload :App, 'confluencer/app'
|
15
|
-
autoload :Bookmarks, 'confluencer/bookmarks'
|
16
|
-
end
|
data/script/console
CHANGED
@@ -4,9 +4,6 @@ libs = " -r irb/completion"
|
|
4
4
|
|
5
5
|
libs << " -r #{File.dirname(__FILE__) + '/../lib/confluencer.rb'}"
|
6
6
|
|
7
|
-
# also initialize a default client for the records
|
8
|
-
libs << " -r #{File.dirname(__FILE__) + '/console_client.rb'}"
|
9
|
-
|
10
7
|
# load console_init
|
11
8
|
libs << " -r #{File.dirname(__FILE__) + '/console_init.rb'}"
|
12
9
|
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
+
- 2
|
7
8
|
- 1
|
8
|
-
|
9
|
-
version: 0.1.4
|
9
|
+
version: 0.2.1
|
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-05 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -31,25 +31,10 @@ dependencies:
|
|
31
31
|
version: 1.3.0
|
32
32
|
type: :development
|
33
33
|
version_requirements: *id001
|
34
|
-
-
|
35
|
-
name: thor
|
36
|
-
prerelease: false
|
37
|
-
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
-
requirements:
|
39
|
-
- - ">="
|
40
|
-
- !ruby/object:Gem::Version
|
41
|
-
segments:
|
42
|
-
- 0
|
43
|
-
- 13
|
44
|
-
- 4
|
45
|
-
version: 0.13.4
|
46
|
-
type: :runtime
|
47
|
-
version_requirements: *id002
|
48
|
-
description: ActiveRecord-like classes that map to Confluence entities and useful scripts that automate tasks
|
34
|
+
description: ActiveRecord-like classes to access Confluence through XMLRPC.
|
49
35
|
email: rgabo@rgabostyle.com
|
50
|
-
executables:
|
51
|
-
|
52
|
-
- confluencer-bookmarks
|
36
|
+
executables: []
|
37
|
+
|
53
38
|
extensions: []
|
54
39
|
|
55
40
|
extra_rdoc_files:
|
@@ -63,9 +48,6 @@ files:
|
|
63
48
|
- README.rdoc
|
64
49
|
- Rakefile
|
65
50
|
- VERSION
|
66
|
-
- bin/confluencer
|
67
|
-
- bin/confluencer-bookmarks
|
68
|
-
- config/confluencer.yaml.example
|
69
51
|
- confluencer.gems
|
70
52
|
- confluencer.gemspec
|
71
53
|
- lib/confluence/blog_entry.rb
|
@@ -73,16 +55,13 @@ files:
|
|
73
55
|
- lib/confluence/client.rb
|
74
56
|
- lib/confluence/page.rb
|
75
57
|
- lib/confluence/record.rb
|
58
|
+
- lib/confluence/session.rb
|
76
59
|
- lib/confluencer.rb
|
77
|
-
- lib/confluencer/app.rb
|
78
|
-
- lib/confluencer/bookmarks.rb
|
79
60
|
- script/console
|
80
|
-
- script/console_client.rb
|
81
61
|
- script/console_init.rb
|
82
62
|
- spec/confluencer_spec.rb
|
83
63
|
- spec/spec.opts
|
84
64
|
- spec/spec_helper.rb
|
85
|
-
- templates/webpage.erb
|
86
65
|
has_rdoc: true
|
87
66
|
homepage: http://github.com/rgabo/confluencer
|
88
67
|
licenses: []
|
@@ -112,7 +91,7 @@ rubyforge_project:
|
|
112
91
|
rubygems_version: 1.3.6
|
113
92
|
signing_key:
|
114
93
|
specification_version: 3
|
115
|
-
summary: Useful
|
94
|
+
summary: Useful classes to manage Confluence.
|
116
95
|
test_files:
|
117
96
|
- spec/confluencer_spec.rb
|
118
97
|
- spec/spec_helper.rb
|
data/bin/confluencer
DELETED
data/bin/confluencer-bookmarks
DELETED
data/lib/confluencer/app.rb
DELETED
@@ -1,61 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'thor'
|
3
|
-
require 'yaml'
|
4
|
-
|
5
|
-
module Confluencer
|
6
|
-
class App < Thor
|
7
|
-
attr_reader :token
|
8
|
-
|
9
|
-
# -v, --verbose
|
10
|
-
class_option :verbose, :desc => "Verbose output", :type => :boolean, :default => false, :aliases => "-v"
|
11
|
-
|
12
|
-
# external configuration
|
13
|
-
class_option :config, :type => :string, :aliases => "-c", :desc => "confluencer configuration file", :default => "config/confluencer.yaml"
|
14
|
-
class_option :instance, :type => :string, :aliases => "-i", :desc => "Name of the Confluence instance", :default => "confluence"
|
15
|
-
# explicitly specify default_task => :help
|
16
|
-
default_task :help
|
17
|
-
|
18
|
-
desc "create-config", "Creates a confluencer configuration file"
|
19
|
-
def create_config
|
20
|
-
default_configuration = { :confluence => { :url => "http://confluence.acmecorp.com", :username => "roger", :password => "jessica"}}
|
21
|
-
|
22
|
-
File.open(options[:config], "w+") do |file|
|
23
|
-
file.puts(default_configuration.to_yaml)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
desc "login", "Logs in and verifies the Confluence account"
|
28
|
-
def login
|
29
|
-
raise Thor::Error, "Required configuration 'username' missing." unless configuration.key? :username
|
30
|
-
raise Thor::Error, "Required configuration 'password' missing." unless configuration.key? :password
|
31
|
-
|
32
|
-
with_confluence do |confluence|
|
33
|
-
@token = confluence.login(configuration[:username], configuration[:password])
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
private
|
38
|
-
|
39
|
-
def configuration
|
40
|
-
@configuration ||= YAML::load(File.open(options[:config]))[options[:instance].to_sym]
|
41
|
-
end
|
42
|
-
|
43
|
-
def with_confluence(&block)
|
44
|
-
raise Thor::Error, "Required configuration 'url' missing." unless configuration.key? :url
|
45
|
-
|
46
|
-
client = Confluence::Client.new(:url => configuration[:url], :token => @token)
|
47
|
-
|
48
|
-
begin
|
49
|
-
# Record objects should use this clent
|
50
|
-
Confluence::Record::client = client
|
51
|
-
|
52
|
-
block.call(client)
|
53
|
-
|
54
|
-
# Nil out client
|
55
|
-
Confluence::Record::client = nil
|
56
|
-
rescue RuntimeError => e
|
57
|
-
raise Thor::Error, e.message.split(":").last.strip
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
@@ -1,72 +0,0 @@
|
|
1
|
-
require 'confluencer/app'
|
2
|
-
require 'erb'
|
3
|
-
|
4
|
-
module Confluencer
|
5
|
-
class Bookmarks < Confluencer::App
|
6
|
-
BOOKMARKS_PAGE_TITLE = ".bookmarks"
|
7
|
-
|
8
|
-
desc "list SPACEKEY", "Lists the bookmarks in a given space"
|
9
|
-
def list(spacekey)
|
10
|
-
invoke :login
|
11
|
-
|
12
|
-
with_confluence do
|
13
|
-
# grab all bookmarks from space
|
14
|
-
bookmarks = Confluence::Bookmark.find_by_space(spacekey)
|
15
|
-
|
16
|
-
# print out bookmarks
|
17
|
-
puts bookmarks.collect {|b| "#{b.bookmark_url} (#{b.title})"}.join "\n"
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
method_option :parent, :type => :string, :default => "Bookmarks", :desc => "Parent page for the pages created"
|
22
|
-
method_option :template, :type => :string, :desc => "ERB template to use", :required => :true
|
23
|
-
desc "create-pages SPACEKEY", "Creates pages for every bookmark"
|
24
|
-
def create_pages(spacekey)
|
25
|
-
invoke :login
|
26
|
-
|
27
|
-
with_confluence do
|
28
|
-
# add a page for each bookmark, remove bookmark in the process
|
29
|
-
bookmarks(spacekey).each do |bookmark|
|
30
|
-
puts bookmark.title
|
31
|
-
|
32
|
-
labels = bookmark.labels << "bookmark"
|
33
|
-
|
34
|
-
page = Confluence::Page.new :space => spacekey, :parentId => parent_page(spacekey).page_id, :title => bookmark.title
|
35
|
-
page.content = template.result(binding)
|
36
|
-
|
37
|
-
# remove bookmark before storing page with same title
|
38
|
-
bookmark.remove
|
39
|
-
page.store
|
40
|
-
|
41
|
-
# update labels, add bookmark
|
42
|
-
page.labels = labels << "bookmark"
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
private
|
48
|
-
|
49
|
-
def bookmarks(spacekey)
|
50
|
-
Confluence::Bookmark.find_by_space(spacekey)
|
51
|
-
end
|
52
|
-
|
53
|
-
def parent_page(spacekey)
|
54
|
-
@parent_pages[spacekey] ||= begin
|
55
|
-
unless @parent_pages[spacekey]
|
56
|
-
begin
|
57
|
-
# get parent page
|
58
|
-
@parent_pages[spacekey] = Confluence::Page.find_by_title(spacekey, options[:parent])
|
59
|
-
rescue RuntimeError
|
60
|
-
# page does not exist yet, create it
|
61
|
-
@parent_pages[spacekey] = Confluence::Page.new :space => spacekey, :title => options[:parent], :content => ""
|
62
|
-
@parent_pages[spacekey].store
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
def template
|
69
|
-
@template ||= ERB.new(IO.read(options[:template]))
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
data/script/console_client.rb
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
# TODO: take client configuration from YAML (console_client.yaml) that is ignored by default, add console_client.yaml.example
|
2
|
-
# initialize client
|
3
|
-
client = Confluence::Client.new :url => "http://192.168.1.80:3800"
|
4
|
-
|
5
|
-
# log in with account
|
6
|
-
client.login('bender', 'futurama')
|
7
|
-
|
8
|
-
# Set client for Confluence records
|
9
|
-
Confluence::Record::client = client
|