mysql2xxxx 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  ==Binaries
4
4
 
5
- mysql2csv --user=dbuser --password=dbpassword --database=dbname [--charset=utf8] [--encoding=UTF-8] --execute="select * from automobile_makes"
6
- mysql2json --user=dbuser --password=dbpassword --database=dbname [--charset=utf8] [--encoding=UTF-8] --execute="select * from automobile_makes"
7
- mysql2xml --user=dbuser --password=dbpassword --database=dbname [--charset=utf8] [--encoding=UTF-8] --execute="select * from automobile_makes"
5
+ mysql2csv --user=dbuser --password=dbpassword --database=dbname --execute="select * from automobile_makes"
6
+ mysql2json --user=dbuser --password=dbpassword --database=dbname --execute="select * from automobile_makes"
7
+ mysql2xml --user=dbuser --password=dbpassword --database=dbname --execute="select * from automobile_makes"
8
8
 
9
9
  To see all options
10
10
 
@@ -25,7 +25,7 @@ Note also that if you're running it inside a Rails application, it will default
25
25
  ==Well-formedness
26
26
 
27
27
  * CSV output depends on FasterCSV <tt>to_csv</tt>
28
- * JSON output depends on ActiveSupport <tt>to_json</tt>
28
+ * JSON output depends on Florian Frank's JSON <tt>JSON.generate</tt>
29
29
  * XML output is written manually, but looks like the output of <tt>mysql [hyphen][hyphen]xml</tt>
30
30
 
31
31
  Copyright 2011 Seamus Abshere
data/Rakefile CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'bundler'
2
2
  Bundler::GemHelper.install_tasks
3
+ require 'bundler/setup'
3
4
 
4
5
  require 'rake'
5
6
  require 'rake/testtask'
@@ -3,7 +3,7 @@
3
3
  ENV['HERE'] = File.dirname(__FILE__)
4
4
  ENV['DBUSER'] = 'root'
5
5
  ENV['DBPASSWORD'] = 'password'
6
- ENV['DBNAME'] = 'data1'
6
+ ENV['DBNAME'] = 'mysql2xxxx_benchmark'
7
7
  ENV['MEMPROF_REPORT_PATH'] = File.expand_path('memprof.txt')
8
8
  ENV['DUMP_PATH'] = File.expand_path('a.dump')
9
9
  ENV['EXECUTE'] = 'SELECT * FROM five_thousand_rows'
@@ -136,12 +136,12 @@ Memprof object counts (top 25):
136
136
  18 ./benchmark/../lib/mysql2xxxx/writer.rb:33:__node__
137
137
  14 ./benchmark/../lib/mysql2xxxx/writer/xml.rb:12:__node__
138
138
  12 ./benchmark/../lib/mysql2xxxx/writer.rb:11:__node__
139
- 12 ./benchmark/../lib/mysql2xxxx/properties.rb:32:__node__
140
- 12 ./benchmark/../lib/mysql2xxxx/properties.rb:28:__node__
141
- 12 ./benchmark/../lib/mysql2xxxx/properties.rb:24:__node__
142
- 12 ./benchmark/../lib/mysql2xxxx/properties.rb:20:__node__
139
+ 12 ./benchmark/../lib/mysql2xxxx/config.rb:32:__node__
140
+ 12 ./benchmark/../lib/mysql2xxxx/config.rb:28:__node__
141
+ 12 ./benchmark/../lib/mysql2xxxx/config.rb:24:__node__
142
+ 12 ./benchmark/../lib/mysql2xxxx/config.rb:20:__node__
143
143
  11 ./benchmark/../lib/mysql2xxxx/writer/xml.rb:4:__node__
144
- 10 ./benchmark/../lib/mysql2xxxx/properties.rb:36:__node__
144
+ 10 ./benchmark/../lib/mysql2xxxx/config.rb:36:__node__
145
145
  9 ./benchmark/../lib/mysql2xxxx/writer.rb:26:__node__
146
146
  8 ./benchmark/../lib/mysql2xxxx/writer.rb:73:__node__
147
147
  8 ./benchmark/../lib/mysql2xxxx/writer.rb:32:__node__
