vagrant-pushbullet 0.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7d1cbbcd221dd4debab453d90c7f2aa8adbdb74c
4
+ data.tar.gz: 3f677bd7f4c7bf3c14c6e6018c67483dbadc9acd
5
+ SHA512:
6
+ metadata.gz: 71ecc0b308d9903cc7e65b87e2151fcd97e0b30a97f1a4cbef98654d5965f665f06976739bebe1567d5610d7d7ba6aa2ed9eef3f9887e7d2542b2565700e3b89
7
+ data.tar.gz: d848a161c272ab3200e2180da2e7f7e711a962d19ea6f00e5dae2746ba60647c926756daac1301b26401db71eeefcf04eac9fa4c540d5fbd484c2378c891924f
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,12 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in vagrant-Pushbullet.gemspec
4
+ gemspec
5
+
6
+ group :development do
7
+ gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git"
8
+ end
9
+
10
+ # group :plugins do
11
+ # gem "vagrant-pushbullet", path: "."
12
+ # end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Brett Swift
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,57 @@
1
+ # Vagrant Pushbullet
2
+
3
+ This gem is a [Vagrant](http://www.vagrantup.com/) plugin that adds Pushbullet notifications to configured devices.
4
+
5
+ ## Setup Pushbullet
6
+
7
+ * First get a Pushbullet Account, and add devices to it.
8
+ - [Pushbullet.com](https://www.pushbullet.com/)
9
+ * Download the *iOS* app, *Chrome* plugin, *Android* app, and more. Add those to your Pushbullet account.
10
+ * Get your HTTP API Token: http://pushbullet.com/account
11
+
12
+ ## Install Plugin
13
+
14
+ ```bash
15
+ $ vagrant plugin install vagrant-pushbullet
16
+ ```
17
+
18
+ ## Plugin Usage
19
+
20
+ This plugin is configured purely by a configuration file in your home directory.
21
+ The plugin will create this file for you, but you will have to edit it manually (for now).
22
+
23
+ `~/.vagrant.d/pushbullet.rb`
24
+ ```ruby
25
+ module PushbulletConfig
26
+ TOKEN = "replace this text with token from pushbullet.com/account" #required
27
+ DEVICES = ['asdfasdfasdf','asdfasdfasdf'] #optional
28
+ end
29
+ ```
30
+
31
+ Run `vagrant pushbullet-config` to retrieve your Device ID's. Add those to the DEVICES array in the config file to limit which devices are notified.
32
+
33
+
34
+ ## Notifications
35
+
36
+ A notification is sent after these commands complete:
37
+
38
+ * note there is currently a bug where if an exception occurs in the provisioning, the notification is not sent.
39
+
40
+ - `vagrant up`
41
+ - `vagrant reload --provision`
42
+ - `vagrant provision`
43
+
44
+ ## Contributing
45
+
46
+ * use feature branches please. Prefer feature/your_feature_name
47
+ * submit pull requests to the `develop` branch
48
+
49
+
50
+ ## Author
51
+
52
+ Brett Swift
53
+
54
+ ## Kudos
55
+
56
+ [tcnksm](https://twitter.com/deeeet)
57
+ - for his vagrant-pushover plugin. This plugin is modeled after his.
data/Rakefile ADDED
@@ -0,0 +1,22 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rubygems'
3
+ require 'bundler/setup'
4
+
5
+ version = VagrantPlugins::Pushbullet::VERSION
6
+
7
+ desc "Install your plugin to your system vagrant."
8
+ task :install_plugin do
9
+ Rake::Task[:build].execute
10
+ system("/usr/bin/vagrant plugin install pkg/vagrant-pushbullet-#{version}.gem")
11
+ end
12
+
13
+ task :uninstall_plugin do
14
+ system("/usr/bin/vagrant plugin uninstall vagrant-pushbullet")
15
+ end
16
+
17
+ Bundler::GemHelper.install_tasks
18
+
19
+ # alias
20
+ task :i => :install_plugin
21
+ task :u => :uninstall_plugin
22
+
data/Vagrantfile ADDED
@@ -0,0 +1,5 @@
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 'Testing Notifications to Pushbullet'"
5
+ end
@@ -0,0 +1,58 @@
1
+ require "net/https"
2
+ require "washbullet"
3
+
4
+ module VagrantPlugins
5
+ module Pushbullet
6
+ class Action
7
+
8
+ def initialize(app,env)
9
+ @app = app
10
+ @ui = env[:ui]
11
+ @machine = env[:machine].name.to_s
12
+ @machinfo = env[:machine]
13
+ end
14
+
15
+ def call(env)
16
+ # Before machine action
17
+ state = env[:machine].state.id
18
+
19
+ # Execute machine action
20
+ @app.call(env)
21
+
22
+ # After execute machine action
23
+ config = env[:machine].config.Pushbullet
24
+ action = env[:machine_action]
25
+ provision = env[:provision_enabled]
26
+
27
+ config_file = ::VagrantPlugins::Pushbullet.config_file
28
+
29
+ unless config_file.exist? && config.is_config_valid
30
+ puts "some validation failed"
31
+ env[:ui].error("Pushbullet plugin configuration has not yet been set up. \nPlease replace required values in config file: #{config_file} ")
32
+ end
33
+
34
+ @machinfo = env[:machine]
35
+ case action
36
+ when :up
37
+ notification(config, config_file) if state != :running && provision && config.is_config_valid
38
+ when :reload
39
+ notification(config, config_file) if provision && config.is_config_valid
40
+ when :provision
41
+ notification(config, config_file) if config.is_config_valid
42
+ end
43
+ end
44
+
45
+ def notification(config, config_file)
46
+ #TODO: append provisioning result, success or fail.
47
+ require config_file
48
+ devices = PushbulletConfig::DEVICES
49
+ token = PushbulletConfig::TOKEN
50
+ client = Washbullet::Client.new(token)
51
+ devices.each {|iden|
52
+ client.push_note(iden, "Vagrant Finished: #{@machine}", '')
53
+ }
54
+ end
55
+ end
56
+ end
57
+ end
58
+
@@ -0,0 +1,55 @@
1
+ require "washbullet"
2
+
3
+ module VagrantPlugins
4
+ module Pushbullet
5
+ class Command < Vagrant.plugin("2", :command)
6
+
7
+ def self.synopsis
8
+ "generates Pushbullet configration file weeeeeeeeeeee"
9
+ end
10
+
11
+ def execute
12
+ config_file = ::VagrantPlugins::Pushbullet.config_file
13
+
14
+ if config_file.exist?
15
+
16
+ @env.ui.warn("Welcome to the Pushbullet Setup Guide")
17
+
18
+ guide = <<-INFO
19
+ This command helps you configure Pushbullet via it's config file: #{config_file}
20
+
21
+ To limit notifications to specific devices:
22
+ - If your token is correct you will see your devices below.
23
+ - Add/remove device id's from the list shown below to: '#{config_file}'.
24
+ To notify all devices:
25
+ - Leave the DEVICES variable empty in your config file.
26
+ INFO
27
+ @env.ui.info(guide)
28
+
29
+ client = Washbullet::Client.new('v1zUVfPeLEveoY8suYABuu9WmuZUDhItndujC7jkt9OgK')
30
+ require config_file
31
+ enabled_devices = PushbulletConfig::DEVICES
32
+
33
+ devices = client.devices.body["devices"]
34
+ msg = []
35
+ devices.each { |device|
36
+ if device["active"]
37
+ devices = PushbulletConfig::DEVICES
38
+ enabled = "\e[32m Enabled"
39
+ disabled = "\e[31m Disabled"
40
+ enabled_theme = enabled_devices.include?(device['iden'])? enabled : disabled
41
+ enabled_theme = enabled if enabled_devices.size == 0
42
+ msg << " #{enabled_theme}: '#{device['nickname']}' id: #{device['iden']} \e[0m"
43
+ end
44
+ }
45
+ msg = msg.join("\n")
46
+ @env.ui.info(msg)
47
+ else
48
+ ::VagrantPlugins::Pushbullet.write_default_key
49
+ @env.ui.error("Please put your pushbullet token from http://pushbullet.com/account into this file: #{config_file}.
50
+ \n ---- Then run this command again to limit pushes to specific devices-----")
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,60 @@
1
+ require "net/https"
2
+
3
+ module VagrantPlugins
4
+ module Pushbullet
5
+ class Config < Vagrant.plugin("2", :config)
6
+
7
+ # API parameters
8
+ attr_accessor :token
9
+ attr_accessor :message
10
+
11
+ def initialize
12
+ super
13
+
14
+ @token = UNSET_VALUE
15
+
16
+ @config_file = UNSET_VALUE
17
+ end
18
+
19
+ def set
20
+ yield self if block_given?
21
+ end
22
+
23
+
24
+ def validate(machine)
25
+ errors = []
26
+ @config_file = ::VagrantPlugins::Pushbullet.config_file
27
+
28
+ unless @config_file && @config_file.exist?
29
+
30
+ errors << "Pushbullet configuration file created at: #{@config_file}"
31
+ errors << "run `pushbullet-config` for assistance on entering required values in that file."
32
+ errors << "\n --- you will not see this error again ----"
33
+ ::VagrantPlugins::Pushbullet.write_default_key
34
+ end
35
+
36
+ require @config_file
37
+ @token = PushbulletConfig::TOKEN
38
+
39
+ {Pushbullet: errors}
40
+ end
41
+
42
+ def attributes
43
+ [ @token ]
44
+ end
45
+
46
+ def is_config_valid
47
+ attributes.each do |attribute|
48
+ return true if attribute != UNSET_VALUE
49
+ end
50
+ false
51
+ end
52
+
53
+ def finalize!
54
+ @token = nil if @token == UNSET_VALUE
55
+ end
56
+ end
57
+
58
+ end
59
+ end
60
+
@@ -0,0 +1,44 @@
1
+ begin
2
+ require "vagrant"
3
+ rescue LoadError
4
+ raise "The Vagrant Pushbullet plugin must be run within Vagrant."
5
+ end
6
+
7
+ module VagrantPlugins
8
+ module Pushbullet
9
+
10
+ class Plugin < Vagrant.plugin("2")
11
+ name "Pushbullet"
12
+ description <<-DESC
13
+ This plugin add a Pushbullet notification to your vagrant command.
14
+ This notificates `up` or `provision` is over.
15
+ DESC
16
+
17
+ #TODO replace this with 'set token' that takes a param.
18
+ command "pushbullet-config" do
19
+ require_relative "command"
20
+ Command
21
+ end
22
+
23
+ action_hook("Pushbullet_hook", :machine_action_up) do |hook|
24
+ require_relative "action"
25
+ hook.prepend(Action)
26
+ end
27
+
28
+ action_hook("Pushbullet_hook", :machine_action_provision) do |hook|
29
+ require_relative "action"
30
+ hook.prepend(Action)
31
+ end
32
+
33
+ action_hook("Pushbullet_hook", :machine_action_reload) do |hook|
34
+ require_relative "action"
35
+ hook.prepend(Action)
36
+ end
37
+
38
+ config(:Pushbullet) do
39
+ require_relative "config"
40
+ Config
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,5 @@
1
+ module VagrantPlugins
2
+ module Pushbullet
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,27 @@
1
+ require "pathname"
2
+ require "vagrant-Pushbullet/version"
3
+ require "vagrant-Pushbullet/plugin"
4
+
5
+ module VagrantPlugins
6
+ module Pushbullet
7
+
8
+ def self.config_file
9
+ vag_home = Pathname.new(File.expand_path("~", __FILE__))
10
+ Pathname.new("#{vag_home}/.vagrant.d/pushbullet.rb")
11
+ end
12
+
13
+ def self.write_default_key
14
+ content = <<-EOF
15
+ module PushbulletConfig
16
+ TOKEN = "<pushbullet_token>" #required
17
+ DEVICES = [] #optional. MUST use quotes. NO empty strings.
18
+ end
19
+ EOF
20
+ #TODO: write default config file again.
21
+ File.open(config_file,'w') do |f|
22
+ f.puts content
23
+ end
24
+ end
25
+
26
+ end
27
+ end
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'vagrant-pushbullet/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "vagrant-pushbullet"
8
+ spec.version = VagrantPlugins::Pushbullet::VERSION
9
+ spec.authors = ["brettswift"]
10
+ spec.email = ["brettswift@gmail.com"]
11
+ spec.summary = %q{Vagrant plugin that adds Pushbullet notifications }
12
+ spec.description = %q{Vagrant plugin that adds Pushbullet notifications }
13
+ spec.homepage = "https://github.com/brettswift/vagrant-pushbullet"
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
+ spec.add_runtime_dependency 'washbullet', '~> 0.3.1'
24
+ end
metadata ADDED
@@ -0,0 +1,99 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant-pushbullet
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - brettswift
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-08-30 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
+ - !ruby/object:Gem::Dependency
42
+ name: washbullet
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: 0.3.1
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 0.3.1
55
+ description: 'Vagrant plugin that adds Pushbullet notifications '
56
+ email:
57
+ - brettswift@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - .gitignore
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - Vagrantfile
68
+ - lib/vagrant-pushbullet.rb
69
+ - lib/vagrant-pushbullet/action.rb
70
+ - lib/vagrant-pushbullet/command.rb
71
+ - lib/vagrant-pushbullet/config.rb
72
+ - lib/vagrant-pushbullet/plugin.rb
73
+ - lib/vagrant-pushbullet/version.rb
74
+ - vagrant-pushbullet.gemspec
75
+ homepage: https://github.com/brettswift/vagrant-pushbullet
76
+ licenses:
77
+ - MIT
78
+ metadata: {}
79
+ post_install_message:
80
+ rdoc_options: []
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - '>='
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ requirements: []
94
+ rubyforge_project:
95
+ rubygems_version: 2.0.14
96
+ signing_key:
97
+ specification_version: 4
98
+ summary: Vagrant plugin that adds Pushbullet notifications
99
+ test_files: []