flattendb 0.1.3 → 0.2.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 33d368b4ee2cd36d0e968a8237b66bc349a49352
4
+ data.tar.gz: e578a7ac382877e76e0523364b7bbd1ffbf5c881
5
+ SHA512:
6
+ metadata.gz: fbf89d4936dd20e96717e94d2da16cdf35b6530ed1262cb325b44e63120334f6c5e1967e7afaf07b6fe300819b3b10d9ec41650aafd4240682900bfe1f358143
7
+ data.tar.gz: c2daea8bd1275ca1e5d2bd85c42d986452aef319acb34d871333fa0398b0697b1abdb51b81027bb35ac974e1f0dd63f23c0f4d5a5149710afbaddba32abd05df
data/README CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  == VERSION
4
4
 
5
- This documentation refers to flattendb version 0.1.3
5
+ This documentation refers to flattendb version 0.2.0
6
6
 
7
7
 
8
8
  == DESCRIPTION
@@ -20,14 +20,16 @@ RubyForge project:: http://rubyforge.org/projects/prometheus
20
20
 
21
21
  == AUTHORS
22
22
 
23
- * Jens Wille <mailto:jens.wille@uni-koeln.de>
23
+ * Jens Wille <mailto:jens.wille@gmail.com>
24
24
 
25
25
 
26
26
  == LICENSE AND COPYRIGHT
27
27
 
28
- Copyright (C) 2007-2011 University of Cologne,
28
+ Copyright (C) 2007-2012 University of Cologne,
29
29
  Albertus-Magnus-Platz, 50923 Cologne, Germany
30
30
 
31
+ Copyright (C) 2013 Jens Wille
32
+
31
33
  flattendb is free software: you can redistribute it and/or modify it under
32
34
  the terms of the GNU Affero General Public License as published by the Free
33
35
  Software Foundation, either version 3 of the License, or (at your option)
data/Rakefile CHANGED
@@ -13,8 +13,8 @@ begin
13
13
  :version => FlattenDB::VERSION,
14
14
  :summary => %q{Flatten relational databases.},
15
15
  :author => %q{Jens Wille},
16
- :email => %q{jens.wille@uni-koeln.de},
17
- :dependencies => %w[libxml-ruby builder] << ['ruby-nuggets', '>= 0.7.3'] << ['athena', '>= 0.1.5']
16
+ :email => %q{jens.wille@gmail.com},
17
+ :dependencies => %w[builder highline libxml-ruby] << ['ruby-nuggets', '>= 0.9.1']
18
18
  }
19
19
  }}
20
20
  rescue LoadError => err
data/bin/flattendb CHANGED
@@ -5,12 +5,14 @@
5
5
  # #
6
6
  # flattendb -- Flatten relational databases #
7
7
  # #
8
- # Copyright (C) 2007-2011 University of Cologne, #
8
+ # Copyright (C) 2007-2012 University of Cologne, #
9
9
  # Albertus-Magnus-Platz, #
10
10
  # 50923 Cologne, Germany #
11
11
  # #
12
+ # Copyright (C) 2013 Jens Wille #
13
+ # #
12
14
  # Authors: #
13
- # Jens Wille <jens.wille@uni-koeln.de> #
15
+ # Jens Wille <jens.wille@gmail.com> #
14
16
  # #
15
17
  # flattendb is free software; you can redistribute it and/or modify it under #
16
18
  # the terms of the GNU Affero General Public License as published by the Free #
@@ -9,6 +9,8 @@
9
9
  /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
10
10
  /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
11
11
 
12
+ USE `ndr`;
13
+
12
14
  DROP TABLE IF EXISTS `object`;
13
15
  /*!40101 SET @saved_cs_client = @@character_set_client */;
14
16
  /*!40101 SET character_set_client = utf8 */;
@@ -2,11 +2,11 @@ object:
2
2
  attr1: ObjID
3
3
  attr2: ObjID
4
4
  fooobject:
5
- @key: ObjID
5
+ :@key: ObjID
6
6
  attr1: attr1ID
7
7
  attr3: attr3ID
8
8
  barobject:
9
- @key: ObjID
9
+ :@key: ObjID
10
10
  attr4: attr4ID
11
11
 
12
12
  #primary_table:
@@ -3,12 +3,14 @@
3
3
  # #
4
4
  # A component of flattendb, the relational database flattener. #
5
5
  # #
