cap_reserve 0.1.1 → 0.1.2
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.
- data/cap_reserve.gemspec +1 -1
- data/lib/cap_reserve.rb +8 -3
- metadata +3 -3
data/cap_reserve.gemspec
CHANGED
data/lib/cap_reserve.rb
CHANGED
@@ -13,6 +13,11 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
13
13
|
env, user, time, force, url, destroy =
|
14
14
|
ENV['RESERVE_ENV'], ENV['USER'], ENV['RESERVE'], ENV['FORCE'], ENV['RESERVE_URL'], ENV['DESTROY']
|
15
15
|
|
16
|
+
help = <<-HELP
|
17
|
+
FORCE=1 to deploy anyway
|
18
|
+
DESTROY=1 to deploy and destroy reservation
|
19
|
+
HELP
|
20
|
+
|
16
21
|
expires_to_string = lambda do |expires|
|
17
22
|
left = Time.at(expires) - Time.now
|
18
23
|
if left < 60
|
@@ -41,11 +46,11 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
41
46
|
get.call("#{url}/reservations/create", {
|
42
47
|
:environment => env, :user => user, :seconds => time.to_i * 60
|
43
48
|
}.merge(params))
|
44
|
-
puts "
|
49
|
+
puts "\n\e[32mReservation created\e[0m: \e[33m#{user}@#{env}\e[0m for \e[33m#{time.to_i} minutes\e[0m\n\n"
|
45
50
|
elsif destroy
|
46
51
|
res = get.call("#{url}/reservations/destroy", :environment => env)
|
47
52
|
if res['status'] == 'reserved'
|
48
|
-
puts "
|
53
|
+
puts "\n\e[32mReservation destroyed\e[0m: \e[33m#{res['user']}@#{env}\e[0m (\e[33m#{expires_to_string.call Time.at(res['expires'])}\e[0m left)\n\n"
|
49
54
|
end
|
50
55
|
end
|
51
56
|
end
|
@@ -58,7 +63,7 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
58
63
|
else
|
59
64
|
res = get.call("#{url}/reservations/show", :environment => env)
|
60
65
|
if res['status'] == 'reserved'
|
61
|
-
puts "
|
66
|
+
puts "\n\e[31mReservation exists\e[0m: \e[33m#{res['user']}@#{env}\e[0m for \e[33m#{expires_to_string.call Time.at(res['expires'])}\e[0m\n#{help}\n"
|
62
67
|
exit 0
|
63
68
|
else
|
64
69
|
create.call({})
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cap_reserve
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 2
|
10
|
+
version: 0.1.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Winton Welsh
|