athena 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c029a5754a067e303b4c673f9904c91531fe1504
4
- data.tar.gz: acc964603b8637cb8b1700225d50881a0d6e1b52
3
+ metadata.gz: d32f444096ae3b9f0ecdd6c038ee9a1ab0c1e8ed
4
+ data.tar.gz: 2ada4ab199db9a4c877a0a332542d8f74897cb9f
5
5
  SHA512:
6
- metadata.gz: c25e93d4cca0744459fa0650036eea7ce7ba4e20d14b1774234cb241ff0ac7d1c96a3cd1e34dfcbc18dbd2d4dcb16ce7450e28c1c12fdb282a3d7962c6297460
7
- data.tar.gz: a5f9d1e45d874eaab1b1e0a952b9cc9ae8e648e63bb064aa2fcbb821aa763bc31b8b86c0463d47197ac4e310a615d75351389bd8a7a95a8171c3b9b315986177
6
+ metadata.gz: 62845c8060a4e0df098029dbadb66606ae6fde1e721e821fb07126ceb43f4934eaa2ca18fcec3b0649ef44b4df0de450bbb289f72ae5ec7d005bcbc3b8aa1f88
7
+ data.tar.gz: 54cdbebac8a5b227f3433cdb3055a63ab8a22a28edf66c8a837225b086ac05dade548edf9c83cab5166dfec2e22b029fba270fbf3224b4215ab6c31757d347ba
data/README CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  == VERSION
4
4
 
5
- This documentation refers to athena version 0.2.4
5
+ This documentation refers to athena version 0.2.5
6
6
 
7
7
 
8
8
  == DESCRIPTION
@@ -23,9 +23,9 @@ placed in <tt>$LOAD_PATH</tt>. See Athena::Formats on how to define custom forma
23
23
  == LINKS
24
24
 
25
25
  <b></b>
26
- Documentation:: http://prometheus.rubyforge.org/athena
27
- Source code:: http://github.com/blackwinter/athena
28
- RubyForge project:: http://rubyforge.org/projects/prometheus
26
+ Documentation:: http://blackwinter.github.com/athena
27
+ Source code:: http://github.com/blackwinter/athena
28
+ RubyGem:: http://rubygems.org/gems/athena
29
29
 
30
30
 
31
31
  == AUTHORS
data/Rakefile CHANGED
@@ -4,17 +4,14 @@ begin
4
4
  require 'hen'
5
5
 
6
6
  Hen.lay! {{
7
- :rubyforge => {
8
- :project => %q{prometheus},
9
- :package => %q{athena}
10
- },
11
-
12
7
  :gem => {
8
+ :name => %q{athena},
13
9
  :version => Athena::VERSION,
14
10
  :summary => %q{Convert database files to various formats.},
15
11
  :author => %q{Jens Wille},
16
12
  :email => %q{jens.wille@gmail.com},
17
- :dependencies => %w[builder highline xmlstreamin] << ['ruby-nuggets', '>= 0.9.1']
13
+ :homepage => :blackwinter,
14
+ :dependencies => %w[builder highline xmlstreamin] << ['ruby-nuggets', '>= 0.9.2']
18
15
  }
19
16
  }}
20
17
  rescue LoadError => err
data/example/config.yaml CHANGED
@@ -79,3 +79,19 @@
79
79
  :attr3: [attr3ID, Val]
80
80
  :attr4: [attr4ID, Val]
81
81
  :dump-pg:
