From c435aa09322b0746b2cc453779673ab2561847f5 Mon Sep 17 00:00:00 2001 From: Chris Anderson Date: Thu, 1 Jan 2009 22:54:41 -0800 Subject: [PATCH] remove couchview --- Rakefile | 3 +- bin/couchview | 48 ------------ couchrest.gemspec | 25 ++++-- lib/couchrest/helper/file_manager.rb | 110 --------------------------- 4 files changed, 18 insertions(+), 168 deletions(-) delete mode 100755 bin/couchview diff --git a/Rakefile b/Rakefile index 6195eee..0df1425 100644 --- a/Rakefile +++ b/Rakefile @@ -5,7 +5,7 @@ require 'rake/gempackagetask' spec = Gem::Specification.new do |s| s.name = "couchrest" - s.version = "0.10.1" + s.version = "0.11.1" s.date = "2008-11-22" s.summary = "Lean and RESTful interface to CouchDB." s.email = "jchris@grabb.it" @@ -19,7 +19,6 @@ spec = Gem::Specification.new do |s| s.extra_rdoc_files = %w( README.rdoc LICENSE THANKS ) s.require_path = "lib" s.bindir = 'bin' - s.executables << 'couchview' s.executables << 'couchdir' s.executables << 'couchapp' s.add_dependency("json", ">= 1.1.2") diff --git a/bin/couchview b/bin/couchview deleted file mode 100755 index c87a741..0000000 --- a/bin/couchview +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env ruby - -require 'optparse' -require 'couchrest' - -%w(generate push).each do |file| - require File.dirname(__FILE__) + "/../lib/couchrest/commands/#{file}" -end - -# Set defaults -options = { - :loud => true, -} - -opts = OptionParser.new do |opts| - opts.banner = "Usage: #$0 [options] (push|generate) directory database" - opts.on('-q', '--quiet', "Omit extra debug info") do - options[:loud] = false - end - opts.on_tail('-h', '--help [push|generate]', "Display detailed help and exit") do |help_command| - puts opts - case help_command - when "push" - puts CouchRest::Commands::Push.help - when "generate" - puts CouchRest::Commands::Generate.help - end - exit - end -end -opts.parse!(ARGV) - -options[:command] = ARGV.shift -options[:directory] = ARGV.shift -options[:trailing_args] = ARGV - -# There must be a better way to check for extra required args -unless (["push", "generate"].include?(options[:command]) && options[:directory] && options[:trailing_args]) - puts(opts) - exit -end - -case options[:command] -when "push" - CouchRest::Commands::Push.run(options) -when "generate" - CouchRest::Commands::Generate.run(options) -end diff --git a/couchrest.gemspec b/couchrest.gemspec index 9a66fb6..b3da1c9 100644 --- a/couchrest.gemspec +++ b/couchrest.gemspec @@ -1,17 +1,16 @@ Gem::Specification.new do |s| s.extra_rdoc_files = ["README.rdoc", "LICENSE", "THANKS"] s.date = "Sat Nov 22 00:00:00 -0800 2008" - s.executables = ["couchview", "couchdir", "couchapp"] + s.executables = ["couchdir", "couchapp"] s.authors = ["J. Chris Anderson"] s.required_rubygems_version = ">= 0" - s.version = "0.10.1" + s.version = "0.11.1" s.files = ["LICENSE", "README.rdoc", "Rakefile", "THANKS", "bin/couchapp", "bin/couchdir", - "bin/couchview", "examples/model", "examples/model/example.rb", "examples/word_count", @@ -43,11 +42,21 @@ Gem::Specification.new do |s| "lib/couchrest/helper/file_manager.rb", "lib/couchrest/helper/pager.rb", "lib/couchrest/helper/streamer.rb", - "lib/couchrest/helper/templates", - "lib/couchrest/helper/templates/bar.txt", - "lib/couchrest/helper/templates/example-map.js", - "lib/couchrest/helper/templates/example-reduce.js", - "lib/couchrest/helper/templates/index.html", + "lib/couchrest/helper/template-app", + "lib/couchrest/helper/template-app/_attachments", + "lib/couchrest/helper/template-app/_attachments/index.html", + "lib/couchrest/helper/template-app/foo", + "lib/couchrest/helper/template-app/foo/bar.txt", + "lib/couchrest/helper/template-app/forms", + "lib/couchrest/helper/template-app/forms/example-form.js", + "lib/couchrest/helper/template-app/forms/lib", + "lib/couchrest/helper/template-app/forms/lib/example-template.html", + "lib/couchrest/helper/template-app/views", + "lib/couchrest/helper/template-app/views/_lib", + "lib/couchrest/helper/template-app/views/_lib/helper.js", + "lib/couchrest/helper/template-app/views/example", + "lib/couchrest/helper/template-app/views/example/map.js", + "lib/couchrest/helper/template-app/views/example/reduce.js", "lib/couchrest/monkeypatches.rb", "lib/couchrest.rb", "spec/couchapp_spec.rb", diff --git a/lib/couchrest/helper/file_manager.rb b/lib/couchrest/helper/file_manager.rb index 49bf41f..0f62aa6 100644 --- a/lib/couchrest/helper/file_manager.rb +++ b/lib/couchrest/helper/file_manager.rb @@ -116,91 +116,6 @@ module CouchRest end end - # deprecated - def push_views(view_dir) - puts "WARNING this is deprecated, use `couchapp` script" - designs = {} - - Dir["#{view_dir}/**/*.*"].each do |design_doc| - design_doc_parts = design_doc.split('/') - next if /^lib\..*$/.match design_doc_parts.last - pre_normalized_view_name = design_doc_parts.last.split("-") - view_name = pre_normalized_view_name[0..pre_normalized_view_name.length-2].join("-") - - folder = design_doc_parts[-2] - - designs[folder] ||= {} - designs[folder]["views"] ||= {} - design_lang = design_doc_parts.last.split(".").last - designs[folder]["language"] ||= LANGS[design_lang] - - libs = "" - Dir["#{view_dir}/lib.#{design_lang}"].collect do |global_lib| - libs << open(global_lib).read - libs << "\n" - end - Dir["#{view_dir}/#{folder}/lib.#{design_lang}"].collect do |global_lib| - libs << open(global_lib).read - libs << "\n" - end - if design_doc_parts.last =~ /-map/ - designs[folder]["views"][view_name] ||= {} - designs[folder]["views"][view_name]["map"] = read(design_doc, libs) - end - - if design_doc_parts.last =~ /-reduce/ - designs[folder]["views"][view_name] ||= {} - designs[folder]["views"][view_name]["reduce"] = read(design_doc, libs) - end - end - - # cleanup empty maps and reduces - designs.each do |name, props| - props["views"].each do |view, funcs| - next unless view.include?("reduce") - props["views"].delete(view) unless funcs.keys.include?("reduce") - end - end - - designs.each do |k,v| - create_or_update("_design/#{k}", v) - end - - designs - end - - def pull_views(view_dir) - prefix = "_design" - ds = db.documents(:startkey => '#{prefix}/', :endkey => '#{prefix}/ZZZZZZZZZ') - ds['rows'].collect{|r|r['id']}.each do |id| - puts directory = id.split('/').last - FileUtils.mkdir_p(File.join(view_dir,directory)) - views = db.get(id)['views'] - - vgroups = views.keys.group_by{|k|k.sub(/\-(map|reduce)$/,'')} - vgroups.each do|g,vs| - mapname = vs.find {|v|views[v]["map"]} - if mapname - # save map - mapfunc = views[mapname]["map"] - mapfile = File.join(view_dir, directory, "#{g}-map.js") # todo support non-js views - File.open(mapfile,'w') do |f| - f.write mapfunc - end - end - - reducename = vs.find {|v|views[v]["reduce"]} - if reducename - # save reduce - reducefunc = views[reducename]["reduce"] - reducefile = File.join(view_dir, directory, "#{g}-reduce.js") # todo support non-js views - File.open(reducefile,'w') do |f| - f.write reducefunc - end - end - end - end - end def dir_to_fields(dir) fields = {} @@ -266,30 +181,5 @@ module CouchRest def md5 string Digest::MD5.hexdigest(string) end - - # deprecated - def read(file, libs=nil) - st = open(file).read - st.sub!(/(\/\/|#)include-lib/,libs) if libs - st - end - - def create_or_update(id, fields) - existing = @db.get(id) rescue nil - - if existing - updated = existing.merge(fields) - if existing != updated - say "replacing #{id}" - db.save(updated) - else - say "skipping #{id}" - end - else - say "creating #{id}" - db.save(fields.merge({"_id" => id})) - end - - end end end