Skip to content

Commit

Permalink
Add support for ruby 1.9.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennis Hoer committed Sep 26, 2014
1 parent 1ac372a commit 69f6c25
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
language: ruby
rvm:
- "2.0.0"
- "1.9.3"
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
[![Build Status](https://travis-ci.org/dhoer/chef-nssm.svg)](https://travis-ci.org/dhoer/chef-nssm)

This cookbook installs the Non-Sucking Service Manager (http://nssm.cc), and exposes resources to `install` and `remove` Windows services.
Read [TLDR](https://github.com/dhoer/chef-nssm/blob/master/TLDR.md) for more details about usage, chefspec matchers, getting help and contributing.
Read [TLDR](https://github.com/dhoer/chef-nssm/blob/master/TLDR.md) for more details about usage, chefspec matchers, getting help, and contributing.

## Requirements

Chef 11.14.2 and Ruby 1.9.3 or higher.

### Platform

- Windows Server 2012 R2
Expand Down
16 changes: 9 additions & 7 deletions TLDR.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,24 @@

Advanced usage of NSSM.

### Examples
### Arguments with Spaces

When dealing with an argument that contain spaces, add triple double quotes `"""` around it:
Having spaces in `servicename` and `program` attributes is not a problem, but spaces in an argument is a different matter.

When dealing with an argument containing spaces, add [3 double quotes](https://stackoverflow.com/questions/7760545/cmd-escape-double-quotes-in-parameter/15262019#15262019?s=62228804c3f84fceb873ee30dd784161) `"""` around it:

nssm 'service name' do
program 'C:\\Windows\\System32\\java.exe'
program 'C:\Program Files\Java\jdk1.7.0_67\bin\java.exe'
args '-jar """C:/path/with spaces to/my-executable.jar"""'
action :install
end

When dealing with an arguments that require interpolation and handling of spaces, then encapsulate the entire args using `%Q{}` notation and use `"""` around the arguments containing spaces:
When dealing with arguments requiring [interpolation](http://en.wikibooks.org/wiki/Ruby_Programming/Syntax/Literals#Interpolation) and contain an argument with spaces, then encapsulate `args` using `%{}` notation and use `"""` around arguments with spaces:

my_path_with_spaces = 'C:/path/with spaces to/my-executable.jar
my_path_with_spaces = 'C:/path/with spaces to/my-executable.jar'
nssm 'service name' do
program 'C:\\Windows\\System32\\java.exe'
args %Q{-jar """#{my_path_with_spaces}"""}
program 'C:\Program Files\Java\jdk1.7.0_67\bin\java.exe'
args %{-jar """#{my_path_with_spaces}"""}
action :install
end

Expand Down
2 changes: 1 addition & 1 deletion providers/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def service_installed?(servicename)

batch "Install #{new_resource.servicename} service" do
code <<-EOH
nssm install "#{new_resource.servicename}" #{new_resource.program} #{new_resource.args}
nssm install "#{new_resource.servicename}" "#{new_resource.program}" #{new_resource.args}
EOH
not_if { service_installed }
end
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/install_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

it 'executes batch command to install service' do
expect(chef_run).to run_batch('Install service name service').with(
code: %r{nssm install "service name" C:\\Windows\\System32\\java.exe -jar C:/path/to/my-executable.jar}
code: %r{nssm install "service name" "C:\\Windows\\System32\\java.exe" -jar C:/path/to/my-executable.jar}
)
end

Expand Down

0 comments on commit 69f6c25

Please sign in to comment.