vagrant-pushover 1.0.0

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 344ec3bf989dbf139f0582b9efbed598daf72d93
4
+ data.tar.gz: da733baa3e86772b887343ad7c05996ebe11e3a8
5
+ SHA512:
6
+ metadata.gz: 88c96e298f15582da84a12b77b2cc467bb227a0db4d1ae92793b9a92c290085b57941d91c490f05a2be96a545963875b46be0c3bdb2db5c2e0ca451ff8936f1a
7
+ data.tar.gz: f3c59ff6580ad070d0a720b0f0a59263ac74379a252d9944815570f49a95be87694a8577e1cc13602270eb3b94e108ccf37218ecac623251e9ce1e09bb1a1483
data/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .vagrant
19
+ vendor/bundle
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in vagrant-pushover.gemspec
4
+ gemspec
5
+
6
+ group :development do
7
+ gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git"
8
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 tcnksm
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,62 @@
1
+ # Vagrant Pushover
2
+
3
+ This is a [Vagrant](http://www.vagrantup.com/) plugin that add [pushover](https://pushover.net/api) notification function to your Vagrant, allowing Vagrant to push noticate your iOS/Androind. If your provisioning takes too much time, use this plugin and go out to have good :coffee:, you can know when you should go back your seat.
4
+
5
+ ![](https://raw.github.com/tcnksm/vagrant-pushover/master/images/sample.png)
6
+
7
+ ## Requirement
8
+
9
+ - Pushover App
10
+ - [iOS](https://itunes.apple.com/us/app/pushover-notifications/id506088175?ls=1&mt=8https://itunes.apple.com/us/app/pushover-notifications/id506088175?ls=1&mt=8)
11
+ - [Android](https://play.google.com/store/apps/details?id=net.superblock.pushover&ts=1392735420)
12
+ - User key of pushover App
13
+ - You can get it from your [dashboard](https://pushover.net)
14
+ - Application token of pushover App
15
+ - You can get it after [registering your application](https://pushover.net/apps/build)
16
+
17
+ ## Installation
18
+
19
+ Install it as a Vagrant plugin.
20
+
21
+ ```bash
22
+ $ vagrant plugin install vagrant-pushover
23
+ ```
24
+
25
+ ## Usage
26
+
27
+ Add configuration in your Vagrantfile. You must set `token` and `user`.
28
+
29
+ ```ruby
30
+ Vagrant.configure("2") do |config|
31
+ config.pushover.set do |p|
32
+ p.token = "YOUR APP TOKEN"
33
+ p.user = "YOUR KEY"
34
+ end
35
+ end
36
+ ```
37
+
38
+ Nofication is not send unless add this configuration. You can set other parameters here, check pushover API documentation [here](https://pushover.net/api).
39
+
40
+ ## When notification is sent
41
+
42
+ Notification is sent in below cases.
43
+
44
+ - `vagrant up`
45
+ - When machine is not yet provisioned.
46
+ - Current machine state is not running.
47
+ - `vagrant up --provision`
48
+ - `vagrant reload --provision`
49
+ - `vagrant provision`
50
+
51
+
52
+ ## Contributing
53
+
54
+ 1. Fork it ( http://github.com/<my-github-username>/vagrant-pushover/fork )
55
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
56
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
57
+ 4. Push to the branch (`git push origin my-new-feature`)
58
+ 5. Create new Pull Request
59
+
60
+ ## Author
61
+
62
+ [tcnksm](https://twitter.com/deeeet)
data/Rakefile ADDED
@@ -0,0 +1,20 @@
1
+ require "vagrant-pushover"
2
+ require "bundler/gem_tasks"
3
+
4
+ version = VagrantPlugins::Pushover::VERSION
5
+
6
+ desc "Install your plugin to your system vagrant."
7
+ task :install_plugin do
8
+ system("git add -u")
9
+ Rake::Task[:build].execute
10
+ system("/usr/bin/vagrant plugin install pkg/vagrant-pushover-#{version}.gem")
11
+ end
12
+
13
+ task :uninstall_plugin do
14
+ system("/usr/bin/vagrant plugin uninstall vagrant-pushover")
15
+ end
16
+
17
+ # alias
18
+ task :i => :install_plugin
19
+ task :u => :uninstall_plugin
20
+
data/Vagrantfile ADDED
@@ -0,0 +1,14 @@
1
+ Vagrant.configure("2") do |config|
2
+ config.vm.box = "precise64"
3
+ config.vm.box_url = "http://files.vagrantup.com/precise64.box"
4
+ config.vm.provision :shell, inline: "echo Hello, world"
5
+
6
+ # Vagrant-pushover plugin configure example
7
+ # See more parameter, https://pushover.net/api
8
+ config.pushover.set do |p|
9
+ p.token = "************"
10
+ p.user = "************"
11
+ p.priority = 1
12
+ p.message = "Provisioning is over. Back to your seat."
13
+ end
14
+ end
data/images/sample.png ADDED
Binary file
@@ -0,0 +1,66 @@
1
+ require "net/https"
2
+
3
+ module VagrantPlugins
4
+ module Pushover
5
+ class Action
6
+
7
+ def initialize(app,env)
8
+ @app = app
9
+ @ui = env[:ui]
10
+ @machine = env[:machine].name.to_s
11
+ end
12
+
13
+ def call(env)
14
+ # Before machine action
15
+ state = env[:machine].state.id
16
+
17
+ # Execute machine action
18
+ @app.call(env)
19
+
20
+ # After execute machine action
21
+ config = env[:machine].config.pushover
22
+ action = env[:machine_action]
23
+ provision = env[:provision_enabled]
24
+
25
+ case action
26
+ when :up
27
+ nortification config if state != :running && provision && config.execute
28
+ when :reload
29
+ nortification config if provision && config.execute
30
+ when :provision
31
+ nortification config if config.execute
32
+ end
33
+ end
34
+
35
+ def nortification config
36
+ message = "[#{@machine}] " + config.message
37
+ url = URI.parse("https://api.pushover.net/1/messages.json")
38
+ req = Net::HTTP::Post.new(url.path)
39
+ req.set_form_data({
40
+ token: config.token,
41
+ user: config.user,
42
+ message: message,
43
+ title: config.title,
44
+ device: config.device,
45
+ url: config.url,
46
+ url_title: config.url_title,
47
+ priority: config.priority,
48
+ timestamp: config.timestamp,
49
+ sound: config.sound,
50
+ })
51
+ res = Net::HTTP.new(url.host, url.port)
52
+ res.use_ssl = true
53
+ res.verify_mode = OpenSSL::SSL::VERIFY_PEER
54
+ status = res.start {|http| http.request(req)}.message
55
+
56
+ if status == "OK"
57
+ @ui.info "Send push notification."
58
+ else
59
+ @ui.error "Send push notification is failed. Parameter is wrong."
60
+ end
61
+
62
+ end
63
+ end
64
+ end
65
+ end
66
+
@@ -0,0 +1,80 @@
1
+ require "net/https"
2
+
3
+ module VagrantPlugins
4
+ module Pushover
5
+ class Config < Vagrant.plugin("2", :config)
6
+
7
+ attr_accessor :execute
8
+
9
+ # API parameters
10
+ # See more details, https://pushover.net/api
11
+ attr_accessor :token
12
+ attr_accessor :user
13
+ attr_accessor :message
14
+ attr_accessor :device
15
+ attr_accessor :title
16
+ attr_accessor :url
17
+ attr_accessor :url_title
18
+ attr_accessor :priority
19
+ attr_accessor :timestamp
20
+ attr_accessor :sound
21
+
22
+ def initialize
23
+ super
24
+ @execute = false
25
+ @token = UNSET_VALUE
26
+ @user = UNSET_VALUE
27
+ @message = UNSET_VALUE
28
+ @device = UNSET_VALUE
29
+ @title = UNSET_VALUE
30
+ @url = UNSET_VALUE
31
+ @url_title = UNSET_VALUE
32
+ @priority = UNSET_VALUE
33
+ @timestamp = UNSET_VALUE
34
+ @sound = UNSET_VALUE
35
+ end
36
+
37
+ def set
38
+ yield self if block_given?
39
+ end
40
+
41
+ def validate(machine)
42
+ errors = []
43
+ errors << "Your application's API token must be set." if @execute && !@token
44
+ errors << "The user/group key must be set." if @execute && !@user
45
+ errors << "You don't need Emergency priority(2) in this plugin." if @execute && @priority == 2
46
+ errors << "Priority must be set {-1,0,1}." if @execute && ( not [-1,0,1].include?(@priority))
47
+
48
+ errors << "See more details, https://pushover.net/api" if errors.any?
49
+ {pushover: errors}
50
+ end
51
+
52
+ def attributes
53
+ [ @title, @message, @token, @user, @device, @url, @url_title, @priority, @timestamp, @sound ]
54
+ end
55
+
56
+ def execute?
57
+ attributes.each do |attribute|
58
+ return true if attribute != UNSET_VALUE
59
+ end
60
+ false
61
+ end
62
+
63
+ def finalize!
64
+ @execute = true if execute?
65
+ @title = "Vagrant pushover" if @title == UNSET_VALUE
66
+ @message = "Provisioning is over." if @message == UNSET_VALUE
67
+ @token = nil if @token == UNSET_VALUE
68
+ @user = nil if @user == UNSET_VALUE
69
+ @device = nil if @device == UNSET_VALUE
70
+ @url = nil if @url == UNSET_VALUE
71
+ @url_title = nil if @url_title == UNSET_VALUE
72
+ @priority = 0 if @priority == UNSET_VALUE
73
+ @timestamp = nil if @timestamp == UNSET_VALUE
74
+ @sound = nil if @sound == UNSET_VALUE
75
+ end
76
+ end
77
+
78
+ end
79
+ end
80
+
@@ -0,0 +1,38 @@
1
+ begin
2
+ require "vagrant"
3
+ rescue LoadError
4
+ raise "The Vagrant pushover plugin must be run within Vagrant."
5
+ end
6
+
7
+ module VagrantPlugins
8
+ module Pushover
9
+
10
+ class Plugin < Vagrant.plugin("2")
11
+ name "Pushover"
12
+ description <<-DESC
13
+ This plugin add a pushover notification to your vagrant command.
14
+ This notificates `up` or `provision` is over.
15
+ DESC
16
+
17
+ action_hook("pushover_hook", :machine_action_up) do |hook|
18
+ require_relative "action"
19
+ hook.prepend(Action)
20
+ end
21
+
22
+ action_hook("pushover_hook", :machine_action_provision) do |hook|
23
+ require_relative "action"
24
+ hook.prepend(Action)
25
+ end
26
+
27
+ action_hook("pushover_hook", :machine_action_reload) do |hook|
28
+ require_relative "action"
29
+ hook.prepend(Action)
30
+ end
31
+
32
+ config(:pushover) do
33
+ require_relative "config"
34
+ Config
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,5 @@
1
+ module VagrantPlugins
2
+ module Pushover
3
+ VERSION = "1.0.0"
4
+ end
5
+ end
@@ -0,0 +1,8 @@
1
+ require "pathname"
2
+ require "vagrant-pushover/version"
3
+ require "vagrant-pushover/plugin"
4
+
5
+ module VagrantPlugins
6
+ module Pushover
7
+ end
8
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'vagrant-pushover/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "vagrant-pushover"
8
+ spec.version = VagrantPlugins::Pushover::VERSION
9
+ spec.authors = ["tcnksm"]
10
+ spec.email = ["nsd22843@gmail.com"]
11
+ spec.summary = %q{Vagrant plugin that adds pushover notification }
12
+ spec.description = %q{Vagrant plugin that adds pushover notification to your iOS/Android. }
13
+ spec.homepage = "https://github.com/tcnksm/vagrant-pushover"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.5"
22
+ spec.add_development_dependency "rake"
23
+ end
metadata ADDED
@@ -0,0 +1,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant-pushover
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - tcnksm
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-02-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: 'Vagrant plugin that adds pushover notification to your iOS/Android. '
42
+ email:
43
+ - nsd22843@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - .gitignore
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - Vagrantfile
54
+ - images/sample.png
55
+ - lib/vagrant-pushover.rb
56
+ - lib/vagrant-pushover/action.rb
57
+ - lib/vagrant-pushover/config.rb
58
+ - lib/vagrant-pushover/plugin.rb
59
+ - lib/vagrant-pushover/version.rb
60
+ - vagrant-pushover.gemspec
61
+ homepage: https://github.com/tcnksm/vagrant-pushover
62
+ licenses:
63
+ - MIT
64
+ metadata: {}
65
+ post_install_message:
66
+ rdoc_options: []
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - '>='
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ requirements: []
80
+ rubyforge_project:
81
+ rubygems_version: 2.0.14
82
+ signing_key:
83
+ specification_version: 4
84
+ summary: Vagrant plugin that adds pushover notification
85
+ test_files: []