mysql-inspector 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.5
1
+ 0.0.6
@@ -4,21 +4,34 @@ module MysqlInspector
4
4
 
5
5
  Precondition = Class.new(StandardError)
6
6
 
7
+ module Utils
8
+
9
+ def file_to_table(file)
10
+ file[/(.*)\.sql/, 1]
11
+ end
12
+
13
+ def sanitize_schema!(schema)
14
+ schema.collect! { |line| line.rstrip[/(.*?),?$/, 1] }
15
+ schema.delete_if { |line| line =~ /(\/\*|--|CREATE TABLE)/ or line == ");" or line.strip.empty? }
16
+ schema.sort!
17
+ schema
18
+ end
19
+ end
20
+
7
21
  module Config
8
22
  extend self
23
+ extend Utils
9
24
 
10
25
  def mysqldump(*args)
11
26
  all_args = ["-u #{mysql_user}"] + args
12
27
  Command.new(mysqldump_path, *all_args)
13
28
  end
14
29
 
15
- def strip_timestamps_from_dump!(dir)
30
+ def strip_noise_from_dump!(dir)
16
31
  Dir[File.join(dir, "*.sql")].each do |file|
17
- lines = File.readlines(file)
32
+ lines = sanitize_schema!(File.readlines(file))
18
33
  File.open(file, "w") do |f|
19
- lines.each do |line|
20
- f.puts line unless line =~ /^--/ or line =~ /^\/\*/ or line.strip.empty?
21
- end
34
+ f.puts lines.join("\n")
22
35
  end
23
36
  end
24
37
  end
@@ -78,7 +91,7 @@ module MysqlInspector
78
91
  raise Precondition, "Can't overwrite an existing schema at #{dir.inspect}" if exists?
79
92
  FileUtils.mkdir_p(dir)
80
93
  Config.mysqldump("--no-data", "-T #{dir}", "--skip-opt", db_name).run!
81
- Config.strip_timestamps_from_dump!(dir)
94
+ Config.strip_noise_from_dump!(dir)
82
95
  File.open(info_file, "w") { |f| f.puts(Time.now.utc.strftime("%Y-%m-%d")) }
83
96
  end
84
97
 
@@ -94,20 +107,6 @@ module MysqlInspector
94
107
  end
95
108
  end
96
109
 
97
- module Utils
98
-
99
- def file_to_table(file)
100
- file[/(.*)\.sql/, 1]
101
- end
102
-
103
- def sanitize_schema!(schema)
104
- schema.collect! { |line| line.rstrip[/(.*?),?$/, 1] }
105
- schema.delete_if { |line| line =~ /(\/\*|--|CREATE TABLE)/ or line == ");" or line.strip.empty? }
106
- schema.sort!
107
- schema
108
- end
109
- end
110
-
111
110
  class Grep
112
111
  include Utils
113
112
 
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{mysql-inspector}
8
- s.version = "0.0.5"
8
+ s.version = "0.0.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ryan Carver"]
12
- s.date = %q{2010-03-18}
12
+ s.date = %q{2010-03-23}
13
13
  s.default_executable = %q{mysql-inspector}
14
14
  s.email = %q{ryan@fivesevensix.com}
15
15
  s.executables = ["mysql-inspector"]
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 5
9
- version: 0.0.5
8
+ - 6
9
+ version: 0.0.6
10
10
  platform: ruby
11
11
  authors:
12
12
  - Ryan Carver
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-03-18 00:00:00 -07:00
17
+ date: 2010-03-23 00:00:00 -07:00
18
18
  default_executable: mysql-inspector
19
19
  dependencies: []
20
20