Skip to content

Commit 0229739

Browse files
committed
Ran rubocop -a
1 parent c41c647 commit 0229739

27 files changed

+586
-626
lines changed

Gemfile

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
if RUBY_VERSION.match(/^1.8/)
2-
raise Gem::VerificationError, "mysql-to-postgresql requires ruby flavor of version 1.9.x"
2+
fail Gem::VerificationError, 'mysql-to-postgresql requires ruby flavor of version 1.9.x'
33
end
44

55
source :rubygems
@@ -20,5 +20,3 @@ platforms :mri_19 do
2020
end
2121

2222
gem 'test-unit'
23-
24-

Rakefile

+26-27
Original file line numberDiff line numberDiff line change
@@ -7,36 +7,36 @@ require 'mysql2psql/version'
77
begin
88
require 'jeweler'
99
Jeweler::Tasks.new do |gem|
10-
gem.name = "mysql2psql"
10+
gem.name = 'mysql2psql'
1111
gem.version = Mysql2psql::Version::STRING
12-
gem.summary = %Q{Tool for converting mysql database to postgresql}
13-
gem.description = %Q{It can create postgresql dump from mysql database or directly load data from mysql to
12+
gem.summary = %(Tool for converting mysql database to postgresql)
13+
gem.description = %{It can create postgresql dump from mysql database or directly load data from mysql to
1414
postgresql (at about 100 000 records per minute). Translates most data types and indexes.}
15-
gem.email = "[email protected]"
16-
gem.homepage = "http://github.com/tardate/mysql2postgresql"
15+
gem.email = '[email protected]'
16+
gem.homepage = 'http://github.com/tardate/mysql2postgresql'
1717
gem.authors = [
18-
"Max Lapshin <[email protected]>",
19-
"Anton Ageev <[email protected]>",
20-
"Samuel Tribehou <[email protected]>",
21-
"Marco Nenciarini <[email protected]>",
22-
"James Nobis <[email protected]>",
23-
24-
"Holger Amann <[email protected]>",
25-
"Maxim Dobriakov <[email protected]>",
26-
"Michael Kimsal <[email protected]>",
27-
"Jacob Coby <[email protected]>",
28-
"Neszt Tibor <[email protected]>",
29-
"Miroslav Kratochvil <[email protected]>",
30-
"Paul Gallagher <[email protected]>"
31-
]
32-
gem.add_dependency "mysql", "= 2.8.1"
33-
gem.add_dependency "pg", "= 0.9.0"
34-
gem.add_development_dependency "test-unit", ">= 2.1.1"
18+
'Max Lapshin <[email protected]>',
19+
'Anton Ageev <[email protected]>',
20+
'Samuel Tribehou <[email protected]>',
21+
'Marco Nenciarini <[email protected]>',
22+
'James Nobis <[email protected]>',
23+
24+
'Holger Amann <[email protected]>',
25+
'Maxim Dobriakov <[email protected]>',
26+
'Michael Kimsal <[email protected]>',
27+
'Jacob Coby <[email protected]>',
28+
'Neszt Tibor <[email protected]>',
29+
'Miroslav Kratochvil <[email protected]>',
30+
'Paul Gallagher <[email protected]>'
31+
]
32+
gem.add_dependency 'mysql', '= 2.8.1'
33+
gem.add_dependency 'pg', '= 0.9.0'
34+
gem.add_development_dependency 'test-unit', '>= 2.1.1'
3535
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
3636
end
3737
Jeweler::GemcutterTasks.new
3838
rescue LoadError
39-
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
39+
puts 'Jeweler (or a dependency) not available. Install it with: gem install jeweler'
4040
end
4141

4242
require 'rake/testtask'
@@ -54,7 +54,7 @@ namespace :test do
5454
end
5555
end
5656

57-
desc "Run all tests"
57+
desc 'Run all tests'
5858
task :test do
5959
Rake::Task['test:units'].invoke
6060
Rake::Task['test:integration'].invoke
@@ -69,12 +69,11 @@ begin
6969
end
7070
rescue LoadError
7171
task :rcov do
72-
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
72+
abort 'RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov'
7373
end
7474
end
7575

