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/version.rb,
lib/bait/integrator.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, Integrator, Object, Phase
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
|
17
18
19
20
21
|
# File 'lib/bait.rb', line 17
def db_dir
db_dir = File.join storage_dir, "databases"
FileUtils.mkdir_p db_dir
db_dir
end
|
.db_file(name) ⇒ Object
23
24
25
26
27
|
# File 'lib/bait.rb', line 23
def db_file name
yaml_file = File.join db_dir, "#{name}.yaml"
FileUtils.touch yaml_file
yaml_file
end
|
35
36
37
|
# File 'lib/bait.rb', line 35
def env
ENV['RACK_ENV'] ||= 'production'
end
|
39
40
41
|
# File 'lib/bait.rb', line 39
def home
File.join Etc.getpwuid.dir, '.bait'
end
|
43
44
45
|
# File 'lib/bait.rb', line 43
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
11
12
13
14
15
|
# File 'lib/bait.rb', line 11
def storage_dir
path = File.join("#{home}", "#{env}")
FileUtils.mkdir_p path
path
end
|
29
30
31
32
33
|
# File 'lib/bait.rb', line 29
def store
@store ||= begin
Moneta.new :YAML, :file => db_file("main")
end
end
|