capistrano-calendar 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -25,6 +25,9 @@ Capistrano recipe should be used in some :after hooks (e.g. after deploy). Recip
25
25
 
26
26
  ## Calendar configuration
27
27
 
28
+ * *:calendar_verbose (nil) - if true display calendar data actions
29
+ * *:calendar_logfile (/tmp/capistrano-calendar-PID.log) - calendar log
30
+ * *:calendar_foreground (nil) - don't daemonize calendar process if true
28
31
  * *:calendar_service* (:google) - calendar service to use e.g. ':google'
29
32
  * **:calendar_username** (nil) - calendar service username e.g 'vasya.pupkin@gmail.com'
30
33
  * **:calendar_password** (nil) - calendar service password e.g 'qwery123456'
@@ -46,7 +49,7 @@ Bold means required options. Value in brackets means default value.
46
49
  Calendar event creation will be executed by default on the one of application servers (specified in :app roles)
47
50
  You can change this behavior via *calendar_runner* option. Examples:
48
51
 
49
- set(:calendar_runner, { :roles => :calendar_notifier, :once => true )
52
+ set(:calendar_runner, { :roles => :calendar_notifier, :once => true })
50
53
  # or
51
54
  set(:calendar_runner, { :hosts => 'notification.example.com' })
52
55
 
@@ -58,21 +61,21 @@ Be sure to pass `:once => true` option if you use *:roles* !
58
61
  set :calendar_username, 'vasya.pupkin@my.company.com'
59
62
  set :calendar_password, '123456'
60
63
 
61
- set :calendar_name { stage }
62
- set :calendar_summary { "" }
64
+ set(:calendar_name) { stage }
65
+ set(:calendar_summary) { "" }
63
66
  set :calendar_timezone, 'UTC'
64
- set :calendar_color, { stage == 'production' ? '#ff000' : '#00ff00' }
67
+ set(:calendar_color), { stage == 'production' ? '#ff000' : '#00ff00' }
65
68
 
66
- set :calendar_event_summary { "Bla" }
67
- set :calendar_event_time { Time.now }
69
+ set(:calendar_event_summary) { "Bla" }
70
+ set(:calendar_event_time) { Time.now }
68
71
 
69
72
  after 'deploy' do
70
- set :calendar_event_title "[Deployed] #{application} #{branch}: #{real_revision}"
73
+ set :calendar_event_title, "[Deployed] #{application} #{branch}: #{real_revision}"
71
74
  top.calendar.create_event
72
75
  end
73
76
 
74
77
  after 'deploy:rollback' do
75
- set :calendar_event_title "[Rollback] #{application} #{branch}: #{real_revision}"
78
+ set :calendar_event_title, "[Rollback] #{application} #{branch}: #{real_revision}"
76
79
  top.calendar.create_event
77
80
  end
78
81
 
@@ -80,12 +83,12 @@ Be sure to pass `:once => true` option if you use *:roles* !
80
83
  # Extra configurations if you are using capistrano-patch:
81
84
  #
82
85
  after 'patch:apply' do
83
- set :calendar_event_title "[Pathed] #{application} #{branch}: #{patch_strategy.revision_to}"
86
+ set :calendar_event_title, "[Pathed] #{application} #{branch}: #{patch_strategy.revision_to}"
84
87
  calendar_client.create_event
85
88
  end
86
89
 
87
90
  after 'patch:revert' do
88
- set :calendar_event_title "[Patch rollback] #{application} #{branch}: #{patch_strategy.revision_from}"
91
+ set :calendar_event_title, "[Patch rollback] #{application} #{branch}: #{patch_strategy.revision_from}"
89
92
  top.calendar.create_event
90
93
  end
91
94
 
@@ -7,6 +7,10 @@ module Capistrano
7
7
 
8
8
  def self.collect(hash)
9
9
  [
10
+ :calendar_verbose,
11
+ :calendar_logfile,
12
+ :calendar_foreground,
13
+
10
14
  :calendar_service,
11
15
  :calendar_username,
12
16
  :calendar_password,
@@ -21,7 +25,7 @@ module Capistrano
21
25
  :calendar_event_summary,
22
26
  :calendar_event_location,
23
27
  :calendar_event_time,
24
- :calendar_event_status
28
+ :calendar_event_status,
25
29
  ].inject({}) { |result, key|
26
30
  result[key] = hash[key] if hash.exists?(key)
27
31
  result
@@ -40,8 +40,12 @@ module Capistrano
40
40
  @configuration.is_a?(Hash) or abort("Bad configuration given")
41
41
 
42
42
  @client = Capistrano::Calendar::Client.new(@configuration)
43
-
44
- daemonize { create_event }
43
+
44
+ if @configuration[:calendar_foreground]
45
+ create_event
46
+ else
47
+ daemonize { create_event }
48
+ end
45
49
  else
46
50
  abort parser.help
47
51
  end
@@ -51,11 +55,18 @@ module Capistrano
51
55
  protected
52
56
 
53
57
  def create_event
58
+ verbose("Creating event with configuration: #{@configuration.inspect}")
59
+
54
60
  client.authenticate
55
- client.create_event
61
+ event = client.create_event
62
+
63
+ verbose("Created event: #{event.inspect}")
64
+ event
56
65
  end
57
66
 
58
67
  def daemonize
68
+ logfile = @configuration[:calendar_logfile] || "/tmp/capistrano-calendar-#{Process.pid}.log"
69
+
59
70
  Process.fork do
60
71
  # Detach the child process from the parent's session.
61
72
  Process.setsid
@@ -76,13 +87,18 @@ module Capistrano
76
87
  # to be sure that any output from the daemon will
77
88
  # not appear in any terminals.
78
89
  $stdin.reopen("/dev/null")
79
- $stdout.reopen("/tmp/capistrano-calendar.stdout")
80
- $stderr.reopen("/tmp/capistrano-calendar.stderr")
90
+ $stdout.reopen(logfile, "a")
91
+ $stderr.reopen(logfile, "a")
81
92
 
82
93
  yield
83
94
  end
95
+
96
+ puts "Logging to: #{logfile}"
84
97
  end
85
98
 
99
+ def verbose(message)
100
+ puts(message) if @configuration[:calendar_verbose]
101
+ end
86
102
  end
87
103
  end
88
104
  end
@@ -1,5 +1,5 @@
1
1
  module Capistrano
2
2
  module Calendar
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-calendar
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Andriy Yanko
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-10-26 00:00:00 Z
18
+ date: 2011-11-14 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: capistrano