Module: Quick

Extended by:
Quick
Included in:
Quick
Defined in:
lib/quick.rb,
lib/quick/fs.rb,
lib/quick/service.rb

Defined Under Namespace

Modules: FS, Service

Constant Summary collapse

VERSION =
'0.2.2'

Instance Method Summary collapse

Instance Method Details

#brb_serviceObject



10
11
12
13
14
15
16
17
18
19
20
21
22
# 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') ⇒ Object



53
54
55
56
57
58
# 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) ⇒ Object



37
38
39
40
41
42
43
44
# 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) ⇒ Object



64
65
66
67
68
69
# 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) ⇒ Object



46
47
48
49
50
51
# 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) ⇒ Object



33
34
35
# File 'lib/quick.rb', line 33

def pry_here(instance=true)
	brb_service.pry_at_block pwd_from_root, instance
end

#pwd_from_rootObject



60
61
62
# File 'lib/quick.rb', line 60

def pwd_from_root
	from_root Dir.pwd
end

#run(dir) ⇒ Object



24
25
26
# File 'lib/quick.rb', line 24

def run(dir)
	Quick::Service.run dir
end

#stopObject



28
29
30
31
# File 'lib/quick.rb', line 28

def stop
	brb_service.stop
	sleep 1
end