c3s 0.2.4 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Manifest CHANGED
@@ -1,6 +1,7 @@
1
1
  Manifest
2
2
  README.rdoc
3
3
  Rakefile
4
+ c3s.gemspec
4
5
  lib/c3s.rb
5
6
  lib/c3s_logger.rb
6
7
  lib/component.rb
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'rake'
3
3
  require 'echoe'
4
4
 
5
- Echoe.new('c3s', '0.2.4') do |p|
5
+ Echoe.new('c3s', '0.2.5') do |p|
6
6
  p.description = "C3s library gem."
7
7
  p.url = "http://github.com/rikas/c3s"
8
8
  p.author = "Ricardo Otero"
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.4"
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-05}
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", "c3s.gemspec"]
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
@@ -18,7 +18,9 @@ require 'configreader'
18
18
  require 'databaseadapter'
19
19
  require 'c3s_logger'
20
20
 
21
- module C3s
21
+ module C3s
22
+ VERSION = "0.2.5"
23
+
22
24
  def self.included(base)
23
25
  base.extend ClassMethods
24
26
  end
@@ -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
- puts "Connecting to database '#{@db_config['database']}'"
28
- begin
29
- # activerecord connection
30
- DatabaseAdapter.new(@db_config)
31
- # raises exception if not connected
32
- ActiveRecord::Base.retrieve_connection
33
- rescue Exception => e
34
- puts "Error: #{e}"
35
- exit
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 Exception => e
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
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-05 00:00:00 +00:00
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: []