summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorahoward <ara.t.howard@gmail.com>2013-12-07 15:05:56 -0700
committerahoward <ara.t.howard@gmail.com>2013-12-07 15:05:56 -0700
commitb23da2d383effec160ddf22725a330885077f89b (patch)
tree22608c68f6205b6349ae81236b2f4bba88522437
parent4e2d1bc6643c72e769b11094e5d4880fb9f94344 (diff)
downloadsystemu-b23da2d383effec160ddf22725a330885077f89b.tar.gz
handle silly hostnames
-rw-r--r--Rakefile1
-rw-r--r--lib/systemu.rb14
-rw-r--r--pkg/systemu-2.6.0.gembin0 -> 13824 bytes
-rw-r--r--systemu.gemspec3
-rw-r--r--test/systemu_test.rb14
5 files changed, 29 insertions, 3 deletions
diff --git a/Rakefile b/Rakefile
index fdf4f20..d103852 100644
--- a/Rakefile
+++ b/Rakefile
@@ -118,6 +118,7 @@ task :gemspec do
spec.platform = Gem::Platform::RUBY
spec.summary = #{ lib.inspect }
spec.description = #{ description.inspect }
+ spec.license = "same as ruby's"
spec.files =\n#{ files.sort.pretty_inspect }
spec.executables = #{ executables.inspect }
diff --git a/lib/systemu.rb b/lib/systemu.rb
index 64cfbcd..04c24d9 100644
--- a/lib/systemu.rb
+++ b/lib/systemu.rb
@@ -14,7 +14,7 @@ class SystemUniversal
#
# constants
#
- SystemUniversal::VERSION = '2.5.2' unless SystemUniversal.send(:const_defined?, :VERSION)
+ SystemUniversal::VERSION = '2.6.0' unless SystemUniversal.send(:const_defined?, :VERSION)
def SystemUniversal.version() SystemUniversal::VERSION end
def version() SystemUniversal::VERSION end
#
@@ -217,11 +217,21 @@ class SystemUniversal
end
end
+ def slug_for(*args)
+ options = args.last.is_a?(Hash) ? args.pop : {}
+ join = (options[:join] || options['join'] || '_').to_s
+ string = args.flatten.compact.join(join)
+ words = string.to_s.scan(%r|[/\w]+|)
+ words.map!{|word| word.gsub %r|[^/0-9a-zA-Z_-]|, ''}
+ words.delete_if{|word| word.nil? or word.strip.empty?}
+ words.join(join).downcase.gsub('/', (join * 2))
+ end
+
def tmpdir d = Dir.tmpdir, max = 42, &b
i = -1 and loop{
i += 1
- tmp = File.join d, "systemu_#{ @host }_#{ @ppid }_#{ @pid }_#{ rand }_#{ i += 1 }"
+ tmp = File.join(d, slug_for("systemu_#{ @host }_#{ @ppid }_#{ @pid }_#{ rand }_#{ i += 1 }"))
begin
Dir.mkdir tmp
diff --git a/pkg/systemu-2.6.0.gem b/pkg/systemu-2.6.0.gem
new file mode 100644
index 0000000..e2d5587
--- /dev/null
+++ b/pkg/systemu-2.6.0.gem
Binary files differ
diff --git a/systemu.gemspec b/systemu.gemspec
index 6d0b469..23a6241 100644
--- a/systemu.gemspec
+++ b/systemu.gemspec
@@ -3,10 +3,11 @@
Gem::Specification::new do |spec|
spec.name = "systemu"
- spec.version = "2.5.2"
+ spec.version = "2.6.0"
spec.platform = Gem::Platform::RUBY
spec.summary = "systemu"
spec.description = "description: systemu kicks the ass"
+ spec.license = "same as ruby's"
spec.files =
["LICENSE",
diff --git a/test/systemu_test.rb b/test/systemu_test.rb
index 19fac1d..6d4bf2b 100644
--- a/test/systemu_test.rb
+++ b/test/systemu_test.rb
@@ -17,6 +17,20 @@ Testing SystemU do
assert{ stdout == stdin }
end
+ testing 'silly hostnames' do
+ host = SystemU.instance_variable_get('@host')
+ silly_hostname = "silly's hostname with spaces"
+ begin
+ SystemU.instance_variable_set('@host', silly_hostname)
+ assert{ SystemU.instance_variable_get('@host') == silly_hostname }
+ stdin = '42'
+ status, stdout, stderr = assert{ systemu :bin/:cat, :stdin => stdin }
+ assert{ status == 0 }
+ ensure
+ assert{ SystemU.instance_variable_set('@host', host) }
+ end
+ end
+
end