Class: Confluence::Connector
- Inherits:
-
Object
- Object
- Confluence::Connector
- Defined in:
- lib/confluence/connector.rb
Instance Attribute Summary collapse
-
#admin_proxy_password ⇒ Object
Returns the value of attribute admin_proxy_password.
-
#admin_proxy_username ⇒ Object
Returns the value of attribute admin_proxy_username.
-
#default_service ⇒ Object
Returns the value of attribute default_service.
-
#password ⇒ Object
Returns the value of attribute password.
-
#url ⇒ Object
Returns the value of attribute url.
-
#username ⇒ Object
Returns the value of attribute username.
Class Method Summary collapse
- .default_confluence_url ⇒ Object
-
.through_admin_proxy ⇒ Object
The given block will be executed using another account, as set in the confluence.yml file under admin_proxy_username and admin_proxy_password.
Instance Method Summary collapse
- #connect(service = nil) ⇒ Object
-
#initialize(options = {}) ⇒ Connector
constructor
A new instance of Connector.
- #load_confluence_config ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Connector
10 11 12 13 14 15 16 |
# File 'lib/confluence/connector.rb', line 10 def initialize( = {}) load_confluence_config @url ||= [:url] @username = [:username] || @username @password = [:password] || @password @default_service = [:service] || 'confluence1' end |
Instance Attribute Details
#admin_proxy_password ⇒ Object
Returns the value of attribute admin_proxy_password.
7 8 9 |
# File 'lib/confluence/connector.rb', line 7 def admin_proxy_password @admin_proxy_password end |
#admin_proxy_username ⇒ Object
Returns the value of attribute admin_proxy_username.
7 8 9 |
# File 'lib/confluence/connector.rb', line 7 def admin_proxy_username @admin_proxy_username end |
#default_service ⇒ Object
Returns the value of attribute default_service.
7 8 9 |
# File 'lib/confluence/connector.rb', line 7 def default_service @default_service end |
#password ⇒ Object
Returns the value of attribute password.
7 8 9 |
# File 'lib/confluence/connector.rb', line 7 def password @password end |
#url ⇒ Object
Returns the value of attribute url.
7 8 9 |
# File 'lib/confluence/connector.rb', line 7 def url @url end |
#username ⇒ Object
Returns the value of attribute username.
7 8 9 |
# File 'lib/confluence/connector.rb', line 7 def username @username end |
Class Method Details
.default_confluence_url ⇒ Object
40 41 42 43 |
# File 'lib/confluence/connector.rb', line 40 def self.default_confluence_url conf = YAML.load_file("#{RAILS_ROOT}/config/confluence.yml")[RAILS_ENV] conf['url'] || conf[:url] end |
.through_admin_proxy ⇒ Object
The given block will be executed using another account, as set in the confluence.yml file under admin_proxy_username and admin_proxy_password. This is useful when you want to execute some function that requires admin privileges. You will of course have to set up a corresponding account on your Confluence server with administrative rights.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/confluence/connector.rb', line 48 def self.through_admin_proxy super_connector = Confluence::Connector.new raise "Cannot execute through_admin_proxy because the admin_proxy_username has not been set." unless super_connector.admin_proxy_username raise "Cannot execute through_admin_proxy because the admin_proxy_password has not been set." unless super_connector.admin_proxy_password super_connector.username = super_connector.admin_proxy_username super_connector.password = super_connector.admin_proxy_password normal_connector = Confluence::RemoteDataObject.connector Confluence::RemoteDataObject.connector = super_connector yield Confluence::RemoteDataObject.connector = normal_connector end |
Instance Method Details
#connect(service = nil) ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/confluence/connector.rb', line 18 def connect(service = nil) unless url and ((admin_proxy_username and admin_proxy_password) or (username and password)) and service || default_service raise "Cannot get Confluence::RPC instance because the confluence url, username, password, or service have not been set" end rpc = Confluence::RPC.new(url, service || default_service) rpc.login(username, password) return rpc end |
#load_confluence_config ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/confluence/connector.rb', line 29 def load_confluence_config conf = YAML.load_file("#{RAILS_ROOT}/config/confluence.yml")[RAILS_ENV] @url = conf['url'] || conf[:url] @default_service = conf['service'] || conf[:service] @admin_proxy_username = conf['admin_proxy_username'] || conf[:admin_proxy_username] @admin_proxy_password = conf['admin_proxy_password'] || conf[:admin_proxy_password] # take these params manually if that's what is sent @username = conf['username'] || conf[:username] || @admin_proxy_username @password = conf['password'] || conf[:password] || @admin_proxy_password end |