relaxdb 0.5 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,8 @@
1
1
  h3. What's New?
2
2
 
3
+ * 2010-05-04
4
+ ** RelaxDB 0.5 released. This is a leaner version of RelaxDB with significant performance improvements and breaking changes. See the "release notes":http://github.com/paulcarey/relaxdb/blob/master/RELEASE_NOTES.textile for upgrading notes.
5
+
3
6
  * 2010-04-10
4
7
  ** RelaxDB 0.4 released. Supports Ruby 1.9.1 and CouchDB 0.11.0.
5
8
  ** Auto-generated views no longer emit the document as a value by default
data/Rakefile CHANGED
@@ -22,9 +22,8 @@ spec = Gem::Specification.new do |s|
22
22
  s.email = EMAIL
23
23
  s.homepage = HOMEPAGE
24
24
 
25
- s.add_dependency "extlib", ">=0.9.4"
26
- s.add_dependency "json"
27
- s.add_dependency "uuid"
25
+ s.add_dependency "extlib", "~> 0.9.4"
26
+ s.add_dependency "json", "~> 1.4"
28
27
 
29
28
  s.require_path = 'lib'
30
29
  s.autorequire = PLUGIN
@@ -1,7 +1,6 @@
1
1
  require 'rubygems'
2
2
  require 'extlib'
3
3
  require 'json'
4
- require 'uuid'
5
4
 
6
5
  require 'cgi'
7
6
  require 'net/http'
@@ -125,11 +125,11 @@ module RelaxDB
125
125
  if writers
126
126
  writers.each do |prop, writer|
127
127
  current_val = send(prop)
128
- # begin
128
+ begin
129
129
  send("#{prop}=", writer.call(current_val, self))
130
- # rescue => e
131
- # RelaxDB.logger.error "Deriving #{prop} from #{source} raised #{e}"
132
- # end
130
+ rescue => e
131
+ RelaxDB.logger.error "Deriving #{prop} from #{source} raised #{e}"
132
+ end
133
133
  end
134
134
  end
135
135
  end
@@ -192,7 +192,7 @@ module RelaxDB
192
192
 
193
193
  alias_method :to_s, :inspect
194
194
 
195
- def to_json
195
+ def to_json(*args)
196
196
  ref_rels = self.class.references_rels.map { |k, v| k.to_s }
197
197
  @data.delete_if { |k,v| ref_rels.include? k }
198
198
 
@@ -16,7 +16,7 @@ class Time
16
16
  # Ensure that all Times are stored as UTC
17
17
  # Times in the following format may be passed directly to
18
18
  # Date.new in a JavaScript runtime
19
- def to_json(options={})
19
+ def to_json(*args)
20
20
  utc
21
21
  %Q("#{strftime "%Y/%m/%d %H:%M:%S +0000"}")
22
22
  end
@@ -5,7 +5,6 @@ module RelaxDB
5
5
  def initialize(host, port)
6
6
  @host = host
7
7
  @port = port
8
- @cx = Net::HTTP.start(@host, @port)
9
8
  end
10
9
 
11
10
  def delete(uri)
@@ -31,26 +30,9 @@ module RelaxDB
31
30
  end
32
31
 
33
32
  def request(req)
