Module: Blade

Extended by:
Blade, Forwardable
Included in:
Blade
Defined in:
lib/blade.rb,
lib/blade/version.rb

Defined Under Namespace

Modules: Assets, CI, Component, Runner, Server Classes: CLI, CombinedTestResults, Model, RackAdapter, Session, TestCase, TestResults

Constant Summary collapse

DEFAULT_FRAMEWORK =
:qunit
DEFAULT_PORT =
9876
VERSION =
"0.3.2"

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



36
37
38
# File 'lib/blade.rb', line 36

def config
  @config
end

#pluginsObject (readonly)

Returns the value of attribute plugins.



36
37
38
# File 'lib/blade.rb', line 36

def plugins
  @plugins
end

Instance Method Details

#clean_tmp_pathObject



86
87
88
89
# File 'lib/blade.rb', line 86

def clean_tmp_path
  tmp_path.rmtree if tmp_path.exist?
  tmp_path.mkpath
end

#initialize!(options = {}) ⇒ Object



65
66
67
68
69
70
71
72
# File 'lib/blade.rb', line 65

def initialize!(options = {})
  @options ||= {}.with_indifferent_access
  @options.merge! options

  setup_config!
  load_plugins!
  load_adapter!
end

#register_component(component) ⇒ Object



16
17
18
# File 'lib/blade.rb', line 16

def register_component(component)
  @components << component
end

#root_pathObject



78
79
80
# File 'lib/blade.rb', line 78

def root_path
  Pathname.new(File.dirname(__FILE__)).join("../")
end

#running?Boolean

Returns:



61
62
63
# File 'lib/blade.rb', line 61

def running?
  @running
end

#start(options = {}) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/blade.rb', line 38

def start(options = {})
  return if running?
  clean_tmp_path

  initialize!(options)
  load_interface!

  handle_exit

  EM.run do
    @components.each { |c| c.start if c.respond_to?(:start) }
    @running = true
  end
end

#stopObject



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

def stop
  return if @stopping
  @stopping = true
  @components.each { |c| c.stop if c.respond_to?(:stop) }
  EM.stop if EM.reactor_running?
  @running = false
end

#tmp_pathObject



82
83
84
# File 'lib/blade.rb', line 82

def tmp_path
  Pathname.new(".").join("tmp/blade")
end

#url(path = "") ⇒ Object



74
75
76
# File 'lib/blade.rb', line 74

def url(path = "")
  "http://localhost:#{config.port}#{path}"
end