sickle 0.5.2 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -0
- data/lib/sickle.rb +9 -0
- data/lib/sickle/version.rb +1 -1
- data/spec/main_spec.rb +12 -0
- data/spec/test_app.rb +4 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c3206ca92bf2b085c6ad94ebdc2d15639d8b2f60
|
4
|
+
data.tar.gz: 0509497cf3267976fda8065c9a4d1a6ec39fd099
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7fb3fbbd7b40bffac21c6167639ac126316a1750cb17d207a42ec1326fe0e5d2ce91f801c0e530b6ce44bb91aaec4f695b5d29435755fd8b2ab5010fd4e45a1
|
7
|
+
data.tar.gz: b84b297c4aac6003c5c4b1d4bd0e65b2274cac71cd3b5c28038e79105e2cecc5d0748cb51c05c94012b0a3b2022eb56eb5ca7dfa525f3600dea202350464eb62
|
data/README.md
CHANGED
@@ -46,6 +46,11 @@ class App
|
|
46
46
|
global_flag :verbose # global flag, defaults to false
|
47
47
|
global_option :with_prefix # global option, defaults to nil
|
48
48
|
|
49
|
+
# optional before hook with access to global options
|
50
|
+
before do
|
51
|
+
$verbose = options[:verbose]
|
52
|
+
end
|
53
|
+
|
49
54
|
desc "install one of the available apps" # command description
|
50
55
|
flag :force # flag for `install` command
|
51
56
|
option :host, :default => "localhost" # option
|
data/lib/sickle.rb
CHANGED
@@ -190,6 +190,10 @@ module Sickle
|
|
190
190
|
end
|
191
191
|
end
|
192
192
|
|
193
|
+
def before(&block)
|
194
|
+
@__before_hook = block
|
195
|
+
end
|
196
|
+
|
193
197
|
def desc(label)
|
194
198
|
Sickle.push_desc(label)
|
195
199
|
end
|
@@ -252,6 +256,11 @@ module Sickle
|
|
252
256
|
|
253
257
|
obj = self.new
|
254
258
|
obj.instance_variable_set(:@__options, results)
|
259
|
+
|
260
|
+
if @__before_hook
|
261
|
+
obj.instance_exec(&@__before_hook)
|
262
|
+
end
|
263
|
+
|
255
264
|
command.meth.bind(obj).call(*args)
|
256
265
|
else
|
257
266
|
puts "\e[31mCommand '#{command_name}' not found\e[0m"
|
data/lib/sickle/version.rb
CHANGED
data/spec/main_spec.rb
CHANGED
@@ -83,4 +83,16 @@ describe Sickle do
|
|
83
83
|
$?.wont_equal 127
|
84
84
|
end
|
85
85
|
end
|
86
|
+
|
87
|
+
describe "before block" do
|
88
|
+
it "should set $verbose to false" do
|
89
|
+
App.run (%w(test-option))
|
90
|
+
$verbose.must_equal false
|
91
|
+
end
|
92
|
+
|
93
|
+
it "should set $verbose to true" do
|
94
|
+
App.run(%w(test-option --verbose))
|
95
|
+
$verbose.must_equal true
|
96
|
+
end
|
97
|
+
end
|
86
98
|
end
|
data/spec/test_app.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sickle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tymon Tobolski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|