zdzolton-cambric 0.6.4 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -109,36 +109,38 @@ by the application.
109
109
  * Configure Rails:
110
110
  * create a config/initializers/cambric.rb file as follows:
111
111
 
112
- Cambric.configure do |config|
113
- config.design_doc_name = 'YOUR_APP_NAME'
114
- config.environment = RAILS_ENV
115
-
116
- config.databases = {
117
- :YOUR_DB_NAME => {
118
- :development => "http://localhost:5984/YOUR_DB_NAME-development",
119
- :test => "http://localhost:5984/YOUR_DB_NAME-test"
120
- },
121
- :YOUR_OTHER_DB => {
122
- :development => "http://localhost:5984/YOUR_OTHER_DB-development",
123
- :test => "http://localhost:5984/YOUR_OTHER_DB-test"
112
+ Cambric.configure do |config|
113
+ config.design_doc_name = 'YOUR_APP_NAME'
114
+ config.environment = RAILS_ENV
115
+
116
+ config.databases = {
117
+ :YOUR_DB_NAME => {
118
+ :development => "http://localhost:5984/YOUR_DB_NAME-development",
119
+ :test => "http://localhost:5984/YOUR_DB_NAME-test"
120
+ },
121
+ :YOUR_OTHER_DB => {
122
+ :development => "http://localhost:5984/YOUR_OTHER_DB-development",
123
+ :test => "http://localhost:5984/YOUR_OTHER_DB-test"
124
+ }
124
125
  }
125
- }
126
- end
127
-
128
- # Push design docs after every request in development, and once in production on app startup
129
- ActionController::Dispatcher.to_prepare(:cambric){ Cambric.prepare_databases }
130
-
131
- * place the following two lines in your test_helper.rb, at the top of the file after the
132
- require statements:
133
-
134
- Cambric.environment = 'test'
135
- Cambric.prepare_databases!
126
+ end
127
+
128
+ ActionController::Dispatcher.to_prepare(:cambric) do
129
+ if RAILS_ENV == 'test'
130
+ # Re-create databases each time in test environment
131
+ Cambric.prepare_databases!
132
+ else
133
+ # Push design docs after every request in
134
+ # development, and once in production on app startup
135
+ Cambric.prepare_databases
136
+ end
137
+ end
136
138
 
137
139
  * create a couchdb directory within your project:
138
140
 
139
- $ cd /your/app/root
140
- $ mkdir -p ./couchdb/your_db/views/some_view_name
141
-
141
+ $ cd /your/app/root
142
+ $ mkdir -p ./couchdb/your_db/views/some_view_name
143
+
142
144
  == Copyright
143
145
 
144
146
  Copyright (c) 2009 Zachary Zolton. See LICENSE for details.
data/Rakefile CHANGED
@@ -10,7 +10,7 @@ begin
10
10
  gem.homepage = "http://github.com/zdzolton/cambric"
11
11
  gem.authors = ["Zachary Zolton", "Geoff Buesing"]
12
12
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
13
- gem.add_dependency('jchris-couchrest')
13
+ gem.add_dependency('mattetti-couchrest')
14
14
  end
15
15
 
16
16
  rescue LoadError
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.4
1
+ 0.7.0
data/cambric.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{cambric}
5
- s.version = "0.6.4"
5
+ s.version = "0.7.0"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Zachary Zolton", "Geoff Buesing"]
9
- s.date = %q{2009-07-08}
9
+ s.date = %q{2009-08-27}
10
10
  s.email = %q{zachary.zolton@gmail.com}
11
11
  s.extra_rdoc_files = [
12
12
  "LICENSE",
@@ -55,11 +55,11 @@ Gem::Specification.new do |s|
55
55
  s.specification_version = 3
56
56
 
57
57
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
58
- s.add_runtime_dependency(%q<jchris-couchrest>, [">= 0"])
58
+ s.add_runtime_dependency(%q<mattetti-couchrest>, [">= 0"])
59
59
  else
60
- s.add_dependency(%q<jchris-couchrest>, [">= 0"])
60
+ s.add_dependency(%q<mattetti-couchrest>, [">= 0"])
61
61
  end
62
62
  else
63
- s.add_dependency(%q<jchris-couchrest>, [">= 0"])
63
+ s.add_dependency(%q<mattetti-couchrest>, [">= 0"])
64
64
  end
65
65
  end
@@ -14,7 +14,7 @@ module Cambric
14
14
 
15
15
  def get_docs_from_view name, options={}
16
16
  cast_as = options.delete(:cast_as) || options.delete('cast_as')
17
- results = view name, options.merge(:reduce => false, :include_docs => true)
17
+ results = view name, options.merge(:include_docs => true)
18
18
  mapper = case cast_as
19
19
  when String then lambda { |r| CouchRest.constantize(r['doc'][cast_as]).new(r['doc']) }
20
20
  when Class then lambda { |r| cast_as.new(r['doc']) }
@@ -22,8 +22,9 @@ describe Cambric::AssumeDesignDocName do
22
22
  Cambric[:tweets].cambric_design_doc.should_not be_nil
23
23
  end
24
24
 
25
- describe "Casting documents from map-only query results" do
25
+ describe "Casting documents from reduce=false query results" do
26
26
  before :all do
27
+ Cambric[:tweets].save_doc 'author' => 'trevor', 'message' => "'sup, guys?", 'created_at' => '2009-06-06 11:52:34'
27
28
  class User < CouchRest::Document; end
28
29
  Cambric[:users].bulk_save [
29
30
  User.new('_id' => 'trevor', 'following' => %w(bob geoff scott brian zach), 'type' => 'User'),
@@ -32,23 +33,39 @@ describe Cambric::AssumeDesignDocName do
32
33
  end
33
34
 
34
35
  it "should cast to specified type, when cast_as is a type" do
35
- followers = Cambric[:users].get_docs_from_view :followers, :cast_as => User, :key => 'bob'
36
+ followers = Cambric[:users].get_docs_from_view :followers, :cast_as => User,
37
+ :key => 'bob', :reduce => false
36
38
  followers.should have(2).elements
37
39
  followers.each{ |f| f.should be_a(User) }
38
40
  end
39
41
 
40
42
  it "should cast to type per-doc when cast_as is a string" do
41
- followers = Cambric[:users].get_docs_from_view :followers, :cast_as => 'type', :key => 'bob'
43
+ followers = Cambric[:users].get_docs_from_view :followers, :cast_as => 'type',
44
+ :key => 'bob', :reduce => false
42
45
  followers.should have(2).elements
43
46
  followers.each{ |f| f.should be_a(User) }
44
47
  end
45
48
 
46
49
  it "should default to returning the plain doc hashes if cast_as is omitted" do
47
- followers = Cambric[:users].get_docs_from_view :followers, :key => 'bob'
50
+ followers = Cambric[:users].get_docs_from_view :followers,
51
+ :key => 'bob', :reduce => false
48
52
  followers.should have(2).elements
49
53
  followers.each{ |f| f.should be_a(Hash) }
50
54
  end
51
55
  end
56
+
57
+ describe "Casting documents from query results on a map-only view" do
58
+ before :all do
59
+ class Tweet < CouchRest::Document; end
60
+ Cambric[:tweets].save_doc Tweet.new('author' => 'trevor', 'message' => "'sup, guys?", 'created_at' => '2009-06-06 11:52:34', 'followers' => %w(zach scott geoff))
61
+ end
62
+
63
+ it "should no longer put reduce=false into the query" do
64
+ tweets = Cambric[:tweets].get_docs_from_view :by_follower_and_created_at,
65
+ :limit => 1, :cast_as => Tweet
66
+ tweets.first.should be_a(Tweet)
67
+ end
68
+ end
52
69
 
53
70
  end
54
71
  end
@@ -61,7 +61,7 @@ describe Cambric do
61
61
  end
62
62
 
63
63
  it "should match the expected database URI for the new environment" do
64
- Cambric[:tweets].uri.should == 'http://127.0.0.1:5984/tweets-development'
64
+ Cambric[:tweets].uri.should == '/tweets-development'
65
65
  end
66
66
  end
67
67
  end
@@ -82,7 +82,7 @@ describe Cambric do
82
82
 
83
83
  it "should have the expected URLs" do
84
84
  %w(users tweets).each do |db|
85
- Cambric[db].uri.should == "http://127.0.0.1:5984/#{db}-testing"
85
+ Cambric[db].uri.should == "/#{db}-testing"
86
86
  end
87
87
  end
88
88
 
@@ -25,7 +25,7 @@ describe Cambric::Configurator do
25
25
 
26
26
  it "should have the expected URLs for development environment" do
27
27
  %w(users tweets).each do |db|
28
- @dbs[db.to_sym].uri.should == "http://127.0.0.1:5984/#{db}-development"
28
+ @dbs[db.to_sym].uri.should == "/#{db}-development"
29
29
  end
30
30
  end
31
31
  end
data/spec/spec_helper.rb CHANGED
@@ -2,7 +2,7 @@ require 'spec'
2
2
 
3
3
  # Gem dependencies... Here?
4
4
  require 'rubygems'
5
- gem 'jchris-couchrest'
5
+ gem 'mattetti-couchrest'
6
6
 
7
7
  require 'json'
8
8
  require 'couchrest'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zdzolton-cambric
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.4
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zachary Zolton
@@ -10,11 +10,11 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-07-08 00:00:00 -07:00
13
+ date: 2009-08-27 00:00:00 -07:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
- name: jchris-couchrest
17
+ name: mattetti-couchrest
18
18
  type: :runtime
19
19
  version_requirement:
20
20
  version_requirements: !ruby/object:Gem::Requirement
@@ -58,6 +58,7 @@ files:
58
58
  - spec/spec_helper.rb
59
59
  has_rdoc: false
60
60
  homepage: http://github.com/zdzolton/cambric
61
+ licenses:
61
62
  post_install_message:
62
63
  rdoc_options:
63
64
  - --charset=UTF-8
@@ -78,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
78
79
  requirements: []
79
80
 
80
81
  rubyforge_project:
81
- rubygems_version: 1.2.0
82
+ rubygems_version: 1.3.5
82
83
  signing_key:
83
84
  specification_version: 3
84
85
  summary: Opinionated management and usage of CouchDB from your Ruby apps.