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-0.10.2 examples/requires.rb
amalgalite-0.10.0 examples/requires.rb
amalgalite-0.10.1 examples/requires.rb
amalgalite-0.5.0-x86-mswin32-60 examples/requires.rb
amalgalite-0.5.0 examples/requires.rb
amalgalite-0.5.1-x86-mswin32-60 examples/requires.rb
amalgalite-0.5.1 examples/requires.rb
amalgalite-0.6.0 examples/requires.rb
amalgalite-0.7.0 examples/requires.rb
amalgalite-0.6.0-x86-mswin32-60 examples/requires.rb
amalgalite-0.7.0-x86-mswin32-60 examples/requires.rb
amalgalite-0.7.1 examples/requires.rb
amalgalite-0.7.1-x86-mswin32-60 examples/requires.rb
amalgalite-0.7.3-x86-mswin32-60 examples/requires.rb
amalgalite-0.7.3 examples/requires.rb
amalgalite-0.7.4-x86-mswin32-60 examples/requires.rb
amalgalite-0.7.5-x86-mswin32-60 examples/requires.rb
amalgalite-0.7.4 examples/requires.rb
amalgalite-0.7.5 examples/requires.rb
amalgalite-0.7.7 examples/requires.rb