lynx 0.4.0 → 1.0.0
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.
- checksums.yaml +4 -4
- data/.travis.yml +6 -5
- data/CHANGES.md +6 -0
- data/lib/lynx/command/basic.rb +1 -2
- data/lib/lynx/command/dump.rb +1 -0
- data/lib/lynx/config.rb +4 -5
- data/lib/lynx/error.rb +3 -0
- data/lib/lynx/pipe/append.rb +3 -3
- data/lib/lynx/pipe/import.rb +2 -1
- data/lib/lynx/pipe/run.rb +2 -1
- data/lib/lynx/pipe/write.rb +3 -3
- data/lib/lynx/system_out.rb +14 -0
- data/lib/lynx/version.rb +1 -1
- data/test/lib/lynx/command/basic_test.rb +0 -6
- data/test/lib/lynx/config_test.rb +5 -5
- data/test/lib/lynx/system_out_test.rb +38 -0
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb25acb5e2f9862705f64406d8331573cf85265f
|
4
|
+
data.tar.gz: 96659f856db07bfede52db5a010d7d8ab1e4229b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f355457fd19658583ae6aa91d514ea7a0b8141dbbdd5561091fbcb164fd7820e699fbf2ec60a4f2b3bba174f8dc9fd844fd783b5d957f2ad05488aeae0a99b0
|
7
|
+
data.tar.gz: be365cd897648d469625ea40c0af6f478f30da1732142c7603acc635c19cf5ef6863e1148d5fede7c417484b671d411de3627da9a1041220757685ac538e41eb
|
data/.travis.yml
CHANGED
data/CHANGES.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# master (unreleased)
|
2
2
|
|
3
|
+
# 1.0.0
|
4
|
+
|
5
|
+
* Removed `--password` support. (sshistrava)
|
6
|
+
* Added config file support. (sshistrava)
|
7
|
+
* Added `Lynx::Error` for failed commands. (sshistrava)
|
8
|
+
|
3
9
|
# 0.4.0
|
4
10
|
|
5
11
|
* Added `#option` method to commands for custom options. (panthomakos)
|
data/lib/lynx/command/basic.rb
CHANGED
@@ -10,7 +10,6 @@ module Lynx
|
|
10
10
|
def instruct(method, &block)
|
11
11
|
define_method(method) do |*args|
|
12
12
|
@command << block.call(self,*args)
|
13
|
-
|
14
13
|
self
|
15
14
|
end
|
16
15
|
end
|
@@ -28,8 +27,8 @@ module Lynx
|
|
28
27
|
end
|
29
28
|
|
30
29
|
def authorize
|
30
|
+
@command << "--defaults-extra-file=#{config.credentials}" if config.credentials
|
31
31
|
@command << "--user=#{config.username}" if config.username
|
32
|
-
@command << "--password=#{config.password}" if config.password
|
33
32
|
@command << "--host=#{config.host}" if config.host
|
34
33
|
@command << "--socket=#{config.socket}" if config.socket
|
35
34
|
|
data/lib/lynx/command/dump.rb
CHANGED
data/lib/lynx/config.rb
CHANGED
@@ -9,16 +9,16 @@ module Lynx
|
|
9
9
|
@config = config
|
10
10
|
end
|
11
11
|
|
12
|
-
[:
|
12
|
+
[:credentials, :username, :host, :database, :socket].each do |method|
|
13
13
|
define_method(method){ self[method] }
|
14
14
|
end
|
15
15
|
|
16
16
|
def mysql
|
17
|
-
@mysql ||= self[:mysql] || detect(MYSQL)
|
17
|
+
@mysql ||= self[:mysql] || detect(MYSQL) || raise(Lynx::Error, 'Failed to detect a valid version of mysql')
|
18
18
|
end
|
19
19
|
|
20
20
|
def dump
|
21
|
-
@dump ||= self[:dump] || detect(DUMP)
|
21
|
+
@dump ||= self[:dump] || detect(DUMP) || raise(Lynx::Error, 'Failed to detect a valid version of mysqldump')
|
22
22
|
end
|
23
23
|
|
24
24
|
private
|
@@ -26,9 +26,8 @@ module Lynx
|
|
26
26
|
def [](key)
|
27
27
|
@config[key.to_sym] || @config[key.to_s]
|
28
28
|
end
|
29
|
-
|
30
29
|
def detect(commands)
|
31
|
-
commands.detect{ |c| system("which #{c}") }
|
30
|
+
commands.detect{ |c| system("which #{c} >/dev/null") }
|
32
31
|
end
|
33
32
|
end
|
34
33
|
end
|
data/lib/lynx/error.rb
ADDED
data/lib/lynx/pipe/append.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'lynx/pipe/basic'
|
2
|
+
require 'lynx/system_out'
|
2
3
|
|
3
4
|
module Lynx
|
4
5
|
module Pipe
|
@@ -8,12 +9,11 @@ module Lynx
|
|
8
9
|
end
|
9
10
|
|
10
11
|
def perform(command)
|
11
|
-
|
12
|
+
SystemOut.run("#{command} >> #{@file}")
|
12
13
|
end
|
13
14
|
|
14
15
|
def clear
|
15
|
-
|
16
|
-
|
16
|
+
SystemOut.run("rm -rf #{@file}")
|
17
17
|
self
|
18
18
|
end
|
19
19
|
end
|
data/lib/lynx/pipe/import.rb
CHANGED
data/lib/lynx/pipe/run.rb
CHANGED
data/lib/lynx/pipe/write.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'lynx/pipe/basic'
|
2
|
+
require 'lynx/system_out'
|
2
3
|
|
3
4
|
module Lynx
|
4
5
|
module Pipe
|
@@ -8,12 +9,11 @@ module Lynx
|
|
8
9
|
end
|
9
10
|
|
10
11
|
def perform(command)
|
11
|
-
|
12
|
+
SystemOut.run("#{command} > #{@file}")
|
12
13
|
end
|
13
14
|
|
14
15
|
def clear
|
15
|
-
|
16
|
-
|
16
|
+
SystemOut.run("rm -rf #{@file}")
|
17
17
|
self
|
18
18
|
end
|
19
19
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'open3'
|
2
|
+
require 'lynx/error'
|
3
|
+
|
4
|
+
module Lynx
|
5
|
+
module SystemOut
|
6
|
+
def self.run(command)
|
7
|
+
stdout, stderr, status = Open3.capture3(command)
|
8
|
+
unless status.success?
|
9
|
+
raise(Lynx::Error, "Failed to perform: #{command} \n STDERR: #{stderr}")
|
10
|
+
end
|
11
|
+
stdout
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/lynx/version.rb
CHANGED
@@ -38,12 +38,6 @@ describe Lynx::Command::Basic do
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
-
def test_authorize_with_password
|
42
|
-
@command.config.stub(:password, 'bar') do
|
43
|
-
assert_equal 'mysql --password=bar', @command.mysql.authorize.to_s
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
41
|
def test_authorize_with_host
|
48
42
|
@command.config.stub(:host, 'local') do
|
49
43
|
assert_equal 'mysql --host=local', @command.mysql.authorize.to_s
|
@@ -5,8 +5,8 @@ describe Lynx::Config do
|
|
5
5
|
def config
|
6
6
|
@config ||= Lynx::Config.new(
|
7
7
|
database: 'lynx',
|
8
|
+
credentials: '/foobar.cnf',
|
8
9
|
username: 'name',
|
9
|
-
password: 'pass',
|
10
10
|
host: 'localhost',
|
11
11
|
socket: '/foo/bar')
|
12
12
|
end
|
@@ -31,6 +31,10 @@ describe Lynx::Config do
|
|
31
31
|
assert_equal 'lynx', config.database
|
32
32
|
end
|
33
33
|
|
34
|
+
it 'knows the credentials' do
|
35
|
+
assert_equal '/foobar.cnf', config.credentials
|
36
|
+
end
|
37
|
+
|
34
38
|
it 'knows the username' do
|
35
39
|
assert_equal 'name', config.username
|
36
40
|
end
|
@@ -39,10 +43,6 @@ describe Lynx::Config do
|
|
39
43
|
assert_equal '/foo/bar', config.socket
|
40
44
|
end
|
41
45
|
|
42
|
-
it 'knows the password' do
|
43
|
-
assert_equal 'pass', config.password
|
44
|
-
end
|
45
|
-
|
46
46
|
it 'knows the host' do
|
47
47
|
assert_equal 'localhost', config.host
|
48
48
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require 'lynx/system_out'
|
3
|
+
require 'lynx/error'
|
4
|
+
require 'open3'
|
5
|
+
|
6
|
+
describe Lynx::SystemOut do
|
7
|
+
|
8
|
+
def setup
|
9
|
+
@command = 'command'
|
10
|
+
@stdout = 'stdout'
|
11
|
+
@stderr = 'stderr'
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should return standard out if command is a success' do
|
15
|
+
mock_process = Minitest::Mock.new
|
16
|
+
def mock_process.success?
|
17
|
+
true
|
18
|
+
end
|
19
|
+
|
20
|
+
Open3.stub(:capture3, [@stdout, @stderr, mock_process]) do
|
21
|
+
assert_equal(@stdout, Lynx::SystemOut.run(@command))
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should raise a Lynx::Error if command is not a success' do
|
26
|
+
mock_process = Minitest::Mock.new
|
27
|
+
def mock_process.success?
|
28
|
+
false
|
29
|
+
end
|
30
|
+
|
31
|
+
Open3.stub(:capture3, [@stdout, @stderr, mock_process]) do
|
32
|
+
err = assert_raises Lynx::Error do
|
33
|
+
Lynx::SystemOut.run(@command)
|
34
|
+
end
|
35
|
+
assert_match"Failed to perform: #{@command} \n STDERR: #{@stderr}", err.message
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lynx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pan Thomakos
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-10-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -58,6 +58,7 @@ files:
|
|
58
58
|
- lib/lynx/command/dump.rb
|
59
59
|
- lib/lynx/config.rb
|
60
60
|
- lib/lynx/d_s_l.rb
|
61
|
+
- lib/lynx/error.rb
|
61
62
|
- lib/lynx/pipe.rb
|
62
63
|
- lib/lynx/pipe/append.rb
|
63
64
|
- lib/lynx/pipe/basic.rb
|
@@ -67,6 +68,7 @@ files:
|
|
67
68
|
- lib/lynx/pipe/p_open.rb
|
68
69
|
- lib/lynx/pipe/run.rb
|
69
70
|
- lib/lynx/pipe/write.rb
|
71
|
+
- lib/lynx/system_out.rb
|
70
72
|
- lib/lynx/version.rb
|
71
73
|
- lynx.gemspec
|
72
74
|
- test/lib/lynx/command/basic_test.rb
|
@@ -77,6 +79,7 @@ files:
|
|
77
79
|
- test/lib/lynx/pipe/get_test.rb
|
78
80
|
- test/lib/lynx/pipe/p_open_test.rb
|
79
81
|
- test/lib/lynx/pipe/write_test.rb
|
82
|
+
- test/lib/lynx/system_out_test.rb
|
80
83
|
homepage: https://www.github.com/panthomakos/lynx
|
81
84
|
licenses: []
|
82
85
|
metadata: {}
|
@@ -96,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
96
99
|
version: '0'
|
97
100
|
requirements: []
|
98
101
|
rubyforge_project:
|
99
|
-
rubygems_version: 2.
|
102
|
+
rubygems_version: 2.6.11
|
100
103
|
signing_key:
|
101
104
|
specification_version: 4
|
102
105
|
summary: Ruby command line wrapper for MySQL.
|
@@ -109,4 +112,5 @@ test_files:
|
|
109
112
|
- test/lib/lynx/pipe/get_test.rb
|
110
113
|
- test/lib/lynx/pipe/p_open_test.rb
|
111
114
|
- test/lib/lynx/pipe/write_test.rb
|
115
|
+
- test/lib/lynx/system_out_test.rb
|
112
116
|
has_rdoc:
|