6
- # Copyright (C) 2007-2011 University of Cologne, #
6
+ # Copyright (C) 2007-2012 University of Cologne, #
7
7
  # Albertus-Magnus-Platz, #
8
8
  # 50923 Cologne, Germany #
9
9
  # #
10
+ # Copyright (C) 2013 Jens Wille #
11
+ # #
10
12
  # Authors: #
11
- # Jens Wille <jens.wille@uni-koeln.de> #
13
+ # Jens Wille <jens.wille@gmail.com> #
12
14
  # #
13
15
  # flattendb is free software; you can redistribute it and/or modify it under #
14
16
  # the terms of the GNU Affero General Public License as published by the Free #
data/lib/flattendb/cli.rb CHANGED
@@ -3,12 +3,14 @@
3
3
  # #
4
4
  # A component of flattendb, the relational database flattener. #
5
5
  # #
6
- # Copyright (C) 2007-2011 University of Cologne, #
6
+ # Copyright (C) 2007-2012 University of Cologne, #
7
7
  # Albertus-Magnus-Platz, #
8
8
  # 50923 Cologne, Germany #
9
9
  # #
10
+ # Copyright (C) 2013 Jens Wille #
11
+ # #
10
12
  # Authors: #
11
- # Jens Wille <jens.wille@uni-koeln.de> #
13
+ # Jens Wille <jens.wille@gmail.com> #
12
14
  # #
13
15
  # flattendb is free software; you can redistribute it and/or modify it under #
14
16
  # the terms of the GNU Affero General Public License as published by the Free #
@@ -3,12 +3,14 @@
3
3
  # #
4
4
  # A component of flattendb, the relational database flattener. #
5
5
  # #
6
- # Copyright (C) 2007-2011 University of Cologne, #
6
+ # Copyright (C) 2007-2012 University of Cologne, #
7
7
  # Albertus-Magnus-Platz, #
8
8
  # 50923 Cologne, Germany #
9
9
  # #
10
+ # Copyright (C) 2013 Jens Wille #
11
+ # #
10
12
  # Authors: #
11
- # Jens Wille <jens.wille@uni-koeln.de> #
13
+ # Jens Wille <jens.wille@gmail.com> #
12
14
  # #
13
15
  # flattendb is free software; you can redistribute it and/or modify it under #
14
16
  # the terms of the GNU Affero General Public License as published by the Free #
@@ -3,12 +3,14 @@
3
3
  # #
4
4
  # A component of flattendb, the relational database flattener. #
5
5
  # #
6
- # Copyright (C) 2007-2011 University of Cologne, #
6
+ # Copyright (C) 2007-2012 University of Cologne, #
7
7
  # Albertus-Magnus-Platz, #
8
8
  # 50923 Cologne, Germany #
9
9
  # #
10
+ # Copyright (C) 2013 Jens Wille #
11
+ # #
10
12
  # Authors: #
11
- # Jens Wille <jens.wille@uni-koeln.de> #
13
+ # Jens Wille <jens.wille@gmail.com> #
12
14
  # #
13
15
  # flattendb is free software; you can redistribute it and/or modify it under #
14
16
  # the terms of the GNU Affero General Public License as published by the Free #
@@ -27,14 +29,14 @@
27
29
  #++
28
30
 
29
31
  require 'libxml'
30
- require 'athena'
32
+ require 'nuggets/util/mysql'
31
33
  require 'flattendb'
32
34
 
33
35
  module FlattenDB
34
36
 
35
37
  class MySQL < Base
36
38
 
37
- JOIN_KEY = '@key'
39
+ JOIN_KEY = :@key
38
40
 
39
41
  attr_reader :type, :name, :tables, :builder
40
42
 
@@ -97,38 +99,23 @@ module FlattenDB
97
99
  end
98
100
 
99
101
  def parse_sql(tables)
100
- columns, table, name = Hash.new { |h, k| h[k] = [] }, nil, nil
101
- parser = Athena::Formats::MySQL::SQLParser.new
102
+ name = nil
102
103
 
