Permalink
Browse files

Merge branch 'master' of github.com:quirkey/soca

  • Loading branch information...
2 parents 8ee51c5 + 6133bb6 commit 433356cf1d57387e93514290919464fac0df43ae @quirkey committed Nov 15, 2011
Showing with 44 additions and 2 deletions.
  1. +38 −0 lib/soca/plugins/haml.rb
  2. +6 −2 lib/soca/pusher.rb
View
@@ -0,0 +1,38 @@
+require 'haml'
+
+module Soca
+ module Plugins
+ class Haml < Soca::Plugin
+
+ name 'haml'
+
+ def run(options={})
+ @options = options
+
+ Dir[File.join(haml_from, "**/*.haml")].each do |file|
+ Soca.logger.debug "Running #{file} through Haml."
+ basename = File.basename(file, ".haml")
+ dir = File.dirname(file).sub(/^#{haml_from}/,
+ haml_to)
+ new_file = basename + ".html"
+ FileUtils.mkdir_p(dir) unless File.exists?(dir)
+
+ File.open(File.join(dir, new_file), 'w') do |f|
+ f << ::Haml::Engine.new(File.read(file)).render
+ end
+ Soca.logger.debug "Wrote to #{File.join(dir, new_file)}"
+ end
+ end
+
+ private
+ def haml_from
+ @options.has_key?(:from) ? File.join(app_dir, @options[:from]) : File.join(app_dir, 'haml')
+ end
+
+ def haml_to
+ @options.has_key?(:to) ? File.join(app_dir, @options[:to]) : File.join(app_dir, '')
+ end
+
+ end
+ end
+end
View
@@ -45,7 +45,7 @@ def json
end
def db_url
- if env =~ /^http\:\/\// # the env is actual a db_url
+ if env =~ /^https?\:\/\// # the env is actual a db_url
env
else
env_config = config['couchapprc']['env'][env]
@@ -147,7 +147,11 @@ def map_file(path, hash)
while !parts.empty?
part = parts.shift
if parts.empty?
- current_hash[part] = file_data
+ if part =~ /.json$/
+ current_hash[part.gsub(/.json$/, '')] = JSON.parse(file_data)
+ else
+ current_hash[part] = file_data
+ end
else
current_hash[part] ||= {}
current_hash = current_hash[part]

0 comments on commit 433356c

Please sign in to comment.