76-
77-
task :default => :test
76+
task default: :test
7877

7978
require 'rdoc/task'
8079
Rake::RDocTask.new do |rdoc|

bin/mysqltopostgres

+9-9
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,26 @@ require 'bundler/setup'
66

77
require 'mysqltopostgres'
88

9-
CONFIG_FILE = File.expand_path(File.expand_path(File.dirname(__FILE__)) + "/../config/database.yml")
9+
CONFIG_FILE = File.expand_path(File.expand_path(File.dirname(__FILE__)) + '/../config/database.yml')
1010

11-
if FileTest.exist?(CONFIG_FILE) or (ARGV.length > 0 and FileTest.exist?(File.expand_path(ARGV[0])))
11+
if FileTest.exist?(CONFIG_FILE) || (ARGV.length > 0 && FileTest.exist?(File.expand_path(ARGV[0])))
1212

1313
if ARGV.length > 0
1414
file = ARGV[0]
1515
else
1616
file = CONFIG_FILE
1717
end
18-
19-
db_yaml = YAML::load_file file
2018

21-
if db_yaml.has_key?('mysql2psql')
19+
db_yaml = YAML.load_file file
20+
21+
if db_yaml.key?('mysql2psql')
2222
# puts db_yaml["mysql2psql"].to_s
23-
Mysql2psql.new(db_yaml["mysql2psql"]).convert
23+
Mysql2psql.new(db_yaml['mysql2psql']).convert
2424
else
2525
# Oh Noes! There is no key in the hash...
26-
raise "'#{file}' does not contain a configuration directive for mysql -> postgres"
26+
fail "'#{file}' does not contain a configuration directive for mysql -> postgres"
2727
end
28-
28+
2929
else
30-
raise "'#{file}' does not exist"
30+
fail "'#{file}' does not exist"
3131
end

lib/mysql2psql/config.rb

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
require 'mysql2psql/config_base'
22

33
class Mysql2psql
4-
54
class Config < ConfigBase
6-
75
def initialize(yaml)
8-
96
super(yaml)
10-
117
end
12-
138
end
14-
15-
end
9+
end

lib/mysql2psql/config_base.rb

+15-16
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,35 @@
22
require 'mysql2psql/errors'
33

44
class Mysql2psql
5-
65
class ConfigBase
76
attr_reader :config, :filepath
87

98
def initialize(yaml)
10-
@filepath=nil
11-
@config = yaml #YAML::load(File.read(filepath))
9+
@filepath = nil
10+
@config = yaml # YAML::load(File.read(filepath))
1211
end
13-
12+
1413
def [](key)
15-
self.send( key )
14+
send(key)
1615
end
16+
1717
def method_missing(name, *args)
18-
token=name.to_s
19-
default = args.length>0 ? args[0] : ''
18+
token = name.to_s
19+
default = args.length > 0 ? args[0] : ''
2020
must_be_defined = default == :none
2121
case token
2222
when /mysql/i
23-
key=token.sub( /^mysql/, '' )
24-
value=config["mysql"][key]
23+
key = token.sub(/^mysql/, '')
24+
value = config['mysql'][key]
2525
when /dest/i
26-
key=token.sub( /^dest/, '' )
27-
value=config["destination"][key]
26+
key = token.sub(/^dest/, '')
27+
value = config['destination'][key]
2828
when /only_tables/i
29-
value=config["tables"]
29+
value = config['tables']
3030
else
31-
value=config[token]
31+
value = config[token]
3232
end
33-
value.nil? ? ( must_be_defined ? (raise Mysql2psql::UninitializedValueError.new("no value and no default for #{name}")) : default ) : value
33+
value.nil? ? ( must_be_defined ? (fail Mysql2psql::UninitializedValueError.new("no value and no default for #{name}")) : default) : value
3434
end
3535
end
36-
37-
end
36+
end

0 commit comments

Comments
 (0)