vagrant-notify 0.5.6 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/.travis.yml +3 -1
- data/CHANGELOG.md +15 -0
- data/README.md +23 -1
- data/files/notify-send.erb +18 -24
- data/lib/vagrant-notify/action/install_command.rb +10 -5
- data/lib/vagrant-notify/action/start_server.rb +7 -2
- data/lib/vagrant-notify/action/stop_server.rb +4 -2
- data/lib/vagrant-notify/config.rb +26 -4
- data/lib/vagrant-notify/server.rb +70 -10
- data/lib/vagrant-notify/version.rb +1 -1
- data/spec/action/install_command_spec.rb +1 -1
- data/spec/action/start_server_spec.rb +3 -2
- data/spec/server_spec.rb +9 -5
- metadata +6 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8409030b38ffe90cf4f105a0ca94d95cf3e4a7dfb733cf7eb97d645d98f47cf1
|
4
|
+
data.tar.gz: c0a08020ba70555cbb88a1faad8be6923dcdbf4eea186dade504a1ad497c9825
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac522b11e032bec6c29efd6f49e9d2c570a06247e098a65bbba53a97a850c9ce13812f68a33fd77519c85c6d2c3f0c3a2dcb018a83ece3ced342b0d890d89bb0
|
7
|
+
data.tar.gz: 9b10bfc83de8be00ae61b77e4fa82415df1aaf39374f5e88cbfec267dd4c52a4d32e257d46848c066357c909fb90010016aa324592ce7232711078ba4a37bfa9
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,19 @@
|
|
1
|
+
## [0.6.0](https://github.com/fgrehm/vagrant-notify/compare/v0.5.6...v0.6.0) (September 5, 2020)
|
2
|
+
IMPROVEMENTS
|
3
|
+
|
4
|
+
- Support for custom notifcation application without the need of a notify-send wrapper script.
|
5
|
+
- Ensure plugin plays nice with read-only boxes.
|
6
|
+
- Updating gem dependencies versions and newer version of Ruby for Travis CI testing.
|
7
|
+
|
8
|
+
BUG FIXES
|
9
|
+
|
10
|
+
- Fixnum deprecation warning. [[GH-40]](https://github.com/fgrehm/vagrant-notify/issues/40)
|
11
|
+
|
1
12
|
## [0.5.6](https://github.com/fgrehm/vagrant-notify/compare/v0.5.5...v0.5.6) (September 29, 2017)
|
13
|
+
IMPROVEMENTS
|
14
|
+
|
15
|
+
- AppleScript wrapper script.
|
16
|
+
|
2
17
|
BUG FIXES
|
3
18
|
|
4
19
|
- `vagrant resume` bug fix. [[GH-39]](https://github.com/fgrehm/vagrant-notify/issues/39)
|
data/README.md
CHANGED
@@ -60,7 +60,7 @@ end
|
|
60
60
|
```
|
61
61
|
|
62
62
|
_Please note that as of v0.5.1, the notification server will automatically be disabled for any of the following
|
63
|
-
[cloud providers](lib/vagrant-notify/plugin.rb#L81-
|
63
|
+
[cloud providers](lib/vagrant-notify/plugin.rb#L81-L84)._
|
64
64
|
|
65
65
|
By default, the notification server is binded to [local interfaces](lib/vagrant-notify/plugin.rb#L86-L93). For networking different than your provider's default network configuration, you can use the ***notify.bind\_ip*** configuration option to bind the notification server onto a different local ip address.
|
66
66
|
|
@@ -71,6 +71,28 @@ Vagrant.configure(2) do |config|
|
|
71
71
|
end
|
72
72
|
```
|
73
73
|
|
74
|
+
By default local server uses ***notify_send*** command for displaying notifications, there is a possibility to use different app without wrapper scripts:
|
75
|
+
* ***notify.sender\_app*** configuration option is used for specifing application name (default: `notify-send`)
|
76
|
+
* ***notify.sender\_params\_str*** defines how params for applications will be passed (default: `[--app-name {app_name}] [--urgency {urgency}] [--expire-time {expire_time}] [--icon {icon}] [--category {category}] [--hint {hint}] {message}`). You can use these variables (escaped by `{` and `}` characters) here:
|
77
|
+
* ***urgency*** - urgency level for notification
|
78
|
+
* ***expire\_time*** - when notification will expire?
|
79
|
+
* ***app\_name*** - application name
|
80
|
+
* ***icon*** - icon for the notification (can be multiple, devided by comma)
|
81
|
+
* ***category*** - category for the notification (can be multiple, devided by comma)
|
82
|
+
* ***hint*** - icon for the notification (need to use this format: TYPE:NAME:VALUE)
|
83
|
+
* ***message*** - message to send
|
84
|
+
* ***notify.sender\_params\_escape*** - should params will be escaped when passed to script (default: `true`)
|
85
|
+
|
86
|
+
This is example how to to run notifications with build-in MacOS X notifications support:
|
87
|
+
```ruby
|
88
|
+
Vagrant.configure(2) do |config|
|
89
|
+
config.vm.box = "ubuntu/trusty64"
|
90
|
+
config.notify.sender_params_str = '-e \'display notification {message} sound name \"default\"\''
|
91
|
+
config.notify.sender_app = 'osascript'
|
92
|
+
config.notify.sender_params_escape = true
|
93
|
+
end
|
94
|
+
```
|
95
|
+
|
74
96
|
**WARNING**
|
75
97
|
|
76
98
|
_Do **NOT** bind the notification server to an IP accessible over a network! The notification server does not have any authentication and doing so will leave your system vulnerable to remote command execution._
|
data/files/notify-send.erb
CHANGED
@@ -8,39 +8,34 @@ require 'rubygems'
|
|
8
8
|
require 'socket'
|
9
9
|
require 'optparse'
|
10
10
|
require 'fileutils'
|
11
|
+
require 'json'
|
11
12
|
|
12
13
|
options = {}
|
13
14
|
OptionParser.new do |opts|
|
14
|
-
|
15
|
-
|
16
|
-
opts.on('-u', '--urgency LEVEL') { |v| options[:
|
17
|
-
opts.on('-t', '--expire-time TIME') { |v| options[:
|
18
|
-
opts.on('-a', '--app-name APP_NAME') { |v| options[:
|
19
|
-
opts.on('-i', '--icon ICON[,ICON...]') { |v| options[:
|
20
|
-
opts.on('-c', '--category TYPE[,TYPE...]') { |v| options[:
|
21
|
-
opts.on('-h', '--hint TYPE:NAME:VALUE') { |v| options[:
|
22
|
-
opts.on('-v', '--version') { |v| options[:
|
23
|
-
|
15
|
+
opts.banner = "Usage: notify-send.rb TITLE [MESSAGE] [options]"
|
16
|
+
|
17
|
+
opts.on('-u', '--urgency LEVEL') { |v| options[:urgency] = v }
|
18
|
+
opts.on('-t', '--expire-time TIME') { |v| options[:expire_time] = v }
|
19
|
+
opts.on('-a', '--app-name APP_NAME') { |v| options[:app_name] = v }
|
20
|
+
opts.on('-i', '--icon ICON[,ICON...]') { |v| options[:icon] = v }
|
21
|
+
opts.on('-c', '--category TYPE[,TYPE...]') { |v| options[:category] = v }
|
22
|
+
opts.on('-h', '--hint TYPE:NAME:VALUE') { |v| options[:hint] = v }
|
23
|
+
opts.on('-v', '--version') { |v| options[:version] = v }
|
24
24
|
end.parse!
|
25
25
|
|
26
|
+
options[:title]=ARGV.pop
|
27
|
+
options[:message]=ARGV.pop if ARGV.length > 0
|
28
|
+
|
26
29
|
# BSD guests do not support shared folders
|
27
30
|
unless RUBY_PLATFORM =~ /freebsd|openbsd|netbsd/
|
28
|
-
if options[:
|
29
|
-
new_filename = options[:
|
30
|
-
FileUtils.cp options[:
|
31
|
-
options[:
|
31
|
+
if options[:icon]
|
32
|
+
new_filename = options[:icon].gsub('/', '-')
|
33
|
+
FileUtils.cp options[:icon], "<%= shared_folder %>/#{new_filename}"
|
34
|
+
options[:icon] = new_filename
|
32
35
|
end
|
33
36
|
end
|
34
37
|
|
35
|
-
cmd = options
|
36
|
-
"-#{key} '#{value}'"
|
37
|
-
end.join(' ')
|
38
|
-
|
39
|
-
# All single quotes part of the message get removed.
|
40
|
-
# TODO: Need to escape values.
|
41
|
-
unless ARGV.empty?
|
42
|
-
cmd << ARGV.map{|a| " '#{a.gsub(/'/, "")}'"}.join(' ')
|
43
|
-
end
|
38
|
+
cmd = JSON.generate(options, quirks_mode: true)
|
44
39
|
|
45
40
|
# VirtualBox is the only provider that can communicate with 127.0.0.1, others will have to use default private networking
|
46
41
|
if "<%= provider_name %>" == "virtualbox"
|
@@ -53,7 +48,6 @@ else
|
|
53
48
|
client_ip = "<%= client_ip %>"
|
54
49
|
end
|
55
50
|
|
56
|
-
|
57
51
|
TCPSocket.open client_ip, <%= host_port %> do |s|
|
58
52
|
s.send cmd, 0
|
59
53
|
end
|
@@ -32,16 +32,21 @@ module Vagrant
|
|
32
32
|
def install_command_on_guest(env, command_path)
|
33
33
|
source = env[:tmp_path].join 'vagrant-notify-send'
|
34
34
|
env[:machine].communicate.upload(source.to_s, '/tmp/notify-send')
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
env[:machine].communicate.sudo(
|
35
|
+
|
36
|
+
begin
|
37
|
+
env[:machine].communicate.sudo('mv /usr/bin/{notify-send,notify-send.bkp}; exit 0')
|
38
|
+
env[:machine].communicate.sudo('mv /tmp/notify-send /usr/bin/notify-send && chmod +x /usr/bin/notify-send')
|
39
|
+
if RUBY_PLATFORM =~ /mswin|msys|mingw|cygwin|bccwin|wince|emc/
|
40
|
+
env[:machine].communicate.sudo("sed 's/\r\$//' -i /usr/bin/notify-send") # dos2unix
|
41
|
+
end
|
42
|
+
rescue => msg
|
43
|
+
env[:machine].ui.warn("vagrant-notify: failed to install /usr/bin/notify-send onto #{env[:machine].name}.\n#{msg}")
|
39
44
|
end
|
40
45
|
end
|
41
46
|
|
42
47
|
def check_if_ruby_on_guest(env)
|
43
48
|
ruby_check = ''
|
44
|
-
env[:machine].communicate.sudo("which ruby || true") {|type, data| ruby_check = data }
|
49
|
+
env[:machine].communicate.sudo("which ruby 2>/dev/null || true") {|type, data| ruby_check = data }
|
45
50
|
if ruby_check.empty?
|
46
51
|
env[:machine].ui.warn("Ruby is not installed on '#{env[:machine].name}' guest VM! vagrant-notify will not work until a version of Ruby is installed.")
|
47
52
|
end
|
@@ -20,10 +20,15 @@ module Vagrant
|
|
20
20
|
|
21
21
|
return if env[:machine].config.notify.enable == false
|
22
22
|
|
23
|
-
|
23
|
+
bind_ip=env[:notify_data][:bind_ip]
|
24
|
+
|
25
|
+
port = next_available_port(bind_ip)
|
26
|
+
sender_app = '"' + env[:machine].config.notify.sender_app + '"'
|
27
|
+
sender_params_str = '"' + env[:machine].config.notify.sender_params_str + '"'
|
28
|
+
sender_params_escape = (env[:machine].config.notify.sender_params_escape) ? 1 : 0
|
24
29
|
|
25
30
|
if which('ruby')
|
26
|
-
env[:notify_data][:pid]
|
31
|
+
env[:notify_data][:pid] = Process.spawn("ruby #{dir}/server.rb #{id} #{port} #{bind_ip} #{sender_app} #{sender_params_str} #{sender_params_escape} #{provider_name}")
|
27
32
|
env[:notify_data][:port] = port
|
28
33
|
|
29
34
|
sleep 5
|
@@ -11,8 +11,10 @@ module Vagrant
|
|
11
11
|
return if env[:machine].config.notify.enable == false
|
12
12
|
|
13
13
|
if env[:machine].state.id == :running
|
14
|
-
|
15
|
-
|
14
|
+
begin
|
15
|
+
env[:machine].communicate.sudo('rm /usr/bin/notify-send; exit 0')
|
16
|
+
env[:machine].communicate.sudo('mv /usr/bin/{notify-send.bkp,notify-send}; exit 0')
|
17
|
+
end
|
16
18
|
end
|
17
19
|
|
18
20
|
@app.call env
|
@@ -1,10 +1,27 @@
|
|
1
1
|
module Vagrant
|
2
2
|
module Notify
|
3
3
|
class Config < Vagrant.plugin(2, :config)
|
4
|
-
|
4
|
+
|
5
|
+
# Enable?
|
6
|
+
attr_accessor :enable
|
7
|
+
|
8
|
+
# Bind IP
|
9
|
+
attr_accessor :bind_ip
|
10
|
+
|
11
|
+
# Notify send application
|
12
|
+
attr_accessor :sender_app
|
13
|
+
|
14
|
+
# Notify send params string
|
15
|
+
attr_accessor :sender_params_str
|
16
|
+
|
17
|
+
# Sender params escape
|
18
|
+
attr_accessor :sender_params_escape
|
5
19
|
|
6
20
|
def initialize()
|
7
21
|
@enable = UNSET_VALUE
|
22
|
+
@sender_app = UNSET_VALUE
|
23
|
+
@sender_params_str = UNSET_VALUE
|
24
|
+
@sender_params_escape = UNSET_VALUE
|
8
25
|
end
|
9
26
|
|
10
27
|
def validate(machine)
|
@@ -18,18 +35,20 @@ module Vagrant
|
|
18
35
|
|
19
36
|
if @enable != 0
|
20
37
|
if @enable != false && @enable != true
|
21
|
-
errors << "Unknown option: #{@enable}"
|
38
|
+
errors << "Unknown option for enable: #{@enable}"
|
22
39
|
end
|
23
40
|
end
|
24
41
|
|
42
|
+
if @sender_params_escape != false && @sender_params_escape != true && @sender_params_escape != UNSET_VALUE
|
43
|
+
errors << "Unknown option for @sender_params_escape: #{@sender_params_escape}"
|
44
|
+
end
|
45
|
+
|
25
46
|
if backed_by_supported_provider?(machine)
|
26
47
|
if @bind_ip.is_a?(String)
|
27
48
|
require "resolv"
|
28
49
|
unless @bind_ip =~ Resolv::IPv4::Regex
|
29
50
|
errors << "Invalid bind IP address: #{@bind_ip}"
|
30
51
|
end
|
31
|
-
elsif @bind_ip.is_a?(FalseClass) || @bind_ip.is_a?(Fixnum) || @bind_ip.is_a?(Array) || @bind_ip.is_a?(Hash)
|
32
|
-
errors << "Unknown bind IP address: #{@bind_ip}"
|
33
52
|
else
|
34
53
|
@bind_ip = SUPPORTED_PROVIDERS[machine.provider_name]
|
35
54
|
end
|
@@ -44,6 +63,9 @@ module Vagrant
|
|
44
63
|
|
45
64
|
def finalize!
|
46
65
|
@enable = 0 if @enable == UNSET_VALUE
|
66
|
+
@sender_app = "notify-send" if @sender_app == UNSET_VALUE
|
67
|
+
@sender_params_str = "[--app-name {app_name}] [--urgency {urgency}] [--expire-time {expire_time}] [--icon {icon}] [--category {category}] [--hint {hint}] {title} [{message}]" if @sender_params_str == UNSET_VALUE
|
68
|
+
@sender_params_escape = true if @sender_app == UNSET_VALUE
|
47
69
|
end
|
48
70
|
|
49
71
|
private
|
@@ -1,14 +1,19 @@
|
|
1
1
|
require 'socket'
|
2
|
+
require 'json'
|
3
|
+
require 'tmpdir'
|
2
4
|
|
3
5
|
module Vagrant
|
4
6
|
module Notify
|
5
7
|
class Server
|
6
8
|
HTTP_RESPONSE = "Hi! You just reached the vagrant notification server"
|
7
9
|
|
8
|
-
def self.run(id, port, bind_ip, machine_name='default', provider='virtualbox')
|
9
|
-
#id
|
10
|
-
#machine_name
|
11
|
-
#provider
|
10
|
+
def self.run(id, port, bind_ip, sender_app, sender_params_str, sender_params_escape, machine_name='default', provider='virtualbox')
|
11
|
+
#id = env[:machine].id
|
12
|
+
#machine_name = env[:machine].name
|
13
|
+
#provider = env[:machine].provider_name
|
14
|
+
#sender_app = env[:machine].config.sender_app
|
15
|
+
#sender_params_str = env[:machine].config.sender_params_str
|
16
|
+
#sender_params_escape = env[:machine].config.sender_params_escape
|
12
17
|
|
13
18
|
if __FILE__ == $0
|
14
19
|
begin
|
@@ -16,7 +21,7 @@ module Vagrant
|
|
16
21
|
rescue
|
17
22
|
exit 1
|
18
23
|
end
|
19
|
-
server = self.new(id, machine_name, provider)
|
24
|
+
server = self.new(id, sender_app, sender_params_str, sender_params_escape, machine_name, provider)
|
20
25
|
|
21
26
|
# Have to wrap this in a begin/rescue block so we can be certain the server is running at all times.
|
22
27
|
begin
|
@@ -33,10 +38,13 @@ module Vagrant
|
|
33
38
|
end
|
34
39
|
end
|
35
40
|
|
36
|
-
def initialize(id, machine_name = :default, provider = :virtualbox)
|
41
|
+
def initialize(id, sender_app, sender_params_str, sender_params_escape, machine_name = :default, provider = :virtualbox)
|
37
42
|
@id = id
|
38
43
|
@machine_name = machine_name
|
39
44
|
@provider = provider
|
45
|
+
@sender_app = sender_app
|
46
|
+
@sender_params_str = sender_params_str
|
47
|
+
@sender_params_escape = sender_params_escape
|
40
48
|
end
|
41
49
|
|
42
50
|
def receive_data(client)
|
@@ -44,8 +52,10 @@ module Vagrant
|
|
44
52
|
if http_request?(args)
|
45
53
|
client.puts HTTP_RESPONSE
|
46
54
|
else
|
47
|
-
|
48
|
-
|
55
|
+
json_data=JSON.parse(args)
|
56
|
+
parsed_args=map_params_str(json_data)
|
57
|
+
fix_icon_path! parsed_args
|
58
|
+
system "#{@sender_app} #{parsed_args}"
|
49
59
|
end
|
50
60
|
client.close
|
51
61
|
rescue => ex
|
@@ -54,12 +64,59 @@ module Vagrant
|
|
54
64
|
|
55
65
|
private
|
56
66
|
|
67
|
+
# Maps params str with values
|
68
|
+
#
|
69
|
+
#@param data [Map] Array values map
|
70
|
+
#
|
71
|
+
#@return [String]
|
72
|
+
def map_params_str(data)
|
73
|
+
cmd=@sender_params_str + ''
|
74
|
+
cmd.gsub! '%', '%%'
|
75
|
+
|
76
|
+
replace=[]
|
77
|
+
cmd.scan(/\[[^\]]+\]/).each do |part|
|
78
|
+
variable=part[/\{[^\}]+\}/][1..-2]
|
79
|
+
if data.key? variable
|
80
|
+
replace << part[1..-2].sub('{' + variable + '}', escape_param(data[variable]))
|
81
|
+
cmd.sub! part, '%'+replace.length.to_s+'$s'
|
82
|
+
else
|
83
|
+
cmd.sub! part, ''
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
cmd.scan(/\{[^\}]+\}/).each do |part|
|
88
|
+
variable=part[1..-2]
|
89
|
+
if data.key? variable
|
90
|
+
replace << escape_param(data[variable])
|
91
|
+
cmd.sub! part, '%'+replace.length.to_s+'$s'
|
92
|
+
end
|
93
|
+
end
|
94
|
+
cmd % replace
|
95
|
+
end
|
96
|
+
|
57
97
|
def log(message)
|
58
|
-
File.open(
|
98
|
+
File.open(@log_path, 'a+') do |log|
|
59
99
|
log.puts "#{message}"
|
60
100
|
end
|
61
101
|
end
|
62
102
|
|
103
|
+
# Escapes param
|
104
|
+
#
|
105
|
+
#@param param [String] Param
|
106
|
+
#
|
107
|
+
#@return [String]
|
108
|
+
def escape_param(param)
|
109
|
+
return param unless @sender_params_escape
|
110
|
+
'"' + param.gsub('"', "\\\"").gsub("'", "\\'").gsub("\\", "\\\\") + '"'
|
111
|
+
end
|
112
|
+
|
113
|
+
# Gets log path
|
114
|
+
#
|
115
|
+
#@return [String]
|
116
|
+
def log_path
|
117
|
+
File.join Dir.tmpdir(), "vagrant-notify-error-#{@id}.log"
|
118
|
+
end
|
119
|
+
|
63
120
|
def read_args(client)
|
64
121
|
''.tap do |args|
|
65
122
|
while tmp = client.gets and tmp !~ /^\s*$/
|
@@ -88,5 +145,8 @@ end
|
|
88
145
|
id = ARGV[0]
|
89
146
|
port = ARGV[1]
|
90
147
|
bind_ip = ARGV[2]
|
148
|
+
sender_app = ARGV[3]
|
149
|
+
sender_params_str = ARGV[4]
|
150
|
+
sender_params_escape = ARGV[5]
|
91
151
|
|
92
|
-
Vagrant::Notify::Server.run
|
152
|
+
Vagrant::Notify::Server.run id, port, bind_ip, sender_app, sender_params_str, sender_params_escape
|
@@ -46,6 +46,6 @@ describe Vagrant::Notify::Action::InstallCommand do
|
|
46
46
|
end
|
47
47
|
|
48
48
|
it 'verify if ruby is installed on guest' do
|
49
|
-
communicator.should have_received(:sudo).with("which ruby || true")
|
49
|
+
communicator.should have_received(:sudo).with("which ruby 2>/dev/null || true")
|
50
50
|
end
|
51
51
|
end
|
@@ -6,7 +6,8 @@ require 'vagrant-notify/server'
|
|
6
6
|
|
7
7
|
describe Vagrant::Notify::Action::StartServer do
|
8
8
|
let(:app) { lambda { |env| } }
|
9
|
-
let(:
|
9
|
+
let(:sender_params_str) { "[--app-name {app_name}] [--urgency {urgency}] [--expire-time {expire_time}] [--icon {icon}] [--category {category}] [--hint {hint}] {message}"}
|
10
|
+
let(:config) { mock(notify: stub(enable: true, sender_app: 'notify-send', sender_params_str: sender_params_str, sender_params_escape: false)) }
|
10
11
|
let(:ui) { mock(success: true)}
|
11
12
|
let(:id) { '425e799c-1293-4939-bo39-263lcc7457e8' }
|
12
13
|
let(:provider_name) { 'virtualbox' }
|
@@ -37,4 +38,4 @@ describe Vagrant::Notify::Action::StartServer do
|
|
37
38
|
# end
|
38
39
|
|
39
40
|
pending 'identifies the next available port'
|
40
|
-
end
|
41
|
+
end
|
data/spec/server_spec.rb
CHANGED
@@ -1,16 +1,20 @@
|
|
1
1
|
require 'vagrant-notify/server'
|
2
2
|
|
3
3
|
describe Vagrant::Notify::Server do
|
4
|
-
let(:arguments) { "
|
4
|
+
let(:arguments) { '{"message":"It Works!"}' }
|
5
5
|
let(:client) { StringIO.new(arguments) }
|
6
|
+
let(:sender_app) { 'notify-send' }
|
7
|
+
let(:sender_params_str) { "[--app-name {app_name}] [--urgency {urgency}] [--expire-time {expire_time}] [--icon {icon}] [--category {category}] [--hint {hint}] {message}" }
|
8
|
+
let(:sender_params_escape) { true }
|
6
9
|
let(:machine_id) { 'machine-id' }
|
10
|
+
let(:return_string) { '"It Works!"'}
|
7
11
|
|
8
|
-
subject { described_class.new(machine_id) }
|
12
|
+
subject { described_class.new(machine_id, sender_app, sender_params_str, sender_params_escape) }
|
9
13
|
|
10
14
|
before { subject.stub(:system => true) }
|
11
15
|
|
12
16
|
it 'runs notify-send with received data from client' do
|
13
|
-
subject.should_receive(:system).with("
|
17
|
+
subject.should_receive(:system).with("#{sender_app} #{return_string}") #server.rb needs to be updated so it strips this exta white space in the response
|
14
18
|
subject.receive_data(client)
|
15
19
|
end
|
16
20
|
|
@@ -20,12 +24,12 @@ describe Vagrant::Notify::Server do
|
|
20
24
|
end
|
21
25
|
|
22
26
|
context 'notification with an icon' do
|
23
|
-
let(:arguments) { "-
|
27
|
+
let(:arguments) { '{"icon":"-tmp-foo-bar.jpg","message":"Test message"}' }
|
24
28
|
|
25
29
|
before { subject.receive_data(client) }
|
26
30
|
|
27
31
|
it 'rewrites icon path before sending the notification' do
|
28
|
-
subject.should have_received(:system).with("
|
32
|
+
subject.should have_received(:system).with("#{sender_app} --icon \"-tmp-foo-bar.jpg\" \"Test message\"")
|
29
33
|
end
|
30
34
|
end
|
31
35
|
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-notify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fabio Rehm
|
8
8
|
- Tony Baltazar
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2020-09-06 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: A Vagrant plugin that forwards `notify-send` from guest to host machine
|
15
15
|
and notifies provisioning status
|
@@ -68,7 +68,7 @@ files:
|
|
68
68
|
homepage: https://github.com/fgrehm/vagrant-notify
|
69
69
|
licenses: []
|
70
70
|
metadata: {}
|
71
|
-
post_install_message:
|
71
|
+
post_install_message:
|
72
72
|
rdoc_options: []
|
73
73
|
require_paths:
|
74
74
|
- lib
|
@@ -83,9 +83,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
83
|
- !ruby/object:Gem::Version
|
84
84
|
version: '0'
|
85
85
|
requirements: []
|
86
|
-
|
87
|
-
|
88
|
-
signing_key:
|
86
|
+
rubygems_version: 3.1.2
|
87
|
+
signing_key:
|
89
88
|
specification_version: 4
|
90
89
|
summary: A Vagrant plugin that forwards `notify-send` from guest to host machine and
|
91
90
|
notifies provisioning status
|