vagrant-pushover 1.0.0 → 1.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 344ec3bf989dbf139f0582b9efbed598daf72d93
4
- data.tar.gz: da733baa3e86772b887343ad7c05996ebe11e3a8
3
+ metadata.gz: e26b332c0e4fd5d053bec67f8905f3da9b02a761
4
+ data.tar.gz: 6b6c855b403adad0cf35b37c2cb1adac9ec5d98a
5
5
  SHA512:
6
- metadata.gz: 88c96e298f15582da84a12b77b2cc467bb227a0db4d1ae92793b9a92c290085b57941d91c490f05a2be96a545963875b46be0c3bdb2db5c2e0ca451ff8936f1a
7
- data.tar.gz: f3c59ff6580ad070d0a720b0f0a59263ac74379a252d9944815570f49a95be87694a8577e1cc13602270eb3b94e108ccf37218ecac623251e9ce1e09bb1a1483
6
+ metadata.gz: cdc860679f3fe731686ed47546d372f69a0cd14acc69367f154b521e9088973eacf76d2cacb58573df06966b3fd762691e707a14ea2a9ba5919702421ca98c7c
7
+ data.tar.gz: f75025aed7674cfa98cc49e4eaa8ebf0fc66dd0cfee1bd7571260dcbeb4936c7dda13c9c4fd82f91a176ef1a95cb05e974249b27a9a2150a0fcfc77adc2b37ff
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Vagrant Pushover
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/vagrant-pushover.png)](http://badge.fury.io/rb/vagrant-pushover)
4
+
3
5
  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
6
 
5
7
  ![](https://raw.github.com/tcnksm/vagrant-pushover/master/images/sample.png)
@@ -37,9 +39,9 @@ end
37
39
 
38
40
  Nofication is not send unless add this configuration. You can set other parameters here, check pushover API documentation [here](https://pushover.net/api).
39
41
 
40
- ## When notification is sent
42
+ ## When notification is sent ?
41
43
 
42
- Notification is sent in below cases.
44
+ Notification is sent after below commands.
43
45
 
44
46
  - `vagrant up`
45
47
  - When machine is not yet provisioned.
@@ -48,7 +50,6 @@ Notification is sent in below cases.
48
50
  - `vagrant reload --provision`
49
51
  - `vagrant provision`
50
52
 
51
-
52
53
  ## Contributing
53
54
 
54
55
  1. Fork it ( http://github.com/<my-github-username>/vagrant-pushover/fork )
data/Vagrantfile CHANGED
@@ -4,11 +4,15 @@ Vagrant.configure("2") do |config|
4
4
  config.vm.provision :shell, inline: "echo Hello, world"
5
5
 
6
6
  # Vagrant-pushover plugin configure example
7
+ # 1) Execute `vagrant pushover-init` and generate .vagrant/pushover.rb.
8
+ # 2) Edit it and set your application token and user key.
9
+ # 3) Read it with below configuration.
10
+ config.pushover.read_key
11
+
12
+ # You can set another parameter like this
7
13
  # See more parameter, https://pushover.net/api
8
14
  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."
15
+ p.priority = 1
16
+ p.message = "Provisioning is over. Back to your seat."
13
17
  end
14
18
  end
@@ -3,6 +3,27 @@ require "vagrant-pushover/version"
3
3
  require "vagrant-pushover/plugin"
4
4
 
5
5
  module VagrantPlugins
6
- module Pushover
6
+ module Pushover
7
+
8
+ def self.config_file
9
+ called_root.join(".vagrant/pushover.rb")
10
+ end
11
+
12
+ def self.called_root
13
+ Pathname.pwd
14
+ end
15
+
16
+ def self.write_default_key
17
+ content = <<-EOF
18
+ module PushoverConfig
19
+ TOKEN = "YOUR APP TOKEN"
20
+ USER = "YOUR USER KEY"
21
+ end
22
+ EOF
23
+ File.open(config_file,'w') do |f|
24
+ f.puts content
25
+ end
26
+ end
27
+
7
28
  end
8
29
  end
@@ -54,9 +54,9 @@ module VagrantPlugins
54
54
  status = res.start {|http| http.request(req)}.message
55
55
 
56
56
  if status == "OK"
57
- @ui.info "Send push notification."
57
+ @ui.info "Send pushover notification."
58
58
  else
59
- @ui.error "Send push notification is failed. Parameter is wrong."
59
+ @ui.error "Send pushover notification is failed. Parameter is wrong."
60
60
  end
61
61
 
62
62
  end
@@ -0,0 +1,18 @@
1
+ require "net/https"
2
+
3
+ module VagrantPlugins
4
+ module Pushover
5
+ class Command < Vagrant.plugin("2", :command)
6
+
7
+ def execute
8
+ config_file = ::VagrantPlugins::Pushover.config_file
9
+ if config_file.exist?
10
+ @env.ui.info("Vagrant-pushover configuration file (.vagrant/pushover.rb) is already exist. Edit it and set your app token and your key.")
11
+ else
12
+ ::VagrantPlugins::Pushover.write_default_key
13
+ @env.ui.info("Generated vagrant-pushover configuration file (.vagrant/pushover.rb). Edit it and set your app token and your key.")
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -37,9 +37,22 @@ module VagrantPlugins
37
37
  def set
38
38
  yield self if block_given?
39
39
  end
40
+
41
+ def read_key
42
+ config_file = ::VagrantPlugins::Pushover.config_file
43
+ if not config_file.exist?
44
+ ::VagrantPlugins::Pushover.write_default_key
45
+ end
46
+
47
+ require config_file
48
+ @token = PushoverConfig::TOKEN
49
+ @user = PushoverConfig::USER
50
+ end
51
+
40
52
 
41
53
  def validate(machine)
42
54
  errors = []
55
+ errors << "Edit .vagrant/pushover.rb and set your keys." if @execute && (@token == "YOUR APP TOKEN" || @user == "YOUR USER KEY" )
43
56
  errors << "Your application's API token must be set." if @execute && !@token
44
57
  errors << "The user/group key must be set." if @execute && !@user
45
58
  errors << "You don't need Emergency priority(2) in this plugin." if @execute && @priority == 2
@@ -14,6 +14,11 @@ module VagrantPlugins
14
14
  This notificates `up` or `provision` is over.
15
15
  DESC
16
16
 
17
+ command "pushover-init" do
18
+ require_relative "command"
19
+ Command
20
+ end
21
+
17
22
  action_hook("pushover_hook", :machine_action_up) do |hook|
18
23
  require_relative "action"
19
24
  hook.prepend(Action)
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module Pushover
3
- VERSION = "1.0.0"
3
+ VERSION = "1.1.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-pushover
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - tcnksm
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-18 00:00:00.000000000 Z
11
+ date: 2014-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -54,6 +54,7 @@ files:
54
54
  - images/sample.png
55
55
  - lib/vagrant-pushover.rb
56
56
  - lib/vagrant-pushover/action.rb
57
+ - lib/vagrant-pushover/command.rb
57
58
  - lib/vagrant-pushover/config.rb
58
59
  - lib/vagrant-pushover/plugin.rb
59
60
  - lib/vagrant-pushover/version.rb