dumpr 1.0 → 1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dd3cfde68c281a599acafcb492f09bc434ca3a80d066f3617e6d6c504aa2c3f2
4
- data.tar.gz: 1208625e0f1dbfef63210656a3313905ce1d1ec5f74c51718652781495998636
3
+ metadata.gz: 205fecfb4696237b6e460954704b0f9553604c993f257acd7dc7dc4ebf96fd92
4
+ data.tar.gz: b2be3a8c4b43607e1e0c606f5b3c1d53d5c5db7973b77a630f4ed6511dd1fb9c
5
5
  SHA512:
6
- metadata.gz: '0148d00c1f332b28dc6f1e640792c4c58bed2242abc64e1094e10e4fc534c589e71bc9e929b23988e9a9053a00b1ceb9a3989704f9856abb8d77b7a9521794ad'
7
- data.tar.gz: 75414e3b37615572f70df9dba1a8cbca2b07609bee818cf1ca44d11d32bb060e4d5b4c6cb6238f4edea33e2fa5009805bf149d22e4f2c17946b41640174dcad4
6
+ metadata.gz: 0eaf3d62ba27241aaa50f17d31a8b5bd249ce12a2fb210179236bd8330ac2053f6580558f579ce0ed378411f6e94ab019362759f90f2a37aa1c4e2ef921aa29f
7
+ data.tar.gz: c1268f23b9dee20df7b8179665b62c755aadc3fbfaebffee16bba8a11dbe111f2e8589137b6cb8dd9db7e016c44c52195386740fe4d71f2a4522721c64a38a90
data/lib/dumpr.rb CHANGED
@@ -3,6 +3,9 @@ require 'dumpr/driver'
3
3
 
4
4
  module Dumpr
5
5
 
6
+ # error raised when there is a bad configuration
7
+ class MissingDriver < RuntimeError; end
8
+
6
9
  # error raised when there is a bad configuration
7
10
  class BadConfig < RuntimeError; end
8
11
 
data/lib/dumpr/cli.rb CHANGED
@@ -134,6 +134,9 @@ ENDSTR
134
134
  else
135
135
  Dumpr.export(options[:driver], options)
136
136
  end
137
+ rescue Dumpr::MissingDriver => e
138
+ puts "#{e.message}."
139
+ exit 1
137
140
  rescue Dumpr::BadConfig => e
138
141
  puts "bad arguments: #{e.message}.\n See --help"
139
142
  exit 1
data/lib/dumpr/driver.rb CHANGED
@@ -100,8 +100,16 @@ module Dumpr
100
100
  @logger
101
101
  end
102
102
 
103
+ def dump_installed?
104
+ raise BadConfig.new "#{self.class} has not defined dump_installed?"
105
+ end
106
+
107
+ def import_installed?
108
+ raise BadConfig.new "#{self.class} has not defined import_installed?"
109
+ end
110
+
103
111
  def dump_cmd
104
- raise BadConfig.new "#{self.class} has not defined dump_cmd!"
112
+ raise BadConfig.new "#{self.class} has not defined dump_cmd"
105
113
  end
106
114
 
107
115
  # DUMPING + EXPORTING
@@ -115,6 +123,9 @@ module Dumpr
115
123
  # if @destination is defined, it then moves the dump to the @destination, which can be a remote host:path
116
124
  def dump
117
125
  logger.debug("begin dump")
126
+ if dump_installed? != true
127
+ raise MissingDriver.new "#{self.class} does not appear to be installed.\nCould not find command `#{dump_cmd.to_s.split.first}`"
128
+ end
118
129
  dumpfn = @dumpfile + (@gzip ? ".gz" : "")
119
130
  Util.with_lockfile("localhost", dumpfn, @opts[:force]) do
120
131
 
@@ -184,6 +195,9 @@ module Dumpr
184
195
  end
185
196
 
186
197
  def import
198
+ if import_installed? != true
199
+ raise MissingDriver.new "#{self.class} does not appear to be installed.\nCould not find command `#{import_cmd.to_s.split.first}`"
200
+ end
187
201
  Util.with_lockfile("localhost", @dumpfile, @opts[:force]) do
188
202
  decompress if @gzip
189
203
 
@@ -11,6 +11,14 @@ module Dumpr
11
11
  @dump_options || "--single-transaction --quick"
12
12
  end
13
13
 
14
+ def dump_installed?
15
+ system("which mysqldump") == true
16
+ end
17
+
18
+ def import_installed?
19
+ system("which mysql") == true
20
+ end
21
+
14
22
  def dump_cmd
15
23
  if @all_databases
16
24
  "mysqldump -u #{user} --password=#{password} -h #{host} -P #{port} --all-databases #{dump_options}"
data/lib/dumpr/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Dumpr
2
- Version = "1.0".freeze
2
+ Version = "1.1".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dumpr
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.0'
4
+ version: '1.1'
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Dickson