athena 0.0.2.56 → 0.0.3.58

Sign up to get free protection for your applications and to get access to all the features.
data/lib/athena/parser.rb CHANGED
@@ -3,9 +3,9 @@
3
3
  # #
4
4
  # A component of athena, the database file converter. #
5
5
  # #
6
- # Copyright (C) 2007 University of Cologne, #
7
- # Albertus-Magnus-Platz, #
8
- # 50932 Cologne, Germany #
6
+ # Copyright (C) 2007-2008 University of Cologne, #
7
+ # Albertus-Magnus-Platz, #
8
+ # 50932 Cologne, Germany #
9
9
  # #
10
10
  # Authors: #
11
11
  # Jens Wille <jens.wille@uni-koeln.de> #
@@ -26,69 +26,65 @@
26
26
  ###############################################################################
27
27
  #++
28
28
 
29
- module Athena
29
+ class Athena::Parser
30
30
 
31
- class Parser
31
+ include Athena::Util
32
32
 
33
- include Util
33
+ DEFAULT_SEPARATOR = ', '
34
+ DEFAULT_EMPTY = '<<EMPTY>>'
34
35
 
35
- DEFAULT_SEPARATOR = ', '
36
- DEFAULT_EMPTY = '<<EMPTY>>'
36
+ attr_reader :config, :spec
37
+ attr_accessor :block
37
38
 
38
- attr_reader :config, :spec
39
- attr_accessor :block
40
-
41
- def initialize(config, spec)
42
- @config = build_config(config)
43
- @spec = Athena::Formats[:in, spec].new(self)
44
- end
39
+ def initialize(config, spec)
40
+ @config = build_config(config)
41
+ @spec = Athena::Formats[:in, spec].new(self)
42
+ end
45
43
 
46
- def parse(source, &block)
47
- self.block = block
44
+ def parse(source, &block)
45
+ self.block = block
48
46
 
49
- spec.parse(source)
50
- Athena::Record.records
51
- end
47
+ spec.parse(source)
48
+ Athena::Record.records
49
+ end
52
50
 
