Module: Jake

Defined in:
lib/jake.rb,
lib/jake/build.rb,
lib/jake/bundle.rb,
lib/jake/helper.rb,
lib/jake/package.rb,
lib/jake/buildable.rb

Defined Under Namespace

Classes: Build, Buildable, Bundle, Helper, Package

Constant Summary collapse

VERSION =
'1.0.0'
CONFIG_FILE =
'jake.yml'
HELPER_FILE =
'Jakefile'
EXTENSION =
'.js'

Class Method Summary collapse

Class Method Details

.build!(path, options = {}) ⇒ Object

Runs a build in the given directory. The directory must contain a jake.yml file, and may contain a Jakefile. See README for example YAML configurations.



23
24
25
26
# File 'lib/jake.rb', line 23

def self.build!(path, options = {})
  build = Build.new(path, options)
  build.run!
end

.clear_hooks!Object

Removes all registered build event hooks.



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

def self.clear_hooks!
  Build.delete_observers
end

.erb(template) ⇒ Object

Returns either an Erubis or ERB instance, depending on what’s available.



52
53
54
# File 'lib/jake.rb', line 52

def self.erb(template)
  defined?(Erubis) ? Erubis::Eruby.new(template) : ERB.new(template)
end

.read(path) ⇒ Object

Returns the contents of the given path, which may be missing a .js extension.



34
35
36
37
38
39
40
# File 'lib/jake.rb', line 34

def self.read(path)
  path = File.expand_path(path)
  [path, "#{path}#{EXTENSION}"].each do |p|
    return File.read(p).strip if File.file?(p)
  end
  return nil
end

.symbolize_hash(hash, deep = true) ⇒ Object

Returns a copy of the given hash with the keys cast to symbols.



43
44
45
46
47
48
49
# File 'lib/jake.rb', line 43

def self.symbolize_hash(hash, deep = true)
  hash.inject({}) do |output, (key, value)|
    value = Jake.symbolize_hash(value) if deep and value.is_a?(Hash)
    output[(key.to_sym rescue key) || key] = value
    output
  end
end