bartask 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +3 -1
- data/lib/bartask/base.rb +5 -2
- data/lib/bartask/cli.rb +11 -3
- data/lib/bartask/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a28ec79acd35a6b336145c815cfe1db335b77a39d9e129f4651d304a7e3821b
|
4
|
+
data.tar.gz: 639e410f31d96ac1ff959276adcb7a83d7bf70737afdb9f361a52dab87e03e82
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb3ef91962d923d340416a975f022c4fb996b48517711d9932e53577aa47eef8addfc4b51582910207681b383d8872536e782cadf154c96b13d0aed1e99d2f63
|
7
|
+
data.tar.gz: deed1e19a2eaa91dd6cf3c8e666c255488ec51597a81706689311ca887cdbd33323e3264989b4ff27b132132f1ec4bc599a2da84515bfcfc07c01f7d181cc4ce
|
data/Rakefile
CHANGED
data/lib/bartask/base.rb
CHANGED
@@ -7,13 +7,16 @@ require "open3"
|
|
7
7
|
|
8
8
|
module Bartask
|
9
9
|
class Base
|
10
|
-
def initialize(config_file_path: nil)
|
10
|
+
def initialize(config_file_path: nil, dump_file_path: nil)
|
11
11
|
@config_file_path = config_file_path || Pathname.new("config/database.yml")
|
12
|
+
@specified_dump_file_path = dump_file_path
|
12
13
|
parse_config_file
|
13
14
|
end
|
14
15
|
|
15
16
|
def dump_file_path
|
16
17
|
@dump_file_path ||= begin
|
18
|
+
return @specified_dump_file_path unless @specified_dump_file_path.nil?
|
19
|
+
|
17
20
|
suffix = branch_name.empty? ? "" : "_#{branch_name}"
|
18
21
|
Pathname.new("tmp/#{@config["database"]}#{suffix}.dump")
|
19
22
|
end
|
@@ -40,7 +43,7 @@ module Bartask
|
|
40
43
|
def branch_name
|
41
44
|
@branch_name ||= begin
|
42
45
|
stdout, _, _ = Open3.capture3("git name-rev --name-only HEAD")
|
43
|
-
stdout.strip
|
46
|
+
stdout.strip.gsub("/", "_")
|
44
47
|
end
|
45
48
|
end
|
46
49
|
|
data/lib/bartask/cli.rb
CHANGED
@@ -7,9 +7,9 @@ class Bartask::Cli
|
|
7
7
|
options = cli.parse
|
8
8
|
|
9
9
|
if options[:mode] == "r"
|
10
|
-
Bartask::Restorer.new(config_file_path: options[:config]).execute
|
10
|
+
Bartask::Restorer.new(config_file_path: options[:config], dump_file_path: options[:dump]).execute
|
11
11
|
else
|
12
|
-
Bartask::Dumper.new(config_file_path: options[:config]).execute
|
12
|
+
Bartask::Dumper.new(config_file_path: options[:config], dump_file_path: options[:dump]).execute
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -44,7 +44,7 @@ class Bartask::Cli
|
|
44
44
|
|
45
45
|
def global_command
|
46
46
|
@global_command ||= OptionParser.new do |opts|
|
47
|
-
opts.banner = "Usage: #{CMD} [
|
47
|
+
opts.banner = "Usage: #{CMD} [subcommand] [options]"
|
48
48
|
opts.separator ""
|
49
49
|
opts.separator USAGE
|
50
50
|
end
|
@@ -58,6 +58,10 @@ class Bartask::Cli
|
|
58
58
|
opts.on("-C", "--config PATH", "Config file path") do |v|
|
59
59
|
@options[:config] = v
|
60
60
|
end
|
61
|
+
|
62
|
+
opts.on("-D", "--dump PATH", "Dump file path") do |v|
|
63
|
+
@options[:dump] = v
|
64
|
+
end
|
61
65
|
end,
|
62
66
|
'r' => OptionParser.new do |opts|
|
63
67
|
opts.banner = "Usage: #{CMD} r [options]"
|
@@ -65,6 +69,10 @@ class Bartask::Cli
|
|
65
69
|
opts.on("-C", "--config PATH", "Config file path") do |v|
|
66
70
|
@options[:config] = v
|
67
71
|
end
|
72
|
+
|
73
|
+
opts.on("-D", "--dump PATH", "Dump file path") do |v|
|
74
|
+
@options[:dump] = v
|
75
|
+
end
|
68
76
|
end
|
69
77
|
}
|
70
78
|
end
|
data/lib/bartask/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bartask
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuji Yaginuma
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-12-
|
11
|
+
date: 2024-12-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|