active_cmis 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -25,6 +25,7 @@ begin
25
25
  gemspec.add_runtime_dependency 'nokogiri', '>= 1.4.1'
26
26
 
27
27
  gemspec.required_ruby_version = '>= 1.8.6'
28
+ gemspec.files.exclude '.gitignore'
28
29
  end
29
30
  Jeweler::GemcutterTasks.new
30
31
  rescue LoadError
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.3
1
+ 0.1.4
@@ -5,8 +5,6 @@ module ActiveCMIS
5
5
  @default_logger ||= Logger.new(nil)
6
6
  end
7
7
 
8
- # Will search for a given configuration in a file, and return the equivalent Repository
9
- #
10
8
  # server_url and repository_id are required options
11
9
  #
12
10
  # server_login, server_password and server_auth can be used to authenticate against the server,
@@ -22,6 +20,47 @@ module ActiveCMIS
22
20
  #
23
21
  # Default locations for the config file are: ./cmis.yml and .cmis.yml in that order
24
22
  # @return [Repository]
23
+ def self.connect(config)
24
+ if config.is_a? Hash
25
+ if config.has_key? "log_file"
26
+ trace_file = config["trace_file"]
27
+ if trace_file == "-"
28
+ trace_file = STDOUT
29
+ end
30
+ logger = Logger.new(trace_file)
31
+ else
32
+ logger = default_logger
33
+ end
34
+ if config.has_key? "log_level"
35
+ logger.level = Logger.const_get(config["trace_level"].upcase) rescue config["trace_level"].to_i
36
+ else
37
+ logger.level = Logger::WARN
38
+ end
39
+
40
+ server = Server.new(config["server_url"], logger)
41
+ if user_name = config["server_login"] and password = config["server_password"]
42
+ auth_type = config["server_auth"] || :basic
43
+ server.authenticate(auth_type, user_name, password)
44
+ end
45
+ repository = server.repository(config["repository_id"])
46
+ if user_name = config["repository_login"] and password = config["repository_password"]
47
+ auth_type = config["repository_auth"] || :basic
48
+ repository.authenticate(auth_type, user_name, password)
49
+ end
50
+ return repository
51
+ elsif config.nil?
52
+ raise "Configuration not found in file"
53
+ else
54
+ raise "Configuration does not have correct format (not a hash)"
55
+ end
56
+ end
57
+
58
+ # Will search for a given configuration in a file, and return the equivalent Repository
59
+ #
60
+ # The options that can be used are the same as for the connect method
61
+ #
62
+ # Default locations for the config file are: ./cmis.yml and .cmis.yml in that order
63
+ # @return [Repository]
25
64
  def self.load_config(config_name, file = nil)
26
65
  if file.nil?
27
66
  ["cmis.yml", File.join(ENV["HOME"], ".cmis.yml")].each do |sl|
@@ -39,38 +78,7 @@ module ActiveCMIS
39
78
  config = YAML.load_file(file)
40
79
  if config.is_a? Hash
41
80
  config = config[config_name]
42
- if config.is_a? Hash
43
- if config.has_key? "log_file"
44
- trace_file = config["trace_file"]
45
- if trace_file == "-"
46
- trace_file = STDOUT
47
- end
48
- logger = Logger.new(trace_file)
49
- else
50
- logger = default_logger
51
- end
52
- if config.has_key? "log_level"
53
- logger.level = Logger.const_get(config["trace_level"].upcase) rescue config["trace_level"].to_i
54
- else
55
- logger.level = Logger::WARN
56
- end
57
-
58
- server = Server.new(config["server_url"], logger)
59
- if user_name = config["server_login"] and password = config["server_password"]
60
- auth_type = config["server_auth"] || :basic
61
- server.authenticate(auth_type, user_name, password)
62
- end
63
- repository = server.repository(config["repository_id"])
64
- if user_name = config["repository_login"] and password = config["repository_password"]
65
- auth_type = config["repository_auth"] || :basic
66
- repository.authenticate(auth_type, user_name, password)
67
- end
68
- return repository
69
- elsif config.nil?
70
- raise "Configuration not found in file"
71
- else
72
- raise "Configuration does not have right format (not a hash)"
73
- end
81
+ connect(config[config_name])
74
82
  else
75
83
  raise "Configuration file does not have right format (not a hash)"
76
84
  end
metadata CHANGED
@@ -1,48 +1,38 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: active_cmis
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 1
8
- - 3
9
- version: 0.1.3
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.4
5
+ prerelease: !!null
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Joeri Samson
13
- autorequire:
9
+ autorequire: !!null
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2010-10-20 00:00:00 +02:00
18
- default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2011-02-28 00:00:00.000000000 +01:00
13
+ default_executable: !!null
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
21
16
  name: nokogiri
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- segments:
28
- - 1
29
- - 4
30
- - 1
17
+ requirement: &73028210 !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
31
22
  version: 1.4.1
32
23
  type: :runtime
33
- version_requirements: *id001
34
- description: A CMIS library implementing both reading and updating capabilities through the AtomPub/REST binding to CMIS.
24
+ prerelease: false
25
+ version_requirements: *73028210
26
+ description: A CMIS library implementing both reading and updating capabilities through
27
+ the AtomPub/REST binding to CMIS.
35
28
  email: joeri@xaop.com
36
29
  executables: []
37
-
38
30
  extensions: []
39
-
40
- extra_rdoc_files:
31
+ extra_rdoc_files:
41
32
  - LICENSE
42
33
  - README.md
43
34
  - TODO
44
- files:
45
- - .gitignore
35
+ files:
46
36
  - LICENSE
47
37
  - README.md
48
38
  - Rakefile
@@ -74,34 +64,27 @@ files:
74
64
  has_rdoc: true
75
65
  homepage: http://xaop.com/labs/activecmis/
76
66
  licenses: []
77
-
78
- post_install_message:
79
- rdoc_options:
67
+ post_install_message: !!null
68
+ rdoc_options:
80
69
  - --charset=UTF-8
81
- require_paths:
70
+ require_paths:
82
71
  - lib
83
- required_ruby_version: !ruby/object:Gem::Requirement
84
- requirements:
85
- - - ">="
86
- - !ruby/object:Gem::Version
87
- segments:
88
- - 1
89
- - 8
90
- - 6
72
+ required_ruby_version: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
91
77
  version: 1.8.6
92
- required_rubygems_version: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- segments:
97
- - 0
98
- version: "0"
78
+ required_rubygems_version: !ruby/object:Gem::Requirement
79
+ none: false
80
+ requirements:
81
+ - - ! '>='
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
99
84
  requirements: []
100
-
101
- rubyforge_project:
102
- rubygems_version: 1.3.6
103
- signing_key:
85
+ rubyforge_project: !!null
86
+ rubygems_version: 1.5.0
87
+ signing_key: !!null
104
88
  specification_version: 3
105
89
  summary: A library to interact with CMIS repositories through the AtomPub/REST binding
106
90
  test_files: []
107
-
data/.gitignore DELETED
@@ -1,3 +0,0 @@
1
- doc
2
- .yardoc
3
- pkg