script 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +25 -9
- data/lib/script.rb +6 -0
- data/lib/script/engine.rb +2 -1
- data/lib/script/step.rb +2 -2
- data/lib/script/version.rb +1 -1
- data/misc/ruby.png +0 -0
- data/scripts/script.rb +10 -12
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b3eebc0b8ffe63d808137cc772a49faa8dc9eac
|
4
|
+
data.tar.gz: f46549975e784a273bf327e195ea576fddd643af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee9167d56e4af31bcb123bb8456262511d67d2d303f462bfc661bd54eddd444749e1976fa4c5eed88b9aab7af5d41b909b1bfd918dfd152df258b416115c336b
|
7
|
+
data.tar.gz: 1fbce152e3984cc426f3cb6f3f890888b0a3542aa7e88a33367a4d13648fd69584a2cf767a9e74f0b4e9624aba5cffdbc3293e346e68674a963d00e1d87b76fe
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,11 +1,14 @@
|
|
1
|
-
# Script<img width="40" align="left" src="
|
1
|
+
# Script[<img width="40" align="left" src="misc/ruby.png">](https://github.com/bmarkons/script#script)
|
2
|
+
[](https://semaphoreci.com/bmarkons/script)
|
3
|
+
[](https://badge.fury.io/rb/script)
|
2
4
|
|
3
|
-
The Script is everything you need to make the most of Ruby
|
5
|
+
The Script is everything you need to make the most of Ruby - a fabulous scripting language. The one started with idea of having nicely formatted output, but ended up in much more...
|
4
6
|
|
5
7
|
###### Table of contents
|
6
8
|
- [Setup](#setup)
|
7
9
|
- [Usage](#usage)
|
8
10
|
- [Steps](#steps)
|
11
|
+
- [Shareables](#shareables)
|
9
12
|
- [Contributing](#contributing)
|
10
13
|
- [License](#license)
|
11
14
|
- [Code of Conduct](#code-of-conduct)
|
@@ -38,27 +41,21 @@ require "script"
|
|
38
41
|
deploy = Script.new
|
39
42
|
|
40
43
|
deploy.step("Setup tools") do
|
41
|
-
|
42
44
|
`sudo apt-get install -y google-cloud-sdk kubectl`
|
43
45
|
`gcloud auth activate-service-account $GCLOUD_SERVICE_ACCOUNT_NAME`
|
44
46
|
`gcloud config set project dummy-project`
|
45
47
|
`gcloud container clusters get-credentials default --zone us-east`
|
46
|
-
|
47
48
|
end
|
48
49
|
|
49
50
|
deploy.step("Deploy docker image") do
|
50
|
-
|
51
51
|
`docker pull dummy`
|
52
52
|
`docker build --cache-from dummy -t dummy`
|
53
53
|
`docker build -t scripter/script .`
|
54
54
|
`docker push dummy`
|
55
|
-
|
56
55
|
end
|
57
56
|
|
58
57
|
deploy.step("Deploy to Kubernetes cluster") do
|
59
|
-
|
60
58
|
`kubectl apply -f k8s.yml --record`
|
61
|
-
|
62
59
|
end
|
63
60
|
|
64
61
|
# Finally, run the script
|
@@ -66,7 +63,26 @@ end
|
|
66
63
|
deploy.run
|
67
64
|
```
|
68
65
|
|
69
|
-
The steps are run in order in which they are registered.
|
66
|
+
The steps are run in order in which they are registered. The output from the script commands is nicely formatted and divided per steps:
|
67
|
+
|
68
|
+

|
69
|
+
|
70
|
+
In case of an exception in one of the steps, the execution of the script is aborted instantly.
|
71
|
+
|
72
|
+
### Shareables
|
73
|
+
|
74
|
+
In case you need to share data between steps, you can pass hash of shareables to the step block:
|
75
|
+
|
76
|
+
```ruby
|
77
|
+
script.step("Step 1") do |shareables|
|
78
|
+
shareables["environment"] = "production"
|
79
|
+
end
|
80
|
+
|
81
|
+
script.step("Step 2") do |shareables|
|
82
|
+
environment = shareables["environment"]
|
83
|
+
puts "Deploying on #{environment} environment"
|
84
|
+
end
|
85
|
+
```
|
70
86
|
|
71
87
|
## Contributing
|
72
88
|
|
data/lib/script.rb
CHANGED
data/lib/script/engine.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
class Script::Engine
|
2
2
|
def initialize
|
3
3
|
@steps = []
|
4
|
+
@shareables = {}
|
4
5
|
end
|
5
6
|
|
6
7
|
def steps
|
@@ -14,7 +15,7 @@ class Script::Engine
|
|
14
15
|
def run
|
15
16
|
@steps.each do |step|
|
16
17
|
puts Script::Output.started(step)
|
17
|
-
step.run
|
18
|
+
step.run(@shareables)
|
18
19
|
puts Script::Output.result(step)
|
19
20
|
|
20
21
|
abort_run if step.result == :failed
|
data/lib/script/step.rb
CHANGED
data/lib/script/version.rb
CHANGED
data/misc/ruby.png
ADDED
Binary file
|
data/scripts/script.rb
CHANGED
@@ -2,17 +2,15 @@
|
|
2
2
|
|
3
3
|
require "script"
|
4
4
|
|
5
|
-
|
5
|
+
Script.define do |s|
|
6
|
+
s.step("step 1") do
|
7
|
+
puts "Step 1"
|
8
|
+
puts "Completed"
|
9
|
+
raise
|
10
|
+
end
|
6
11
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
12
|
+
s.step("step 2") do
|
13
|
+
puts "Step 2"
|
14
|
+
puts "Completed"
|
15
|
+
end
|
11
16
|
end
|
12
|
-
|
13
|
-
script.step("step 2") do
|
14
|
-
puts "Step 2"
|
15
|
-
puts "Completed"
|
16
|
-
end
|
17
|
-
|
18
|
-
script.run
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: script
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bmarkons
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|
@@ -103,6 +103,7 @@ files:
|
|
103
103
|
- lib/script/output.rb
|
104
104
|
- lib/script/step.rb
|
105
105
|
- lib/script/version.rb
|
106
|
+
- misc/ruby.png
|
106
107
|
- script.gemspec
|
107
108
|
- scripts/gh-md-toc
|
108
109
|
- scripts/script.rb
|
@@ -126,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
126
127
|
version: '0'
|
127
128
|
requirements: []
|
128
129
|
rubyforge_project:
|
129
|
-
rubygems_version: 2.5.1
|
130
|
+
rubygems_version: 2.5.2.1
|
130
131
|
signing_key:
|
131
132
|
specification_version: 4
|
132
133
|
summary: Ruby scripting
|