Sha256: a5e7333eb57ddfd987bfc974fdb2947660f2d0122f9e77aca6693d5b9e977852

Contents?: true

Size: 737 Bytes

Versions: 4

Compression:

Stored size: 737 Bytes

Contents

# 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

      name 'macro'

      def before_push
        @pusher.document['views'].each do |view,code|
          ['map','reduce'].each{|part| macro_expand_on(part,code) if code[part]}
        end
      end

      private
      def macro_expand_on(part,code)
       code[part] = code[part].split("\n").inject(" ") do |res,line|
          if line =~ /\/\/ !code (.*)/
           res += "\n#{File.read(File.join(pusher.app_dir, $1))}\n"
          else
           res += "#{line}\n"
          end
        end.strip
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
soca-0.3.3 lib/soca/plugins/macro.rb
soca-0.3.2 lib/soca/plugins/macro.rb
soca-0.3.1 lib/soca/plugins/macro.rb
soca-0.3.0 lib/soca/plugins/macro.rb