s/localhost/127.0.0.1/
This commit is contained in:
parent
12c09085df
commit
7461e3fede
|
@ -31,7 +31,7 @@ CouchRest install, from the project root directory run `rake`, or `autotest`
|
||||||
Quick Start:
|
Quick Start:
|
||||||
|
|
||||||
# with !, it creates the database if it doesn't already exist
|
# with !, it creates the database if it doesn't already exist
|
||||||
@db = CouchRest.database!("http://localhost:5984/couchrest-test")
|
@db = CouchRest.database!("http://127.0.0.1:5984/couchrest-test")
|
||||||
response = @db.save({:key => 'value', 'another key' => 'another value'})
|
response = @db.save({:key => 'value', 'another key' => 'another value'})
|
||||||
doc = @db.get(response['id'])
|
doc = @db.get(response['id'])
|
||||||
puts doc.inspect
|
puts doc.inspect
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
require File.expand_path(File.dirname(__FILE__)) + '/../../couchrest'
|
require File.expand_path(File.dirname(__FILE__)) + '/../../couchrest'
|
||||||
|
|
||||||
cr = CouchRest.new("http://localhost:5984")
|
cr = CouchRest.new("http://127.0.0.1:5984")
|
||||||
@db = cr.database('word-count-example')
|
@db = cr.database('word-count-example')
|
||||||
@word_memoizer = {}
|
@word_memoizer = {}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
require File.dirname(__FILE__) + '/../../couchrest'
|
require File.dirname(__FILE__) + '/../../couchrest'
|
||||||
|
|
||||||
couch = CouchRest.new("http://localhost:5984")
|
couch = CouchRest.new("http://127.0.0.1:5984")
|
||||||
db = couch.database('word-count-example')
|
db = couch.database('word-count-example')
|
||||||
db.delete! rescue nil
|
db.delete! rescue nil
|
||||||
db = couch.create_db('word-count-example')
|
db = couch.create_db('word-count-example')
|
||||||
|
@ -62,6 +62,6 @@ end
|
||||||
# }
|
# }
|
||||||
# })
|
# })
|
||||||
|
|
||||||
# puts "The books have been stored in your CouchDB. To initiate the MapReduce process, visit http://localhost:5984/_utils/ in your browser and click 'word-count-example', then select view 'words' or 'count'. The process could take about 15 minutes on an average MacBook."
|
# puts "The books have been stored in your CouchDB. To initiate the MapReduce process, visit http://127.0.0.1:5984/_utils/ in your browser and click 'word-count-example', then select view 'words' or 'count'. The process could take about 15 minutes on an average MacBook."
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
require File.dirname(__FILE__) + '/../../couchrest'
|
require File.dirname(__FILE__) + '/../../couchrest'
|
||||||
|
|
||||||
couch = CouchRest.new("http://localhost:5984")
|
couch = CouchRest.new("http://127.0.0.1:5984")
|
||||||
db = couch.database('word-count-example')
|
db = couch.database('word-count-example')
|
||||||
|
|
||||||
puts "Now that we've parsed all those books into CouchDB, the queries we can run are incredibly flexible."
|
puts "Now that we've parsed all those books into CouchDB, the queries we can run are incredibly flexible."
|
||||||
|
@ -35,5 +35,5 @@ puts "\nHere are the params for 'flight' in the da-vinci book:"
|
||||||
puts params.inspect
|
puts params.inspect
|
||||||
puts
|
puts
|
||||||
puts 'The url looks like this:'
|
puts 'The url looks like this:'
|
||||||
puts 'http://localhost:5984/word-count-example/_view/word_count/count?key=["flight","da-vinci"]'
|
puts 'http://127.0.0.1:5984/word-count-example/_view/word_count/count?key=["flight","da-vinci"]'
|
||||||
puts "\nTry dropping that in your browser..."
|
puts "\nTry dropping that in your browser..."
|
|
@ -72,7 +72,7 @@ module CouchRest
|
||||||
db = nil if db && db.empty?
|
db = nil if db && db.empty?
|
||||||
|
|
||||||
{
|
{
|
||||||
:host => host || "localhost:5984",
|
:host => host || "127.0.0.1:5984",
|
||||||
:database => db,
|
:database => db,
|
||||||
:doc => docid
|
:doc => docid
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ module CouchRest
|
||||||
foo-project/bar-views/my-design/viewname-reduce.js
|
foo-project/bar-views/my-design/viewname-reduce.js
|
||||||
foo-project/bar-views/my-design/noreduce-map.js
|
foo-project/bar-views/my-design/noreduce-map.js
|
||||||
|
|
||||||
Pushed to => http://localhost:5984/baz-database/_design/my-design
|
Pushed to => http://127.0.0.1:5984/baz-database/_design/my-design
|
||||||
|
|
||||||
And the design document:
|
And the design document:
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,7 +18,7 @@ module CouchRest
|
||||||
# than this example.
|
# than this example.
|
||||||
#
|
#
|
||||||
# class Article < CouchRest::Model
|
# class Article < CouchRest::Model
|
||||||
# use_database CouchRest.database!('http://localhost:5984/couchrest-model-test')
|
# use_database CouchRest.database!('http://127.0.0.1:5984/couchrest-model-test')
|
||||||
# unique_id :slug
|
# unique_id :slug
|
||||||
#
|
#
|
||||||
# view_by :date, :descending => true
|
# view_by :date, :descending => true
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
module CouchRest
|
module CouchRest
|
||||||
class Server
|
class Server
|
||||||
attr_accessor :uri, :uuid_batch_count
|
attr_accessor :uri, :uuid_batch_count
|
||||||
def initialize server = 'http://localhost:5984', uuid_batch_count = 1000
|
def initialize server = 'http://127.0.0.1:5984', uuid_batch_count = 1000
|
||||||
@uri = server
|
@uri = server
|
||||||
@uuid_batch_count = uuid_batch_count
|
@uuid_batch_count = uuid_batch_count
|
||||||
end
|
end
|
||||||
|
|
|
@ -14,7 +14,7 @@ module CouchRest
|
||||||
"css" => "text/css",
|
"css" => "text/css",
|
||||||
"js" => "test/javascript"
|
"js" => "test/javascript"
|
||||||
}
|
}
|
||||||
def initialize(dbname, host="http://localhost:5984")
|
def initialize(dbname, host="http://127.0.0.1:5984")
|
||||||
@db = CouchRest.new(host).database(dbname)
|
@db = CouchRest.new(host).database(dbname)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -46,48 +46,48 @@ describe CouchRest do
|
||||||
it "should parse just a dbname" do
|
it "should parse just a dbname" do
|
||||||
db = CouchRest.parse "my-db"
|
db = CouchRest.parse "my-db"
|
||||||
db[:database].should == "my-db"
|
db[:database].should == "my-db"
|
||||||
db[:host].should == "localhost:5984"
|
db[:host].should == "127.0.0.1:5984"
|
||||||
end
|
end
|
||||||
it "should parse a host and db" do
|
it "should parse a host and db" do
|
||||||
db = CouchRest.parse "localhost/my-db"
|
db = CouchRest.parse "127.0.0.1/my-db"
|
||||||
db[:database].should == "my-db"
|
db[:database].should == "my-db"
|
||||||
db[:host].should == "localhost"
|
db[:host].should == "127.0.0.1"
|
||||||
end
|
end
|
||||||
it "should parse a host and db with http" do
|
it "should parse a host and db with http" do
|
||||||
db = CouchRest.parse "http://localhost/my-db"
|
db = CouchRest.parse "http://127.0.0.1/my-db"
|
||||||
db[:database].should == "my-db"
|
db[:database].should == "my-db"
|
||||||
db[:host].should == "localhost"
|
db[:host].should == "127.0.0.1"
|
||||||
end
|
end
|
||||||
it "should parse a host with a port and db" do
|
it "should parse a host with a port and db" do
|
||||||
db = CouchRest.parse "localhost:5555/my-db"
|
db = CouchRest.parse "127.0.0.1:5555/my-db"
|
||||||
db[:database].should == "my-db"
|
db[:database].should == "my-db"
|
||||||
db[:host].should == "localhost:5555"
|
db[:host].should == "127.0.0.1:5555"
|
||||||
end
|
end
|
||||||
it "should parse a host with a port and db with http" do
|
it "should parse a host with a port and db with http" do
|
||||||
db = CouchRest.parse "http://localhost:5555/my-db"
|
db = CouchRest.parse "http://127.0.0.1:5555/my-db"
|
||||||
db[:database].should == "my-db"
|
db[:database].should == "my-db"
|
||||||
db[:host].should == "localhost:5555"
|
db[:host].should == "127.0.0.1:5555"
|
||||||
end
|
end
|
||||||
it "should parse just a host" do
|
it "should parse just a host" do
|
||||||
db = CouchRest.parse "http://localhost:5555/"
|
db = CouchRest.parse "http://127.0.0.1:5555/"
|
||||||
db[:database].should be_nil
|
db[:database].should be_nil
|
||||||
db[:host].should == "localhost:5555"
|
db[:host].should == "127.0.0.1:5555"
|
||||||
end
|
end
|
||||||
it "should parse just a host no slash" do
|
it "should parse just a host no slash" do
|
||||||
db = CouchRest.parse "http://localhost:5555"
|
db = CouchRest.parse "http://127.0.0.1:5555"
|
||||||
db[:host].should == "localhost:5555"
|
db[:host].should == "127.0.0.1:5555"
|
||||||
db[:database].should be_nil
|
db[:database].should be_nil
|
||||||
end
|
end
|
||||||
it "should get docid" do
|
it "should get docid" do
|
||||||
db = CouchRest.parse "localhost:5555/my-db/my-doc"
|
db = CouchRest.parse "127.0.0.1:5555/my-db/my-doc"
|
||||||
db[:database].should == "my-db"
|
db[:database].should == "my-db"
|
||||||
db[:host].should == "localhost:5555"
|
db[:host].should == "127.0.0.1:5555"
|
||||||
db[:doc].should == "my-doc"
|
db[:doc].should == "my-doc"
|
||||||
end
|
end
|
||||||
it "should get docid with http" do
|
it "should get docid with http" do
|
||||||
db = CouchRest.parse "http://localhost:5555/my-db/my-doc"
|
db = CouchRest.parse "http://127.0.0.1:5555/my-db/my-doc"
|
||||||
db[:database].should == "my-db"
|
db[:database].should == "my-db"
|
||||||
db[:host].should == "localhost:5555"
|
db[:host].should == "127.0.0.1:5555"
|
||||||
db[:doc].should == "my-doc"
|
db[:doc].should == "my-doc"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -137,24 +137,24 @@ describe CouchRest do
|
||||||
|
|
||||||
describe "easy initializing a database adapter" do
|
describe "easy initializing a database adapter" do
|
||||||
it "should be possible without an explicit CouchRest instantiation" do
|
it "should be possible without an explicit CouchRest instantiation" do
|
||||||
db = CouchRest.database "http://localhost:5984/couchrest-test"
|
db = CouchRest.database "http://127.0.0.1:5984/couchrest-test"
|
||||||
db.should be_an_instance_of(CouchRest::Database)
|
db.should be_an_instance_of(CouchRest::Database)
|
||||||
db.host.should == "localhost:5984"
|
db.host.should == "127.0.0.1:5984"
|
||||||
end
|
end
|
||||||
# TODO add https support (need test environment...)
|
# TODO add https support (need test environment...)
|
||||||
# it "should work with https" # do
|
# it "should work with https" # do
|
||||||
# db = CouchRest.database "https://localhost:5984/couchrest-test"
|
# db = CouchRest.database "https://127.0.0.1:5984/couchrest-test"
|
||||||
# db.host.should == "https://localhost:5984"
|
# db.host.should == "https://127.0.0.1:5984"
|
||||||
# end
|
# end
|
||||||
it "should not create the database automatically" do
|
it "should not create the database automatically" do
|
||||||
db = CouchRest.database "http://localhost:5984/couchrest-test"
|
db = CouchRest.database "http://127.0.0.1:5984/couchrest-test"
|
||||||
lambda{db.info}.should raise_error(RestClient::ResourceNotFound)
|
lambda{db.info}.should raise_error(RestClient::ResourceNotFound)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "ensuring the db exists" do
|
describe "ensuring the db exists" do
|
||||||
it "should be super easy" do
|
it "should be super easy" do
|
||||||
db = CouchRest.database! "http://localhost:5984/couchrest-test-2"
|
db = CouchRest.database! "http://127.0.0.1:5984/couchrest-test-2"
|
||||||
db.name.should == 'couchrest-test-2'
|
db.name.should == 'couchrest-test-2'
|
||||||
db.info["db_name"].should == 'couchrest-test-2'
|
db.info["db_name"].should == 'couchrest-test-2'
|
||||||
end
|
end
|
||||||
|
|
|
@ -159,7 +159,7 @@ describe CouchRest::Database do
|
||||||
|
|
||||||
docs = [{'key' => 'value'}, {'_id' => 'totally-uniq'}]
|
docs = [{'key' => 'value'}, {'_id' => 'totally-uniq'}]
|
||||||
id_docs = [{'key' => 'value', '_id' => 'asdf6sgadkfhgsdfusdf'}, {'_id' => 'totally-uniq'}]
|
id_docs = [{'key' => 'value', '_id' => 'asdf6sgadkfhgsdfusdf'}, {'_id' => 'totally-uniq'}]
|
||||||
CouchRest.should_receive(:post).with("http://localhost:5984/couchrest-test/_bulk_docs", {:docs => id_docs})
|
CouchRest.should_receive(:post).with("http://127.0.0.1:5984/couchrest-test/_bulk_docs", {:docs => id_docs})
|
||||||
|
|
||||||
@db.bulk_save(docs)
|
@db.bulk_save(docs)
|
||||||
end
|
end
|
||||||
|
|
|
@ -45,7 +45,7 @@ class Course < CouchRest::Model
|
||||||
end
|
end
|
||||||
|
|
||||||
class Article < CouchRest::Model
|
class Article < CouchRest::Model
|
||||||
use_database CouchRest.database!('http://localhost:5984/couchrest-model-test')
|
use_database CouchRest.database!('http://127.0.0.1:5984/couchrest-model-test')
|
||||||
unique_id :slug
|
unique_id :slug
|
||||||
|
|
||||||
view_by :date, :descending => true
|
view_by :date, :descending => true
|
||||||
|
@ -106,8 +106,8 @@ describe CouchRest::Model do
|
||||||
@db = @cr.create_db(TESTDB) rescue nil
|
@db = @cr.create_db(TESTDB) rescue nil
|
||||||
@adb = @cr.database('couchrest-model-test')
|
@adb = @cr.database('couchrest-model-test')
|
||||||
@adb.delete! rescue nil
|
@adb.delete! rescue nil
|
||||||
CouchRest.database!('http://localhost:5984/couchrest-model-test')
|
CouchRest.database!('http://127.0.0.1:5984/couchrest-model-test')
|
||||||
CouchRest::Model.default_database = CouchRest.database!('http://localhost:5984/couchrest-test')
|
CouchRest::Model.default_database = CouchRest.database!('http://127.0.0.1:5984/couchrest-test')
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should use the default database" do
|
it "should use the default database" do
|
||||||
|
|
|
@ -15,12 +15,12 @@ describe CouchRest::FileManager do
|
||||||
lambda{CouchRest::FileManager.new}.should raise_error
|
lambda{CouchRest::FileManager.new}.should raise_error
|
||||||
end
|
end
|
||||||
it "should accept a db name" do
|
it "should accept a db name" do
|
||||||
@fm = CouchRest::FileManager.new(TESTDB, 'http://localhost')
|
@fm = CouchRest::FileManager.new(TESTDB, 'http://127.0.0.1')
|
||||||
@fm.db.name.should == TESTDB
|
@fm.db.name.should == TESTDB
|
||||||
end
|
end
|
||||||
it "should default to localhost couchdb" do
|
it "should default to 127.0.0.1 couchdb" do
|
||||||
@fm = CouchRest::FileManager.new(TESTDB)
|
@fm = CouchRest::FileManager.new(TESTDB)
|
||||||
@fm.db.host.should == 'http://localhost:5984'
|
@fm.db.host.should == 'http://127.0.0.1:5984'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ require File.dirname(__FILE__) + '/../lib/couchrest'
|
||||||
|
|
||||||
FIXTURE_PATH = File.dirname(__FILE__) + '/fixtures'
|
FIXTURE_PATH = File.dirname(__FILE__) + '/fixtures'
|
||||||
|
|
||||||
COUCHHOST = "http://localhost:5984"
|
COUCHHOST = "http://127.0.0.1:5984"
|
||||||
TESTDB = 'couchrest-test'
|
TESTDB = 'couchrest-test'
|
||||||
|
|
||||||
def reset_test_db!
|
def reset_test_db!
|
||||||
|
|
|
@ -2,11 +2,11 @@ require 'rubygems'
|
||||||
require 'couchrest'
|
require 'couchrest'
|
||||||
|
|
||||||
# set the source db and map view
|
# set the source db and map view
|
||||||
source = CouchRest.new("http://localhost:5984").database('source-db')
|
source = CouchRest.new("http://127.0.0.1:5984").database('source-db')
|
||||||
source_view = 'mydesign/view-map'
|
source_view = 'mydesign/view-map'
|
||||||
|
|
||||||
# set the target db
|
# set the target db
|
||||||
target = CouchRest.new("http://localhost:5984").database('target-db')
|
target = CouchRest.new("http://127.0.0.1:5984").database('target-db')
|
||||||
|
|
||||||
|
|
||||||
pager = CouchRest::Pager.new(source)
|
pager = CouchRest::Pager.new(source)
|
||||||
|
|
|
@ -5,10 +5,10 @@ require 'couchrest'
|
||||||
# use it to create a smaller dataset on which to prototype views.
|
# use it to create a smaller dataset on which to prototype views.
|
||||||
|
|
||||||
# specify the source database
|
# specify the source database
|
||||||
source = CouchRest.new("http://localhost:5984").database('source-db')
|
source = CouchRest.new("http://127.0.0.1:5984").database('source-db')
|
||||||
|
|
||||||
# specify the target database
|
# specify the target database
|
||||||
target = CouchRest.new("http://localhost:5984").database('target-db')
|
target = CouchRest.new("http://127.0.0.1:5984").database('target-db')
|
||||||
|
|
||||||
# pager efficiently yields all view rows
|
# pager efficiently yields all view rows
|
||||||
pager = CouchRest::Pager.new(source)
|
pager = CouchRest::Pager.new(source)
|
||||||
|
|
Loading…
Reference in a new issue