Permalink
Browse files

macro works

  • Loading branch information...
1 parent 40144b4 commit 9904164dbd5c38e02a9d54cad2fa66008ae7e90f narkisr committed with quirkey Jan 31, 2011
Showing with 18 additions and 9 deletions.
  1. +1 −0 lib/soca.rb
  2. +10 −4 lib/soca/plugins/macro.rb
  3. +7 −5 test/test_plugins.rb
View
1 lib/soca.rb
@@ -1,3 +1,4 @@
+require 'rubygems'
require 'json'
require 'typhoeus'
require 'base64'
View
14 lib/soca/plugins/macro.rb
@@ -7,10 +7,16 @@ class Macro < Soca::Plugin
name 'macro'
def run(options = {})
- @pusher.document['views'].each do |view,code|
- puts code
- end
+ @pusher.document['views'].each do |view,code|
+ code['map'] = code['map'].split("\n").inject(" ") do |res,line|
+ if line =~ /\/\/ !code (.*)/
+ res+=File.read($1)
+ else
+ res += line
+ end
+ end
+ end
end
+ end
end
- end
end
View
12 test/test_plugins.rb
@@ -4,13 +4,15 @@ class TestSocaPusher < Test::Unit::TestCase
context "macro plugin" do
setup do
- @push = Soca::Pusher.new(@test_app_dir)
+ @pusher = Soca::Pusher.new(@test_app_dir)
end
-
- should "sanity" do
- @push.push!
+
+ should "replace !code macros with file contents" do
+ @pusher.push!
+ sammy = File.read("#{@test_app_dir}/js/vendor/sammy-0.5.4.js")
+ assert @pusher.document['views']['recent']['map'].include?(sammy)
end
- end
+ end
end

0 comments on commit 9904164

Please sign in to comment.