script 0.0.4 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +5 -2
- data/README.md +50 -27
- data/lib/script/version.rb +1 -1
- data/script.gemspec +2 -1
- data/scripts/script.rb +11 -9
- metadata +19 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f1399ac78e96bea7357b6e68477cf6ec9c379966
|
4
|
+
data.tar.gz: b6458f57445515f08e39e4bec1ed9a6ca41bcf51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea4674a144d25c850401e77a3db238d0ac028f1f9f591f20e4626e54a164e8fc1b584f71b9ab84bf2a800405beb6daae3b7e41c8c601bc57dd0d1825c856246a
|
7
|
+
data.tar.gz: bafbaf00ab2d203846f5b2c064341b6443b9adebe444b712bf95c6306678a09a101457afe86b1c5a4e534cad4b0f321d274787f1449a95a6e0eceec27a78fdf7
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
script (0.0
|
4
|
+
script (1.0.0)
|
5
5
|
colorize
|
6
6
|
|
7
7
|
GEM
|
@@ -15,6 +15,8 @@ GEM
|
|
15
15
|
rspec-core (~> 3.7.0)
|
16
16
|
rspec-expectations (~> 3.7.0)
|
17
17
|
rspec-mocks (~> 3.7.0)
|
18
|
+
rspec-autotest (1.0.0)
|
19
|
+
rspec-core (>= 2.99.0.beta1, < 4.0.0)
|
18
20
|
rspec-core (3.7.0)
|
19
21
|
rspec-support (~> 3.7.0)
|
20
22
|
rspec-expectations (3.7.0)
|
@@ -29,10 +31,11 @@ PLATFORMS
|
|
29
31
|
ruby
|
30
32
|
|
31
33
|
DEPENDENCIES
|
32
|
-
bundler
|
34
|
+
bundler
|
33
35
|
byebug
|
34
36
|
rake (~> 10.0)
|
35
37
|
rspec (~> 3.0)
|
38
|
+
rspec-autotest
|
36
39
|
script!
|
37
40
|
|
38
41
|
BUNDLED WITH
|
data/README.md
CHANGED
@@ -8,6 +8,7 @@ The Script is everything you need to make the most of Ruby - a fabulous scriptin
|
|
8
8
|
- [Setup](#setup)
|
9
9
|
- [Usage](#usage)
|
10
10
|
- [Steps](#steps)
|
11
|
+
- [Output](#output)
|
11
12
|
- [Shareables](#shareables)
|
12
13
|
- [Contributing](#contributing)
|
13
14
|
- [License](#license)
|
@@ -21,53 +22,75 @@ Install gem:
|
|
21
22
|
gem install script
|
22
23
|
```
|
23
24
|
|
24
|
-
|
25
|
+
Or add it as dependency to your Gemfile:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
gem 'script'
|
29
|
+
```
|
30
|
+
|
31
|
+
Then simply require it in your script file:
|
25
32
|
|
26
33
|
```
|
27
34
|
require 'script'
|
28
35
|
```
|
29
36
|
|
37
|
+
And you're good to go.
|
38
|
+
|
30
39
|
## Usage
|
31
40
|
|
32
41
|
### Steps
|
33
42
|
|
34
|
-
|
43
|
+
Steps encourages you to split commands into higher level constructs which are essential for more complex scripts.
|
44
|
+
|
45
|
+
Use Script to define the steps:
|
35
46
|
|
36
47
|
```ruby
|
37
|
-
#!/usr/
|
48
|
+
#!/usr/bin/env ruby
|
38
49
|
|
39
50
|
require "script"
|
40
51
|
|
41
|
-
|
52
|
+
Script.define do |s|
|
53
|
+
s.step("step 1") do
|
54
|
+
# Commands
|
55
|
+
end
|
42
56
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
`gcloud config set project dummy-project`
|
47
|
-
`gcloud container clusters get-credentials default --zone us-east`
|
57
|
+
s.step("step 2") do
|
58
|
+
# Commands
|
59
|
+
end
|
48
60
|
end
|
61
|
+
```
|
49
62
|
|
50
|
-
|
51
|
-
`docker pull dummy`
|
52
|
-
`docker build --cache-from dummy -t dummy`
|
53
|
-
`docker build -t scripter/script .`
|
54
|
-
`docker push dummy`
|
55
|
-
end
|
63
|
+
Once you've run the ruby script, it will execute each of the steps in the order they were defined.
|
56
64
|
|
57
|
-
|
58
|
-
`kubectl apply -f k8s.yml --record`
|
59
|
-
end
|
65
|
+
### Error handling
|
60
66
|
|
61
|
-
|
67
|
+
In case of an error in one of the steps, the script is stopped right away without executing further steps.
|
62
68
|
|
63
|
-
|
64
|
-
|
69
|
+
### Output
|
70
|
+
|
71
|
+
Nicely formatted output is the primary motivation behind the Script. Most of the time you want to separate your commands output , in order to help investigation or debugging later.
|
65
72
|
|
66
|
-
|
73
|
+
Let's take for an example the following script:
|
67
74
|
|
68
|
-
|
75
|
+
```ruby
|
76
|
+
#!/usr/bin/env ruby
|
77
|
+
|
78
|
+
require "script"
|
69
79
|
|
70
|
-
|
80
|
+
Script.define do |s|
|
81
|
+
s.step("setup") do
|
82
|
+
system("bundle install")
|
83
|
+
end
|
84
|
+
|
85
|
+
s.step("build") do
|
86
|
+
system("bundle exec rake spec")
|
87
|
+
end
|
88
|
+
|
89
|
+
s.step("deploy") do
|
90
|
+
system("gem push script-*")
|
91
|
+
end
|
92
|
+
end
|
93
|
+
```
|
71
94
|
|
72
95
|
### Shareables
|
73
96
|
|
@@ -75,12 +98,12 @@ In case you need to share data between steps, you can pass hash of shareables to
|
|
75
98
|
|
76
99
|
```ruby
|
77
100
|
script.step("Step 1") do |shareables|
|
78
|
-
|
101
|
+
shareables["environment"] = "production"
|
79
102
|
end
|
80
103
|
|
81
104
|
script.step("Step 2") do |shareables|
|
82
|
-
|
83
|
-
|
105
|
+
environment = shareables["environment"]
|
106
|
+
puts "Deploying on #{environment} environment"
|
84
107
|
end
|
85
108
|
```
|
86
109
|
|
data/lib/script/version.rb
CHANGED
data/script.gemspec
CHANGED
@@ -23,8 +23,9 @@ Gem::Specification.new do |spec|
|
|
23
23
|
|
24
24
|
spec.add_dependency "colorize"
|
25
25
|
|
26
|
-
spec.add_development_dependency "bundler"
|
26
|
+
spec.add_development_dependency "bundler"
|
27
27
|
spec.add_development_dependency "rake", "~> 10.0"
|
28
28
|
spec.add_development_dependency "rspec", "~> 3.0"
|
29
29
|
spec.add_development_dependency "byebug"
|
30
|
+
spec.add_development_dependency "rspec-autotest"
|
30
31
|
end
|
data/scripts/script.rb
CHANGED
@@ -3,14 +3,16 @@
|
|
3
3
|
require "script"
|
4
4
|
|
5
5
|
Script.define do |s|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
raise
|
10
|
-
end
|
6
|
+
s.step("setup") do
|
7
|
+
system("bundle install")
|
8
|
+
end
|
11
9
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
10
|
+
s.step("build") do
|
11
|
+
system("bundle exec rake spec")
|
12
|
+
end
|
13
|
+
|
14
|
+
s.step("deploy") do
|
15
|
+
system("gem push script-*")
|
16
|
+
end
|
16
17
|
end
|
18
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: script
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bmarkons
|
@@ -28,16 +28,16 @@ dependencies:
|
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec-autotest
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
83
97
|
description: Gives you a hand with composing neat Ruby scripts.
|
84
98
|
email:
|
85
99
|
- mamaveb@gmail.com
|