vagrant-pushbullet 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7d1cbbcd221dd4debab453d90c7f2aa8adbdb74c
4
- data.tar.gz: 3f677bd7f4c7bf3c14c6e6018c67483dbadc9acd
3
+ metadata.gz: af4d393525735d38ac184cb042021596e7cd85a8
4
+ data.tar.gz: 5b09f487377d9fd30fdbc0aff454ed767e6eb366
5
5
  SHA512:
6
- metadata.gz: 71ecc0b308d9903cc7e65b87e2151fcd97e0b30a97f1a4cbef98654d5965f665f06976739bebe1567d5610d7d7ba6aa2ed9eef3f9887e7d2542b2565700e3b89
7
- data.tar.gz: d848a161c272ab3200e2180da2e7f7e711a962d19ea6f00e5dae2746ba60647c926756daac1301b26401db71eeefcf04eac9fa4c540d5fbd484c2378c891924f
6
+ metadata.gz: d6f790325aa3add30115059781fb95a141231e35c2803aa6f3c743c3d6730480494490f1b0c9d3199e1d81551ab86e4b02731cbb6e7a2da1cb9886fe3ea15701
7
+ data.tar.gz: c1d345ec30331b2ddee6f387ab4a7cf26d42d42d9a861c5507caa90dd242170f0b28088af2ca2d6a81944bad490479a628c278ba8c8d3b0dde9a82344ac80e8e
@@ -31,7 +31,6 @@ module VagrantPlugins
31
31
  env[:ui].error("Pushbullet plugin configuration has not yet been set up. \nPlease replace required values in config file: #{config_file} ")
32
32
  end
33
33
 
34
- @machinfo = env[:machine]
35
34
  case action
36
35
  when :up
37
36
  notification(config, config_file) if state != :running && provision && config.is_config_valid
@@ -48,9 +47,15 @@ module VagrantPlugins
48
47
  devices = PushbulletConfig::DEVICES
49
48
  token = PushbulletConfig::TOKEN
50
49
  client = Washbullet::Client.new(token)
51
- devices.each {|iden|
52
- client.push_note(iden, "Vagrant Finished: #{@machine}", '')
53
- }
50
+ if(devices.length > 0)
51
+ devices.each {|iden|
52
+ client.push_note(iden, "Vagrant Finished: #{@machine}", '')
53
+ }
54
+ else
55
+ #push to all
56
+ client.push_note('', "Vagrant Finished: #{@machine}", '')
57
+ end
58
+
54
59
  end
55
60
  end
56
61
  end
@@ -25,12 +25,14 @@ To notify all devices:
25
25
  - Leave the DEVICES variable empty in your config file.
26
26
  INFO
27
27
  @env.ui.info(guide)
28
-
29
- client = Washbullet::Client.new('v1zUVfPeLEveoY8suYABuu9WmuZUDhItndujC7jkt9OgK')
30
28
  require config_file
29
+
30
+ wb_client = get_washbullet_client(PushbulletConfig::TOKEN,config_file)
31
+ return if wb_client == nil
32
+
31
33
  enabled_devices = PushbulletConfig::DEVICES
32
34
 
33
- devices = client.devices.body["devices"]
35
+ devices = wb_client.devices.body["devices"]
34
36
  msg = []
35
37
  devices.each { |device|
36
38
  if device["active"]
@@ -49,6 +51,26 @@ INFO
49
51
  @env.ui.error("Please put your pushbullet token from http://pushbullet.com/account into this file: #{config_file}.
50
52
  \n ---- Then run this command again to limit pushes to specific devices-----")
51
53
  end
54
+ end
55
+
56
+ private
57
+
58
+ def get_washbullet_client(api_token,config_file)
59
+ if (api_token.nil? || api_token.empty?)
60
+ @env.ui.error("Your API Token is not set. \nYou can find it here: http://pushbullet.com/account \nAnd enter it here: #{config_file}")
61
+ return nil
62
+ end
63
+
64
+ begin
65
+ client = Washbullet::Client.new(api_token)
66
+ rescue Washbullet::Unauthorized
67
+ @env.ui.error("Pushbullet API Authentication failed. Please compare your API Token: http://pushbullet.com/account with: #{config_file}")
68
+ return nil
69
+ rescue Exception => e
70
+ @env.ui.error("There was an unknown exception with the Pushbullet plugin. \n Please report this to https://github.com/brettswift/vagrant-pushbullet")
71
+ raise e
72
+ end
73
+
52
74
  end
53
75
  end
54
76
  end
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module Pushbullet
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
@@ -13,7 +13,7 @@ module VagrantPlugins
13
13
  def self.write_default_key
14
14
  content = <<-EOF
15
15
  module PushbulletConfig
16
- TOKEN = "<pushbullet_token>" #required
16
+ TOKEN = "" #required
17
17
  DEVICES = [] #optional. MUST use quotes. NO empty strings.
18
18
  end
19
19
  EOF
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-pushbullet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - brettswift