Module: Spade

Defined in:
lib/spade/shell.rb,
lib/spade.rb,
lib/spade/cli.rb,
lib/spade/bundle.rb,
lib/spade/loader.rb,
lib/spade/server.rb,
lib/spade/console.rb,
lib/spade/context.rb,
lib/spade/exports.rb,
lib/spade/reactor.rb,
lib/spade/version.rb,
lib/spade/cli/base.rb,
lib/spade/evaluator.rb,
lib/spade/package/spec/support/core_test.rb

Overview

Project: Spade - CommonJS Runtime Copyright: ©2010 Strobe Inc. All rights reserved. License: Licened under MIT license (see LICENSE)

Defined Under Namespace

Modules: Bundle, CLI, Namespace, Server Classes: Console, Context, Evaluator, Exports, Loader, MainContext, Reactor, Shell

Constant Summary collapse

SPADE_DIR =
'.spade'
VERSION =
'0.1.1.1'

Class Method Summary collapse

Class Method Details

.boot_pathObject



30
31
32
# File 'lib/spade.rb', line 30

def self.boot_path
  File.dirname(Spade.jspath)
end

.current_contextObject



45
46
47
# File 'lib/spade.rb', line 45

def self.current_context
  @current_context
end

.current_context=(ctx) ⇒ Object



49
50
51
# File 'lib/spade.rb', line 49

def self.current_context=(ctx)
  @current_context = ctx
end

.discover_root(cur_path) ⇒ Object

find the current path with a package.json or .packages or cur_path



35
36
37
38
39
40
41
42
43
# File 'lib/spade.rb', line 35

def self.discover_root(cur_path)
  ret = File.expand_path(cur_path)
  while ret != '/' && ret != '.'
    return ret if File.exists?(File.join(ret,'package.json')) || File.exists?(File.join(ret,'.spade'))
    ret = File.dirname ret
  end

  return cur_path
end

.exports(klass, path = nil) ⇒ Object



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

def self.exports(klass, path = nil)
  path = @current_path if path.nil?
  @exports ||= {}
  @exports[path] = klass
end

.exports=(klass) ⇒ Object



53
54
55
# File 'lib/spade.rb', line 53

def self.exports=(klass)
  exports(klass, nil)
end

.exports_for(path) ⇒ Object



63
64
65
66
67
68
69
70
# File 'lib/spade.rb', line 63

def self.exports_for(path)
  @current_path = path
  require path
  @current_path = nil

  @exports ||= {}
  @exports[path]
end

.jspathObject



26
27
28
# File 'lib/spade.rb', line 26

def self.jspath
  File.expand_path("../spade/package/lib/spade.js", __FILE__)
end