module Quick

Constants

VERSION

Public Instance Methods

brb_service() click to toggle source
# File lib/quick.rb, line 10
def brb_service
        @brb_service ||=
                begin
                        uri = File.read('#brb_uri')
                        service = BrB::Tunnel.create nil, uri
                        if service.error?
                                raise "failed to connect to the Quick instance"
                        end
                        service
                end
rescue Errno::ENOENT
        raise "not in a Quick directory"
end
class_here(name, super_path='Object') click to toggle source
# File lib/quick.rb, line 53
def class_here(name, super_path='Object')
        const_defined? name
        brb_service.new_mod_block pwd_from_root, name, from_root(super_path)
rescue NameError
        raise "invalid class name"
end
eval_here(code, instance=true) click to toggle source
# File lib/quick.rb, line 37
def eval_here(code, instance=true)
        success, result = brb_service.eval_block pwd_from_root, code, instance
        if success
                result
        else
                raise result
        end
end
from_root(path) click to toggle source
# File lib/quick.rb, line 64
def from_root(path)
        pn = Pathname.new path
        return path if pn.relative?
        root = Pathname.new brb_service.mount_point_block
        pn.relative_path_from(root).to_path
end
module_here(name) click to toggle source
# File lib/quick.rb, line 46
def module_here(name)
        const_defined? name
        brb_service.new_mod_block pwd_from_root, name
rescue NameError
        raise "invalid module name"
end
pry_here(instance=true) click to toggle source
# File lib/quick.rb, line 33
def pry_here(instance=true)
        brb_service.pry_at_block pwd_from_root, instance
end
pwd_from_root() click to toggle source
# File lib/quick.rb, line 60
def pwd_from_root
        from_root Dir.pwd
end
run(dir) click to toggle source
# File lib/quick.rb, line 24
def run(dir)
        Quick::Service.run dir
end
stop() click to toggle source
# File lib/quick.rb, line 28
def stop
        brb_service.stop
        sleep 1
end