53
- private
51
+ private
52
+
53
+ def build_config(config)
54
+ config.inject({}) { |hash, (field, v)|
55
+ if field.to_s =~ /^__/
56
+ hash.merge(field => v)
57
+ else
58
+ case v
59
+ when String, Array
60
+ elements = [*v]
61
+ v = {}
62
+ when Hash
63
+ elements = v[:elements] || v[:element].to_a
64
+
65
+ raise ArgumentError, "no elements specified for field #{field}" \
66
+ unless elements.is_a?(Array)
67
+ else
68
+ raise ArgumentError, "illegal value for field #{field}"
69
+ end
54
70
 
55
- def build_config(config)
56
- config.inject({}) { |hash, (field, v)|
57
- if field.to_s =~ /^__/
58
- hash.merge(field => v)
59
- else
60
- case v
61
- when String, Array
62
- elements = [*v]
63
- v = {}
64
- when Hash
65
- elements = v[:elements] || v[:element].to_a
71
+ separator = v[:separator] || DEFAULT_SEPARATOR
66
72
 
67
- raise ArgumentError, "no elements specified for field #{field}" \
68
- unless elements.is_a?(Array)
69
- else
70
- raise ArgumentError, "illegal value for field #{field}"
73
+ elements.each { |element|
74
+ verbose(:config) do
75
+ spit "#{field.to_s.upcase} -> #{element}"
71
76
  end
72
77
 
73
- separator = v[:separator] || DEFAULT_SEPARATOR
74
-
75
- elements.each { |element|
76
- verbose(:config) do
77
- spit "#{field.to_s.upcase} -> #{element}"
78
- end
79
-
80
- (hash[element] ||= {})[field] = {
81
- :string => v[:string] || ['%s'] * elements.size * separator,
82
- :empty => v[:empty] || DEFAULT_EMPTY,
83
- :elements => elements
84
- }
78
+ (hash[element] ||= {})[field] = {
79
+ :string => v[:string] || ['%s'] * elements.size * separator,
80
+ :empty => v[:empty] || DEFAULT_EMPTY,
81
+ :elements => elements
85
82
  }
83
+ }
86
84
 
87
- hash
88
- end
89
- }
90
- end
91
-
85
+ hash
86
+ end
87
+ }
92
88
  end
93
89
 
94
90
  end
data/lib/athena/record.rb CHANGED
@@ -3,9 +3,9 @@
3
3
  # #
4
4
  # A component of athena, the database file converter. #
5
5
  # #
6
- # Copyright (C) 2007 University of Cologne, #
7
- # Albertus-Magnus-Platz, #
8
- # 50932 Cologne, Germany #
6
+ # Copyright (C) 2007-2008 University of Cologne, #
7
+ # Albertus-Magnus-Platz, #
8
+ # 50932 Cologne, Germany #
9
9
  # #
10
10
  # Authors: #
11
11
  # Jens Wille <jens.wille@uni-koeln.de> #
@@ -26,78 +26,74 @@
26
26
  ###############################################################################
27
27
  #++
28
28
 
29
- module Athena
29
+ class Athena::Record
30
30
 
31
- class Record
31
+ include Athena::Util
32
32
 
33
- include Util
33
+ @records = []
34
34
 
35
- @records = []
35
+ class << self
36
36
 
37
- class << self
38
-
39
- def records
40
- @records
41
- end
42
-
43
- def [](field = nil, config = nil)
44
- record = records.last
45
- raise NoRecordError unless record
37
+ def records
38
+ @records
39
+ end
46
40
 
47
- record.fill(field, config) if field && config
48
- record
49
- end
41
+ def [](field = nil, config = nil)
42
+ record = records.last
43
+ raise NoRecordError unless record
50
44
 
45
+ record.fill(field, config) if field && config
46
+ record
51
47
  end
52
48
 
53
- attr_reader :struct, :block, :id
54
-
55
- def initialize(block, id = object_id.abs)
56
- @struct = {}
57
- @block = block
58
- @id = id
49
+ end
59
50
 
60
- add_record
61
- end
51
+ attr_reader :struct, :block, :id
62
52
 
63
- def fill(field, config)
64
- struct[field] ||= config.merge({ :values => Hash.new { |h, k| h[k] = [] } })
65
- end
53
+ def initialize(block, id = object_id.abs)
54
+ @struct = {}
55
+ @block = block
56
+ @id = id
66
57
 
67
- def update(element, data, field_config = nil)
68
- if field_config
69
- field_config.each { |field, config|
70
- fill(field, config)
71
- }
72
- end
58
+ add_record
59
+ end
73
60
 
74
- struct.each_key { |field|
75
- verbose(:data) do
76
- value = data.strip
77
- spit "#{field.to_s.upcase}[#{element}] << #{value}" unless value.empty?
78
- end
61
+ def fill(field, config)
62
+ struct[field] ||= config.merge({ :values => Hash.new { |h, k| h[k] = [] } })
63
+ end
79
64
 
80
- struct[field][:values][element] << data
65
+ def update(element, data, field_config = nil)
66
+ if field_config
67
+ field_config.each { |field, config|
68
+ fill(field, config)
81
69
  }
82
70
  end
83
71
 
84
- def close
85
- block ? block[self] : self
86
- end
72
+ struct.each_key { |field|
73
+ verbose(:data) do
74
+ value = data.strip
75
+ spit "#{field.to_s.upcase}[#{element}] << #{value}" unless value.empty?
76
+ end
87
77
 
88
- def to(format)
89
- Athena::Formats[:out, format].convert(self)
90
- end
78
+ struct[field][:values][element] << data
79
+ }
80
+ end
91
81
 
92
- private
82
+ def close
83
+ block ? block[self] : self
84
+ end
93
85
 
94
- def add_record
95
- self.class.records << self
96
- end
86
+ def to(format)
87
+ Athena::Formats[:out, format].convert(self)
88
+ end
97
89
 
98
- class NoRecordError < StandardError
99
- end
90
+ private
91
+
92
+ def add_record
93
+ self.class.records << self
94
+ end
100
95
 
96
+ class NoRecordError < StandardError
101
97
  end
102
98
 
103
99
  end
data/lib/athena/util.rb CHANGED
@@ -3,9 +3,9 @@
3
3
  # #
4
4
  # A component of athena, the database file converter. #
5
5
  # #
6
- # Copyright (C) 2007 University of Cologne, #
7
- # Albertus-Magnus-Platz, #
8
- # 50932 Cologne, Germany #
6
+ # Copyright (C) 2007-2008 University of Cologne, #
7
+ # Albertus-Magnus-Platz, #
8
+ # 50932 Cologne, Germany #
9
9
  # #
10
10
  # Authors: #
11
11
  # Jens Wille <jens.wille@uni-koeln.de> #
@@ -26,25 +26,21 @@
26
26
  ###############################################################################
27
27
  #++
28
28
 
29
- module Athena
29
+ module Athena::Util
30
30
 
31
- module Util
31
+ extend self
32
32
 
33
- extend self
33
+ def verbose(what, klass = self.class, &block)
34
+ if $Verbose[what]
35
+ klass.send(:define_method, :spit) { |msg|
36
+ warn "*#{what}: #{msg}"
37
+ }
38
+ klass.send(:define_method, :indent) { |*level|
39
+ ' ' * (level.first || 0)
40
+ }
34
41
 
35
- def verbose(what, klass = self.class, &block)
36
- if $Verbose[what]
37
- klass.send(:define_method, :spit) { |msg|
38
- warn "*#{what}: #{msg}"
39
- }
40
- klass.send(:define_method, :indent) { |*level|
41
- ' ' * (level.first || 0)
42
- }
43
-
44
- instance_eval(&block)
45
- end
42
+ instance_eval(&block)
46
43
  end
47
-
48
44
  end
49
45
 
50
46
  end
@@ -3,9 +3,9 @@
3
3
  # #
4
4
  # A component of athena, the database file converter. #
5
5
  # #
6
- # Copyright (C) 2007 University of Cologne, #
7
- # Albertus-Magnus-Platz, #
8
- # 50932 Cologne, Germany #
6
+ # Copyright (C) 2007-2008 University of Cologne, #
7
+ # Albertus-Magnus-Platz, #
8
+ # 50932 Cologne, Germany #
9
9
  # #
10
10
  # Authors: #
11
11
  # Jens Wille <jens.wille@uni-koeln.de> #
@@ -26,30 +26,26 @@
26
26
  ###############################################################################
27
27
  #++
28
28
 
29
- module Athena
29
+ module Athena::Version
30
30
 
31
- module Version
31
+ MAJOR = 0
32
+ MINOR = 0
33
+ TINY = 3
32
34
 
33
- MAJOR = 0
34
- MINOR = 0
35
- TINY = 2
35
+ class << self
36
36
 
37
- class << self
38
-
39
- # Returns array representation.
40
- def to_a
41
- [MAJOR, MINOR, TINY]
42
- end
43
-
44
- # Short-cut for version string.
45
- def to_s
46
- to_a.join('.')
47
- end
37
+ # Returns array representation.
38
+ def to_a
39
+ [MAJOR, MINOR, TINY]
40
+ end
48
41
 
42
+ # Short-cut for version string.
43
+ def to_s
44
+ to_a.join('.')
49
45
  end
50
46
 
51
47
  end
52
48
 
53
- VERSION = Version.to_s
49
+ Athena::VERSION = to_s
54
50
 
55
51
  end
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.2.56
4
+ version: 0.0.3.58
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: 2008-01-08 00:00:00 +01:00
12
+ date: 2008-03-17 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -37,14 +37,15 @@ executables:
37
37
  extensions: []
38
38
 
39
39
  extra_rdoc_files:
40
- - README
41
40
  - COPYING
42
41
  - ChangeLog
42
+ - README
43
43
  files:
44
44
  - lib/athena/formats.rb
45
45
  - lib/athena/version.rb
46
46
  - lib/athena/util.rb
47
47
  - lib/athena/formats/sisis.rb
48
+ - lib/athena/formats/ferret.rb
48
49
  - lib/athena/formats/xml.rb
49
50
  - lib/athena/formats/dbm.rb
50
51
  - lib/athena/formats/lingo.rb
@@ -63,15 +64,15 @@ has_rdoc: true
63
64
  homepage: http://prometheus.rubyforge.org/athena
64
65
  post_install_message:
65
66
  rdoc_options:
66
- - --all
67
- - --inline-source
67
+ - --title
68
+ - athena Application documentation
68
69
  - --charset
69
70
  - UTF-8
70
71
  - --main
71
72
  - README
72
- - --title
73
- - athena Application documentation
74
73
  - --line-numbers
74
+ - --all
75
+ - --inline-source
75
76
  require_paths:
76
77
  - lib
77
78
  required_ruby_version: !ruby/object:Gem::Requirement