Sha256: b195213c5fcdbfeaa86b9333345de8f45a324728f76d6d647395266a77e4317a
Contents?: true
Size: 1.34 KB
Versions: 4
Compression:
Stored size: 1.34 KB
Contents
require 'coffee-script' module Soca module Plugins class CoffeeScript < Soca::Plugin name 'coffeescript' # Run the coffeescript plugin. # Available options: # # * :files - Run these files through CoffeeScript. Can be an array of patterns # or a single file. The default is '*.coffee'. # * :vars - Additional variables to interpolate. By default the `env` and # `config` are interpolated. # def before_build file_patterns = options[:files] || '**/*.coffee' files = Dir[*[file_patterns].flatten] vars = { :env => pusher.env, :config => pusher.config }.merge(options[:vars] || {}) Soca.logger.debug "CoffeeScript vars: #{vars.inspect}" files.each do |file| Soca.logger.debug "Running #{file} through CoffeeScript." basename = File.basename(file) dir = File.dirname(file) parts = basename.split(/\./) new_file = (parts.length > 2 ? parts[0..-2].join('.') : parts[0]) + ".js" output_dir = options[:output_dir] || dir File.open(File.join(output_dir, new_file), 'w') do |f| f << ::CoffeeScript.compile(File.read(file), vars) end Soca.logger.debug "Wrote to #{new_file}" end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
soca-0.3.3 | lib/soca/plugins/coffeescript.rb |
soca-0.3.2 | lib/soca/plugins/coffeescript.rb |
soca-0.3.1 | lib/soca/plugins/coffeescript.rb |
soca-0.3.0 | lib/soca/plugins/coffeescript.rb |