Module: Blade
- Extended by:
- Blade
- Included in:
- Blade
- Defined in:
- lib/blade.rb,
lib/blade/version.rb
Defined Under Namespace
Modules: Assets, CI, Component, RackRouter, Runner, Server
Classes: CLI, Config, Model, RackAdapter, Session, TestResults
Constant Summary
collapse
- CONFIG_DEFAULTS =
{
framework: :qunit,
port: 9876,
build: { path: "." }
}
- CONFIG_FILENAMES =
%w( blade.yml .blade.yml )
- VERSION =
"0.5.0"
Instance Attribute Summary collapse
Instance Method Summary
collapse
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
40
41
42
|
# File 'lib/blade.rb', line 40
def config
@config
end
|
Instance Method Details
#clean_tmp_path ⇒ Object
102
103
104
105
|
# File 'lib/blade.rb', line 102
def clean_tmp_path
tmp_path.rmtree if tmp_path.exist?
tmp_path.mkpath
end
|
#initialize!(options = {}) ⇒ Object
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
# File 'lib/blade.rb', line 69
def initialize!(options = {})
return if @initialized
@initialized = true
options = CONFIG_DEFAULTS.deep_merge(blade_file_options).deep_merge(options)
@config = Blade::Config.new options
config.load_paths = Array(config.load_paths)
config.logical_paths = Array(config.logical_paths)
if config.build?
config.build.logical_paths = Array(config.build.logical_paths)
config.build.path ||= "."
end
config.plugins ||= {}
load_plugins
load_adapter
end
|
#register_component(component) ⇒ Object
23
24
25
|
# File 'lib/blade.rb', line 23
def register_component(component)
@components << component
end
|
#root_path ⇒ Object
94
95
96
|
# File 'lib/blade.rb', line 94
def root_path
Pathname.new(File.dirname(__FILE__)).join("../")
end
|
#running? ⇒ Boolean
65
66
67
|
# File 'lib/blade.rb', line 65
def running?
@running
end
|
#start(options = {}) ⇒ Object
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/blade.rb', line 42
def start(options = {})
return if running?
clean_tmp_path
initialize!(options)
load_interface
handle_exit
EM.run do
@components.each { |c| c.try(:start) }
@running = true
end
end
|
#stop ⇒ Object
57
58
59
60
61
62
63
|
# File 'lib/blade.rb', line 57
def stop
return if @stopping
@stopping = true
@components.each { |c| c.try(:stop) }
EM.stop if EM.reactor_running?
@running = false
end
|
#tmp_path ⇒ Object
98
99
100
|
# File 'lib/blade.rb', line 98
def tmp_path
Pathname.new(".").join("tmp/blade")
end
|
#url(path = "/") ⇒ Object
90
91
92
|
# File 'lib/blade.rb', line 90
def url(path = "/")
"http://localhost:#{config.port}#{path}"
end
|