c3s 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest +1 -0
- data/Rakefile +1 -1
- data/c3s.gemspec +3 -3
- data/lib/c3s.rb +3 -1
- data/lib/component_connection.rb +15 -12
- data/lib/configreader.rb +4 -2
- metadata +3 -3
data/Manifest
CHANGED
data/Rakefile
CHANGED
data/c3s.gemspec
CHANGED
@@ -2,15 +2,15 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{c3s}
|
5
|
-
s.version = "0.2.
|
5
|
+
s.version = "0.2.5"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Ricardo Otero"]
|
9
|
-
s.date = %q{2009-12-
|
9
|
+
s.date = %q{2009-12-09}
|
10
10
|
s.description = %q{C3s library gem.}
|
11
11
|
s.email = %q{oterosantos@gmail.com}
|
12
12
|
s.extra_rdoc_files = ["README.rdoc", "lib/c3s.rb", "lib/c3s_logger.rb", "lib/component.rb", "lib/component_connection.rb", "lib/configreader.rb", "lib/databaseadapter.rb", "lib/model.rb", "lib/nodetracker.rb", "lib/publisher.rb"]
|
13
|
-
s.files = ["Manifest", "README.rdoc", "Rakefile", "lib/c3s.rb", "lib/c3s_logger.rb", "lib/component.rb", "lib/component_connection.rb", "lib/configreader.rb", "lib/databaseadapter.rb", "lib/model.rb", "lib/nodetracker.rb", "lib/publisher.rb"
|
13
|
+
s.files = ["Manifest", "README.rdoc", "Rakefile", "c3s.gemspec", "lib/c3s.rb", "lib/c3s_logger.rb", "lib/component.rb", "lib/component_connection.rb", "lib/configreader.rb", "lib/databaseadapter.rb", "lib/model.rb", "lib/nodetracker.rb", "lib/publisher.rb"]
|
14
14
|
s.homepage = %q{http://github.com/rikas/c3s}
|
15
15
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "C3s", "--main", "README.rdoc"]
|
16
16
|
s.require_paths = ["lib"]
|
data/lib/c3s.rb
CHANGED
data/lib/component_connection.rb
CHANGED
@@ -4,35 +4,38 @@ module C3s
|
|
4
4
|
# The configuration file
|
5
5
|
CONFIG_FILE = "component.yml"
|
6
6
|
|
7
|
-
def initialize(componentclass)
|
7
|
+
def initialize(componentclass, options={})
|
8
|
+
@no_db = options[:no_db]
|
8
9
|
if !componentclass.superclass.eql?(C3s::Component)
|
9
10
|
puts "ERROR: #{componentclass} is not a valid C3s::Component!"
|
10
11
|
exit
|
11
12
|
end
|
12
13
|
|
13
|
-
reader = C3s::ConfigReader.new(CONFIG_FILE)
|
14
|
+
reader = C3s::ConfigReader.new(CONFIG_FILE, options)
|
14
15
|
puts "Reading configurations from '#{CONFIG_FILE}'..."
|
15
16
|
@server_config = reader.section('server')
|
16
17
|
@client_config = reader.section('client')
|
17
18
|
|
18
19
|
# a jid parameter is usefull, so lets merge it on client configuration
|
19
20
|
@client_config.merge!('jid' => @client_config['name']+"."+@server_config['url'])
|
20
|
-
@db_config = reader.section('db')
|
21
|
+
@db_config = reader.section('db') if !@no_db
|
21
22
|
|
22
23
|
puts "Creating new location component with jid '#{@client_config['jid']}'..."
|
23
24
|
@component = componentclass.new(@server_config.merge(@client_config))
|
24
25
|
end
|
25
26
|
|
26
27
|
def start
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
28
|
+
if !@no_db
|
29
|
+
puts "Connecting to database '#{@db_config['database']}'"
|
30
|
+
begin
|
31
|
+
# activerecord connection
|
32
|
+
DatabaseAdapter.new(@db_config)
|
33
|
+
# raises exception if not connected
|
34
|
+
ActiveRecord::Base.retrieve_connection
|
35
|
+
rescue Exception => e
|
36
|
+
puts "Error: #{e}"
|
37
|
+
exit
|
38
|
+
end
|
36
39
|
end
|
37
40
|
connect()
|
38
41
|
end
|
data/lib/configreader.rb
CHANGED
@@ -9,10 +9,12 @@ module C3s
|
|
9
9
|
##
|
10
10
|
# Reads the configuration file
|
11
11
|
# file::[String] the configuration file
|
12
|
-
def initialize(file)
|
12
|
+
def initialize(file, options={})
|
13
13
|
@config = YAML::load_file(File.join(file))
|
14
|
+
|
15
|
+
SECTIONS.delete('db') if options[:no_db]
|
14
16
|
check_config
|
15
|
-
rescue
|
17
|
+
rescue Errno::ENOENT => e
|
16
18
|
fatal_error("Could not find the configuration file '#{file}'")
|
17
19
|
end
|
18
20
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: c3s
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ricardo Otero
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-12-
|
12
|
+
date: 2009-12-09 00:00:00 +00:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -34,6 +34,7 @@ files:
|
|
34
34
|
- Manifest
|
35
35
|
- README.rdoc
|
36
36
|
- Rakefile
|
37
|
+
- c3s.gemspec
|
37
38
|
- lib/c3s.rb
|
38
39
|
- lib/c3s_logger.rb
|
39
40
|
- lib/component.rb
|
@@ -43,7 +44,6 @@ files:
|
|
43
44
|
- lib/model.rb
|
44
45
|
- lib/nodetracker.rb
|
45
46
|
- lib/publisher.rb
|
46
|
-
- c3s.gemspec
|
47
47
|
has_rdoc: true
|
48
48
|
homepage: http://github.com/rikas/c3s
|
49
49
|
licenses: []
|