diff --git a/bin/couchapp b/bin/couchapp index d25a31a..d4e9bce 100755 --- a/bin/couchapp +++ b/bin/couchapp @@ -30,11 +30,14 @@ when /generate/ when /push/ dirname = ARGV.shift + current = Dir.getwd + dir = File.expand_path(File.join(current, dirname)) + dirapp = File.split(dir).last if ARGV.length == 2 appname = ARGV.shift dbstring = ARGV.shift elsif ARGV.length == 1 - appname = dirname + appname = dirapp dbstring = ARGV.shift else puts opts @@ -43,7 +46,7 @@ when /push/ end dbspec = CouchRest.parse(dbstring) fm = CouchRest::FileManager.new(dbspec[:database], dbspec[:host]) - fm.push_app(dirname, appname) + fm.push_app(dir, appname) when /pull/ else diff --git a/lib/couchrest/helper/templates/example-reduce.js b/lib/couchrest/helper/templates/example-reduce.js index 23f61c5..23eea60 100644 --- a/lib/couchrest/helper/templates/example-reduce.js +++ b/lib/couchrest/helper/templates/example-reduce.js @@ -1,7 +1,7 @@ // example reduce function to count the // number of rows in a given key range. -function(keys, value, rereduce) { +function(keys, values, rereduce) { if (rereduce) { return sum(values); } else { diff --git a/lib/couchrest/helper/templates/index.html b/lib/couchrest/helper/templates/index.html index 5e48e98..8b3c2b7 100644 --- a/lib/couchrest/helper/templates/index.html +++ b/lib/couchrest/helper/templates/index.html @@ -16,7 +16,7 @@ var dbname = document.location.href.split('/')[3]; var design = unescape(document.location.href.split('/')[4]).split('/')[1]; var DB = $.couch.db(dbname); - DB.view(design+"/example-map",{success: function(json) { + DB.view(design+"/example",{success: function(json) { $("#view").html(json.rows.map(function(row) { return '
  • '+row.key+'
  • '; }).join('')); diff --git a/spec/couchapp_spec.rb b/spec/couchapp_spec.rb index e81b2b9..aa3e0e7 100644 --- a/spec/couchapp_spec.rb +++ b/spec/couchapp_spec.rb @@ -50,6 +50,20 @@ describe "couchapp" do doc['_attachments']['index.html']["content_type"].should == 'text/html' end end + + describe "push . #{TESTDB}" do + before(:all) do + @cr = CouchRest.new(COUCHHOST) + @db = @cr.database(TESTDB) + @db.delete! rescue nil + @db = @cr.create_db(TESTDB) rescue nil + `#{@run} generate my-app` + end + it "should create the design document" do + `cd #{@fixdir}/my-app && #{@couchapp} push . #{TESTDB}` + lambda{@db.get("_design/my-app")}.should_not raise_error + end + end describe "push my-app my-design #{TESTDB}" do before(:all) do