Skip to content

Commit

Permalink
handle files that use sync dbm via tmp directory and port
Browse files Browse the repository at this point in the history
  • Loading branch information
jhellerstein committed Nov 22, 2016
1 parent d041f99 commit 468fedc
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions bin/budplot
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ def make_instance(mods)
# If we're given a single identifier that names a class, just return an
# instance of that class. Otherwise, define a bogus class that includes all
# the module names specified by the user and return an instance.
tmpserver = TCPServer.new('127.0.0.1', 0) # get a free port
default_params = {:dbm_dir => "/tmp/budplot_dbm_" + SecureRandom.uuid.to_s, :port => tmpserver.addr[1]}


mods.each do |m|
unless is_constant? m
puts "Error: unable to find definition for module or class \"#{m}\""
Expand All @@ -30,7 +34,7 @@ def make_instance(mods)
mod_klass = eval m
if mod_klass.class == Class
if mods.length == 1
return mod_klass.new
return mod_klass.new(default_params)
else
puts "Error: cannot intermix class \"#{mod_klass}\" with modules"
exit
Expand All @@ -50,7 +54,7 @@ def make_instance(mods)
]
class_def = def_lines.flatten.join("\n")
eval(class_def)
f = FooBar.new
f = FooBar.new(default_params)
3.times{ f.tick }
f
end
Expand Down Expand Up @@ -220,6 +224,7 @@ end
modules = []
ARGV.each do |arg|
if File.exists? arg
arg = File.expand_path arg
require arg
else
modules << arg
Expand Down

0 comments on commit 468fedc

Please sign in to comment.