steps 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG ADDED
@@ -0,0 +1,2 @@
1
+ = 1.0
2
+ * Initial Release
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "colored", ">= 1.2"
4
+ gem "highline", ">= 1.6"
5
+
6
+ group :development do
7
+ gem "rspec", "~> 2.11"
8
+ gem "bundler", "~> 1.0"
9
+ gem "jeweler", "~> 1.8"
10
+ gem "simplecov", ">= 0"
11
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,40 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ colored (1.2)
5
+ diff-lcs (1.2.4)
6
+ git (1.2.5)
7
+ highline (1.6.19)
8
+ jeweler (1.8.4)
9
+ bundler (~> 1.0)
10
+ git (>= 1.2.5)
11
+ rake
12
+ rdoc
13
+ json (1.8.0)
14
+ multi_json (1.7.7)
15
+ rake (10.0.4)
16
+ rdoc (4.0.1)
17
+ json (~> 1.4)
18
+ rspec (2.13.0)
19
+ rspec-core (~> 2.13.0)
20
+ rspec-expectations (~> 2.13.0)
21
+ rspec-mocks (~> 2.13.0)
22
+ rspec-core (2.13.1)
23
+ rspec-expectations (2.13.0)
24
+ diff-lcs (>= 1.1.3, < 2.0)
25
+ rspec-mocks (2.13.1)
26
+ simplecov (0.7.1)
27
+ multi_json (~> 1.0)
28
+ simplecov-html (~> 0.7.1)
29
+ simplecov-html (0.7.1)
30
+
31
+ PLATFORMS
32
+ ruby
33
+
34
+ DEPENDENCIES
35
+ bundler (~> 1.0)
36
+ colored (>= 1.2)
37
+ highline (>= 1.6)
38
+ jeweler (~> 1.8)
39
+ rspec (~> 2.11)
40
+ simplecov
data/LICENSE.txt ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
data/README.md ADDED
@@ -0,0 +1,135 @@
1
+ # steps
2
+
3
+ ## General
4
+
5
+ A gem that produces simple user feedback in scripting environments.
6
+
7
+ Integrates with:
8
+
9
+ - Capistrano Tasks
10
+ - Rake Tasks
11
+ - Generic Ruby shell scripting
12
+
13
+ ## Installation
14
+
15
+ ### Github
16
+
17
+ Add this to your Gemfile to install and use directly from github.
18
+
19
+ ```ruby
20
+ gem "steps", :git => 'git://github.com/crowdfavorite/gem-steps.git'
21
+ ```
22
+
23
+ ### RubyGems.org
24
+
25
+ This gem is available as 'steps' from rubygems.org
26
+
27
+ gem install steps
28
+
29
+ ## Usage
30
+
31
+ To define a "step" in your scripting process simply surround the grouping of operations like this.
32
+
33
+ ```ruby
34
+ step "Do Something" do
35
+ # stuff you want to do
36
+ end
37
+ ```
38
+
39
+ Nested steps are supported
40
+
41
+ ### Other
42
+
43
+ **Exit if step fails. If nested, fail parent step.**
44
+
45
+ ```ruby
46
+ step "Super Important", :vital => true do
47
+ # vital stuff
48
+ end
49
+ ```
50
+
51
+ **Manually bail out of a step**
52
+
53
+ ```ruby
54
+ step "Do Something" do
55
+ # do something
56
+ if you_want_to_bail
57
+ raise "This is the error Message"
58
+ end
59
+ end
60
+ ```
61
+
62
+ **Custom Complete Message**
63
+
64
+ ```ruby
65
+ step "Do Something" do
66
+ # do something
67
+ "This is the success Message"
68
+ end
69
+ ```
70
+
71
+ **Provide feedback**
72
+
73
+ ```ruby
74
+ step "Do Something" do
75
+ # do something
76
+ report "The user would like to see this info"
77
+ # do more stuff
78
+ end
79
+ ```
80
+ ### Getting User Feedback (highline integration)
81
+
82
+ #### confirm
83
+
84
+ Function similar to highline agree function, except it plays nice with our output.
85
+
86
+ It also accepts a `:vital` option if you want to exit with a negative response (No).
87
+
88
+ ```ruby
89
+ step "Confirm Blue" do
90
+ if confirm "Do you like blue?"
91
+ # bail out if they are not sure they like blue
92
+ confirm "Are you sure you like blue?", :vital => true
93
+ end
94
+ end
95
+ ```
96
+
97
+ #### retrieve
98
+
99
+ The retrieve function is essentially a shadow of the highline ask function, except it plays nice with our output
100
+
101
+ ```ruby
102
+ step "Get Favorite Color" do
103
+ feedback = retrieve "What is your favorite color?"
104
+ end
105
+ ```
106
+
107
+ ### Capistrano Deployment Integration
108
+
109
+ If you want to quiet down your Capistrano output and use this to provide the output, you can manually quiet the Capistrano logger and use this gem in the following way.
110
+
111
+ ```ruby
112
+ require 'steps'
113
+
114
+ logger.level = Logger::IMPORTANT # or Capistrano::Logger::IMPORTANT
115
+
116
+ # ... omitted ..
117
+
118
+ before "deploy:update_code" do start_to "Deploy" end
119
+ after "deploy:update_code" do success end
120
+
121
+ before "bundle:install" do start_to "Bundle" end
122
+ after "bundle:install" do success end
123
+
124
+ before "deploy:migrate" do start_to "Migrate Database" end
125
+ after "deploy:migrate" do success end
126
+
127
+ before "deploy:assets:clean" do start_to "Clean" end
128
+ after "deploy:assets:clean" do success end
129
+
130
+ before "deploy:assets:precompile" do start to "Compile Assets" end
131
+ after "deploy:assets:precompile" do success end
132
+
133
+ before "deploy:restart" do start_to "Restart" end
134
+ after "deploy:restart" do success end
135
+ ```
data/Rakefile ADDED
@@ -0,0 +1,30 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "steps"
18
+ gem.homepage = "http://github.com/crowdfavorite/gem-steps"
19
+ gem.license = "Apache 2.0"
20
+ gem.summary = %Q{Scripting output helper}
21
+ gem.description = <<-EOF.gsub(/^ {4}/, '')
22
+ A way to simplify the output of shell scripting written in ruby.
23
+
24
+ Integrates with Capistrano and Rake tasks.
25
+ EOF
26
+ gem.authors = ["Crowd Favorite"]
27
+ # dependencies defined in Gemfile
28
+ end
29
+ Jeweler::RubygemsDotOrgTasks.new
30
+
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.1
data/lib/steps.rb ADDED
@@ -0,0 +1,35 @@
1
+ # encoding: utf-8
2
+ require 'steps/output'
3
+
4
+ def step(desc, options={}, &block)
5
+ Steps::Output.step(desc, options, &block)
6
+ end
7
+
8
+ def confirm(message, options={})
9
+ Steps::Output.confirm(message, options)
10
+ end
11
+
12
+ def retrieve(message, answer_type = String, &block)
13
+ Steps::Output.retrieve(message, answer_type, &block)
14
+ end
15
+
16
+ def start_to(message)
17
+ Steps::Output.start_to(message)
18
+ end
19
+
20
+ def success(message = "✔")
21
+ Steps::Output.success(message)
22
+ end
23
+
24
+ def error(message = "X")
25
+ Steps::Output.error(message)
26
+ end
27
+
28
+ def error_and_exit(message)
29
+ Steps::Output.error_and_exit(message)
30
+ end
31
+
32
+ def report(message)
33
+ step message.bold.blue do " " end
34
+ end
35
+
@@ -0,0 +1,130 @@
1
+ # encoding: utf-8
2
+ STDOUT.sync
3
+ require 'colored'
4
+ require 'highline'
5
+ require 'steps/spinner'
6
+
7
+ module Steps
8
+ class Output
9
+
10
+ @spinner = Steps::Spinner.new
11
+ @task_depth = 0
12
+ @stacked_result = false
13
+ @highline = HighLine.new
14
+
15
+ def self.step(desc, options)
16
+ self.start_to desc
17
+ begin
18
+ smessage = yield
19
+ smessage = "✔" unless smessage.is_a? String
20
+ self.success smessage
21
+ rescue Exception => e
22
+ message = e.message.empty? ? "X" : e.message
23
+
24
+ self.error(message)
25
+ if options[:vital]
26
+ if @task_depth > 1
27
+ raise "X"
28
+ else
29
+ exit
30
+ end
31
+ end
32
+ end
33
+ end
34
+
35
+ def self.start_to message
36
+ lead_str = ""
37
+ if @spinner.running?
38
+ @spinner.stop
39
+ if @stacked_result
40
+ lead_str = "\r#{`tput el`}"
41
+ else
42
+ lead_str = "\n"
43
+ end
44
+ end
45
+
46
+ if @task_depth > 0
47
+ message = lead_str + ("| " * (@task_depth - 1)) + "├── " + message
48
+ end
49
+
50
+ print "#{message}".yellow + " "
51
+ @spinner.start
52
+ @task_depth += 1
53
+ @stacked_result = false
54
+ end
55
+
56
+ def self.result message
57
+ @spinner.stop
58
+
59
+ puts message
60
+
61
+ if @task_depth > 0
62
+ @task_depth -= 1
63
+ if @task_depth > 0
64
+ print "| ".yellow * (@task_depth - 1)
65
+ @spinner.start
66
+ end
67
+ end
68
+ @stacked_result = true
69
+ end
70
+
71
+ def self.error message
72
+ if @spinner.running?
73
+ @spinner.stop
74
+ end
75
+ self.result message.red
76
+ end
77
+
78
+ def self.error_and_exit message
79
+ self.error message
80
+ exit
81
+ end
82
+
83
+ def self.success message
84
+ self.result message.green
85
+ end
86
+
87
+ def self.info message
88
+ self.result message.blue
89
+ end
90
+
91
+ def self.confirm(message, options={})
92
+ message = message + " (y|n) > "
93
+ message = (options[:vital] ? message.red : message.blue) + " "
94
+ message = "├── ".yellow + message if @task_depth > 0
95
+ @spinner.stop
96
+ if @task_depth > 0 and not @stacked_result
97
+ print "\n" + ("| ".yellow * (@task_depth - 1))
98
+ end
99
+ result = @highline.agree(message)
100
+ if @task_depth > 0
101
+ print "| ".yellow * (@task_depth - 1)
102
+ @spinner.start
103
+ end
104
+
105
+ if options[:vital] and not result
106
+ if @task_depth > 0
107
+ raise "Aborting"
108
+ else
109
+ self.error_and_exit "Aborting"
110
+ end
111
+ end
112
+
113
+ @stacked_result = true
114
+ return result
115
+ end
116
+
117
+ def self.retrieve(message, answer_type, &block)
118
+ message = message + " > "
119
+ message = message.blue + " "
120
+ message = "├── ".yellow + message if @task_depth > 0
121
+ @spinner.stop
122
+ result = @highline.ask(message, answer_type, &block)
123
+ if @task_depth > 0
124
+ print "| ".yellow * (@task_depth - 1)
125
+ @spinner.start
126
+ end
127
+ return result
128
+ end
129
+ end
130
+ end
@@ -0,0 +1,37 @@
1
+ module Steps
2
+
3
+ # Simple shell spinner to provide user feedback
4
+ #
5
+ class Spinner
6
+
7
+ def initialize
8
+ @running = false
9
+ @chars = ['|', '/', '-', '\\']
10
+ end
11
+
12
+ def running?
13
+ @running
14
+ end
15
+
16
+ def start()
17
+ if (!@running)
18
+ @running = true
19
+ @spinner_thread = Thread.new do
20
+ while @running do
21
+ print @chars.push(@chars.shift).first
22
+ sleep(0.1)
23
+ print "\b \b"
24
+ end
25
+ end
26
+ end
27
+ end
28
+
29
+ def stop()
30
+ if @running
31
+ @running = false
32
+ @spinner_thread.join
33
+ end
34
+ end
35
+
36
+ end
37
+ end
@@ -0,0 +1,4 @@
1
+ module Steps
2
+ VERSION = '1.0'
3
+ end
4
+
data/steps.gemspec ADDED
@@ -0,0 +1,66 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "steps"
8
+ s.version = "1.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Crowd Favorite"]
12
+ s.date = "2013-07-11"
13
+ s.description = "A way to simplify the output of shell scripting written in ruby.\n\nIntegrates with Capistrano and Rake tasks.\n"
14
+ s.extra_rdoc_files = [
15
+ "LICENSE.txt",
16
+ "README.md"
17
+ ]
18
+ s.files = [
19
+ "CHANGELOG",
20
+ "Gemfile",
21
+ "Gemfile.lock",
22
+ "LICENSE.txt",
23
+ "README.md",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "lib/steps.rb",
27
+ "lib/steps/output.rb",
28
+ "lib/steps/spinner.rb",
29
+ "lib/steps/version.rb",
30
+ "steps.gemspec",
31
+ "test.rb"
32
+ ]
33
+ s.homepage = "http://github.com/crowdfavorite/gem-steps"
34
+ s.licenses = ["Apache 2.0"]
35
+ s.require_paths = ["lib"]
36
+ s.rubygems_version = "1.8.25"
37
+ s.summary = "Scripting output helper"
38
+
39
+ if s.respond_to? :specification_version then
40
+ s.specification_version = 3
41
+
42
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
43
+ s.add_runtime_dependency(%q<colored>, [">= 1.2"])
44
+ s.add_runtime_dependency(%q<highline>, [">= 1.6"])
45
+ s.add_development_dependency(%q<rspec>, ["~> 2.11"])
46
+ s.add_development_dependency(%q<bundler>, ["~> 1.0"])
47
+ s.add_development_dependency(%q<jeweler>, ["~> 1.8"])
48
+ s.add_development_dependency(%q<simplecov>, [">= 0"])
49
+ else
50
+ s.add_dependency(%q<colored>, [">= 1.2"])
51
+ s.add_dependency(%q<highline>, [">= 1.6"])
52
+ s.add_dependency(%q<rspec>, ["~> 2.11"])
53
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
54
+ s.add_dependency(%q<jeweler>, ["~> 1.8"])
55
+ s.add_dependency(%q<simplecov>, [">= 0"])
56
+ end
57
+ else
58
+ s.add_dependency(%q<colored>, [">= 1.2"])
59
+ s.add_dependency(%q<highline>, [">= 1.6"])
60
+ s.add_dependency(%q<rspec>, ["~> 2.11"])
61
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
62
+ s.add_dependency(%q<jeweler>, ["~> 1.8"])
63
+ s.add_dependency(%q<simplecov>, [">= 0"])
64
+ end
65
+ end
66
+
data/test.rb ADDED
@@ -0,0 +1,54 @@
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+ require 'steps'
3
+
4
+ confirm "This is not a vital question, right?"
5
+
6
+ step "Update Something" do
7
+ sleep 1
8
+ end
9
+
10
+ confirm "Is this a vital question?", :vital => true
11
+
12
+ step "Do Something else" do
13
+ confirm "Is this a vital question?", :vital => true
14
+ sleep 1
15
+ step "Nested Something" do
16
+ sleep 1
17
+ step "Double! Again" do
18
+ report "Something you probably want to know"
19
+ sleep 1
20
+ end
21
+ step "Double! Again" do
22
+ sleep 1
23
+ report "Something you probably want to know"
24
+ end
25
+ step "Double! Nested Something" do
26
+ step "Triple (and vital)! Nested Something", :vital => true do
27
+ report "this is something important"
28
+ report "Something else important"
29
+ step "Quad! Nested Something" do
30
+ sleep 1
31
+ if confirm "Is this a vital question?", :vital => true
32
+ step "resolution" do
33
+ sleep 1
34
+ end
35
+ end
36
+ end
37
+ sleep 1
38
+ answer = retrieve "What is your favorite color?"
39
+ step "favorite color" do
40
+ sleep 1
41
+ answer
42
+ end
43
+ end
44
+ step "Another Triple" do
45
+ sleep 1
46
+ end
47
+ sleep 1
48
+ end
49
+ sleep 1
50
+ end
51
+
52
+ sleep 1
53
+ raise
54
+ end
metadata ADDED
@@ -0,0 +1,161 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: steps
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Crowd Favorite
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-07-11 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: colored
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '1.2'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '1.2'
30
+ - !ruby/object:Gem::Dependency
31
+ name: highline
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '1.6'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '1.6'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: '2.11'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '2.11'
62
+ - !ruby/object:Gem::Dependency
63
+ name: bundler
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: '1.0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: '1.0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: jeweler
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: '1.8'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: '1.8'
94
+ - !ruby/object:Gem::Dependency
95
+ name: simplecov
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ description: ! 'A way to simplify the output of shell scripting written in ruby.
111
+
112
+
113
+ Integrates with Capistrano and Rake tasks.
114
+
115
+ '
116
+ email:
117
+ executables: []
118
+ extensions: []
119
+ extra_rdoc_files:
120
+ - LICENSE.txt
121
+ - README.md
122
+ files:
123
+ - CHANGELOG
124
+ - Gemfile
125
+ - Gemfile.lock
126
+ - LICENSE.txt
127
+ - README.md
128
+ - Rakefile
129
+ - VERSION
130
+ - lib/steps.rb
131
+ - lib/steps/output.rb
132
+ - lib/steps/spinner.rb
133
+ - lib/steps/version.rb
134
+ - steps.gemspec
135
+ - test.rb
136
+ homepage: http://github.com/crowdfavorite/gem-steps
137
+ licenses:
138
+ - Apache 2.0
139
+ post_install_message:
140
+ rdoc_options: []
141
+ require_paths:
142
+ - lib
143
+ required_ruby_version: !ruby/object:Gem::Requirement
144
+ none: false
145
+ requirements:
146
+ - - ! '>='
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
149
+ required_rubygems_version: !ruby/object:Gem::Requirement
150
+ none: false
151
+ requirements:
152
+ - - ! '>='
153
+ - !ruby/object:Gem::Version
154
+ version: '0'
155
+ requirements: []
156
+ rubyforge_project:
157
+ rubygems_version: 1.8.25
158
+ signing_key:
159
+ specification_version: 3
160
+ summary: Scripting output helper
161
+ test_files: []