capistrano-pushover 0.0.2 → 0.1

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/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/README.md CHANGED
@@ -23,7 +23,7 @@ Add to deploy.rb:
23
23
  require 'hipchat/capistrano'
24
24
 
25
25
  set :pushover_app_token, 'Your Pushover Application Token'
26
- set :pusehover_user_key, 'Your Pushover User Token'
26
+ set :pushover_user_key, 'Your Pushover User Token'
27
27
 
28
28
  Now you are ready to recieve notificaion about deploys.
29
29
 
@@ -17,5 +17,7 @@ Gem::Specification.new do |gem|
17
17
 
18
18
  gem.add_development_dependency 'rake'
19
19
  gem.add_development_dependency 'rspec'
20
+ gem.add_development_dependency 'capistrano-spec'
21
+ gem.add_development_dependency 'capistrano'
20
22
  gem.add_dependency 'rushover'
21
23
  end
@@ -1,74 +1,84 @@
1
- require "capistrano-pushover/version"
2
- require "rushover"
3
-
1
+ require 'capistrano'
2
+ require 'capistrano-pushover/version'
3
+ require 'rushover'
4
4
 
5
5
  module Capistrano
6
6
  module Pushover
7
- Capistrano::Configuration.instance(:must_exist).load do
8
-
9
- set :pushover_with_migrations, false
7
+ def self.load_into(configuration)
8
+ configuration.load do
10
9
 
11
- namespace :pushover do
10
+ set :pushover_with_migrations, false
12
11
 
13
- task :set_user do
14
- set :pushover_client, Rushover::Client.new(pushover_app_token)
15
- set :pushover_user, Rushover::User.new(pusehover_user_key, pushover_client)
16
- end
12
+ namespace :pushover do
17
13
 
18
- task :configure_for_migrations do
19
- set :pushover_with_migrations, true
20
- end
14
+ task :set_user do
15
+ set :pushover_client, Rushover::Client.new(pushover_app_token)
16
+ set :pushover_user, Rushover::User.new(pushover_user_key, pushover_client)
17
+ end
21
18
 
22
- task :notify_deploy_started do
23
- on_rollback do
24
- pushover_user.notify("#{human} cancelled deployment of #{deployment_name} to #{env}.", :title => "#{application} cancelled deployment", :priority => 1)
19
+ task :configure_for_migrations do
20
+ set :pushover_with_migrations, true
25
21
  end
26
22
 
27
- message = "#{human} is deploying #{deployment_name} to #{env}"
28
- message << " (with migrations)" if pushover_with_migrations
29
- message << "."
23
+ task :notify_deploy_started do
24
+ on_rollback do
25
+ notify("#{human} cancelled deployment of #{deployment_name} to #{env}.", :title => "#{application} cancelled deployment", :priority => 1)
26
+ end
30
27
 
31
- pushover_user.notify(message, :title => "#{application} started deploying", :priority => priority)
32
- end
28
+ message = "#{human} is deploying #{deployment_name} to #{env}"
29
+ message << " (with migrations)" if pushover_with_migrations
30
+ message << "."
33
31
 
34
- task :notify_deploy_finished do
35
- pushover_user.notify("#{human} finished deploying #{deployment_name} to #{env}.", :title => "#{application} finished deploying", :priority => priority)
36
- end
32
+ notify(message, :title => "#{application} started deploying", :priority => priority)
33
+ end
37
34
 
38
- def priority
39
- fetch(:pushover_priority, 0)
40
- end
35
+ task :notify_deploy_finished do
36
+ notify("#{human} finished deploying #{deployment_name} to #{env}.", :title => "#{application} finished deploying", :priority => priority)
37
+ end
41
38
 
42
- def deployment_name
43
- if branch
44
- "#{application}/#{branch}"
45
- else
46
- application
39
+ def notify(message, options = {})
40
+ pushover_user.notify message, options
47
41
  end
48
- end
49
42
 
50
- def human
51
- ENV['PUSHOVER_USER'] ||
52
- if (u = %x{git config user.name}.strip) != ""
53
- u
54
- elsif (u = ENV['USER']) != ""
55
- u
43
+ def priority
44
+ fetch(:pushover_priority, 0)
45
+ end
46
+
47
+ def deployment_name
48
+ if branch
49
+ "#{application}/#{branch}"
56
50
  else