@@ -137,13 +137,13 @@ Memprof object counts (top 25):
137
137
  22 ./benchmark/../lib/mysql2xxxx/writer.rb:35:__node__
138
138
  20 ./benchmark/../lib/mysql2xxxx/writer.rb:16:__node__
139
139
  14 ./benchmark/../lib/mysql2xxxx/writer/xml.rb:12:__node__
140
- 14 ./benchmark/../lib/mysql2xxxx/properties.rb:18:__node__
140
+ 14 ./benchmark/../lib/mysql2xxxx/config.rb:18:__node__
141
141
  12 ./benchmark/../lib/mysql2xxxx/writer.rb:11:__node__
142
- 12 ./benchmark/../lib/mysql2xxxx/properties.rb:36:__node__
143
- 12 ./benchmark/../lib/mysql2xxxx/properties.rb:32:__node__
144
- 12 ./benchmark/../lib/mysql2xxxx/properties.rb:14:__node__
145
- 12 ./benchmark/../lib/mysql2xxxx/properties.rb:10:__node__
142
+ 12 ./benchmark/../lib/mysql2xxxx/config.rb:36:__node__
143
+ 12 ./benchmark/../lib/mysql2xxxx/config.rb:32:__node__
144
+ 12 ./benchmark/../lib/mysql2xxxx/config.rb:14:__node__
145
+ 12 ./benchmark/../lib/mysql2xxxx/config.rb:10:__node__
146
146
  11 ./benchmark/../lib/mysql2xxxx/writer/xml.rb:4:__node__
147
147
  10 ./benchmark/../lib/mysql2xxxx/writer.rb:34:__node__
148
- 10 ./benchmark/../lib/mysql2xxxx/properties.rb:40:__node__
148
+ 10 ./benchmark/../lib/mysql2xxxx/config.rb:40:__node__
149
149
  9 ./benchmark/../lib/mysql2xxxx/writer.rb:26:__node__
data/bin/mysql2csv CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require "mysql2xxxx"
4
+ require 'mysql2xxxx/cli'
4
5
 
5
6
  cli = Mysql2xxxx::Cli.new
6
7
  cli.parse_options
data/bin/mysql2json CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require "mysql2xxxx"
4
+ require 'mysql2xxxx/cli'
4
5
 
5
6
  cli = Mysql2xxxx::Cli.new
6
7
  cli.parse_options
data/bin/mysql2xml CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require "mysql2xxxx"
4
+ require 'mysql2xxxx/cli'
4
5
 
5
6
  cli = Mysql2xxxx::Cli.new
6
7
  cli.parse_options
data/lib/mysql2xxxx.rb CHANGED
@@ -3,20 +3,17 @@ unless RUBY_VERSION >= '1.9'
3
3
  end
4
4
  require 'active_support'
5
5
  require 'active_support/version'
6
- %w{
7
- active_support/core_ext/object
8
- active_support/core_ext/string
9
- active_support/core_ext/hash
10
- }.each do |active_support_3_requirement|
11
- require active_support_3_requirement
12
- end if ::ActiveSupport::VERSION::MAJOR == 3
6
+ require 'active_support/core_ext' if ::ActiveSupport::VERSION::MAJOR >= 3
7
+
8
+ # will use mysql2 as soon as :stream => true is supported
9
+ # https://github.com/brianmario/mysql2/pull/223
13
10
  require 'mysql'
14
11
 
12
+ require 'mysql2xxxx/config'
13
+ require 'mysql2xxxx/writer'
14
+ require 'mysql2xxxx/writer/json'
15
+ require 'mysql2xxxx/writer/csv'
16
+ require 'mysql2xxxx/writer/xml'
17
+
15
18
  module Mysql2xxxx
16
- autoload :JSON, 'mysql2xxxx/writer/json'
17
- autoload :CSV, 'mysql2xxxx/writer/csv'
18
- autoload :XML, 'mysql2xxxx/writer/xml'
19
- autoload :Writer, 'mysql2xxxx/writer'
20
- autoload :Properties, 'mysql2xxxx/properties'
21
- autoload :Cli, 'mysql2xxxx/cli'
22
19
  end
@@ -3,7 +3,7 @@ require 'mixlib/cli'
3
3
  module Mysql2xxxx
