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

Instance Method Summary collapse

Instance Method Details

#brb_serviceObject



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/quick.rb', line 8

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



44
45
46
47
48
# File 'lib/quick.rb', line 44

def class_here(name, super_path='Object')
	raise "invalid class name" unless ('A'..'Z').include? name[0]
	p [pwd_from_root, name, from_root(super_path)]
	brb_service.new_mod_block pwd_from_root, name, from_root(super_path)
end

#eval_here(code, instance = true) ⇒ Object



35
36
37
# File 'lib/quick.rb', line 35

def eval_here(code, instance=true)
	brb_service.eval_block pwd_from_root, code, instance
end

#from_root(path) ⇒ Object



54
55
56
57
58
59
# File 'lib/quick.rb', line 54

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



39
40
41
42
# File 'lib/quick.rb', line 39

def module_here(name)
	raise "invalid module name" unless ('A'..'Z').include? name[0]
	brb_service.new_mod_block pwd_from_root, name
end

#pry_here(instance = true) ⇒ Object



31
32
33
# File 'lib/quick.rb', line 31

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

#pwd_from_rootObject



50
51
52
# File 'lib/quick.rb', line 50

def pwd_from_root
	from_root Dir.pwd
end

#run(dir) ⇒ Object



22
23
24
# File 'lib/quick.rb', line 22

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

#stopObject



26
27
28
29
# File 'lib/quick.rb', line 26

def stop
	brb_service.stop
	sleep 1
end