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

Version Path
amalgalite-1.9.4-x64-mingw-ucrt examples/requires.rb
amalgalite-1.9.4-x86-mingw32 examples/requires.rb
amalgalite-1.9.4-x64-mingw32 examples/requires.rb
amalgalite-1.9.4 examples/requires.rb
amalgalite-1.9.1-x86-mingw32 examples/requires.rb
amalgalite-1.9.1-x64-mingw32 examples/requires.rb
amalgalite-1.9.1-x64-mingw-ucrt examples/requires.rb
amalgalite-1.9.1 examples/requires.rb
amalgalite-1.9.0-x64-mingw-ucrt examples/requires.rb
amalgalite-1.9.0-x86-mingw32 examples/requires.rb
amalgalite-1.9.0-x64-mingw32 examples/requires.rb
amalgalite-1.9.0 examples/requires.rb
amalgalite-1.8.0-x64-mingw-ucrt examples/requires.rb
amalgalite-1.8.0-x64-mingw32 examples/requires.rb
amalgalite-1.8.0-x86-mingw32 examples/requires.rb
amalgalite-1.8.0 examples/requires.rb
amalgalite-1.7.0-x86-mingw32 examples/requires.rb
amalgalite-1.7.0-x64-mingw32 examples/requires.rb
amalgalite-1.7.0 examples/requires.rb
amalgalite-1.6.3-x86-mingw32 examples/requires.rb