athena 0.0.7 → 0.0.8

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/README CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  == VERSION
4
4
 
5
- This documentation refers to athena version 0.0.7
5
+ This documentation refers to athena version 0.0.8
6
6
 
7
7
 
8
8
  == DESCRIPTION
@@ -15,7 +15,7 @@ TODO: well, the description... ;-)
15
15
  <b></b>
16
16
  Documentation:: <http://prometheus.rubyforge.org/athena>
17
17
  Source code (old):: <http://prometheus.rubyforge.org/svn/athena>
18
- Source code: <http://github.com/blackwinter/athena>
18
+ Source code:: <http://github.com/blackwinter/athena>
19
19
  Rubyforge project:: <http://rubyforge.org/projects/prometheus>
20
20
 
21
21
 
data/bin/athena CHANGED
@@ -5,7 +5,7 @@
5
5
  # #
6
6
  # athena -- Convert database files to various formats #
7
7
  # #
8
- # Copyright (C) 2007-2008 University of Cologne, #
8
+ # Copyright (C) 2007-2009 University of Cologne, #
9
9
  # Albertus-Magnus-Platz, #
10
10
  # 50932 Cologne, Germany #
11
11
  # #
@@ -165,19 +165,19 @@ abort "Config not found for target: #{target}." unless config
165
165
  parser = Athena.parser(config, spec)
166
166
 
167
167
  if Athena.deferred_output?(format)
168
- records = parser.parse(options[:input])
168
+ res = parser.parse(options[:input])
169
169
 
