cohitre-relaxdb 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README.textile +164 -0
- data/Rakefile +52 -0
- data/docs/spec_results.html +604 -0
- data/lib/more/grapher.rb +48 -0
- data/lib/relaxdb.rb +38 -0
- data/lib/relaxdb/all_delegator.rb +48 -0
- data/lib/relaxdb/belongs_to_proxy.rb +29 -0
- data/lib/relaxdb/design_doc.rb +50 -0
- data/lib/relaxdb/document.rb +386 -0
- data/lib/relaxdb/extlib.rb +3 -0
- data/lib/relaxdb/has_many_proxy.rb +81 -0
- data/lib/relaxdb/has_one_proxy.rb +45 -0
- data/lib/relaxdb/paginate_params.rb +54 -0
- data/lib/relaxdb/paginator.rb +78 -0
- data/lib/relaxdb/query.rb +74 -0
- data/lib/relaxdb/references_many_proxy.rb +99 -0
- data/lib/relaxdb/relaxdb.rb +157 -0
- data/lib/relaxdb/server.rb +132 -0
- data/lib/relaxdb/sorted_by_view.rb +62 -0
- data/lib/relaxdb/uuid_generator.rb +21 -0
- data/lib/relaxdb/view_object.rb +34 -0
- data/lib/relaxdb/view_result.rb +18 -0
- data/lib/relaxdb/view_uploader.rb +47 -0
- data/lib/relaxdb/views.rb +42 -0
- data/spec/belongs_to_spec.rb +80 -0
- data/spec/callbacks_spec.rb +64 -0
- data/spec/denormalisation_spec.rb +49 -0
- data/spec/design_doc_spec.rb +34 -0
- data/spec/document_spec.rb +364 -0
- data/spec/has_many_spec.rb +147 -0
- data/spec/has_one_spec.rb +128 -0
- data/spec/query_spec.rb +80 -0
- data/spec/references_many_spec.rb +141 -0
- data/spec/relaxdb_spec.rb +137 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +10 -0
- data/spec/spec_models.rb +130 -0
- data/spec/view_object_spec.rb +47 -0
- metadata +119 -0
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/spec/spec_helper.rb
ADDED
data/spec/spec_models.rb
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
class Atom < RelaxDB::Document
|
2
|
+
end
|
3
|
+
|
4
|
+
class Primitives < RelaxDB::Document
|
5
|
+
|
6
|
+
property :str
|
7
|
+
property :num
|
8
|
+
property :true_bool
|
9
|
+
property :false_bool
|
10
|
+
property :created_at
|
11
|
+
property :empty
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
class BespokeReader < RelaxDB::Document
|
16
|
+
property :val
|
17
|
+
def val; @val + 5; end
|
18
|
+
end
|
19
|
+
|
20
|
+
class BespokeWriter < RelaxDB::Document
|
21
|
+
property :val
|
22
|
+
def val=(v); @val = v - 10; end
|
23
|
+
end
|
24
|
+
|
25
|
+
class Letter < RelaxDB::Document
|
26
|
+
|
27
|
+
property :letter
|
28
|
+
property :number
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
class Invite < RelaxDB::Document
|
33
|
+
|
34
|
+
property :message
|
35
|
+
|
36
|
+
belongs_to :sender
|
37
|
+
belongs_to :recipient
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
class Item < RelaxDB::Document
|
42
|
+
|
43
|
+
property :name
|
44
|
+
belongs_to :user
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
class User < RelaxDB::Document
|
49
|
+
|
50
|
+
property :name
|
51
|
+
property :age
|
52
|
+
|
53
|
+
has_many :items, :class => "Item"
|
54
|
+
|
55
|
+
has_many :invites_received, :class => "Invite", :known_as => :recipient
|
56
|
+
has_many :invites_sent, :class => "Invite", :known_as => :sender
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
class Post < RelaxDB::Document
|
61
|
+
|
62
|
+
property :subject
|
63
|
+
property :content
|
64
|
+
property :created_at
|
65
|
+
property :viewed_at
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
class Rating < RelaxDB::Document
|
70
|
+
|
71
|
+
property :stars, :default => 5
|
72
|
+
belongs_to :photo
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
class Photo < RelaxDB::Document
|
77
|
+
|
78
|
+
property :name
|
79
|
+
|
80
|
+
has_one :rating
|
81
|
+
|
82
|
+
references_many :tags, :class => "Tag", :known_as => :photos
|
83
|
+
|
84
|
+
has_many :taggings, :class => "Tagging"
|
85
|
+
|
86
|
+
end
|
87
|
+
|
88
|
+
class Tag < RelaxDB::Document
|
89
|
+
|
90
|
+
property :name
|
91
|
+
references_many :photos, :class => "Photo", :known_as => :tags
|
92
|
+
|
93
|
+
has_many :taggings, :class => "Tagging"
|
94
|
+
|
95
|
+
end
|
96
|
+
|
97
|
+
class Tagging < RelaxDB::Document
|
98
|
+
|
99
|
+
belongs_to :photo
|
100
|
+
belongs_to :tag
|
101
|
+
property :relevance
|
102
|
+
|
103
|
+
end
|
104
|
+
|
105
|
+
class MultiWordClass < RelaxDB::Document
|
106
|
+
has_one :multi_word_child
|
107
|
+
has_many :multi_word_children, :class => "MultiWordChild"
|
108
|
+
end
|
109
|
+
|
110
|
+
class MultiWordChild < RelaxDB::Document
|
111
|
+
belongs_to :multi_word_class
|
112
|
+
end
|
113
|
+
|
114
|
+
class TwitterUser < RelaxDB::Document
|
115
|
+
|
116
|
+
property :name
|
117
|
+
references_many :followers, :class => "User", :known_as => :leaders
|
118
|
+
references_many :leaders, :class => "User", :known_as => :followers
|
119
|
+
|
120
|
+
end
|
121
|
+
|
122
|
+
class Dysfunctional < RelaxDB::Document
|
123
|
+
has_one :failure
|
124
|
+
has_many :failures, :class => "Failure"
|
125
|
+
end
|
126
|
+
|
127
|
+
class Failure < RelaxDB::Document
|
128
|
+
property :pathological, :validator => lambda { false }
|
129
|
+
belongs_to :dysfunctional
|
130
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
require File.dirname(__FILE__) + '/spec_models.rb'
|
3
|
+
|
4
|
+
describe RelaxDB::ViewObject do
|
5
|
+
|
6
|
+
describe ".new" do
|
7
|
+
|
8
|
+
it "should provide readers for the object passed in the hash" do
|
9
|
+
data = { :name => "chaise", :variety => "longue" }
|
10
|
+
obj = RelaxDB::ViewObject.new(data)
|
11
|
+
obj.name.should == "chaise"
|
12
|
+
obj.variety.should == "longue"
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should try to convert objects ending in _at to a time" do
|
16
|
+
now = Time.now
|
17
|
+
data = { :ends_at => now.to_s }
|
18
|
+
obj = RelaxDB::ViewObject.new(data)
|
19
|
+
obj.ends_at.should be_close(now, 1)
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
describe ".create" do
|
25
|
+
|
26
|
+
it "should return an array of view objects when passed an array" do
|
27
|
+
data = [ {:half_life => 2}, {:half_life => 16} ]
|
28
|
+
obj = RelaxDB::ViewObject.create(data)
|
29
|
+
obj.size.should == 2
|
30
|
+
obj[0].half_life.should == 2
|
31
|
+
obj[1].half_life.should == 16
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should return a view object when passed a hash" do
|
35
|
+
data = {:half_life => 32}
|
36
|
+
obj = RelaxDB::ViewObject.create(data)
|
37
|
+
obj.half_life.should == 32
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should return a simple value when passed a primitive" do
|
41
|
+
obj = RelaxDB::ViewObject.create(10)
|
42
|
+
obj.should == 10
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
metadata
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cohitre-relaxdb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Paul Carey
|
8
|
+
autorequire: relaxdb
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-08-25 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: extlib
|
17
|
+
version_requirement:
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.9.4
|
23
|
+
version:
|
24
|
+
- !ruby/object:Gem::Dependency
|
25
|
+
name: json
|
26
|
+
version_requirement:
|
27
|
+
version_requirements: !ruby/object:Gem::Requirement
|
28
|
+
requirements:
|
29
|
+
- - ">="
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: "0"
|
32
|
+
version:
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: uuid
|
35
|
+
version_requirement:
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: "0"
|
41
|
+
version:
|
42
|
+
description:
|
43
|
+
email: paul.p.carey@gmail.com
|
44
|
+
executables: []
|
45
|
+
|
46
|
+
extensions: []
|
47
|
+
|
48
|
+
extra_rdoc_files: []
|
49
|
+
|
50
|
+
files:
|
51
|
+
- LICENSE
|
52
|
+
- README.textile
|
53
|
+
- Rakefile
|
54
|
+
- docs/spec_results.html
|
55
|
+
- lib/relaxdb
|
56
|
+
- lib/relaxdb/all_delegator.rb
|
57
|
+
- lib/relaxdb/belongs_to_proxy.rb
|
58
|
+
- lib/relaxdb/design_doc.rb
|
59
|
+
- lib/relaxdb/document.rb
|
60
|
+
- lib/relaxdb/extlib.rb
|
61
|
+
- lib/relaxdb/has_many_proxy.rb
|
62
|
+
- lib/relaxdb/has_one_proxy.rb
|
63
|
+
- lib/relaxdb/paginate_params.rb
|
64
|
+
- lib/relaxdb/paginator.rb
|
65
|
+
- lib/relaxdb/query.rb
|
66
|
+
- lib/relaxdb/references_many_proxy.rb
|
67
|
+
- lib/relaxdb/relaxdb.rb
|
68
|
+
- lib/relaxdb/server.rb
|
69
|
+
- lib/relaxdb/sorted_by_view.rb
|
70
|
+
- lib/relaxdb/uuid_generator.rb
|
71
|
+
- lib/relaxdb/view_object.rb
|
72
|
+
- lib/relaxdb/view_result.rb
|
73
|
+
- lib/relaxdb/view_uploader.rb
|
74
|
+
- lib/relaxdb/views.rb
|
75
|
+
- lib/more/grapher.rb
|
76
|
+
- lib/relaxdb.rb
|
77
|
+
- more/grapher.rb
|
78
|
+
- spec/belongs_to_spec.rb
|
79
|
+
- spec/callbacks_spec.rb
|
80
|
+
- spec/denormalisation_spec.rb
|
81
|
+
- spec/design_doc_spec.rb
|
82
|
+
- spec/document_spec.rb
|
83
|
+
- spec/has_many_spec.rb
|
84
|
+
- spec/has_one_spec.rb
|
85
|
+
- spec/query_spec.rb
|
86
|
+
- spec/references_many_spec.rb
|
87
|
+
- spec/relaxdb_spec.rb
|
88
|
+
- spec/spec.opts
|
89
|
+
- spec/spec_helper.rb
|
90
|
+
- spec/spec_models.rb
|
91
|
+
- spec/view_object_spec.rb
|
92
|
+
has_rdoc: false
|
93
|
+
homepage: http://github.com/paulcarey/relaxdb/
|
94
|
+
post_install_message:
|
95
|
+
rdoc_options: []
|
96
|
+
|
97
|
+
require_paths:
|
98
|
+
- lib
|
99
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: "0"
|
104
|
+
version:
|
105
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: "0"
|
110
|
+
version:
|
111
|
+
requirements: []
|
112
|
+
|
113
|
+
rubyforge_project:
|
114
|
+
rubygems_version: 1.2.0
|
115
|
+
signing_key:
|
116
|
+
specification_version: 2
|
117
|
+
summary: RelaxDB provides a simple interface to CouchDB
|
118
|
+
test_files: []
|
119
|
+
|