script 0.0.2 → 0.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2dfd5efe6e5e7710e5d007dc9d46719bd6bc0edf
4
- data.tar.gz: 0788cf8cc9e1d05310cb6e081b75124ade1889ed
3
+ metadata.gz: 872a8cf06708366e28dddb15b4ce5329d886c179
4
+ data.tar.gz: 6d4f26cb5d7dd669933a9bd168d3060ae22488aa
5
5
  SHA512:
6
- metadata.gz: 561c94cffb4cd771696370f588219e8a33c3e2eb52adf093eb9f63610237de733c258ba524addd3bb1e51e73571a28e6d1669a49a91d92ab96cc3bc7ed2bf1f9
7
- data.tar.gz: 0b1632aa572f972228dd530f705e2a11ae86842d25f7386724ee82e9d39ffb06aad86c2a847dcf89cb37074d69f59facda65d4ceadeb7e693f5af70b2234fcf0
6
+ metadata.gz: 445cb6296d580a65ea6bc3e931c20fae66e134eeb5f2af47eadabf853ff9b94baed6df6d060f0b78c1d38412c797653548387b2f7b4f4d9ca02e3ed1a69333d8
7
+ data.tar.gz: a20c4b72f3598aa6825f888802d63fd042953ceb466710d0631aed951e47354b2f5a81c2511325898b3eee55e8186eff576e31a44ad9cef14d084191b9eb6fd9
@@ -1,12 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- script (0.0.1)
4
+ script (0.0.2)
5
+ colorize
5
6
 
6
7
  GEM
7
8
  remote: https://rubygems.org/
8
9
  specs:
9
10
  byebug (9.0.6)
11
+ colorize (0.8.1)
10
12
  diff-lcs (1.3)
11
13
  rake (10.4.2)
12
14
  rspec (3.7.0)
data/README.md CHANGED
@@ -1,13 +1,14 @@
1
1
  # Script<img width="40" align="left" src="https://cdn.codementor.io/assets/topic/category_header/ruby-on-rails-bc9ab2af8d92eb4e7eb3211d548a09ad.png">
2
2
 
3
- The Script is everything you need to make the most of Ruby as fabulous scripting language.
4
-
5
- * [Script](#script)
6
- * [Setup](#setup)
7
- * [Usage](#usage)
8
- * [Contributing](#contributing)
9
- * [License](#license)
10
- * [Code of Conduct](#code-of-conduct)
3
+ The Script is everything you need to make the most of Ruby, as fabulous scripting language.
4
+
5
+ ###### Table of contents
6
+ - [Setup](#setup)
7
+ - [Usage](#usage)
8
+ - [Steps](#steps)
9
+ - [Contributing](#contributing)
10
+ - [License](#license)
11
+ - [Code of Conduct](#code-of-conduct)
11
12
 
12
13
  ## Setup
13
14
 
@@ -1,6 +1,9 @@
1
1
  require "script/version"
2
2
  require "script/engine"
3
3
  require "script/step"
4
+ require "script/output"
5
+
6
+ require "colorize"
4
7
 
5
8
  class Script
6
9
  def initialize
@@ -13,7 +13,16 @@ class Script::Engine
13
13
 
14
14
  def run
15
15
  @steps.each do |step|
16
+ puts Script::Output.started(step)
16
17
  step.run
18
+ puts Script::Output.result(step)
19
+
20
+ abort_run if step.result == :failed
17
21
  end
18
22
  end
23
+
24
+ def abort_run
25
+ # TODO: Print the result per steps table
26
+ abort
27
+ end
19
28
  end
@@ -0,0 +1,26 @@
1
+ module Script::Output
2
+ module_function
3
+
4
+ def started(step)
5
+ [
6
+ separator,
7
+ "Started: #{step.headline}",
8
+ ""
9
+ ].join("\n").colorize(:yellow)
10
+ end
11
+
12
+ def result(step)
13
+ color = :green if step.result == :succeded
14
+ color = :red if step.result == :failed
15
+
16
+ [
17
+ "",
18
+ "#{step.result.capitalize}: #{step.headline}",
19
+ separator
20
+ ].join("\n").colorize(color)
21
+ end
22
+
23
+ def separator
24
+ "-" * 80
25
+ end
26
+ end
@@ -6,5 +6,16 @@ class Script::Step
6
6
 
7
7
  def run
8
8
  @block.call
9
+ @result = :succeded
10
+ rescue
11
+ @result = :failed
12
+ end
13
+
14
+ def result
15
+ @result
16
+ end
17
+
18
+ def headline
19
+ @headline
9
20
  end
10
21
  end
@@ -1,3 +1,3 @@
1
1
  class Script
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["bmarkons"]
10
10
  spec.email = ["mamaveb@gmail.com"]
11
11
 
12
- spec.summary = %q{"Ruby scripting"}
13
- spec.description = %q{"Gives you a hand with composing neat Ruby scripts."}
12
+ spec.summary = %q{Ruby scripting}
13
+ spec.description = %q{Gives you a hand with composing neat Ruby scripts.}
14
14
  spec.homepage = "https://github.com/bmarkons/script"
15
15
  spec.license = "MIT"
16
16
 
@@ -21,6 +21,8 @@ Gem::Specification.new do |spec|
21
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
22
  spec.require_paths = ["lib"]
23
23
 
24
+ spec.add_dependency "colorize"
25
+
24
26
  spec.add_development_dependency "bundler", "~> 1.16"
25
27
  spec.add_development_dependency "rake", "~> 10.0"
26
28
  spec.add_development_dependency "rspec", "~> 3.0"
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "script"
4
+
5
+ script = Script.new
6
+
7
+ script.step("step 1") do
8
+ puts "Step 1"
9
+ puts "Completed"
10
+ raise
11
+ end
12
+
13
+ script.step("step 2") do
14
+ puts "Step 2"
15
+ puts "Completed"
16
+ end
17
+
18
+ script.run
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: script
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - bmarkons
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-12-16 00:00:00.000000000 Z
11
+ date: 2017-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: colorize
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -66,7 +80,7 @@ dependencies:
66
80
  - - ">="
67
81
  - !ruby/object:Gem::Version
68
82
  version: '0'
69
- description: '"Gives you a hand with composing neat Ruby scripts."'
83
+ description: Gives you a hand with composing neat Ruby scripts.
70
84
  email:
71
85
  - mamaveb@gmail.com
72
86
  executables: []
@@ -86,10 +100,12 @@ files:
86
100
  - bin/setup
87
101
  - lib/script.rb
88
102
  - lib/script/engine.rb
103
+ - lib/script/output.rb
89
104
  - lib/script/step.rb
90
105
  - lib/script/version.rb
91
106
  - script.gemspec
92
107
  - scripts/gh-md-toc
108
+ - scripts/script.rb
93
109
  homepage: https://github.com/bmarkons/script
94
110
  licenses:
95
111
  - MIT
@@ -113,5 +129,5 @@ rubyforge_project:
113
129
  rubygems_version: 2.5.1
114
130
  signing_key:
115
131
  specification_version: 4
116
- summary: '"Ruby scripting"'
132
+ summary: Ruby scripting
117
133
  test_files: []