4
4
  class Cli
5
5
  include ::Mixlib::CLI
6
- %w{ user password host Port database charset encoding }.each do |o|
6
+ %w{ user password host Port database }.each do |o|
7
7
  option o.downcase.to_sym,
8
8
  :short => "-#{o[0,1]} #{o.upcase}",
9
9
  :long => "--#{o.downcase}=#{o.upcase}",
@@ -0,0 +1,59 @@
1
+ module Mysql2xxxx
2
+ class Config
3
+ attr_reader :options
4
+ def initialize(options = {})
5
+ @options = options.symbolize_keys
6
+ end
7
+
8
+ def user
9
+ options[:user] || active_record_config.try(:[], :username)
10
+ end
11
+
12
+ def password
13
+ options[:password] || active_record_config.try(:[], :password)
14
+ end
15
+
16
+ def host
17
+ options[:host] || active_record_config.try(:[], :host)
18
+ end
19
+
20
+ def port
21
+ options[:port] || active_record_config.try(:[], :port)
22
+ end
23
+
24
+ def socket
25
+ options[:socket] || active_record_config.try(:[], :socket)
26
+ end
27
+
28
+ def database
29
+ options[:database] || active_record_connection.try(:current_database)
30
+ end
31
+
32
+ def execute
33
+ options[:execute]
34
+ end
35
+
36
+ # Whether to write \N instead of a blank string for NULL. This is helpful for mysqlimport.
37
+ #
38
+ # Only applies to CSV
39
+ def slash_n
40
+ options.fetch :slash_n, false
41
+ end
42
+
43
+ private
44
+
45
+ def active_record_connection
46
+ if defined?(::ActiveRecord)
47
+ ::ActiveRecord::Base.connection
48
+ end
49
+ rescue
50
+ # oh well
51
+ end
52
+
53
+ def active_record_config
54
+ if active_record_connection
55
+ active_record_connection.instance_variable_get :@config
56
+ end
57
+ end
58
+ end
59
+ end
@@ -1,3 +1,3 @@
1
1
  module Mysql2xxxx
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -1,16 +1,16 @@
1
1
  require 'stringio'
2
- if ::RUBY_VERSION >= '1.9'
3
- require 'ensure/encoding'
4
- else
5
- require 'iconv'
6
- end
2
+ require 'iconv'
7
3
 
8
4
  module Mysql2xxxx
9
5
  class Writer
10
- attr_reader :properties
6
+ MYSQL_CHARSET = 'utf8'
7
+ ICONV_TO = 'UTF-8//TRANSLIT'
8
+ ICONV_FROM = 'UTF-8'
9
+
10
+ attr_reader :config
11
11
 
12
12
  def initialize(options = {})
13
- @properties = Properties.new options
13
+ @config = Config.new options
14
14
  end
15
15
 
16
16
  def keys
@@ -19,7 +19,7 @@ module Mysql2xxxx
19
19
 
20
20
  def last_statement
21
21
  return @last_statement if @last_statement.is_a? ::String
22
- statements = properties.execute.split(';').select { |statement| statement.to_s.strip.length > 0 }
22
+ statements = config.execute.split(';').select { |statement| statement.to_s.strip.length > 0 }
23
23
  @last_statement = statements.pop
24
24
  statements.each do |statement|
25
25
  dbh.query statement
@@ -37,8 +37,8 @@ module Mysql2xxxx
37
37
  def dbh
38
38
  return @dbh if @dbh.is_a? ::Mysql
39
39
  @dbh = ::Mysql.init
40
- @dbh.options ::Mysql::SET_CHARSET_NAME, properties.charset
41
- @dbh.real_connect properties.host, properties.user, properties.password, properties.database, properties.port, properties.socket
40
+ @dbh.options ::Mysql::SET_CHARSET_NAME, MYSQL_CHARSET
41
+ @dbh.real_connect config.host, config.user, config.password, config.database, config.port, config.socket
42
42
  # so that we can use_result instead of store_result
43
43
  @dbh.query_with_result = false
44
44
  @dbh
@@ -61,24 +61,16 @@ module Mysql2xxxx
61
61
  end
