cohitre-relaxdb 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,10 @@
1
+ begin
2
+ require 'spec'
3
+ rescue LoadError
4
+ require 'rubygems'
5
+ gem 'rspec'
6
+ require 'spec'
7
+ end
8
+
9
+ $:.unshift(File.dirname(__FILE__) + '/../lib')
10
+ require 'relaxdb'
@@ -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
+