Skip to content
This repository has been archived by the owner on Feb 7, 2018. It is now read-only.

Commit

Permalink
Make unix? an instance method.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabe Berke-Williams committed Feb 3, 2012
1 parent ae8ae22 commit 4183c89
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .bundle/config
@@ -0,0 +1,2 @@
---
BUNDLE_BIN: bundler_binstubs
12 changes: 6 additions & 6 deletions lib/cocaine/command_line.rb
Expand Up @@ -41,6 +41,10 @@ def run
output output
end end


def unix?
(RbConfig::CONFIG['host_os'] =~ /mswin|mingw/).nil?
end

private private


def with_modified_path def with_modified_path
Expand Down Expand Up @@ -79,7 +83,7 @@ def interpolation(vars, key)


def shell_quote(string) def shell_quote(string)
return "" if string.nil? return "" if string.nil?
if self.class.unix? if unix?
if string.empty? if string.empty?
"''" "''"
else else
Expand All @@ -91,11 +95,7 @@ def shell_quote(string)
end end


def bit_bucket def bit_bucket
self.class.unix? ? "2>/dev/null" : "2>NUL" unix? ? "2>/dev/null" : "2>NUL"
end

def self.unix?
(RbConfig::CONFIG['host_os'] =~ /mswin|mingw/).nil?
end end
end end
end end
6 changes: 3 additions & 3 deletions spec/cocaine/command_line_spec.rb
Expand Up @@ -143,17 +143,17 @@
end end


it "detects that the system is unix" do it "detects that the system is unix" do
Cocaine::CommandLine.unix?.should be_true Cocaine::CommandLine.new("convert").unix?.should be_true
end end


it "detects that the system is windows" do it "detects that the system is windows" do
on_windows! on_windows!
Cocaine::CommandLine.unix?.should be_false Cocaine::CommandLine.new("convert").unix?.should be_false
end end


it "detects that the system is windows (mingw)" do it "detects that the system is windows (mingw)" do
on_mingw! on_mingw!
Cocaine::CommandLine.unix?.should be_false Cocaine::CommandLine.new("convert").unix?.should be_false
end end


it "logs the command to a supplied logger" do it "logs the command to a supplied logger" do
Expand Down

0 comments on commit 4183c89

Please sign in to comment.