Module: Spade

Defined in:
lib/spade/core.rb,
lib/spade/core/version.rb

Defined Under Namespace

Modules: Core

Constant Summary collapse

JSPATH =
File.expand_path("../js/spade.js", __FILE__)
SPADE_DIR =
'.spade'

Class Method Summary collapse

Class Method Details

.current_contextObject

The next 5 methods should maybe be in Runtime



21
22
23
# File 'lib/spade/core.rb', line 21

def self.current_context
  @current_context
end

.current_context=(ctx) ⇒ Object



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

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



9
10
11
12
13
14
15
16
17
# File 'lib/spade/core.rb', line 9

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



33
34
35
36
37
# File 'lib/spade/core.rb', line 33

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

.exports=(klass) ⇒ Object



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

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

.exports_for(path) ⇒ Object



39
40
41
42
43
44
45
46
# File 'lib/spade/core.rb', line 39

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

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