57
- "Someone"
51
+ application
58
52
  end
59
- end
53
+ end
60
54
 
61
- def env
62
- fetch(:pushover_env, fetch(:rack_env, fetch(:rails_env, "production")))
63
- end
55
+ def human
56
+ ENV['PUSHOVER_USER'] ||
57
+ if (u = %x{git config user.name}.strip) != ""
58
+ u
59
+ elsif (u = ENV['USER']) != ""
60
+ u
61
+ else
62
+ "Someone"
63
+ end
64
+ end
64
65
 
65
- before "pushover:notify_deploy_started", "pushover:set_user"
66
- before "deploy:migrations", "pushover:configure_for_migrations"
67
- before "deploy:update_code", "pushover:notify_deploy_started"
68
- after "deploy", "pushover:notify_deploy_finished"
69
- after "deploy:migrations", "pushover:notify_deploy_finished"
70
- end
66
+ def env
67
+ fetch(:pushover_env, fetch(:rack_env, fetch(:rails_env, "production")))
68
+ end
71
69
 
70
+ before "pushover:notify_deploy_started", "pushover:set_user"
71
+ before "deploy:migrations", "pushover:configure_for_migrations"
72
+ before "deploy:update_code", "pushover:notify_deploy_started"
73
+ after "deploy", "pushover:notify_deploy_finished"
74
+ after "deploy:migrations", "pushover:notify_deploy_finished"
75
+ end
76
+ end
72
77
  end
73
78
  end
74
79
  end
80
+
81
+ # may as well load it if we have it
82
+ if Capistrano::Configuration.instance
83
+ Capistrano::Pushover.load_into(Capistrano::Configuration.instance)
84
+ end
@@ -1,5 +1,5 @@
1
1
  module Capistrano
2
2
  module Pushover
3
- VERSION = "0.0.2"
3
+ VERSION = "0.1"
4
4
  end
5
5
  end
