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/version.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/query_result.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, Version Classes: Acl, AclEntry, AttributePrefix, Collection, Document, Error, Folder, HTTPError, Object, Policy, PropertyDefinition, QueryResult, Relationship, Rendition, Repository, Server
Class Method Summary collapse
-
.connect(config) ⇒ Repository
server_url and repository_id are required options.
-
.default_logger ⇒ Logger
Default logger: no output.
-
.load_config(config_name, file = nil) ⇒ Repository
Will search for a given configuration in a file, and return the equivalent Repository.
Class Method Details
.connect(config) ⇒ 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
23 24 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 |
# File 'lib/active_cmis/active_cmis.rb', line 23 def self.connect(config) if config.is_a? Hash if config.has_key? "log_file" trace_file = config["log_file"] if trace_file == "-" trace_file = STDOUT end logger = Logger.new(trace_file) else logger = default_logger end if config.has_key? "log_level" logger.level = (Logger.const_get(config["log_level"].upcase) rescue config["log_level"].to_i) else logger.level = Logger::WARN end if user_name = config["server_login"] and password = config["server_password"] auth_type = config["server_auth"] || :basic authentication_info = [auth_type, user_name, password] end server = Server.new(config["server_url"], logger, authentication_info) if user_name = config["repository_login"] and password = config["repository_password"] auth_type = config["repository_auth"] || :basic authentication_info = [auth_type, user_name, password] end repository = server.repository(config["repository_id"], authentication_info) return repository else raise "Configuration does not have correct format (#{config.class} is not a hash)" end end |
.default_logger ⇒ Logger
Default logger: no output
4 5 6 |
# File 'lib/active_cmis/active_cmis.rb', line 4 def self.default_logger @default_logger ||= Logger.new(nil) end |
.load_config(config_name, file = nil) ⇒ Repository
Will search for a given configuration in a file, and return the equivalent Repository
The options that can be used are the same as for the connect method
Default locations for the config file are: ./cmis.yml and .cmis.yml in that order
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/active_cmis/active_cmis.rb', line 62 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 if config = config[config_name] connect(config) else raise "Configuration not found in file" end else raise "Configuration file #{file} does not have right format (not a hash)" end end |