34
- res = Net::HTTP.start(@host, @port) { |http|
33
+ res = Net::HTTP.start(@host, @port) {|http|
35
34
  http.request(req)
36
35
  }
37
-
38
- #
39
- # When using this chunk of code, as opposed to the one above, CouchDB
40
- # started throwing emfile errors. I can't imagine they're related,
41
- # but worth noting nonetheless. On second thoughts, I think they are!
42
- #
43
- # The tests don't close the cx after they run - just open new ones, this
44
- # could be causing CouchDB to run out of handles.
45
- #
46
- # begin
47
- # # @cx = Net::HTTP.start(@host, @port) unless @cx.active?
48
- # res = @cx.request(req)
49
- # rescue
50
- # @cx = Net::HTTP.start(@host, @port)
51
- # res = @cx.request(req)
52
- # end
53
-
54
36
  if (not res.kind_of?(Net::HTTPSuccess))
55
37
  handle_error(req, res)
56
38
  end
metadata CHANGED
@@ -5,7 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 5
8
- version: "0.5"
8
+ - 1
9
+ version: 0.5.1
9
10
  platform: ruby
10
11
  authors:
11
12
  - Paul Carey
@@ -13,7 +14,7 @@ autorequire: relaxdb
13
14
  bindir: bin
14
15
  cert_chain: []
15
16
 
16
- date: 2010-04-27 00:00:00 +01:00
17
+ date: 2010-05-04 00:00:00 +01:00
17
18
  default_executable:
18
19
  dependencies:
19
20
  - !ruby/object:Gem::Dependency
@@ -21,7 +22,7 @@ dependencies:
21
22
  prerelease: false
22
23
  requirement: &id001 !ruby/object:Gem::Requirement
23
24
  requirements:
24
- - - ">="
25
+ - - ~>
25
26
  - !ruby/object:Gem::Version
26
27
  segments:
27
28
  - 0
@@ -35,64 +36,51 @@ dependencies:
35
36
  prerelease: false
36
37
  requirement: &id002 !ruby/object:Gem::Requirement
37
38
  requirements:
38
- - - ">="
39
+ - - ~>
39
40
  - !ruby/object:Gem::Version
40
41
  segments:
41
- - 0
42
- version: "0"
42
+ - 1
43
+ - 4
44
+ version: "1.4"
43
45
  type: :runtime
44
46
  version_requirements: *id002
45
- - !ruby/object:Gem::Dependency
46
- name: uuid
47
- prerelease: false
48
- requirement: &id003 !ruby/object:Gem::Requirement
49
- requirements:
50
- - - ">="
51
- - !ruby/object:Gem::Version
52
- segments:
53
- - 0
54
- version: "0"
55
- type: :runtime
56
- version_requirements: *id003
57
- description: RelaxDB provides a simple interface to CouchDB
47
+ description:
58
48
  email: paul.p.carey@gmail.com
59
49
  executables: []
60
50
 
61
51
  extensions: []
62
52
 
63
- extra_rdoc_files:
64
- - README.textile
65
- - LICENSE
53
+ extra_rdoc_files: []
54
+
66
55
  files:
67
56
  - LICENSE
68
57
  - README.textile
69
58
  - readme.rb
70
59
  - Rakefile
71
60
  - docs/spec_results.html
72
- - lib/more/grapher.rb
73
61
  - lib/relaxdb/all_delegator.rb
74
62
  - lib/relaxdb/design_doc.rb
75
63
  - lib/relaxdb/document.rb
76
64
  - lib/relaxdb/extlib.rb
65
+ - lib/relaxdb/net_http_server.rb
77
66
  - lib/relaxdb/migration.rb
78
67
  - lib/relaxdb/migration_version.rb
79
- - lib/relaxdb/net_http_server.rb
80
68
  - lib/relaxdb/paginate_params.rb
81
69
  - lib/relaxdb/paginator.rb
82
70
  - lib/relaxdb/query.rb
83
71
  - lib/relaxdb/references_proxy.rb
84
72
  - lib/relaxdb/relaxdb.rb
85
73
  - lib/relaxdb/server.rb
86
- - lib/relaxdb/taf2_curb_server.rb
87
74
  - lib/relaxdb/uuid_generator.rb
75
+ - lib/relaxdb/taf2_curb_server.rb
88
76
  - lib/relaxdb/validators.rb
89
77
  - lib/relaxdb/view_by_delegator.rb
90
78
  - lib/relaxdb/view_object.rb
91
79
  - lib/relaxdb/view_result.rb
92
80
  - lib/relaxdb/view_uploader.rb
93
81
  - lib/relaxdb/views.rb
82
+ - lib/more/grapher.rb
94
83
  - lib/relaxdb.rb
95
- - spec/all_delegator_spec.rb
96
84
  - spec/callbacks_spec.rb
97
85
  - spec/derived_properties_spec.rb
98
86
  - spec/design_doc_spec.rb
@@ -102,7 +90,6 @@ files:
102
90
  - spec/migration_version_spec.rb
103
91
  - spec/paginate_params_spec.rb
104
92
  - spec/paginate_spec.rb
105
- - spec/qpaginate_spec.rb
106
93
  - spec/query_spec.rb
107
94
  - spec/references_proxy_spec.rb
108
95
  - spec/relaxdb_spec.rb
@@ -111,7 +98,6 @@ files:
111
98
  - spec/spec_helper.rb
112
99
  - spec/spec_models.rb
113
100
  - spec/uuid_generator_spec.rb
114
- - spec/view_by_spec.rb
115
101
  - spec/view_docs_by_spec.rb
116
102
  - spec/view_object_spec.rb
117
103
  has_rdoc: true
@@ -1,52 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper.rb'
2
- require File.dirname(__FILE__) + '/spec_models.rb'
3
-
4
- describe RelaxDB::AllDelegator do
5
-
6
- before(:all) do
7
- setup_test_db
8
- end
9
-
10
- describe "size" do
11
-
12
- it "should return the total count for a given class" do
13
- docs = (1..101).map { |i| Primitives.new :num => i }
14
- RelaxDB.bulk_save! *docs
15
- Primitives.all.size.should == 101
16
- end
17
-
18
- end
19
-
20
- describe "all" do
21
-
22
- it "should return the ids for the given class" do
23
- docs = (1..3).map { |i| Primitives.new :_id => "p#{i}" }
24
- RelaxDB.bulk_save! *docs
25
- Primitives.all.should == %w(p1 p2 p3)
26
- end
27
-
28
- end
29
-
30
- describe "load" do
31
-
32
- it "should load all docs for the given class" do
33
- docs = (1..3).map { |i| Primitives.new :num => i }
34
- RelaxDB.bulk_save! *docs
35
- pms = Primitives.all.load!
36
- pms.map { |p| p.num }.inject(&:+).should == 6
37
- end
38
-
39
- end
40
-
41
- describe "destroy" do
42
-
43
- it "should destroy all docs for the given class" do
44
- docs = (1..3).map { |i| Primitives.new :num => i }
45
- RelaxDB.bulk_save! *docs
46
- Primitives.all.destroy!
47
- Primitives.all.load!.should == []
48
- end
49
-
50
- end
51
-
52
- end
@@ -1,88 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper.rb'
2
- require File.dirname(__FILE__) + '/spec_models.rb'
3
-
4
- describe "RelaxDB Pagination" do
5
-
6
- before(:each) do
7
- setup_test_db
8
-
9
- letters = [
10
- ["a", 1], ["a", 2], ["a", 3],
11
- ["b", 1], ["b", 2], ["b", 3], ["b", 4], ["b", 5],
12
- ["c", 1], ["c", 2]
13
- ].map { |o| Letter.new :letter => o[0], :number => o[1], :_id => "#{o[0]}#{o[1]}" }
14
-
15
- RelaxDB.bulk_save *letters
16
- end
17
-
18
- # helper function
19
- def s(letters)
20
- letters.map { |l| "#{l.letter}#{l.number}"}.join(", ")
21
- end
22
-
23
- def n(letters)
24
- letters.map { |l| "#{l.number}"}.join(", ")
25
- end
26
-
27
- describe "functional tests" do
28
-
29
- it "should navigate through a series" do
30
- query = lambda do |page_params|
31
- RelaxDB.qpaginate_view "Letter_by_letter_and_number", :page_params => page_params,
32
- :startkey => ["a"], :endkey => ["a",{}], :limit => 2,
33
- :attributes => [:letter, :number]
34
- end
35
-
36
- letters = query.call({})
37
- s(letters).should == "a1, a2"
38
- letters.prev_params.should be_false
39
-
40
- letters = query.call(letters.next_params)
41
- s(letters).should == "a3"
42
- letters.next_params.should be_false
43
-
44
- letters = query.call(letters.prev_params)
45
- s(letters).should == "a1, a2"
46
- letters.next_params.should be
47
- end
48
-
49
- end
50
-
51
- describe "Non emitted docs" do
52
-
53
- before(:each) do
54
- map = <<-FUNC
55
- function (doc) {
56
- if (doc.relaxdb_class === "Letter") {
57
- emit([doc.letter, doc.number], null);
58
- }
59
- }
60
- FUNC
61
-
62
- view_name = "Letter_by_letter_and_number_v2"
63
- RelaxDB::DesignDocument.get(RelaxDB.dd).add_map_view(view_name, map).save
64
- end
65
-
66
- it "should navigate through a series when 1 emitted as val" do
67
- query = lambda do |page_params|
68
- RelaxDB.qpaginate_docs "Letter_by_letter_and_number_v2", :page_params => page_params,
69
- :startkey => ["a"], :endkey => ["a",{}], :limit => 2,
70
- :attributes => [:letter, :number]
71
- end
72
-
73
- letters = query.call({})
74
- s(letters).should == "a1, a2"
75
- letters.prev_params.should be_false
76
-
77
- letters = query.call(letters.next_params)
78
- s(letters).should == "a3"
79
- letters.next_params.should be_false
80
-
81
- letters = query.call(letters.prev_params)
82
- s(letters).should == "a1, a2"
83
- letters.next_params.should be
84
- end
85
-
86
- end
87
-
88
- end
@@ -1,84 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper.rb'
2
- require File.dirname(__FILE__) + '/spec_models.rb'
3
-
4
- describe "view_by" do
5
-
6
- before(:each) do
7
- setup_test_db
8
-
9
- docs = (1..10).map { |i| Primitives.new :_id => "id#{i}", :str => i.to_s }
10
- RelaxDB.bulk_save! *docs
11
- end
12
-
13
- it "should return an array of doc ids for a key" do
14
- docs = Primitives.by_str :key => "5"
15
- docs.first.should == "id5"
16
- end
17
-
18
- it "should obey startkey and endkey directives" do
19
- docs = Primitives.by_str :startkey => "3", :endkey => "6"
20
- docs.should == %w(id3 id4 id5 id6)
21
- end
22
-
23
- it "should return all when none specified" do
24
- docs = Primitives.by_str
25
- docs.size.should == 10
26
- end
27
-
28
- it "should return arrays that behave normally" do
29
- p1 = Primitives.by_str :key => "1"
30
- p2 = Primitives.by_str :key => "2"
31
- RelaxDB.load!(p1 + p2).map { |p| p.str }.join.should == "12"
32
- end
33
-
34
- describe "delegator" do
35
-
36
- it "should load the returned doc ids" do
37
- docs = Primitives.by_str :key => "5"
38
- docs.load!.first.str.should == "5"
39
- end
40
-
41
- it "should load the doc for a single param" do
42
- res = Primitives.by_str "8"
43
- res.str.should == "8"
44
- end
45
-
46
- it "should return the delegator when no params given" do
47
- docs = Primitives.by_str.load!
48
- docs.map { |d| d.str }.join.length.should == 11
49
- end
50
-
51
- end
52
-
53
- describe "request count" do
54
-
55
- before(:each) do
56
- RelaxDB.db.reset_req_count
57
- end
58
-
59
- it "should not issue any requests before accessingn the delegator" do
60
- doc_ids = Primitives.by_str
61
- RelaxDB.db.req_count.should == 0
62
- end
63
-
64
- it "should issue a single request when retrieving ids only" do
65
- doc_ids = Primitives.by_str
66
- doc_ids[0]
67
- RelaxDB.db.req_count.should == 1
68
- end
69
-
70
- it "should make two requests when loading docs after touching ids" do
71
- doc_ids = Primitives.by_str
72
- doc_ids[0].should == "id1"
73
- doc_ids.load!
74
- RelaxDB.db.req_count.should == 2
75
- end
76
-
77
- it "should issue a single request when retrieving docs directly" do
78
- Primitives.by_str.load!
79
- RelaxDB.db.req_count.should == 1
80
- end
81
-
82
- end
83
-
84
- end