prep_kit 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/.gitignore +7 -9
- data/Gemfile.lock +42 -0
- data/lib/prep_kit/context.rb +48 -0
- data/lib/prep_kit/task.rb +42 -0
- data/lib/prep_kit/version.rb +1 -1
- data/lib/prep_kit.rb +2 -2
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3c72a456ade8b38e4f186ac75238ebeef64dd40
|
4
|
+
data.tar.gz: 4d07cfe6f29710834edcdebe8d5c4faa226b1b92
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d6b10f620178ffd64fe29f1481282d76d05719048696f4ae9f3bc7f91f634d9349ea47e229367a92634bf7ac19b89e20892f27175445e87bd1e588a4ee3514ab
|
7
|
+
data.tar.gz: fadc062d7c17ccd5c838cb0df0f561436858639f2cb6910ad682150a9f512e8f735b0afb36b9b861337e4ee41034b9940dadff99fd74a94cf336b5f6649f4c20
|
data/.gitignore
CHANGED
data/Gemfile.lock
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
prep_kit (0.1.1)
|
5
|
+
remote_marshal
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
file-tail (1.1.0)
|
11
|
+
tins (~> 1.0)
|
12
|
+
net-scp (1.2.1)
|
13
|
+
net-ssh (>= 2.6.5)
|
14
|
+
net-ssh (3.0.2)
|
15
|
+
rake (10.4.2)
|
16
|
+
remote_marshal (0.1.9)
|
17
|
+
net-scp
|
18
|
+
net-ssh
|
19
|
+
sourcify
|
20
|
+
ruby2ruby (2.2.0)
|
21
|
+
ruby_parser (~> 3.1)
|
22
|
+
sexp_processor (~> 4.0)
|
23
|
+
ruby_parser (3.7.3)
|
24
|
+
sexp_processor (~> 4.1)
|
25
|
+
sexp_processor (4.6.1)
|
26
|
+
sourcify (0.5.0)
|
27
|
+
file-tail (>= 1.0.5)
|
28
|
+
ruby2ruby (>= 1.2.5)
|
29
|
+
ruby_parser (>= 2.0.5)
|
30
|
+
sexp_processor (>= 3.0.5)
|
31
|
+
tins (1.8.2)
|
32
|
+
|
33
|
+
PLATFORMS
|
34
|
+
ruby
|
35
|
+
|
36
|
+
DEPENDENCIES
|
37
|
+
bundler (~> 1.10)
|
38
|
+
prep_kit!
|
39
|
+
rake (~> 10.0)
|
40
|
+
|
41
|
+
BUNDLED WITH
|
42
|
+
1.10.6
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module PrepKit
|
2
|
+
class Context
|
3
|
+
def initialize(host, user, options)
|
4
|
+
@vars = {}
|
5
|
+
@env = RemoteMarshal.new(host, user, options)
|
6
|
+
end
|
7
|
+
|
8
|
+
def task(name, &block)
|
9
|
+
raise AssignError, name if @vars[name]
|
10
|
+
|
11
|
+
@vars[name] = block
|
12
|
+
end
|
13
|
+
|
14
|
+
def load(filename)
|
15
|
+
instance_eval open(filename, &:read), filename
|
16
|
+
end
|
17
|
+
|
18
|
+
def call(name)
|
19
|
+
raise NotFoundError, name unless Proc === (block = @vars[name])
|
20
|
+
|
21
|
+
Task.new(self).action &block
|
22
|
+
end
|
23
|
+
|
24
|
+
def sh(command)
|
25
|
+
status, output, error = @env.exec!(command)
|
26
|
+
|
27
|
+
raise RuntimeError, error unless status == 0
|
28
|
+
|
29
|
+
output
|
30
|
+
end
|
31
|
+
|
32
|
+
def test?(path, option)
|
33
|
+
status, *_ = @env.test?(path, option)
|
34
|
+
|
35
|
+
status == 0
|
36
|
+
end
|
37
|
+
|
38
|
+
%i(upload download).each do |name|
|
39
|
+
define_method(name) do |src, dst|
|
40
|
+
@env.public_send("#{name}!", src, dst)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def current_directory
|
45
|
+
nil
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module PrepKit
|
2
|
+
class Task
|
3
|
+
def initialize(parent, directory = nil)
|
4
|
+
@parent = parent
|
5
|
+
@directory = directory
|
6
|
+
end
|
7
|
+
|
8
|
+
def sh(command)
|
9
|
+
chdir = @directory ? "cd #{@directory};" : nil
|
10
|
+
|
11
|
+
@parent.sh([chdir, command].compact.join(' '))
|
12
|
+
end
|
13
|
+
|
14
|
+
def test?(path, option)
|
15
|
+
@parent.test?(path, option)
|
16
|
+
end
|
17
|
+
|
18
|
+
def upload(src, dst)
|
19
|
+
@parent.upload(src, current_directory(dst))
|
20
|
+
end
|
21
|
+
|
22
|
+
def download(src, dst)
|
23
|
+
@parent.download(current_directory(src), dst)
|
24
|
+
end
|
25
|
+
|
26
|
+
def within(directory, &block)
|
27
|
+
directory = current_directory(directory)
|
28
|
+
|
29
|
+
raise RuntimeError, directory unless test?(directory, '-d')
|
30
|
+
|
31
|
+
Task.new(self, directory).action &block
|
32
|
+
end
|
33
|
+
|
34
|
+
def action(&block)
|
35
|
+
instance_eval &block
|
36
|
+
end
|
37
|
+
|
38
|
+
def current_directory(directory = nil)
|
39
|
+
File.join(*([@parent&.current_directory, @directory, directory].compact))
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/lib/prep_kit/version.rb
CHANGED
data/lib/prep_kit.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prep_kit
|
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
|
- daisuko
|
@@ -63,12 +63,15 @@ files:
|
|
63
63
|
- ".travis.yml"
|
64
64
|
- CODE_OF_CONDUCT.md
|
65
65
|
- Gemfile
|
66
|
+
- Gemfile.lock
|
66
67
|
- LICENSE.txt
|
67
68
|
- README.md
|
68
69
|
- Rakefile
|
69
70
|
- bin/console
|
70
71
|
- bin/setup
|
71
72
|
- lib/prep_kit.rb
|
73
|
+
- lib/prep_kit/context.rb
|
74
|
+
- lib/prep_kit/task.rb
|
72
75
|
- lib/prep_kit/version.rb
|
73
76
|
- prep_kit.gemspec
|
74
77
|
homepage: https://github.com/daisuko/prep_kit
|