Sha256: ede7940e3de80e077d7dd0ad56ad268d185177c5792a7d3b2834c1df20850fea
Contents?: true
Size: 915 Bytes
Versions: 5
Compression:
Stored size: 915 Bytes
Contents
class CouchViewGenerator < Rails::Generator::Base def manifest record do |m| db_name = args.shift full_view_name = args.shift design_doc = full_view_name.index('/') ? full_view_name.split('/').first : nil view_name = full_view_name.split('/').last # should only contain map, reduce, or be empty (only map) bad_option = false if args.empty? args << 'map' else args.each do |arg| if arg != 'map' && arg != 'reduce' puts "Invalid option '#{arg}': expecting 'map' and/or 'reduce'" bad_option = true end end next if bad_option end dir = File.join(['couchdb', 'views', db_name, design_doc].compact) m.directory(dir) args.each do |method| m.file("#{method}.js", File.join(dir, "#{view_name}-#{method}.js"), :collision => :ask) end end end end
Version data entries
5 entries across 5 versions & 1 rubygems