62
62
 
63
63
  def recode_as_utf8(raw_str)
64
- return if raw_str.nil?
65
- if ::RUBY_VERSION >= '1.9'
66
- $stderr.puts "[mysql2xxxx] Raw - #{raw_str}" if ::ENV['MYSQL2XXXX_DEBUG'] == 'true'
67
- recoded_str = raw_str.ensure_encoding 'UTF-8', :external_encoding => properties.encoding, :invalid_characters => :transcode
68
- $stderr.puts "[mysql2xxxx] Recoded - #{recoded_str}" if ::ENV['MYSQL2XXXX_DEBUG'] == 'true'
69
- recoded_str
70
- else
71
- $stderr.puts "[mysql2xxxx] Raw - #{raw_str}" if ::ENV['MYSQL2XXXX_DEBUG'] == 'true'
72
- recoded_str = ::Iconv.conv('UTF-8//TRANSLIT', properties.encoding, raw_str.to_s + ' ')[0..-2]
73
- $stderr.puts "[mysql2xxxx] Recoded - #{recoded_str}" if ::ENV['MYSQL2XXXX_DEBUG'] == 'true'
74
- recoded_str
64
+ unless raw_str.nil?
65
+ [ iconv.iconv(raw_str), iconv.iconv(nil) ].join
75
66
  end
76
67
  end
77
68
 
78
69
  def close
70
+ @dead = true
71
+ iconv.close
79
72
  result.free
80
73
  dbh.close
81
- @dead = true
82
74
  end
83
75
 
84
76
  def to_s
@@ -94,10 +86,16 @@ module Mysql2xxxx
94
86
  end
95
87
 
96
88
  def to_path(path)
97
- f = ::File.open(path, 'w')
89
+ f = ::RUBY_VERSION >= '1.9' ? ::File.open(path, 'w', :binmode => true) : ::File.open(path, 'w')
98
90
  to_file f
99
91
  f.close
100
92
  nil
101
93
  end
94
+
95
+ private
96
+
97
+ def iconv
98
+ @iconv ||= ::Iconv.new(ICONV_TO, ICONV_FROM)
99
+ end
102
100
  end
103
101
  end
@@ -6,10 +6,22 @@ end
6
6
 
7
7
  module Mysql2xxxx
8
8
  class CSV < Writer
9
+ SLASH_N = '\N'.freeze
9
10
  def to_file(f)
10
- f.write keys.to_csv
11
+ slash_n = config.slash_n
12
+
13
+ if slash_n
14
+ f.write keys.map { |v| v.nil? ? SLASH_N : v }.to_csv
15
+ else
16
+ f.write keys.to_csv
17
+ end
18
+
11
19
  stream_arrays do |ary|
12
- f.write ary.to_csv
20
+ if slash_n
21
+ f.write ary.map { |v| v.nil? ? SLASH_N : v }.to_csv
22
+ else
23
+ f.write ary.to_csv
24
+ end
13
25
  end
14
26
  nil
15
27
  end
@@ -1,8 +1,4 @@
1
- %w{
2
- active_support/json/encoding
3
- }.each do |active_support_3_requirement|
4
- require active_support_3_requirement
5
- end if ::ActiveSupport::VERSION::MAJOR == 3
1
+ require 'json'
6
2
 
7
3
  module Mysql2xxxx
8
4
  class JSON < Writer
@@ -15,7 +11,7 @@ module Mysql2xxxx
15
11
  else
16
12
  f.write ','
17
13
  end
18
- f.write hsh.to_json
14
+ f.write ::JSON.generate(hsh)
19
15
  end
20
16
  f.write ']'
21
17
  nil
@@ -9,7 +9,7 @@ module Mysql2xxxx
9
9
  # i tried to use builder, but the String#to_xs nonsense got in the way
10
10
  def to_file(f)
11
11
  f.write %{<?xml version="1.0" encoding="utf-8" ?>}
