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.1'

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



46
47
48
49
50
# File 'lib/quick.rb', line 46

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



37
38
39
# File 'lib/quick.rb', line 37

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

#from_root(path) ⇒ Object



56
57
58
59
60
61
# File 'lib/quick.rb', line 56

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



41
42
43
44
# File 'lib/quick.rb', line 41

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



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



52
53
54
# File 'lib/quick.rb', line 52

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