103
- input.each { |line|
104
- case line
105
- when /\AUSE\s+`(.+?)`/i
104
+ Util::MySQL::Parser.parse(input) { |event, *args|
105
+ case event
106
+ when :use
106
107
  raise 'dump file contains more than one database' if name
107
- name = $1
108
- when /\ACREATE\s+TABLE\s+`(.+?)`/i
109
- table = $1
110
- when /\A\s+`(.+?)`/i
111
- columns[table] << $1 if table
112
- when /\A\).*;\Z/
113
- table = nil
114
- when /\AINSERT\s+INTO\s+`(.+?)`\s+(?:\((.+?)\)\s+)?VALUES\s*(.*);\Z/i
115
- _table, _columns, _values = $1, $2, $3
116
-
117
- _columns = _columns.nil? ? columns[_table] :
118
- _columns.split(/\s*,\s*/).each { |column| column.delete!('`') }
119
-
120
- next if _columns.empty?
121
-
122
- parser.parse(_values) { |row|
123
- fields = {}
124
-
125
- row.each_with_index { |value, index|
126
- column = _columns[index] or next
127
- fields[column] = value.to_s
128
- }
108
+ name = args.first
109
+ when :insert
110
+ fields, _, table, columns, values = {}, *args
129
111
 
130
- (tables[_table] ||= []) << fields
112
+ values.each_with_index { |value, index|
113
+ if column = columns[index]
114
+ fields[column] = value.to_s
115
+ end
131
116
  }
117
+
118
+ (tables[table] ||= []) << fields
132
119
  end
133
120
  }
134
121
 
@@ -143,7 +130,7 @@ module FlattenDB
143
130
  when Array
144
131
  inject_foreign(tables, primary_table, foreign_table, *spec)
145
132
  when Hash
146
- raise ArgumentError, "invalid join table spec, '#{JOIN_KEY}' missing" unless spec.has_key?(JOIN_KEY)
133
+ raise ArgumentError, "invalid join table spec, #{JOIN_KEY.inspect} missing" unless spec.has_key?(JOIN_KEY)
147
134
 
148
135
  join_key_spec = spec.delete(JOIN_KEY)
149
136
 
@@ -160,9 +147,7 @@ module FlattenDB
160
147
  end
161
148
  } if config
162
149
 
163
- tables.delete_if { |table, _|
164
- table != primary_table
165
- }
150
+ tables.delete_if { |table, _| table != primary_table }
166
151
  end
167
152
 
168
153
  def inject_foreign(tables, primary_table, foreign_table, local_key, foreign_key = local_key, foreign_tables = tables, foreign_table_name = foreign_table)
@@ -200,7 +185,7 @@ module FlattenDB
200
185
 
201
186
  def field_to_xml(field, content, builder)
202
187
  case content
203
- when String
188
+ when String, Numeric, true, false, nil
204
189
  builder.tag!(column_to_element(field), content)
205
190
  when Array
