blackwinter-athena 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,107 @@
1
+ #--
2
+ ###############################################################################
3
+ # #
4
+ # A component of athena, the database file converter. #
5
+ # #
6
+ # Copyright (C) 2007-2008 University of Cologne, #
7
+ # Albertus-Magnus-Platz, #
8
+ # 50932 Cologne, Germany #
9
+ # #
10
+ # Authors: #
11
+ # Jens Wille <jens.wille@uni-koeln.de> #
12
+ # #
13
+ # athena is free software; you can redistribute it and/or modify it under the #
14
+ # terms of the GNU General Public License as published by the Free Software #
15
+ # Foundation; either version 3 of the License, or (at your option) any later #
16
+ # version. #
17
+ # #
18
+ # athena is distributed in the hope that it will be useful, but WITHOUT ANY #
19
+ # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS #
20
+ # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more #
21
+ # details. #
22
+ # #
23
+ # You should have received a copy of the GNU General Public License along #
24
+ # with athena. If not, see <http://www.gnu.org/licenses/>. #
25
+ # #
26
+ ###############################################################################
27
+ #++
28
+
29
+ class Athena::Record
30
+
31
+ include Athena::Util
32
+
33
+ @records = []
34
+
35
+ class << self
36
+
37
+ def records
38
+ @records
39
+ end
40
+
41
+ def [](field = nil, config = nil)
42
+ record = records.last
43
+ raise NoRecordError unless record
44
+
45
+ record.fill(field, config) if field && config
46
+ record
47
+ end
48
+
49
+ end
50
+
51
+ attr_reader :struct, :block, :id
52
+
53
+ def initialize(block, id = object_id.abs)
54
+ @struct = {}
55
+ @block = block
56
+ @id = id
57
+
58
+ add_record
59
+
60
+ if block_given?
61
+ begin
62
+ yield self
63
+ ensure
64
+ close
65
+ end
66
+ end
67
+ end
68
+
69
+ def fill(field, config)
70
+ struct[field] ||= config.merge({ :values => Hash.new { |h, k| h[k] = [] } })
71
+ end
72
+
73
+ def update(element, data, field_config = nil)
74
+ if field_config
75
+ field_config.each { |field, config|
76
+ fill(field, config)
77
+ }
78
+ end
79
+
80
+ struct.each_key { |field|
81
+ verbose(:data) do
82
+ value = data.strip
83
+ spit "#{field.to_s.upcase}[#{element}] << #{value}" unless value.empty?
84
+ end
85
+
86
+ struct[field][:values][element] << data
87
+ }
88
+ end
89
+
90
+ def close
91
+ block ? block[self] : self
92
+ end
93
+
94
+ def to(format)
95
+ Athena::Formats[:out, format].convert(self)
96
+ end
97
+
98
+ private
99
+
100
+ def add_record
101
+ self.class.records << self
102
+ end
103
+
104
+ class NoRecordError < StandardError
105
+ end
106
+
107
+ end
@@ -0,0 +1,46 @@
1
+ #--
2
+ ###############################################################################
3
+ # #
4
+ # A component of athena, the database file converter. #
5
+ # #
6
+ # Copyright (C) 2007-2008 University of Cologne, #
7
+ # Albertus-Magnus-Platz, #
8
+ # 50932 Cologne, Germany #
9
+ # #
10
+ # Authors: #
11
+ # Jens Wille <jens.wille@uni-koeln.de> #
12
+ # #
13
+ # athena is free software; you can redistribute it and/or modify it under the #
14
+ # terms of the GNU General Public License as published by the Free Software #
15
+ # Foundation; either version 3 of the License, or (at your option) any later #
16
+ # version. #
17
+ # #
18
+ # athena is distributed in the hope that it will be useful, but WITHOUT ANY #
19
+ # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS #
20
+ # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more #
21
+ # details. #
22
+ # #
23
+ # You should have received a copy of the GNU General Public License along #
24
+ # with athena. If not, see <http://www.gnu.org/licenses/>. #
25
+ # #
26
+ ###############################################################################
27
+ #++
28
+
29
+ module Athena::Util
30
+
31
+ extend self
32
+
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
+ }
41
+
42
+ instance_eval(&block)
43
+ end
44
+ end
45
+
46
+ end
@@ -0,0 +1,51 @@
1
+ #--
2
+ ###############################################################################
3
+ # #
4
+ # A component of athena, the database file converter. #
5
+ # #
6
+ # Copyright (C) 2007-2008 University of Cologne, #
7
+ # Albertus-Magnus-Platz, #
8
+ # 50932 Cologne, Germany #
9
+ # #
10
+ # Authors: #
11
+ # Jens Wille <jens.wille@uni-koeln.de> #
12
+ # #
13
+ # athena is free software; you can redistribute it and/or modify it under the #
14
+ # terms of the GNU General Public License as published by the Free Software #
15
+ # Foundation; either version 3 of the License, or (at your option) any later #
16
+ # version. #
17
+ # #
18
+ # athena is distributed in the hope that it will be useful, but WITHOUT ANY #
19
+ # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS #
20
+ # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more #
21
+ # details. #
22
+ # #
23
+ # You should have received a copy of the GNU General Public License along #
24
+ # with athena. If not, see <http://www.gnu.org/licenses/>. #
25
+ # #
26
+ ###############################################################################
27
+ #++
28
+
29
+ module Athena::Version
30
+
31
+ MAJOR = 0
32
+ MINOR = 0
33
+ TINY = 6
34
+
35
+ class << self
36
+
37
+ # Returns array representation.
38
+ def to_a
39
+ [MAJOR, MINOR, TINY]
40
+ end
41
+
42
+ # Short-cut for version string.
43
+ def to_s
44
+ to_a.join('.')
45
+ end
46
+
47
+ end
48
+
49
+ Athena::VERSION = to_s
50
+
51
+ end
data/lib/athena.rb ADDED
@@ -0,0 +1,75 @@
1
+ #--
2
+ ###############################################################################
3
+ # #
4
+ # athena -- Convert database files to various formats #
5
+ # #
6
+ # Copyright (C) 2007-2008 University of Cologne, #
7
+ # Albertus-Magnus-Platz, #
8
+ # 50932 Cologne, Germany #
9
+ # #
10
+ # Authors: #
11
+ # Jens Wille <jens.wille@uni-koeln.de> #
12
+ # #
13
+ # athena is free software; you can redistribute it and/or modify it under the #
14
+ # terms of the GNU General Public License as published by the Free Software #
15
+ # Foundation; either version 3 of the License, or (at your option) any later #
16
+ # version. #
17
+ # #
18
+ # athena is distributed in the hope that it will be useful, but WITHOUT ANY #
19
+ # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS #
20
+ # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more #
21
+ # details. #
22
+ # #
23
+ # You should have received a copy of the GNU General Public License along #
24
+ # with athena. If not, see <http://www.gnu.org/licenses/>. #
25
+ # #
26
+ ###############################################################################
27
+ #++
28
+
29
+ # Athena is a library to convert (mainly) prometheus database files to various
30
+ # output formats. It's accompanied by a corresponding script that gives access
31
+ # to all its converting features.
32
+ #
33
+ # In order to support additional input and/or output formats, Athena::Formats
34
+ # needs to be sub-classed and, respectively, an instance method _parse_ or a
35
+ # class method _convert_ supplied. This way, a specific format can even function
36
+ # as both input and output format.
37
+
38
+ module Athena
39
+ end
40
+
41
+ require 'athena/util'
42
+ require 'athena/parser'
43
+ require 'athena/record'
44
+ require 'athena/formats'
45
+ require 'athena/version'
46
+
47
+ module Athena
48
+
49
+ extend self
50
+
51
+ def parser(config, format)
52
+ Parser.new(config, format)
53
+ end
54
+
55
+ def input_formats
56
+ Formats.formats[:in].sort
57
+ end
58
+
59
+ def valid_input_format?(format)
60
+ Formats.valid_format?(:in, format)
61
+ end
62
+
63
+ def output_formats
64
+ Formats.formats[:out].sort
65
+ end
66
+
67
+ def valid_output_format?(format)
68
+ Formats.valid_format?(:out, format)
69
+ end
70
+
71
+ def deferred_output?(format)
72
+ Formats[:out, format].deferred?
73
+ end
74
+
75
+ end
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: blackwinter-athena
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.6
5
+ platform: ruby
6
+ authors:
7
+ - Jens Wille
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-12-03 00:00:00 -08:00
13
+ default_executable: athena
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: xmlstreamin
17
+ version_requirement:
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: "0"
23
+ version:
24
+ - !ruby/object:Gem::Dependency
25
+ name: ruby-nuggets
26
+ version_requirement:
27
+ version_requirements: !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ version: "0"
32
+ version:
33
+ description: Convert database files to various formats.
34
+ email: jens.wille@uni-koeln.de
35
+ executables:
36
+ - athena
37
+ extensions: []
38
+
39
+ extra_rdoc_files:
40
+ - COPYING
41
+ - ChangeLog
42
+ - README
43
+ files:
44
+ - lib/athena/formats.rb
45
+ - lib/athena/version.rb
46
+ - lib/athena/util.rb
47
+ - lib/athena/formats/sisis.rb
48
+ - lib/athena/formats/ferret.rb
49
+ - lib/athena/formats/xml.rb
50
+ - lib/athena/formats/dbm.rb
51
+ - lib/athena/formats/lingo.rb
52
+ - lib/athena/record.rb
53
+ - lib/athena/parser.rb
54
+ - lib/athena.rb
55
+ - bin/athena
56
+ - COPYING
57
+ - README
58
+ - ChangeLog
59
+ - Rakefile
60
+ - example/sisis-ex.txt
61
+ - example/config.yaml
62
+ - example/example.xml
63
+ has_rdoc: true
64
+ homepage: http://prometheus.rubyforge.org/athena
65
+ post_install_message:
66
+ rdoc_options:
67
+ - --inline-source
68
+ - --title
69
+ - athena Application documentation
70
+ - --charset
71
+ - UTF-8
72
+ - --main
73
+ - README
74
+ - --all
75
+ - --line-numbers
76
+ require_paths:
77
+ - lib
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: "0"
83
+ version:
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: "0"
89
+ version:
90
+ requirements: []
91
+
92
+ rubyforge_project: prometheus
93
+ rubygems_version: 1.2.0
94
+ signing_key:
95
+ specification_version: 2
96
+ summary: Convert database files to various formats.
97
+ test_files: []
98
+