Permalink
Browse files

Whitespace cleanup

  • Loading branch information...
1 parent eb84d42 commit 6d1d2cc8ba368ea4e5b285206a22f60dfb0a365e @quirkey committed Oct 2, 2011
Showing with 64 additions and 64 deletions.
  1. +0 −1 Gemfile
  2. +14 −15 Gemfile.lock
  3. +22 −19 lib/soca/plugins/macro.rb
  4. +28 −29 test/test_macro_plugin.rb
View
@@ -12,7 +12,6 @@ gem 'coffee-script', '~> 2.1.2'
group :development do
gem 'rake'
gem 'jeweler'
- gem "yard", ">= 0"
end
group :test do
gem "shoulda", ">= 0"
View
@@ -4,18 +4,18 @@ GEM
archive-tar-minitar (0.5.2)
coffee-script (2.1.3)
coffee-script-source
- coffee-script-source (1.0.1)
+ coffee-script-source (1.1.2)
compass (0.10.6)
haml (>= 3.0.4)
downlow (0.1.4)
archive-tar-minitar (>= 0.5.2)
rubyzip (>= 0.9.4)
fakeweb (1.3.0)
- fssm (0.2.5)
+ fssm (0.2.7)
git (1.2.5)
- haml (3.0.25)
- jeweler (1.5.2)
- bundler (~> 1.0.0)
+ haml (3.1.3)
+ jeweler (1.6.4)
+ bundler (~> 1.0)
git (>= 1.2.5)
rake
jim (0.3.1)
@@ -38,25 +38,25 @@ GEM
yajl-ruby
yajl-ruby
json (1.4.6)
- leftright (0.9.0)
+ leftright (0.9.1)
+ metaclass (0.0.1)
mime-types (1.16)
- mocha (0.9.10)
- rake
+ mocha (0.10.0)
+ metaclass (~> 0.0.1)
mustache (0.11.2)
- rack (1.2.1)
- rack-test (0.5.7)
+ rack (1.3.3)
+ rack-test (0.6.1)
rack (>= 1.0)
- rake (0.8.7)
+ rake (0.9.2)
rubyzip (0.9.4)
shoulda (2.11.3)
- test-unit (2.1.2)
+ test-unit (2.4.0)
thor (0.14.6)
typhoeus (0.2.4)
mime-types
mime-types
version_sorter (1.1.0)
- yajl-ruby (0.8.0)
- yard (0.6.4)
+ yajl-ruby (1.0.0)
PLATFORMS
ruby
@@ -73,4 +73,3 @@ DEPENDENCIES
shoulda
thor (~> 0.14.0)
typhoeus (~> 0.2.4)
- yard
View
@@ -1,25 +1,28 @@
-# see http://tinyurl.com/6ab5svl views in coucdb < 1.1.x does not allow require of modules therfor we need to use macors
+# see http://tinyurl.com/6ab5svl views in coucdb < 1.1.x
+# does not allow you to require modules so we can use couchapp
+# style macros instead
module Soca
- module Plugins
- class Macro < Soca::Plugin
+ module Plugins
+ class Macro < Soca::Plugin
- name 'macro'
+ name 'macro'
- def run(options = {})
- @pusher.document['views'].each do |view,code|
- ['map','reduce'].each{|part| macro_expand_on(part,code) if code[part]}
- end
- end
-
- def macro_expand_on(part,code)
- code[part] = code[part].split("\n").inject(" ") do |res,line|
- if line =~ /\/\/ !code (.*)/
- res += "\n#{File.read($1)}\n"
- else
- res += "#{line}\n"
- end
- end.strip
- end
+ def run(options = {})
+ @pusher.document['views'].each do |view,code|
+ ['map','reduce'].each{|part| macro_expand_on(part,code) if code[part]}
end
+ end
+
+ def macro_expand_on(part,code)
+ code[part] = code[part].split("\n").inject(" ") do |res,line|
+ if line =~ /\/\/ !code (.*)/
+ res += "\n#{File.read($1)}\n"
+ else
+ res += "#{line}\n"
+ end
+ end.strip
+ end
+
end
+ end
end
View
@@ -2,38 +2,37 @@
class TestSocaPusher < Test::Unit::TestCase
- context "macro plugin" do
- setup do
- @pusher = Soca::Pusher.new(@test_app_dir)
- @sammy = File.read("#{@test_app_dir}/js/vendor/sammy-0.5.4.js")
- @views = "#{@test_app_dir}/db/views/"
- end
-
- should "replace !code macros with file contents" do
- @pusher.push!
- assert @pusher.document['views']['recent'].all?{|part| part[1].include?(@sammy)}
- end
-
- should "keep the original code" do
- @pusher.push!
- parts = ['map','reduce'].inject({}){|res,part| res[part] = File.read("#{@views}/recent/#{part}.js").split("\n");res}
- parts.each do |part,lines|
- assert contain_lines(part,lines)
- end
- end
-
- should "be able to process views with map only" do
- @pusher.push!
- lines = File.read("#{@views}/only_map/map.js").split("\n")
- assert contain_lines('map',lines)
-
- end
+ context "macro plugin" do
+ setup do
+ @pusher = Soca::Pusher.new(@test_app_dir)
+ @sammy = File.read("#{@test_app_dir}/js/vendor/sammy-0.5.4.js")
+ @views = "#{@test_app_dir}/db/views/"
end
- def contain_lines(part,lines)
- lines.delete(' // !code js/vendor/sammy-0.5.4.js')
- lines.all? { |line| @pusher.document['views']['recent'][part].include?(line)}
+ should "replace !code macros with file contents" do
+ @pusher.push!
+ assert @pusher.document['views']['recent'].all?{|part| part[1].include?(@sammy)}
end
+ should "keep the original code" do
+ @pusher.push!
+ parts = ['map','reduce'].inject({}){|res,part| res[part] = File.read("#{@views}/recent/#{part}.js").split("\n");res}
+ parts.each do |part,lines|
+ assert contain_lines(part,lines)
+ end
+ end
+
+ should "be able to process views with map only" do
+ @pusher.push!
+ lines = File.read("#{@views}/only_map/map.js").split("\n")
+ assert contain_lines('map',lines)
+
+ end
+ end
+
+ def contain_lines(part,lines)
+ lines.delete(' // !code js/vendor/sammy-0.5.4.js')
+ lines.all? { |line| @pusher.document['views']['recent'][part].include?(line)}
+ end
end

0 comments on commit 6d1d2cc

Please sign in to comment.