170
- records.map { |record|
170
+ res.map { |record|
171
171
  record.to(format)
172
172
  }.flatten.sort.uniq.each { |line|
173
173
  options[:output].puts line
174
174
  }
175
175
  else
176
- records = parser.parse(options[:input]) { |record|
176
+ res = parser.parse(options[:input]) { |record|
177
177
  options[:output].puts record.to(format)
178
178
  }
179
179
  end
180
180
 
181
181
  Athena::Util.verbose(:count) do
182
- spit records.size
182
+ spit res.is_a?(Numeric) ? res : res.size
183
183
  end
@@ -3,7 +3,7 @@
3
3
  # #
4
4
  # A component of athena, the database file converter. #
5
5
  # #
6
- # Copyright (C) 2007-2008 University of Cologne, #
6
+ # Copyright (C) 2007-2009 University of Cologne, #
7
7
  # Albertus-Magnus-Platz, #
8
8
  # 50932 Cologne, Germany #
9
9
  # #
@@ -48,7 +48,7 @@ class Athena::Formats
48
48
  when nil
49
49
  raise NoRecordElementError, 'no record element specified'
50
50
  else
51
- raise IllegalRecordElementError, "illegal record element #{@record_element}"
51
+ raise IllegalRecordElementError, "illegal record element #{@record_element.inspect}"
52
52
  end
53
53
 
54
54
  @config = config
@@ -3,7 +3,7 @@
3
3
  # #
4
4
  # A component of athena, the database file converter. #
5
5
  # #
6
- # Copyright (C) 2007-2008 University of Cologne, #
6
+ # Copyright (C) 2007-2009 University of Cologne, #
7
7
  # Albertus-Magnus-Platz, #
8
8
  # 50932 Cologne, Germany #
9
9
  # #
@@ -43,7 +43,7 @@ class Athena::Formats
43
43
  when nil
44
44
  raise NoRecordElementError, 'no record element specified'
45
45
  else
46
- raise IllegalRecordElementError, "illegal record element #{@record_element}"
46
+ raise IllegalRecordElementError, "illegal record element #{@record_element.inspect}"
47
47
  end
48
48
 
49
49
  @config = config
@@ -51,7 +51,7 @@ class Athena::Formats
51
51
  end
52
52
 
53
53
  def parse(source)
54
- record = nil
54
+ record, num = nil, 0
55
55
 
56
56
  source.each { |line|
57
57
  element, value = line.match(/(\d+).*?:\s*(.*)/)[1, 2]
@@ -60,12 +60,15 @@ class Athena::Formats
60
60
  when record_element
61
61
  record.close if record
62
62
  record = Athena::Record.new(parser.block, value)
63
+ num += 1
63
64
  else
64
65
  record.update(element, value, config[element])
65
66
  end
66
67
  }
67
68
 
68
69
  record.close if record
70
+
71
+ num
69
72
  end
70
73
 
71
74
  class NoRecordElementError < StandardError
@@ -3,7 +3,7 @@
3
3
  # #
4
4
  # A component of athena, the database file converter. #
5
5
  # #
6
- # Copyright (C) 2007-2008 University of Cologne, #
6
+ # Copyright (C) 2007-2009 University of Cologne, #
7
7
  # Albertus-Magnus-Platz, #
8
8
  # 50932 Cologne, Germany #
9
9
  # #
@@ -63,7 +63,7 @@ class Athena::Formats
63
63
  when nil
64
64
  raise NoRecordElementError, 'no record element specified'
65
65
  else
66
- raise IllegalRecordElementError, "illegal record element #{record_element}"
66
+ raise IllegalRecordElementError, "illegal record element #{record_element.inspect}"
67
67
  end
68
68
 
69
69
  element_specs = config.inject({}) { |specs, (element, element_spec)|
@@ -209,7 +209,7 @@ class Athena::Formats
209
209
  def start(context, name, attrs)
210
210
  super
211
211
 
212
- self.record = Athena::Record.new(parser.block)
212
+ self.record = Athena::Record.new(parser.block, nil, true)
213
213
  end
214
214
 
215
215
  def done(context, name)
@@ -45,7 +45,7 @@ class Athena::Parser
45
45
  self.block = block
46
46
 
47
47
  res = spec.parse(source)
48
- block ? res : Athena::Record.records
48
+ res.is_a?(Numeric) ? res : Athena::Record.records
49
49
  end
50
50
 
51
51
  private
@@ -62,8 +62,7 @@ class Athena::Parser
62
62
  when Hash
63
63
  elements = v[:elements] || v[:element].to_a
64
64
 
65
- raise ArgumentError, "no elements specified for field #{field}" \
66
- unless elements.is_a?(Array)
65
+ raise ArgumentError, "no elements specified for field #{field}" unless elements.is_a?(Array)
67
66
  else
68
67
  raise ArgumentError, "illegal value for field #{field}"
69
68
  end
@@ -50,12 +50,12 @@ class Athena::Record
50
50
 
51
51
  attr_reader :struct, :block, :id
52
52
 
53
- def initialize(block, id = object_id.abs)
53
+ def initialize(block, id = nil, _add_record = !block)
54
54
  @struct = {}
55
55
  @block = block
56
- @id = id
56
+ @id = id || object_id.abs
57
57
 
58
- add_record unless block
58
+ add_record if _add_record
59
59
 
60
60
  if block_given?
61
61
  begin
@@ -3,7 +3,7 @@
3
3
  # #
4
4
  # A component of athena, the database file converter. #
5
5
  # #
6
- # Copyright (C) 2007-2008 University of Cologne, #
6
+ # Copyright (C) 2007-2009 University of Cologne, #
7
7
  # Albertus-Magnus-Platz, #
8
8
  # 50932 Cologne, Germany #
9
9
  # #
@@ -31,7 +31,7 @@ module Athena::Util
31
31
  extend self
32
32
 
33
33
  def verbose(what, klass = self.class, &block)
34
- if $Verbose[what]
34
+ if $Verbose && $Verbose[what]
35
35
  klass.send(:define_method, :spit) { |msg|
36
36
  warn "*#{what}: #{msg}"
37
37
  }
@@ -30,7 +30,7 @@ module Athena::Version
30
30
 
31
31
  MAJOR = 0
32
32
  MINOR = 0
33
- TINY = 7
33
+ TINY = 8
34
34
 
35
35
  class << self
36
36
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: athena
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jens Wille
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-08-20 00:00:00 +02:00
12
+ date: 2009-08-21 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -68,15 +68,15 @@ licenses: []
68
68
 
69
69
  post_install_message:
70
70
  rdoc_options:
71
- - --line-numbers
72
71
  - --main
73
72
  - README
73
+ - --line-numbers
74
74
  - --inline-source
75
75
  - --title
76
76
  - athena Application documentation
77
+ - --all
77
78
  - --charset
78
79
  - UTF-8
79
- - --all
80
80
  require_paths:
81
81
  - lib
82
82
  required_ruby_version: !ruby/object:Gem::Requirement