Sha256: 5524573d8f43ea32e7795b47de8846f0d461e1f4727bd5c8fe56d65c79ba5c94
Contents?: true
Size: 988 Bytes
Versions: 87
Compression:
Stored size: 988 Bytes
Contents
#!/usr/bin/env ruby # # An Amalgalite example showing how to 'require' data in an amalgalite database # # We'll make a database with one table, that we store file contents in. # $: << "../lib" $: << "../ext" require 'rubygems' require 'amalgalite' style = ARGV.shift || "normal" # # create the database # dbfile = Amalgalite::Requires::Bootstrap::DEFAULT_DB File.unlink( dbfile ) if File.exist?( dbfile ) require 'amalgalite/packer' options = { :verbose => true } if style == "compressed" then options[:compressed] = true end p = Amalgalite::Packer.new( options ) p.pack( [ "require_me.rb" ] ) require 'amalgalite/requires' begin Amalgalite::Requires.new( :dbfile_name => p.dbfile ) FileUtils.mv 'require_me.rb', 'rm.rb', :verbose => true require 'require_me' e = RequireMe.new( "#{style} require style works!" ) e.foo require 'require_me' puts ensure FileUtils.mv 'rm.rb', 'require_me.rb', :verbose => true File.unlink( dbfile ) if File.exist?( dbfile ) end
Version data entries
87 entries across 87 versions & 2 rubygems