82
+ :midos-ex:
83
+ :__record_element: "000"
84
+ :language:
85
+ :elements: ["015"]
86
+ :separator: " / "
87
+ :title:
88
+ :elements:
89
+ - "331"
90
+ - "335"
91
+ :string: "%s: %s"
92
+ :empty: ">>n/a<<"
93
+ :date:
94
+ :elements:
95
+ - "424"
96
+ - "425"
97
+ :separator: ", "
@@ -0,0 +1,53 @@
1
+ 000:3
2
+ 001:000000003
3
+ 002:02.05.2001
4
+ 003:27.08.2002
5
+ 015:ger | lat
6
+ 036:m
7
+ 125:Blattmaß 38 x 30 cm; Hinterklebt ; Klebereste | Blattmaß 30 x 31,5 cm; Fragment: unterer Textteil fehlt teilweise
8
+ 331:Denckwürdiges Geheimnuß
9
+ 335:Teutsche Erklärung des Kupfferstücks
10
+ 370:Dum tua privato fessus das lumina somno | Einer/ oder gar drey müssen für das Volck sterben
11
+ 424:1620
12
+ 425:[ca. 1620]
13
+ 433:1 Bl.
14
+ 434:1 Ill.; Radierung 19,5 x 27,5 cm(nach einem Kupferstich von Gaspar Dooms)
15
+ 435:Satzspiegel 38 x 30 cm
16
+ 509:Verfasser ermittelt aus Nachweis
17
+ 511:Erscheinungsjahr ermittelt aus Inhalt und Nachweis
18
+ 720:Politisches Flugblatt | Prokaiserliches Flugblatt
19
+ &&&
20
+
21
+ 000:4
22
+ 001:000000004
23
+ 002:03.05.2001
24
+ 003:29.08.2002
25
+ 015:ger
26
+ 036:m
27
+ 331:Machometische Zanck= und Haderkatzen
28
+ 370:UNser Planet Ist Machomet, Saturnisch Thier Sind wir allhier
29
+ 424:1621
30
+ 425:1621
31
+ 433:1 Bl.
32
+ 434:1 Ill.; Kupferstich 14 x 24 cm
33
+ 435:Satzspiegel 30,5 x 24,5 cm
34
+ 720:Politische Flugblatt | Antiunionistisches Flugblatt
35
+ 721:Dreissigjähriger Krieg | Böhmisch-Pfälzischer Krieg
36
+ &&&
37
+
38
+ 000:5
39
+ 001:000000005
40
+ 002:03.05.2001
41
+ 003:29.08.2002
42
+ 015:ger
43
+ 036:m
44
+ 331:Alles hatt Sein Zeydt | -- Hää?
45
+ 424:1621
46
+ 425:[1621]
47
+ 433:1 Bl.
48
+ 434:1 Ill.; 16 x 27,5 cm
49
+ 435:Satspiegel 16 x 27,5 cm
50
+ 511:Erscheinungsjahr ermittelt aus Bildinhalt und Nachweis
51
+ 527:Andere Ausgabe: Einbl. V,8 b-8; Deutsche illustrierte Flugblätter des 16. und 17. Jahrhunderts
52
+ &&&
53
+
data/lib/athena.rb CHANGED
@@ -106,5 +106,5 @@ module Athena
106
106
 
107
107
  end
108
108
 
109
- require 'nuggets/util/pluggable'
110
- Util::Pluggable.load_plugins_for(Athena)
109
+ require 'nuggets/pluggable'
110
+ Nuggets::Pluggable.load_plugins_for(Athena)
data/lib/athena/cli.rb CHANGED
@@ -28,12 +28,12 @@
28
28
  ###############################################################################
29
29
  #++
30
30
 
31
- require 'nuggets/util/cli'
31
+ require 'nuggets/cli'
32
32
  require 'athena'
33
33
 
34
34
  module Athena
35
35
 
36
- class CLI < ::Util::CLI
36
+ class CLI < ::Nuggets::CLI
37
37
 
38
38
  class << self
39
39
 
@@ -57,12 +57,12 @@ module Athena
57
57
  abort "No output format specified and none could be inferred." unless format
58
58
  abort "Invalid output format: #{format}. Use `-l' to get a list of available formats." unless Athena.valid_output_format?(format)
59
59
 
60
- target_config = if t = options[:target]
61
- config[target = t.to_sym]
60
+ if t = options[:target]
61
+ target_config = config[target = t.to_sym]
62
62
  else
63
63
  [options[:target_fallback] || 'generic', ".#{spec}", ":#{format}"].inject([]) { |s, t|
64
64
  s << (s.last ? s.last + t : t)
65
- }.reverse.find { |t| config[target = t.to_sym] }
65
+ }.reverse.find { |t| target_config = config[target = t.to_sym] }
66
66
  end or abort "Config not found for target: #{target}."
67
67
 
68
68
  input = options[:input]
@@ -207,8 +207,6 @@ module Athena
207
207
  registered.compact
208
208
  end
209
209
 
210
- protected
211
-
212
210
  # call-seq:
213
211
  # Athena::Formats.format_name(name) -> aString
214
212
  #
@@ -28,21 +28,58 @@
28
28
  ###############################################################################
29
29
  #++
30
30
 
31
- require 'iconv'
32
31
  require 'athena'
32
+ require 'nuggets/midos'
33
33
 
34
34
  module Athena::Formats
35
35
 
36
36
  class DBM < Base
37
37
 
38
- VALUE_SEPARATOR = '|'
39
- RECORD_SEPARATOR = '&&&'
38
+ RECORD_SEPARATOR = Nuggets::Midos::Parser::DEFAULT_RS
39
+ FIELD_SEPARATOR = Nuggets::Midos::Parser::DEFAULT_FS
40
+ VALUE_SEPARATOR = Nuggets::Midos::Parser::DEFAULT_VS
41
+
42
+ TO_LATIN1 = begin
43
+ require 'iconv'
44
+ rescue LoadError
45
+ Object.new.tap { |x|
46
+ if ENV['ATHENA_DBM_NOCONV']
47
+ def x.iconv(s); s; end
48
+ else
49
+ def x.iconv(s); s.encode('iso-8859-1', 'utf-8'); end
50
+ end
51
+ }
52
+ else
53
+ iconv = Iconv.new('latin1//TRANSLIT//IGNORE', 'utf-8')
54
+ def iconv.iconv(s); s; end if ENV['ATHENA_DBM_NOCONV']
55
+ iconv
56
+ end
57
+
58
+ attr_reader :dbm_parser
59
+
60
+ def parse(input, &block)
61
+ num = 0
62
+
63
+ dbm_parser.parse(input) { |id, doc|
64
+ Athena::Record.new(id, block) { |record|
65
+ config.each { |element, field_config|
66
+ Array(doc[element]).each { |value|
67
+ record.update(element, value, field_config)
68
+ }
69
+ }
70
+ }
40
71
 
41
- ICONV_TO_LATIN1 = Iconv.new('latin1//TRANSLIT//IGNORE', 'utf-8')
42
- def ICONV_TO_LATIN1.iconv(s); s; end if ENV['ATHENA_DBM_NOCONV']
72
+ num += 1
73
+ }
74
+
75
+ num
76
+ end
43
77
 
