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.1'
- CONFIG_FILE =
'jake.yml'
- HELPER_FILE =
'Jakefile'
- EXTENSION =
'.js'
Class Method Summary collapse
-
.build!(path, options = {}) ⇒ Object
Runs a build in the given directory.
-
.clear_hooks! ⇒ Object
Removes all registered build event hooks.
-
.erb(template) ⇒ Object
Returns either an Erubis or ERB instance, depending on what’s available.
-
.path(*parts) ⇒ Object
Returns a path made by joining the given pieces and removing unnecessary /.
-
.read(path) ⇒ Object
Returns the contents of the given path, which may be missing a .js extension.
-
.symbolize_hash(hash, deep = true) ⇒ Object
Returns a copy of the given hash with the keys cast to symbols.
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, = {}) build = Build.new(path, ) 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.
59 60 61 |
# File 'lib/jake.rb', line 59 def self.erb(template) defined?(Erubis) ? Erubis::Eruby.new(template) : ERB.new(template) end |
.path(*parts) ⇒ Object
Returns a path made by joining the given pieces and removing unnecessary /. sections using expand_path.
35 36 37 38 |
# File 'lib/jake.rb', line 35 def self.path(*parts) parts = parts.compact.map { |p| p.to_s } File.(File.join(*parts)) end |
.read(path) ⇒ Object
Returns the contents of the given path, which may be missing a .js extension.
41 42 43 44 45 46 47 |
# File 'lib/jake.rb', line 41 def self.read(path) path = File.(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.
50 51 52 53 54 55 56 |
# File 'lib/jake.rb', line 50 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 |