athena 0.2.1 → 0.2.2
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 +12 -2
- data/Rakefile +1 -1
- data/bin/athena +1 -1
- data/example/athena_plugin.rb +13 -0
- data/lib/athena.rb +54 -26
- data/lib/athena/cli.rb +18 -41
- data/lib/athena/formats.rb +363 -53
- data/lib/athena/formats/dbm.rb +2 -2
- data/lib/athena/formats/ferret.rb +4 -21
- data/lib/athena/formats/lingo.rb +58 -54
- data/lib/athena/formats/sisis.rb +2 -21
- data/lib/athena/formats/sql.rb +24 -45
- data/lib/athena/formats/xml.rb +36 -53
- data/lib/athena/record.rb +1 -3
- data/lib/athena/version.rb +1 -1
- metadata +24 -24
- data/lib/athena/parser.rb +0 -90
data/lib/athena/record.rb
CHANGED
@@ -54,9 +54,7 @@ module Athena
|
|
54
54
|
attr_reader :struct, :block, :id
|
55
55
|
|
56
56
|
def initialize(id = nil, block = nil, add = !block)
|
57
|
-
@id
|
58
|
-
@block = block
|
59
|
-
@struct = {}
|
57
|
+
@id, @block, @struct = id || object_id.map_positive, block, {}
|
60
58
|
|
61
59
|
add_record if add
|
62
60
|
|
data/lib/athena/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: athena
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 2
|
10
|
+
version: 0.2.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jens Wille
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2012-04-20 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: builder
|
@@ -53,12 +53,12 @@ dependencies:
|
|
53
53
|
requirements:
|
54
54
|
- - ">="
|
55
55
|
- !ruby/object:Gem::Version
|
56
|
-
hash:
|
56
|
+
hash: 61
|
57
57
|
segments:
|
58
58
|
- 0
|
59
|
-
-
|
60
|
-
-
|
61
|
-
version: 0.
|
59
|
+
- 8
|
60
|
+
- 1
|
61
|
+
version: 0.8.1
|
62
62
|
type: :runtime
|
63
63
|
version_requirements: *id003
|
64
64
|
description: Convert database files to various formats.
|
@@ -72,41 +72,41 @@ extra_rdoc_files:
|
|
72
72
|
- COPYING
|
73
73
|
- ChangeLog
|
74
74
|
files:
|
75
|
-
- lib/athena/
|
76
|
-
- lib/athena/
|
77
|
-
- lib/athena/formats/xml.rb
|
75
|
+
- lib/athena/version.rb
|
76
|
+
- lib/athena/formats.rb
|
78
77
|
- lib/athena/formats/lingo.rb
|
79
|
-
- lib/athena/formats/ferret.rb
|
80
78
|
- lib/athena/formats/dbm.rb
|
81
79
|
- lib/athena/formats/sql.rb
|
80
|
+
- lib/athena/formats/xml.rb
|
82
81
|
- lib/athena/formats/sisis.rb
|
83
|
-
- lib/athena/
|
84
|
-
- lib/athena/
|
85
|
-
- lib/athena/
|
82
|
+
- lib/athena/formats/ferret.rb
|
83
|
+
- lib/athena/cli.rb
|
84
|
+
- lib/athena/record.rb
|
86
85
|
- lib/athena.rb
|
87
86
|
- bin/athena
|
88
|
-
- README
|
89
87
|
- ChangeLog
|
90
|
-
- Rakefile
|
91
88
|
- COPYING
|
89
|
+
- README
|
90
|
+
- Rakefile
|
92
91
|
- example/dump-my.sql
|
93
|
-
- example/
|
92
|
+
- example/sisis-ex.txt
|
94
93
|
- example/dump-pg.sql
|
94
|
+
- example/config.yaml
|
95
95
|
- example/example.xml
|
96
|
-
- example/
|
96
|
+
- example/athena_plugin.rb
|
97
97
|
homepage: http://prometheus.rubyforge.org/athena
|
98
98
|
licenses: []
|
99
99
|
|
100
100
|
post_install_message:
|
101
101
|
rdoc_options:
|
102
|
-
- --all
|
103
|
-
- --main
|
104
|
-
- README
|
105
102
|
- --charset
|
106
103
|
- UTF-8
|
107
104
|
- --title
|
108
|
-
- athena Application documentation (v0.2.
|
105
|
+
- athena Application documentation (v0.2.2)
|
106
|
+
- --main
|
107
|
+
- README
|
109
108
|
- --line-numbers
|
109
|
+
- --all
|
110
110
|
require_paths:
|
111
111
|
- lib
|
112
112
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -130,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
130
130
|
requirements: []
|
131
131
|
|
132
132
|
rubyforge_project: prometheus
|
133
|
-
rubygems_version: 1.8.
|
133
|
+
rubygems_version: 1.8.23
|
134
134
|
signing_key:
|
135
135
|
specification_version: 3
|
136
136
|
summary: Convert database files to various formats.
|
data/lib/athena/parser.rb
DELETED
@@ -1,90 +0,0 @@
|
|
1
|
-
#--
|
2
|
-
###############################################################################
|
3
|
-
# #
|
4
|
-
# A component of athena, the database file converter. #
|
5
|
-
# #
|
6
|
-
# Copyright (C) 2007-2011 University of Cologne, #
|
7
|
-
# Albertus-Magnus-Platz, #
|
8
|
-
# 50923 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 Affero General Public License as published by the Free #
|
15
|
-
# Software Foundation; either version 3 of the License, or (at your option) #
|
16
|
-
# any later 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 Affero General Public License for #
|
21
|
-
# more details. #
|
22
|
-
# #
|
23
|
-
# You should have received a copy of the GNU Affero General Public License #
|
24
|
-
# along with athena. If not, see <http://www.gnu.org/licenses/>. #
|
25
|
-
# #
|
26
|
-
###############################################################################
|
27
|
-
#++
|
28
|
-
|
29
|
-
require 'athena'
|
30
|
-
|
31
|
-
module Athena
|
32
|
-
|
33
|
-
class Parser
|
34
|
-
|
35
|
-
DEFAULT_SEPARATOR = ', '
|
36
|
-
DEFAULT_EMPTY = '<<EMPTY>>'
|
37
|
-
|
38
|
-
attr_reader :config, :spec
|
39
|
-
|
40
|
-
def initialize(config, spec)
|
41
|
-
@config = build_config(config)
|
42
|
-
@spec = Formats[:in, spec].new(self)
|
43
|
-
end
|
44
|
-
|
45
|
-
def parse(source, &block)
|
46
|
-
res = spec.parse(source, &block)
|
47
|
-
res.is_a?(Numeric) ? res : Record.records
|
48
|
-
end
|
49
|
-
|
50
|
-
private
|
51
|
-
|
52
|
-
def build_config(config)
|
53
|
-
hash = {}
|
54
|
-
|
55
|
-
config.each { |field, value|
|
56
|
-
if field.to_s =~ /\A__/
|
57
|
-
hash[field] = value
|
58
|
-
else
|
59
|
-
case value
|
60
|
-
when String, Array
|
61
|
-
elements, value = [*value], {}
|
62
|
-
when Hash
|
63
|
-
elements = value[:elements] || value[:element].to_a
|
64
|
-
|
65
|
-
raise ArgumentError, "no elements specified for field #{field}" unless elements.is_a?(Array)
|
66
|
-
else
|
67
|
-
raise ArgumentError, "illegal value for field #{field}"
|
68
|
-
end
|
69
|
-
|
70
|
-
separator = value[:separator] || DEFAULT_SEPARATOR
|
71
|
-
|
72
|
-
elements.each { |element|
|
73
|
-
(hash[element] ||= {})[field] = {
|
74
|
-
:string => value[:string] || ['%s'] * elements.size * separator,
|
75
|
-
:empty => value[:empty] || DEFAULT_EMPTY,
|
76
|
-
:elements => elements
|
77
|
-
}
|
78
|
-
}
|
79
|
-
end
|
80
|
-
}
|
81
|
-
|
82
|
-
hash
|
83
|
-
end
|
84
|
-
|
85
|
-
class ConfigError < StandardError
|
86
|
-
end
|
87
|
-
|
88
|
-
end
|
89
|
-
|
90
|
-
end
|