cap_reserve 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/cap_reserve.gemspec +1 -1
  2. data/lib/cap_reserve.rb +8 -3
  3. metadata +3 -3
data/cap_reserve.gemspec CHANGED
@@ -6,7 +6,7 @@ $:.unshift lib unless $:.include?(lib)
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "cap_reserve"
9
- s.version = '0.1.1'
9
+ s.version = '0.1.2'
10
10
  s.platform = Gem::Platform::RUBY
11
11
  s.authors = [ "Winton Welsh" ]
12
12
  s.email = [ "mail@wintoni.us" ]
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 "Reservation created: #{user}@#{env} for #{time.to_i} minutes"
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 "Reservation destroyed: #{res['user']}@#{env} (#{expires_to_string.call Time.at(res['expires'])} left)"
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 "Reservation exists: #{res['user']}@#{env} for #{expires_to_string.call Time.at(res['expires'])}"
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: 25
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 1
10
- version: 0.1.1
9
+ - 2
10
+ version: 0.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Winton Welsh