cap_gun 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1 +1,3 @@
1
+ v0.0.2. Converts the release times to the current time zone; improved docs.
2
+
1
3
  v0.0.1. Initial release. Rock n roll mcdonalds.
@@ -6,14 +6,17 @@ Tell everyone about your releases! Send email notification after Capistrano dep
6
6
 
7
7
  Drop your ActionMailer configuration information into your deploy.rb file, configure recipients for the deployment notifications, and setup the callback task.
8
8
 
9
- Setup and configuration are done entirely inside your deploy.rb file to KISS. Your emails are sent locally, from the box performing the deployment, but CapGun queries the server to grab the necessary release info.
9
+ Setup and configuration are done entirely inside your deploy.rb file to keep it super simple. Your emails are sent locally from the box performing the deployment, but CapGun queries the server to grab the necessary release info.
10
10
 
11
- We include the Net::SMTP TLS hack inside as a vendored dependancy to allow super easy email sending without setting up an MTA.
11
+ This even includes the Net::SMTP TLS hack inside as a vendored dependancy to allow super easy email sending without setting up an MTA.
12
12
 
13
13
  == CONFIG
14
14
 
15
15
  In your Capistrano config file (usually deploy.rb):
16
16
 
17
+ # require cap_gun (the path will depend on where you unpacked or if you are just using it as a gem)
18
+ require 'vendor/plugins/cap_gun/lib/cap_gun' # typical Rails vendor/plugins location
19
+
17
20
  # setup action mailer with a hash of options
18
21
  set :cap_gun_action_mailer_config, {
19
22
  :address => "smtp.gmail.com",
@@ -1,16 +1,16 @@
1
1
 
2
- # Gem::Specification for Cap_gun-0.0.1
2
+ # Gem::Specification for Cap_gun-0.0.2
3
3
  # Originally generated by Echoe
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = %q{cap_gun}
7
- s.version = "0.0.1"
7
+ s.version = "0.0.2"
8
8
 
9
9
  s.specification_version = 2 if s.respond_to? :specification_version=
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.authors = ["Rob Sanheim, Relevance"]
13
- s.date = %q{2008-04-17}
13
+ s.date = %q{2008-04-20}
14
14
  s.description = %q{Super simple capistrano deployments.}
15
15
  s.email = %q{opensource@thinkrelevance.com}
16
16
  s.extra_rdoc_files = ["CHANGELOG", "lib/cap_gun.rb", "MIT-LICENSE", "README.rdoc"]
@@ -25,8 +25,9 @@ require File.join(File.dirname(__FILE__), *%w[.. vendor action_mailer_tls lib sm
25
25
  #
26
26
  # cap -s comment="fix for bug #303" deploy
27
27
  #
28
+ # See README for full install/config instructions.
28
29
  module CapGun
29
- VERSION = '0.0.1'
30
+ VERSION = '0.0.2'
30
31
 
31
32
  module Helper
32
33
 
@@ -38,7 +39,7 @@ module CapGun
38
39
  ActionMailer::Base.smtp_settings = cap.cap_gun_action_mailer_config
39
40
  end
40
41
 
41
- # Current user - unsupported on Windows
42
+ # Current user - unsupported on Windows, patches welcome
42
43
  def current_user
43
44
  platform.include?('mswin') ? nil : `id -un`.strip
44
45
  end
@@ -48,14 +49,31 @@ module CapGun
48
49
  RUBY_PLATFORM
49
50
  end
50
51
 
51
- # Assuming the standard Capistrano timestamp directory, gives you a prettier date/time for output.
52
- # This does not take into account anything to do with timezones, but I believe Capistrano always
53
- # uses UTC so we could convert to a specified time zone for even friendlier display.
52
+ # Gives you a prettier date/time for output from the standard Capistrano timestamped release directory.
53
+ # This assumes Capistrano uses UTC for its date/timestamped directories, and converts to the local
54
+ # machine timezone.
54
55
  def humanize_release_time(path)
55
56
  match = path.match(/(\d+)$/)
56
57
  return unless match
57
- time = Time.parse(match[1])
58
- time.strftime("%B #{time.day.ordinalize}, %Y %l:%M %p %Z").gsub(/\s+/, ' ').strip
58
+ local = convert_from_utc(match[1])
59
+ local.strftime("%B #{local.day.ordinalize}, %Y %l:%M %p #{local_timezone}").gsub(/\s+/, ' ').strip
60
+ end
61
+
62
+ # Use some DateTime magicrey to convert UTC to the current time zone
63
+ # When the whole world is on Rails 2.1 (and therefore new ActiveSupport) we can use the magic timezone support there.
64
+ def convert_from_utc(timestamp)
65
+ # we know Capistrano release timestamps are UTC, but Ruby doesn't, so make it explicit
66
+ utc_time = timestamp << "UTC"
67
+ datetime = DateTime.parse(utc_time)
68
+ datetime.new_offset(local_datetime_zone_offset)
69
+ end
70
+
71
+ def local_datetime_zone_offset
72
+ @local_datetime_zone_offset ||= DateTime.now.offset
73
+ end
74
+
75
+ def local_timezone
76
+ @current_timezone ||= Time.now.zone
59
77
  end
60
78
 
61
79
  extend self
@@ -70,6 +88,11 @@ module CapGun
70
88
  adv_attr_accessor :email_prefix
71
89
 
72
90
  # Grab the options for emaililng from cap_gun_email_envelope (should be set in your deploy file)
91
+ #
92
+ # Valid options:
93
+ # :recipients (required) an array or string of email address(es) that should get notifications
94
+ # :from the sender of the notification, defaults to cap_gun@example.com
95
+ # :email_prefix subject prefix, defaults to [DEPLOY]
73
96
  def init(envelope = {})
74
97
  recipients envelope[:recipients]
75
98
  from (envelope[:from] || DEFAULT_SENDER)
@@ -56,12 +56,26 @@ describe "CapGun" do
56
56
  current_user
57
57
  end
58
58
 
59
+ end
60
+
61
+ describe "handling release time" do
62
+ include CapGun::Helper
63
+
64
+ before do # make DateTime act as if local timezone is EDT
65
+ stubs(:local_timezone).returns("EDT")
66
+ stubs(:local_datetime_zone_offset).returns(Rational(-1,6))
67
+ end
68
+
59
69
  it "returns nil for weird release path" do
60
70
  humanize_release_time("/data/foo/my_release").should == nil
61
71
  end
62
72
 
63
73
  it "parse datetime from release path" do
64
- humanize_release_time("/data/foo/releases/20080402152141").should == "April 2nd, 2008 3:21 PM EDT"
74
+ humanize_release_time("/data/foo/releases/20080227120000").should == "February 27th, 2008 8:00 AM EDT"
75
+ end
76
+
77
+ it "converts time from release into localtime" do
78
+ humanize_release_time("/data/foo/releases/20080410040000").should == "April 10th, 2008 12:00 AM EDT"
65
79
  end
66
80
 
67
81
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cap_gun
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rob Sanheim, Relevance
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-04-17 00:00:00 -04:00
12
+ date: 2008-04-20 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies: []
15
15