@@ -0,0 +1,75 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe Capistrano::Pushover, "loaded into a configuration" do
4
+
5
+ before do
6
+ @configuration = Capistrano::Configuration.new
7
+ Capistrano::Pushover.load_into(@configuration)
8
+
9
+ @configuration.set :pushover_app_token, 'foo'
10
+ @configuration.set :pushover_user_key, 'bar'
11
+ @configuration.set :application, 'worldrelaxation'
12
+ end
13
+
14
+ it "makes sure the configuration variables exits" do
15
+ @configuration.fetch(:pushover_app_token).should == 'foo'
16
+ @configuration.fetch(:pushover_user_key).should == 'bar'
17
+ end
18
+
19
+ it "defines pushover:notify_deploy_started" do
20
+ @configuration.find_task('pushover:notify_deploy_started').should_not == nil
21
+ end
22
+
23
+ it "defines pushover:notify_deploy_finished" do
24
+ @configuration.find_task('pushover:notify_deploy_finished').should_not == nil
25
+ end
26
+
27
+ it "defines pushover:configure_for_migrations" do
28
+ @configuration.find_task('pushover:configure_for_migrations').should_not == nil
29
+ end
30
+
31
+ it "defines pushover:set_user" do
32
+ @configuration.find_task('pushover:set_user').should_not == nil
33
+ end
34
+
35
+ it "before pushover:notify_deploy_started performs pushover:set_user" do
36
+ @configuration.should callback('pushover:set_user').before('pushover:notify_deploy_started')
37
+ end
38
+
39
+ it "before deploy:migrations performs pushover:configure_for_migrations" do
40
+ @configuration.should callback('pushover:configure_for_migrations').before('deploy:migrations')
41
+ end
42
+
43
+ it "before deploy:update_code performs pushover:notify_deploy_started" do
44
+ @configuration.should callback('pushover:notify_deploy_started').before('deploy:update_code')
45
+ end
46
+
47
+ it "after deploy performs pushover:notify_deploy_finished" do
48
+ @configuration.should callback('pushover:notify_deploy_finished').after('deploy')
49
+ end
50
+
51
+ it "after deploy:migrations performs pushover:notify_deploy_finished" do
52
+ @configuration.should callback('pushover:notify_deploy_finished').after('deploy')
53
+ end
54
+
55
+ it "pushover:notify_deploy_started notifing the user deploying and the branch being deployed to production" do
56
+ @configuration.set(:branch, :bar)
57
+ notification = mock('Pushover')
58
+ Rushover::Client.stub(:new).and_return(notification)
59
+ ENV['PUSHOVER_USER'] = 'foobaruser'
60
+ notification.should_receive(:notify).with("bar", "foobaruser is deploying worldrelaxation/bar to production.", {:title=>"worldrelaxation started deploying", :priority=>0})
61
+ @configuration.find_and_execute_task('pushover:notify_deploy_started')
62
+ end
63
+
64
+
65
+ it "pushover:notify_deploy_finished notifing the user who deployed and the branch that was deployed to production" do
66
+ @configuration.set(:branch, :bar)
67
+ notification = mock('Pushover')
68
+ Rushover::Client.stub(:new).and_return(notification)
69
+ ENV['PUSHOVER_USER'] = 'foobaruser'
70
+ notification.should_receive(:notify).with("bar", "foobaruser finished deploying worldrelaxation/bar to production.", {:title=>"worldrelaxation finished deploying", :priority=>0})
71
+ @configuration.find_and_execute_task('pushover:set_user')
72
+ @configuration.find_and_execute_task('pushover:notify_deploy_finished')
73
+ end
74
+
75
+ end
@@ -0,0 +1,21 @@
1
+ require 'bundler'
2
+ begin
3
+ Bundler.setup(:default, :development)
4
+ rescue Bundler::BundlerError => e
5
+ $stderr.puts e.message
6
+ $stderr.puts "Run `bundle install` to install missing gems"
7
+ exit e.status_code
8
+ end
9
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
10
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
11
+ require 'capistrano-pushover'
12
+ require 'rspec'
13
+ require 'rspec/autorun'
14
+
15
+ # Requires supporting files with custom matchers and macros, etc,
16
+ # in ./support/ and its subdirectories.
17
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
18
+
19
+ RSpec.configure do |config|
20
+
21
+ end
@@ -0,0 +1,6 @@
1
+ require 'capistrano/spec'
2
+
3
+ RSpec.configure do |config|
4
+ config.include Capistrano::Spec::Helpers
5
+ config.include Capistrano::Spec::Matchers
6
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-pushover
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: '0.1'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-11 00:00:00.000000000 Z
12
+ date: 2012-10-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -43,6 +43,38 @@ dependencies:
43
43
  - - ! '>='
44
44
  - !ruby/object:Gem::Version
45
45
  version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: capistrano-spec
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: capistrano
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
46
78
  - !ruby/object:Gem::Dependency
47
79
  name: rushover
48
80
  requirement: !ruby/object:Gem::Requirement
@@ -67,6 +99,7 @@ extensions: []
67
99
  extra_rdoc_files: []
68
100
  files:
69
101
  - .gitignore
102
+ - .rspec
70
103
  - .rvmrc
71
104
  - Gemfile
72
105
  - LICENSE
@@ -75,6 +108,9 @@ files:
75
108
  - capistrano-pushover.gemspec
76
109
  - lib/capistrano-pushover.rb
77
110
  - lib/capistrano-pushover/version.rb
111
+ - spec/capistrano-pushover_spec.rb
112
+ - spec/spec_helper.rb
113
+ - spec/support/capistrano.rb
78
114
  homepage: https://github.com/shukydvir/capistrano-pushover
79
115
  licenses: []
80
116
  post_install_message:
@@ -89,7 +125,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
89
125
  version: '0'
90
126
  segments:
91
127
  - 0
92
- hash: 3940367720314031294
128
+ hash: 1169079496221250501
93
129
  required_rubygems_version: !ruby/object:Gem::Requirement
94
130
  none: false
95
131
  requirements:
@@ -98,11 +134,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
134
  version: '0'
99
135
  segments:
100
136
  - 0
101
- hash: 3940367720314031294
137
+ hash: 1169079496221250501
102
138
  requirements: []
103
139
  rubyforge_project:
104
140
  rubygems_version: 1.8.24
105
141
  signing_key:
106
142
  specification_version: 3
107
143
  summary: Send deploy notification to Pushover
108
- test_files: []
144
+ test_files:
145
+ - spec/capistrano-pushover_spec.rb
146
+ - spec/spec_helper.rb
147
+ - spec/support/capistrano.rb