Module: Bait
- Extended by:
- Assets
- Defined in:
- lib/bait.rb,
lib/bait/api.rb,
lib/bait/cli.rb,
lib/bait/build.rb,
lib/bait/phase.rb,
lib/bait/assets.rb,
lib/bait/object.rb,
lib/bait/pubsub.rb,
lib/bait/tester.rb,
lib/bait/version.rb,
lib/bait/build_helper.rb,
lib/bait/simple_query.rb,
lib/bait/simplecov_support.rb
Defined Under Namespace
Modules: Assets, BuildHelper, CLI, SimpleCovSupport, SimpleQuery
Classes: Api, Build, Object, Phase, Tester
Constant Summary
collapse
- VERSION =
File.open(File.join(File.dirname(__FILE__), "..", "..", "VERSION")){|f| f.read.strip}
- @@Subscribers =
[]
Class Method Summary
collapse
Methods included from Assets
assets
Class Method Details
.add_subscriber(stream) ⇒ Object
6
7
8
|
# File 'lib/bait/pubsub.rb', line 6
def add_subscriber stream
@@Subscribers << stream
end
|
.broadcast(*args) ⇒ Object
12
13
14
15
16
|
# File 'lib/bait/pubsub.rb', line 12
def broadcast *args
@@Subscribers.each do |out|
out << "data: #{args.to_json}\n\n"
end
end
|
16
17
18
19
20
|
# File 'lib/bait.rb', line 16
def db_dir
db_dir = File.join storage_dir, "databases"
FileUtils.mkdir_p db_dir
db_dir
end
|
.db_file(name) ⇒ Object
22
23
24
25
26
|
# File 'lib/bait.rb', line 22
def db_file name
yaml_file = File.join db_dir, "#{name}.yaml"
FileUtils.touch yaml_file
yaml_file
end
|
34
35
36
|
# File 'lib/bait.rb', line 34
def env
ENV['RACK_ENV'] ||= 'production'
end
|
38
39
40
|
# File 'lib/bait.rb', line 38
def home
File.join Etc.getpwuid.dir, '.bait'
end
|
42
43
44
|
# File 'lib/bait.rb', line 42
def public
Pathname.new(File.join(File.dirname(__FILE__), 'bait', 'public'))
end
|
.remove_subscriber(stream) ⇒ Object
9
10
11
|
# File 'lib/bait/pubsub.rb', line 9
def remove_subscriber stream
@@Subscribers.delete stream
end
|
.storage_dir ⇒ Object
10
11
12
13
14
|
# File 'lib/bait.rb', line 10
def storage_dir
path = File.join("#{home}", "#{env}")
FileUtils.mkdir_p path
path
end
|
28
29
30
31
32
|
# File 'lib/bait.rb', line 28
def store
@store ||= begin
Moneta.new :YAML, :file => db_file("main")
end
end
|