12
- f.write %{<resultset statement="#{properties.execute.to_xs}" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">}
12
+ f.write %{<resultset statement="#{config.execute.to_xs}" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">}
13
13
  stream_arrays do |ary|
14
14
  f.write %{<row>}
15
15
  ary.each_with_index do |v, i|
data/mysql2xxxx.gemspec CHANGED
@@ -24,8 +24,9 @@ Gem::Specification.new do |s|
24
24
  s.add_dependency 'mixlib-cli'
25
25
  s.add_dependency 'fast_xs'
26
26
  s.add_dependency 'fastercsv'
27
- s.add_dependency 'ensure-encoding'
27
+ s.add_dependency 'json'
28
28
 
29
+ s.add_development_dependency 'rake'
29
30
  s.add_development_dependency 'activerecord'
30
31
  s.add_development_dependency 'shell-executer'
31
32
  s.add_development_dependency 'posix-spawn'
@@ -6,7 +6,7 @@ class TestMysql2xxxx < Test::Unit::TestCase
6
6
  a = Mysql2xxxx::JSON.new @options
7
7
  str = a.to_s
8
8
  assert str.include?('Acura')
9
- assert str.include?(%q{Citro\u00ebn})
9
+ assert str.include?('Citroën')
10
10
  assert !str.include?('DaimlerChrysler')
11
11
  end
12
12
 
@@ -25,4 +25,11 @@ class TestMysql2xxxx < Test::Unit::TestCase
25
25
  assert str.include?('Citro&#235;n')
26
26
  assert !str.include?('DaimlerChrysler')
27
27
  end
28
+
29
+ def test_4_slash_n_for_nulls
30
+ a = Mysql2xxxx::CSV.new @options
31
+ assert a.to_s.include?(',,')
32
+ b = Mysql2xxxx::CSV.new @options.merge(:slash_n => true)
33
+ assert b.to_s.include?(',\N,')
34
+ end
28
35
  end
metadata CHANGED
@@ -1,140 +1,148 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: mysql2xxxx
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
4
5
  prerelease:
5
- version: 0.1.1
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Seamus Abshere
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-05-18 00:00:00 -05:00
14
- default_executable:
15
- dependencies:
16
- - !ruby/object:Gem::Dependency
12
+ date: 2012-01-16 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
17
15
  name: activesupport
18
- prerelease: false
19
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &2154830840 !ruby/object:Gem::Requirement
20
17
  none: false
21
- requirements:
22
- - - ">="
23
- - !ruby/object:Gem::Version
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
24
21
  version: 2.3.10
25
22
  type: :runtime
26
- version_requirements: *id001
27
- - !ruby/object:Gem::Dependency
28
- name: mysql
29
23
  prerelease: false
30
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: *2154830840
25
+ - !ruby/object:Gem::Dependency
26
+ name: mysql
27
+ requirement: &2154830240 !ruby/object:Gem::Requirement
31
28
  none: false
32
- requirements:
33
- - - ">="
34
- - !ruby/object:Gem::Version
35
- version: "0"
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
36
33
  type: :runtime
37
- version_requirements: *id002
38
- - !ruby/object:Gem::Dependency
39
- name: mixlib-cli
40
34
  prerelease: false
41
- requirement: &id003 !ruby/object:Gem::Requirement
35
+ version_requirements: *2154830240
36
+ - !ruby/object:Gem::Dependency
37
+ name: mixlib-cli
38
+ requirement: &2154829640 !ruby/object:Gem::Requirement
42
39
  none: false
43
- requirements:
44
- - - ">="
45
- - !ruby/object:Gem::Version
46
- version: "0"
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
47
44
  type: :runtime
48
- version_requirements: *id003
49
- - !ruby/object:Gem::Dependency
50
- name: fast_xs
51
45
  prerelease: false
52
- requirement: &id004 !ruby/object:Gem::Requirement
46
+ version_requirements: *2154829640
47
+ - !ruby/object:Gem::Dependency
48
+ name: fast_xs
49
+ requirement: &2154828940 !ruby/object:Gem::Requirement
53
50
  none: false
54
- requirements:
55
- - - ">="
56
- - !ruby/object:Gem::Version
57
- version: "0"
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
58
55
  type: :runtime
59
- version_requirements: *id004
60
- - !ruby/object:Gem::Dependency
61
- name: fastercsv
62
56
  prerelease: false
63
- requirement: &id005 !ruby/object:Gem::Requirement
57
+ version_requirements: *2154828940
58
+ - !ruby/object:Gem::Dependency
59
+ name: fastercsv
60
+ requirement: &2154828140 !ruby/object:Gem::Requirement
64
61
  none: false
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: "0"
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
69
66
  type: :runtime
70
- version_requirements: *id005
71
- - !ruby/object:Gem::Dependency
72
- name: ensure-encoding
73
67
  prerelease: false
74
- requirement: &id006 !ruby/object:Gem::Requirement
68
+ version_requirements: *2154828140
69
+ - !ruby/object:Gem::Dependency
70
+ name: json
71
+ requirement: &2154821260 !ruby/object:Gem::Requirement
75
72
  none: false
76
- requirements:
77
- - - ">="
78
- - !ruby/object:Gem::Version
79
- version: "0"
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
80
77
  type: :runtime
81
- version_requirements: *id006
82
- - !ruby/object:Gem::Dependency
83
- name: activerecord
84
78
  prerelease: false
85
- requirement: &id007 !ruby/object:Gem::Requirement
79
+ version_requirements: *2154821260
80
+ - !ruby/object:Gem::Dependency
81
+ name: rake
82
+ requirement: &2154820760 !ruby/object:Gem::Requirement
86
83
  none: false
87
- requirements:
88
- - - ">="
89
- - !ruby/object:Gem::Version
90
- version: "0"
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
91
88
  type: :development
92
- version_requirements: *id007
93
- - !ruby/object:Gem::Dependency
94
- name: shell-executer
95
89
  prerelease: false
96
- requirement: &id008 !ruby/object:Gem::Requirement
90
+ version_requirements: *2154820760
91
+ - !ruby/object:Gem::Dependency
92
+ name: activerecord
93
+ requirement: &2154820120 !ruby/object:Gem::Requirement
97
94
  none: false
98
- requirements:
99
- - - ">="
100
- - !ruby/object:Gem::Version
101
- version: "0"
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
102
99
  type: :development
103
- version_requirements: *id008
104
- - !ruby/object:Gem::Dependency
105
- name: posix-spawn
106
100
  prerelease: false
107
- requirement: &id009 !ruby/object:Gem::Requirement
101
+ version_requirements: *2154820120
102
+ - !ruby/object:Gem::Dependency
103
+ name: shell-executer
104
+ requirement: &2154819500 !ruby/object:Gem::Requirement
108
105
  none: false
109
- requirements:
110
- - - ">="
111
- - !ruby/object:Gem::Version
112
- version: "0"
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: *2154819500
113
+ - !ruby/object:Gem::Dependency
114
+ name: posix-spawn
115
+ requirement: &2154818880 !ruby/object:Gem::Requirement
116
+ none: false
117
+ requirements:
118
+ - - ! '>='
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
113
121
  type: :development
114
- version_requirements: *id009
115
- - !ruby/object:Gem::Dependency
116
- name: ruby-debug19
117
122
  prerelease: false
118
- requirement: &id010 !ruby/object:Gem::Requirement
123
+ version_requirements: *2154818880
124
+ - !ruby/object:Gem::Dependency
125
+ name: ruby-debug19
126
+ requirement: &2154818240 !ruby/object:Gem::Requirement
119
127
  none: false
120
- requirements:
121
- - - ">="
122
- - !ruby/object:Gem::Version
123
- version: "0"
128
+ requirements:
129
+ - - ! '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
124
132
  type: :development
125
- version_requirements: *id010
126
- description: Gives you binaries like mysql2csv, mysql2json, and mysql2xml, and Ruby classes to match.
127
- email:
133
+ prerelease: false
134
+ version_requirements: *2154818240
135
+ description: Gives you binaries like mysql2csv, mysql2json, and mysql2xml, and Ruby
136
+ classes to match.
137
+ email:
128
138
  - seamus@abshere.net
129
- executables:
139
+ executables:
130
140
  - mysql2csv
131
141
  - mysql2json
132
142
  - mysql2xml
133
143
  extensions: []
134
-
135
144
  extra_rdoc_files: []
136
-
137
- files:
145
+ files:
138
146
  - .gemtest
139
147
  - .gitignore
140
148
  - Gemfile
@@ -153,7 +161,7 @@ files:
153
161
  - bin/mysql2xml
154
162
  - lib/mysql2xxxx.rb
155
163
  - lib/mysql2xxxx/cli.rb
156
- - lib/mysql2xxxx/properties.rb
164
+ - lib/mysql2xxxx/config.rb
157
165
  - lib/mysql2xxxx/version.rb
158
166
  - lib/mysql2xxxx/writer.rb
159
167
  - lib/mysql2xxxx/writer/csv.rb
@@ -169,35 +177,32 @@ files:
169
177
  - test/test_multiline_sql.rb
170
178
  - test/test_mysql2xxxx.rb
171
179
  - test/test_well_formedness.rb
172
- has_rdoc: true
173
180
  homepage: https://github.com/seamusabshere/mysql2xxxx
174
181
  licenses: []
175
-
176
182
  post_install_message:
177
183
  rdoc_options: []
178
-
179
- require_paths:
184
+ require_paths:
180
185
  - lib
181
- required_ruby_version: !ruby/object:Gem::Requirement
186
+ required_ruby_version: !ruby/object:Gem::Requirement
182
187
  none: false
183
- requirements:
184
- - - ">="
185
- - !ruby/object:Gem::Version
186
- version: "0"
187
- required_rubygems_version: !ruby/object:Gem::Requirement
188
+ requirements:
189
+ - - ! '>='
190
+ - !ruby/object:Gem::Version
191
+ version: '0'
192
+ required_rubygems_version: !ruby/object:Gem::Requirement
188
193
  none: false
189
- requirements:
190
- - - ">="
191
- - !ruby/object:Gem::Version
192
- version: "0"
194
+ requirements:
195
+ - - ! '>='
196
+ - !ruby/object:Gem::Version
197
+ version: '0'
193
198
  requirements: []
194
-
195
199
  rubyforge_project: mysql2xxxx
196
- rubygems_version: 1.6.2
200
+ rubygems_version: 1.8.10
197
201
  signing_key:
198
202
  specification_version: 3
199
- summary: In a memory-sensitive way (but not fast), dump mysql tables to JSON, CSV, XML.
200
- test_files:
203
+ summary: In a memory-sensitive way (but not fast), dump mysql tables to JSON, CSV,
204
+ XML.
205
+ test_files:
201
206
  - test/fixtures/automobile_make_years.sql
202
207
  - test/fixtures/automobile_makes.sql
203
208
  - test/helper.rb
@@ -1,71 +0,0 @@
1
- module Mysql2xxxx
2
- class Properties
3
- attr_reader :options
4
- def initialize(options = {})
5
- @options = options.dup
6
- @options.stringify_keys!
7
- end
8
-
9
- def user
10
- options['user'] || active_record_config.try(:[], :username)
11
- end
12
-
13
- def password
14
- options['password'] || active_record_config.try(:[], :password)
15
- end
16
-
17
- def host
18
- options['host'] || active_record_config.try(:[], :host)
19
- end
20
-
21
- # MySQL connection charset
22
- #
23
- # If you change this, you also have to change :encoding
24
- #
25
- # Default: utf8
26
- def charset
27
- options['charset'] || 'utf8'
28
- end
29
-
30
- # Encoding
31
- #
32
- # If you change this, you also have to change :charset
33
- #
34
- # Default: UTF-8
35
- def encoding
36
- options['encoding'] || 'UTF-8'
37
- end
38
-
39
- def port
40
- options['port'] || active_record_config.try(:[], :port)
41
- end
42
-
43
- def socket
44
- options['socket'] || active_record_config.try(:[], :socket)
45
- end
46
-
47
- def database
48
- options['database'] || active_record_connection.try(:current_database)
49
- end
50
-
51
- def execute
52
- options['execute']
53
- end
54
-
55
- private
56
-
57
- def active_record_connection
58
- if defined?(::ActiveRecord)
59
- ::ActiveRecord::Base.connection
60
- end
61
- rescue
62
- # oh well
63
- end
64
-
65
- def active_record_config
66
- if active_record_connection
67
- active_record_connection.instance_variable_get :@config
68
- end
69
- end
70
- end
71
- end