44
78
  def convert(record)
45
- dbm = ["ID:#{record.id}"]
79
+ rs, fs, vs, crlf_re, iconv =
80
+ RECORD_SEPARATOR, FIELD_SEPARATOR, VALUE_SEPARATOR, CRLF_RE, TO_LATIN1
81
+
82
+ dbm = ["ID#{fs}#{record.id}"]
46
83
 
47
84
  record.struct.each { |field, struct|
48
85
  struct_values = struct[:values]
@@ -53,22 +90,30 @@ module Athena::Formats
53
90
 
54
91
  struct_values[element].each { |value|
55
92
  if value
56
- value = value.strip.gsub(CRLF_RE, ' ')
93
+ value = value.strip.gsub(crlf_re, ' ')
57
94
  values << value unless value.empty?
58
95
  end
59
96
  }
60
97
 
61
- values.empty? ? struct[:empty] : values.join(VALUE_SEPARATOR)
98
+ values.empty? ? struct[:empty] : values.join(vs)
62
99
  }
63
100
 
64
- dbm << "#{field.to_s.upcase}:#{ICONV_TO_LATIN1.iconv(struct[:string] % strings)}"
101
+ dbm << "#{field.to_s.upcase}#{fs}#{iconv.iconv(struct[:string] % strings)}"
65
102
  }
66
103
 
67
- dbm << RECORD_SEPARATOR << CRLF
104
+ dbm << rs << CRLF
68
105
 
69
106
  dbm.join(CRLF)
70
107
  end
71
108
 
109
+ private
110
+
111
+ def init_in(*)
112
+ @__record_element_ok__ = [String, nil]
113
+ super
114
+ @dbm_parser = Nuggets::Midos::Parser.new(:key => record_element)
115
+ end
116
+
72
117
  end
73
118
 
74
119
  Midos = DBM
@@ -28,7 +28,6 @@
28
28
  ###############################################################################
29
29
  #++
30
30
 
31
- require 'iconv'
32
31
  require 'enumerator'
33
32
  require 'athena'
34
33
 
@@ -67,7 +67,7 @@ module Athena::Formats
67
67
  def init_in(*)
68
68
  @__record_element_ok__ = [String, nil]
69
69
  super
70
- @sql_parser = Util::MySQL::Parser.new
70
+ @sql_parser = Nuggets::MySQL::Parser.new
71
71
  end
72
72
 
73
73
  end
@@ -4,7 +4,7 @@ module Athena
4
4
 
5
5
  MAJOR = 0
6
6
  MINOR = 2
7
- TINY = 4
7
+ TINY = 5
8
8
 
9
9
  class << self
10
10
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: athena
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
  - Jens Wille
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-03-12 00:00:00.000000000 Z
11
+ date: 2013-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: builder
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - '>='
60
60
  - !ruby/object:Gem::Version
61
- version: 0.9.1
61
+ version: 0.9.2
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - '>='
67
67
  - !ruby/object:Gem::Version
68
- version: 0.9.1
68
+ version: 0.9.2
69
69
  description: Convert database files to various formats.
70
70
  email: jens.wille@gmail.com
71
71
  executables:
@@ -97,8 +97,9 @@ files:
97
97
  - example/dump-my.sql
98
98
  - example/dump-pg.sql
99
99
  - example/example.xml
100
+ - example/midos-ex.dbm
100
101
  - example/sisis-ex.txt
101
- homepage: http://prometheus.rubyforge.org/athena
102
+ homepage: http://github.com/blackwinter/athena
102
103
  licenses: []
103
104
  metadata: {}
104
105
  post_install_message:
@@ -108,7 +109,7 @@ rdoc_options:
108
109
  - --line-numbers
109
110
  - --all
110
111
  - --title
111
- - athena Application documentation (v0.2.4)
112
+ - athena Application documentation (v0.2.5)
112
113
  - --main
113
114
  - README
114
115
  require_paths:
@@ -124,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
124
125
  - !ruby/object:Gem::Version
125
126
  version: '0'
126
127
  requirements: []
127
- rubyforge_project: prometheus
128
+ rubyforge_project:
128
129
  rubygems_version: 2.0.3
129
130
  signing_key:
130
131
  specification_version: 4