Top Level Namespace
Defined Under Namespace
Modules: EventMachine, Foxbat, Kernel
Instance Method Summary collapse
Instance Method Details
#require_or_get(lib, version, ns) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/foxbat.rb', line 11 def require_or_get(lib, version, ns) jar = "#{lib}-#{version}.jar" jarpath = File.dirname(__FILE__) + '/' + jar if !File.exist?(jarpath) puts "Couldn't find #{lib}, let's download it now." require 'net/http' f = open(jarpath, 'w') Net::HTTP.start('search.maven.org') do |http| begin http.request_get("/remotecontent?filepath=#{ns}/#{lib}/#{version}/#{jar}") do |resp| puts "Downloading #{jar} from maven repository..." resp.read_body do |segment| f.write(segment) end puts "Done." end ensure f.close() end end end require jar end |