lynx 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of lynx might be problematic. Click here for more details.
- data/README.md +2 -2
- data/lib/lynx.rb +16 -0
- data/lib/lynx/command/basic.rb +1 -1
- data/lib/lynx/config.rb +7 -3
- data/lib/lynx/pipe.rb +1 -0
- data/lib/lynx/pipe/debug.rb +7 -2
- data/lib/lynx/pipe/run.rb +1 -1
- data/lib/lynx/version.rb +1 -1
- data/lynx.gemspec +3 -3
- data/test/lib/lynx/config_test.rb +4 -0
- metadata +4 -4
data/README.md
CHANGED
data/lib/lynx.rb
CHANGED
@@ -4,12 +4,28 @@ require 'lynx/command'
|
|
4
4
|
require 'lynx/pipe'
|
5
5
|
require 'lynx/d_s_l'
|
6
6
|
|
7
|
+
require 'erb'
|
8
|
+
require 'yaml'
|
9
|
+
|
7
10
|
module Lynx
|
8
11
|
class << self
|
9
12
|
def config(options)
|
10
13
|
Lynx::DSL.new(options)
|
11
14
|
end
|
12
15
|
|
16
|
+
def rails(env = nil)
|
17
|
+
if defined?(Rails)
|
18
|
+
env ||= Rails.env
|
19
|
+
hash = Rails.configuration.database_configuration
|
20
|
+
elsif File.exists?('config/database.yml')
|
21
|
+
hash = YAML::load(ERB.new(IO.read('config/database.yml')).result)
|
22
|
+
else
|
23
|
+
raise RuntimeError, 'unable to find configuration file'
|
24
|
+
end
|
25
|
+
|
26
|
+
config(hash[env.to_s])
|
27
|
+
end
|
28
|
+
|
13
29
|
def append(*args)
|
14
30
|
Pipe::Append.new(*args)
|
15
31
|
end
|
data/lib/lynx/command/basic.rb
CHANGED
@@ -43,7 +43,7 @@ module Lynx
|
|
43
43
|
instruct(:no_data){ '--no-data' }
|
44
44
|
instruct(:skip_triggers){ '--skip-triggers' }
|
45
45
|
instruct(:compact){ '--compact' }
|
46
|
-
instruct(:ignore){ |c,table| "--ignore-table=#{table}" }
|
46
|
+
instruct(:ignore){ |c,table| "--ignore-table=#{c.config.database}.#{table}" }
|
47
47
|
instruct(:no_create_info){ '--no-create-info' }
|
48
48
|
|
49
49
|
def to_s
|
data/lib/lynx/config.rb
CHANGED
@@ -10,19 +10,23 @@ module Lynx
|
|
10
10
|
end
|
11
11
|
|
12
12
|
[:username, :password, :host, :database].each do |method|
|
13
|
-
define_method(method){
|
13
|
+
define_method(method){ self[method] }
|
14
14
|
end
|
15
15
|
|
16
16
|
def mysql
|
17
|
-
@mysql ||=
|
17
|
+
@mysql ||= self[:mysql] || detect(MYSQL)
|
18
18
|
end
|
19
19
|
|
20
20
|
def dump
|
21
|
-
@dump ||=
|
21
|
+
@dump ||= self[:dump] || detect(DUMP)
|
22
22
|
end
|
23
23
|
|
24
24
|
private
|
25
25
|
|
26
|
+
def [](key)
|
27
|
+
@config[key.to_sym] || @config[key.to_s]
|
28
|
+
end
|
29
|
+
|
26
30
|
def detect(commands)
|
27
31
|
commands.detect{ |c| system("which #{c}") }
|
28
32
|
end
|
data/lib/lynx/pipe.rb
CHANGED
data/lib/lynx/pipe/debug.rb
CHANGED
@@ -3,12 +3,13 @@ require 'lynx/pipe/basic'
|
|
3
3
|
module Lynx
|
4
4
|
module Pipe
|
5
5
|
class Debug < Basic
|
6
|
-
def initialize(pipe = nil)
|
6
|
+
def initialize(pipe = nil, io = STDOUT)
|
7
7
|
@pipe = pipe
|
8
|
+
@io = io
|
8
9
|
end
|
9
10
|
|
10
11
|
def perform(command)
|
11
|
-
puts "[Lynx] #{command}"
|
12
|
+
@io.puts "[Lynx] #{filter(command)}"
|
12
13
|
|
13
14
|
@pipe.perform(command) if has_pipe?
|
14
15
|
end
|
@@ -21,6 +22,10 @@ module Lynx
|
|
21
22
|
|
22
23
|
private
|
23
24
|
|
25
|
+
def filter(command)
|
26
|
+
command.to_s.gsub(/--password=.*?\s/, '--password=[FILTERED]')
|
27
|
+
end
|
28
|
+
|
24
29
|
def has_pipe?
|
25
30
|
!!@pipe
|
26
31
|
end
|
data/lib/lynx/pipe/run.rb
CHANGED
data/lib/lynx/version.rb
CHANGED
data/lynx.gemspec
CHANGED
@@ -8,9 +8,9 @@ Gem::Specification.new do |gem|
|
|
8
8
|
gem.version = Lynx::VERSION
|
9
9
|
gem.authors = ["Pan Thomakos"]
|
10
10
|
gem.email = ["pan.thomakos@gmail.com"]
|
11
|
-
gem.description = %q{
|
12
|
-
gem.summary = %q{
|
13
|
-
gem.homepage = ""
|
11
|
+
gem.description = %q{Ruby command line wrapper for MySQL.}
|
12
|
+
gem.summary = %q{Ruby command line wrapper for MySQL.}
|
13
|
+
gem.homepage = "https://www.github.com/panthomakos/lynx"
|
14
14
|
|
15
15
|
gem.files = `git ls-files`.split($/)
|
16
16
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
@@ -16,6 +16,10 @@ describe Lynx::Config do
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
+
it 'recognizes string parameters' do
|
20
|
+
assert_equal 'lqsym', Lynx::Config.new('mysql' => 'lqsym').mysql
|
21
|
+
end
|
22
|
+
|
19
23
|
it 'knows the dump command' do
|
20
24
|
Kernel.stub(:system, true) do
|
21
25
|
assert_equal 'mysqldump', config.dump
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lynx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -27,7 +27,7 @@ dependencies:
|
|
27
27
|
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '0'
|
30
|
-
description:
|
30
|
+
description: Ruby command line wrapper for MySQL.
|
31
31
|
email:
|
32
32
|
- pan.thomakos@gmail.com
|
33
33
|
executables: []
|
@@ -62,7 +62,7 @@ files:
|
|
62
62
|
- test/lib/lynx/pipe/append_test.rb
|
63
63
|
- test/lib/lynx/pipe/get_test.rb
|
64
64
|
- test/lib/lynx/pipe/write_test.rb
|
65
|
-
homepage:
|
65
|
+
homepage: https://www.github.com/panthomakos/lynx
|
66
66
|
licenses: []
|
67
67
|
post_install_message:
|
68
68
|
rdoc_options: []
|
@@ -85,7 +85,7 @@ rubyforge_project:
|
|
85
85
|
rubygems_version: 1.8.23
|
86
86
|
signing_key:
|
87
87
|
specification_version: 3
|
88
|
-
summary:
|
88
|
+
summary: Ruby command line wrapper for MySQL.
|
89
89
|
test_files:
|
90
90
|
- test/lib/lynx/command/basic_test.rb
|
91
91
|
- test/lib/lynx/command/dump_test.rb
|