206
191
  content.each { |item|
@@ -3,8 +3,8 @@ module FlattenDB
3
3
  module Version
4
4
 
5
5
  MAJOR = 0
6
- MINOR = 1
7
- TINY = 3
6
+ MINOR = 2
7
+ TINY = 0
8
8
 
9
9
  class << self
10
10
 
data/lib/flattendb.rb CHANGED
@@ -3,12 +3,14 @@
3
3
  # #
4
4
  # flattendb -- Flatten relational databases #
5
5
  # #
6
- # Copyright (C) 2007-2011 University of Cologne, #
6
+ # Copyright (C) 2007-2012 University of Cologne, #
7
7
  # Albertus-Magnus-Platz, #
8
8
  # 50923 Cologne, Germany #
9
9
  # #
10
+ # Copyright (C) 2013 Jens Wille #
11
+ # #
10
12
  # Authors: #
11
- # Jens Wille <jens.wille@uni-koeln.de> #
13
+ # Jens Wille <jens.wille@gmail.com> #
12
14
  # #
13
15
  # flattendb is free software; you can redistribute it and/or modify it under #
14
16
  # the terms of the GNU Affero General Public License as published by the Free #
metadata CHANGED
@@ -1,152 +1,130 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: flattendb
3
- version: !ruby/object:Gem::Version
4
- hash: 29
5
- prerelease:
6
- segments:
7
- - 0
8
- - 1
9
- - 3
10
- version: 0.1.3
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - Jens Wille
14
8
  autorequire:
15
9
  bindir: bin
16
10
  cert_chain: []
17
-
18
- date: 2011-08-16 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
21
- name: libxml-ruby
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- none: false
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- hash: 3
29
- segments:
30
- - 0
31
- version: "0"
32
- type: :runtime
33
- version_requirements: *id001
34
- - !ruby/object:Gem::Dependency
11
+ date: 2013-03-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
35
14
  name: builder
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
36
21
  prerelease: false
37
- requirement: &id002 !ruby/object:Gem::Requirement
38
- none: false
39
- requirements:
40
- - - ">="
41
- - !ruby/object:Gem::Version
42
- hash: 3
43
- segments:
44
- - 0
45
- version: "0"
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: highline
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
46
34
  type: :runtime
47
- version_requirements: *id002
48
- - !ruby/object:Gem::Dependency
49
- name: ruby-nuggets
50
35
  prerelease: false
51
- requirement: &id003 !ruby/object:Gem::Requirement
52
- none: false
53
- requirements:
54
- - - ">="
55
- - !ruby/object:Gem::Version
56
- hash: 5
57
- segments:
58
- - 0
59
- - 7
60
- - 3
61
- version: 0.7.3
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: libxml-ruby
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
62
48
  type: :runtime
63
- version_requirements: *id003
64
- - !ruby/object:Gem::Dependency
65
- name: athena
66
49
  prerelease: false
67
- requirement: &id004 !ruby/object:Gem::Requirement
68
- none: false
69
- requirements:
70
- - - ">="
71
- - !ruby/object:Gem::Version
72
- hash: 17
73
- segments:
74
- - 0
75
- - 1
76
- - 5
77
- version: 0.1.5
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: ruby-nuggets
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 0.9.1
78
62
  type: :runtime
79
- version_requirements: *id004
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: 0.9.1
80
69
  description: Flatten relational databases.
81
- email: jens.wille@uni-koeln.de
82
- executables:
70
+ email: jens.wille@gmail.com
71
+ executables:
83
72
  - flattendb
84
73
  - flattendb.mdb
85
74
  - flattendb.mysql
86
75
  extensions: []
87
-
88
- extra_rdoc_files:
76
+ extra_rdoc_files:
89
77
  - README
90
78
  - COPYING
91
79
  - ChangeLog
92
- files:
80
+ files:
93
81
  - lib/flattendb.rb
94
- - lib/flattendb/cli.rb
95
- - lib/flattendb/version.rb
96
82
  - lib/flattendb/base.rb
97
- - lib/flattendb/types/mysql.rb
83
+ - lib/flattendb/cli.rb
98
84
  - lib/flattendb/types/mdb.rb
85
+ - lib/flattendb/types/mysql.rb
86
+ - lib/flattendb/version.rb
99
87
  - bin/flattendb
100
88
  - bin/flattendb.mdb
101
89
  - bin/flattendb.mysql
102
- - README
90
+ - COPYING
103
91
  - ChangeLog
92
+ - README
104
93
  - Rakefile
105
- - COPYING
106
- - example/mysql-sample.flat.xml
107
94
  - example/mysql-sample.flat-sql.xml
108
- - example/mysql-sample2flat.yaml
109
- - example/mysql-sample.xml
95
+ - example/mysql-sample.flat.xml
110
96
  - example/mysql-sample.sql
97
+ - example/mysql-sample.xml
98
+ - example/mysql-sample2flat.yaml
111
99
  homepage: http://prometheus.rubyforge.org/flattendb
112
100
  licenses: []
113
-
101
+ metadata: {}
114
102
  post_install_message:
115
- rdoc_options:
116
- - --main
117
- - README
118
- - --all
103
+ rdoc_options:
119
104
  - --charset
120
105
  - UTF-8
121
- - --title
122
- - flattendb Application documentation (v0.1.3)
123
106
  - --line-numbers
124
- require_paths:
107
+ - --all
108
+ - --title
109
+ - flattendb Application documentation (v0.2.0)
110
+ - --main
111
+ - README
112
+ require_paths:
125
113
  - lib
126
- required_ruby_version: !ruby/object:Gem::Requirement
127
- none: false
128
- requirements:
129
- - - ">="
130
- - !ruby/object:Gem::Version
131
- hash: 3
132
- segments:
133
- - 0
134
- version: "0"
135
- required_rubygems_version: !ruby/object:Gem::Requirement
136
- none: false
137
- requirements:
138
- - - ">="
139
- - !ruby/object:Gem::Version
140
- hash: 3
141
- segments:
142
- - 0
143
- version: "0"
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - '>='
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - '>='
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
144
124
  requirements: []
145
-
146
125
  rubyforge_project: prometheus
147
- rubygems_version: 1.8.8
126
+ rubygems_version: 2.0.3
148
127
  signing_key:
149
- specification_version: 3
128
+ specification_version: 4
150
129
  summary: Flatten relational databases.
151
130
  test_files: []
152
-