Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Version 0.1.2

  • Loading branch information...
commit f0074dd054796a9dbf240794af99244842169683 1 parent 219a079
@winton authored
Showing with 9 additions and 4 deletions.
  1. +1 −1  cap_reserve.gemspec
  2. +8 −3 lib/cap_reserve.rb
View
2  cap_reserve.gemspec
@@ -6,7 +6,7 @@ $:.unshift lib unless $:.include?(lib)
Gem::Specification.new do |s|
s.name = "cap_reserve"
- s.version = '0.1.1'
+ s.version = '0.1.2'
s.platform = Gem::Platform::RUBY
s.authors = [ "Winton Welsh" ]
s.email = [ "mail@wintoni.us" ]
View
11 lib/cap_reserve.rb
@@ -13,6 +13,11 @@
env, user, time, force, url, destroy =
ENV['RESERVE_ENV'], ENV['USER'], ENV['RESERVE'], ENV['FORCE'], ENV['RESERVE_URL'], ENV['DESTROY']
+ help = <<-HELP
+FORCE=1 to deploy anyway
+DESTROY=1 to deploy and destroy reservation
+HELP
+
expires_to_string = lambda do |expires|
left = Time.at(expires) - Time.now
if left < 60
@@ -41,11 +46,11 @@
get.call("#{url}/reservations/create", {
:environment => env, :user => user, :seconds => time.to_i * 60
}.merge(params))
- puts "Reservation created: #{user}@#{env} for #{time.to_i} minutes"
+ puts "\n\e[32mReservation created\e[0m: \e[33m#{user}@#{env}\e[0m for \e[33m#{time.to_i} minutes\e[0m\n\n"
elsif destroy
res = get.call("#{url}/reservations/destroy", :environment => env)
if res['status'] == 'reserved'
- puts "Reservation destroyed: #{res['user']}@#{env} (#{expires_to_string.call Time.at(res['expires'])} left)"
+ 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"
end
end
end
@@ -58,7 +63,7 @@
else
res = get.call("#{url}/reservations/show", :environment => env)
if res['status'] == 'reserved'
- puts "Reservation exists: #{res['user']}@#{env} for #{expires_to_string.call Time.at(res['expires'])}"
+ 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"
exit 0
else
create.call({})
Please sign in to comment.
Something went wrong with that request. Please try again.