Permalink
Browse files

added coffeescript

  • Loading branch information...
1 parent 925472b commit 3706590fb7df191bc48614038d29a326cd396ad4 Richard Metzler committed with quirkey Oct 30, 2010
Showing with 50 additions and 1 deletion.
  1. +1 −0 Rakefile
  2. +43 −0 lib/soca/plugins/coffeescript.rb
  3. +1 −0 lib/soca/templates/hooks/before_build.rb
  4. +5 −1 soca.gemspec
View
@@ -18,6 +18,7 @@ begin
gem.add_dependency 'jim', '~>0.2.3'
gem.add_dependency 'compass', '~>0.10.5'
gem.add_dependency 'mustache', '~>0.11.2'
+ gem.add_dependency 'coffee-script', '~> 1.1.0'
gem.add_development_dependency "shoulda", ">= 0"
gem.add_development_dependency "yard", ">= 0"
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
@@ -0,0 +1,43 @@
+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 run(options = {})
+ 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('.') : basename[0] + ".js"
+
+ File.open(File.join(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
@@ -1,2 +1,3 @@
# any pre build scripting or plugins should go here
+plugin 'coffeescript'
plugin 'jim'
View
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Aaron Quint"]
- s.date = %q{2010-10-29}
+ s.date = %q{2010-10-30}
s.default_executable = %q{soca}
s.description = %q{soca is a different way of writing apps for CouchDB. The structure is up to you.}
s.email = %q{aaron@quirkey.com}
@@ -29,6 +29,7 @@ Gem::Specification.new do |s|
"lib/soca.rb",
"lib/soca/cli.rb",
"lib/soca/plugin.rb",
+ "lib/soca/plugins/coffeescript.rb",
"lib/soca/plugins/compass.rb",
"lib/soca/plugins/jim.rb",
"lib/soca/plugins/mustache.rb",
@@ -91,6 +92,7 @@ Gem::Specification.new do |s|
s.add_runtime_dependency(%q<jim>, ["~> 0.2.3"])
s.add_runtime_dependency(%q<compass>, ["~> 0.10.5"])
s.add_runtime_dependency(%q<mustache>, ["~> 0.11.2"])
+ s.add_runtime_dependency(%q<coffee-script>, ["~> 1.1.0"])
s.add_development_dependency(%q<shoulda>, [">= 0"])
s.add_development_dependency(%q<yard>, [">= 0"])
else
@@ -101,6 +103,7 @@ Gem::Specification.new do |s|
s.add_dependency(%q<jim>, ["~> 0.2.3"])
s.add_dependency(%q<compass>, ["~> 0.10.5"])
s.add_dependency(%q<mustache>, ["~> 0.11.2"])
+ s.add_dependency(%q<coffee-script>, ["~> 1.1.0"])
s.add_dependency(%q<shoulda>, [">= 0"])
s.add_dependency(%q<yard>, [">= 0"])
end
@@ -112,6 +115,7 @@ Gem::Specification.new do |s|
s.add_dependency(%q<jim>, ["~> 0.2.3"])
s.add_dependency(%q<compass>, ["~> 0.10.5"])
s.add_dependency(%q<mustache>, ["~> 0.11.2"])
+ s.add_dependency(%q<coffee-script>, ["~> 1.1.0"])
s.add_dependency(%q<shoulda>, [">= 0"])
s.add_dependency(%q<yard>, [">= 0"])
end

0 comments on commit 3706590

Please sign in to comment.