Module: ActiveCMIS
- Defined in:
- lib/active_cmis/ns.rb,
lib/active_cmis/acl.rb,
lib/active_cmis/rel.rb,
lib/active_cmis/type.rb,
lib/active_cmis/folder.rb,
lib/active_cmis/object.rb,
lib/active_cmis/policy.rb,
lib/active_cmis/server.rb,
lib/active_cmis/document.rb,
lib/active_cmis/acl_entry.rb,
lib/active_cmis/rendition.rb,
lib/active_cmis/collection.rb,
lib/active_cmis/exceptions.rb,
lib/active_cmis/repository.rb,
lib/active_cmis/active_cmis.rb,
lib/active_cmis/atomic_types.rb,
lib/active_cmis/relationship.rb,
lib/active_cmis/internal/utils.rb,
lib/active_cmis/attribute_prefix.rb,
lib/active_cmis/internal/caching.rb,
lib/active_cmis/internal/connection.rb,
lib/active_cmis/property_definition.rb
Defined Under Namespace
Modules: AtomicType, Internal, NS, Rel, Type Classes: Acl, AclEntry, AttributePrefix, Collection, Document, Error, Folder, HTTPError, Object, Policy, PropertyDefinition, Relationship, Rendition, Repository, Server
Class Method Summary collapse
-
.default_logger ⇒ Logger
Default logger: Outputs to STDOUT and has level set to DEBUG.
-
.load_config(config_name, file = nil) ⇒ Repository
Will search for a given configuration in a file, and return the equivalent Repository.
Class Method Details
.default_logger ⇒ Logger
Default logger: Outputs to STDOUT and has level set to DEBUG
4 5 6 |
# File 'lib/active_cmis/active_cmis.rb', line 4 def self.default_logger @default_logger ||= Logger.new(STDOUT) end |
.load_config(config_name, file = nil) ⇒ Repository
Will search for a given configuration in a file, and return the equivalent Repository
server_url and repository_id are required options
server_login, server_password and server_auth can be used to authenticate against the server, server_auth is optional and defaults to :basic
You can also authenticate to the repository, by replacing server_ with repository_, by default the repository will use the same authentication parameters as the server
The amoung of logging can be configured by setting log_level (default WARN), this can be done either by naming a Logger::Severity constant or the equivalent integer
The destination of the logger output can be set with log_file (defaults to STDOUT), (should not contain ~)
Default locations for the config file are: ./cmis.yml and .cmis.yml in that order
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/active_cmis/active_cmis.rb', line 25 def self.load_config(config_name, file = nil) if file.nil? ["cmis.yml", File.join(ENV["HOME"], ".cmis.yml")].each do |sl| if File.exist?(sl) file ||= sl end end if file.nil? raise "No configuration provided, and none found in standard locations" end elsif !File.exist?(file) raise "Configuration file #{file} does not exist" end config = YAML.load_file(file) if config.is_a? Hash config = config[config_name] if config.is_a? Hash if config.has_key? "log_file" logger = Logger.new(config["trace_file"]) else logger = default_logger end if config.has_key? "log_level" logger.level = Logger.const_get(config["trace_level"].upcase) rescue config["trace_level"].to_i else logger.level = Logger::WARN end server = Server.new(config["server_url"], logger) if user_name = config["server_login"] and password = config["server_password"] auth_type = config["server_auth"] || :basic server.authenticate(auth_type, user_name, password) end repository = server.repository(config["repository_id"]) if user_name = config["repository_login"] and password = config["repository_password"] auth_type = config["repository_auth"] || :basic repository.authenticate(auth_type, user_name, password) end return repository elsif config.nil? raise "Configuration not found in file" else raise "Configuration does not have right format (not a hash)" end else raise "Configuration file does not have right format (not a hash)" end end |