friendly_postgres 0.4.3 → 0.4.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +5 -0
- data/VERSION +1 -1
- data/friendly.gemspec +12 -8
- data/friendly_postgres.gemspec +237 -0
- data/lib/friendly/attribute.rb +9 -2
- data/lib/friendly/data_store.rb +2 -1
- data/lib/friendly/document/associations.rb +50 -0
- data/lib/friendly/document/attributes.rb +114 -0
- data/lib/friendly/document/convenience.rb +41 -0
- data/lib/friendly/document/mixin.rb +15 -0
- data/lib/friendly/document/scoping.rb +66 -0
- data/lib/friendly/document/storage.rb +63 -0
- data/lib/friendly/document.rb +11 -198
- data/lib/friendly/scope_proxy.rb +0 -2
- data/lib/friendly/translator.rb +2 -1
- data/lib/friendly.rb +0 -2
- data/spec/integration/default_value_spec.rb +22 -7
- data/spec/integration/dirty_tracking_spec.rb +43 -0
- data/spec/integration/finder_spec.rb +7 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/unit/attribute_spec.rb +28 -8
- data/spec/unit/data_store_spec.rb +13 -0
- data/spec/unit/document/attributes_spec.rb +130 -0
- data/spec/unit/document_spec.rb +0 -40
- data/spec/unit/translator_spec.rb +7 -12
- metadata +13 -8
- data/lib/friendly/config.rb +0 -5
- data/lib/friendly/named_scope.rb +0 -17
- data/spec/unit/config_spec.rb +0 -4
- data/spec/unit/named_scope_spec.rb +0 -16
data/spec/unit/document_spec.rb
CHANGED
@@ -60,46 +60,6 @@ describe "Friendly::Document" do
|
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
|
-
describe "converting a document to a hash" do
|
64
|
-
before do
|
65
|
-
@object = @klass.new(:name => "Stewie")
|
66
|
-
end
|
67
|
-
|
68
|
-
it "creates a hash that contains its attributes" do
|
69
|
-
@object.to_hash.should == {:name => "Stewie",
|
70
|
-
:id => @object.id,
|
71
|
-
:created_at => @object.created_at,
|
72
|
-
:updated_at => @object.updated_at}
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
describe "setting the attributes all at once" do
|
77
|
-
before do
|
78
|
-
@object = @klass.new
|
79
|
-
@object.attributes = {:name => "Bond"}
|
80
|
-
end
|
81
|
-
|
82
|
-
it "sets the attributes using the setters" do
|
83
|
-
@object.name.should == "Bond"
|
84
|
-
end
|
85
|
-
|
86
|
-
it "raises ArgumentError when there are duplicate keys of differing type" do
|
87
|
-
lambda {
|
88
|
-
@object.attributes = {:name => "Bond", "name" => "Bond"}
|
89
|
-
}.should raise_error(ArgumentError)
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
describe "initializing a document" do
|
94
|
-
before do
|
95
|
-
@doc = @klass.new :name => "Bond"
|
96
|
-
end
|
97
|
-
|
98
|
-
it "sets the attributes using the setters" do
|
99
|
-
@doc.name.should == "Bond"
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
63
|
describe "table name" do
|
104
64
|
it "by default: is the class name, converted with pluralize.underscore" do
|
105
65
|
User.table_name.should == "users"
|
@@ -16,20 +16,15 @@ describe "Friendly::Translator" do
|
|
16
16
|
:created_at => @time,
|
17
17
|
:updated_at => @time,
|
18
18
|
:attributes => "THE JSON"}
|
19
|
-
@
|
20
|
-
@
|
19
|
+
@doc = stub
|
20
|
+
@klass = stub
|
21
|
+
@klass.stubs(:new_without_change_tracking).
|
22
|
+
with(:updated_at => @time, :new_record => false,
|
23
|
+
:name => "Stewie", :created_at => @time).returns(@doc)
|
21
24
|
end
|
22
25
|
|
23
|
-
it "creates a
|
24
|
-
@
|
25
|
-
end
|
26
|
-
|
27
|
-
it "sets updated_at" do
|
28
|
-
@doc.updated_at.should == @time
|
29
|
-
end
|
30
|
-
|
31
|
-
it "sets new_record to false" do
|
32
|
-
@doc.new_record.should be_false
|
26
|
+
it "creates a new object without change tracking" do
|
27
|
+
@translator.to_object(@klass, @row).should == @doc
|
33
28
|
end
|
34
29
|
end
|
35
30
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: friendly_postgres
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Golick
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-01-
|
12
|
+
date: 2010-01-24 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -114,6 +114,7 @@ files:
|
|
114
114
|
- VERSION
|
115
115
|
- examples/friendly.yml
|
116
116
|
- friendly.gemspec
|
117
|
+
- friendly_postgres.gemspec
|
117
118
|
- lib/friendly.rb
|
118
119
|
- lib/friendly/associations.rb
|
119
120
|
- lib/friendly/associations/association.rb
|
@@ -122,13 +123,17 @@ files:
|
|
122
123
|
- lib/friendly/boolean.rb
|
123
124
|
- lib/friendly/cache.rb
|
124
125
|
- lib/friendly/cache/by_id.rb
|
125
|
-
- lib/friendly/config.rb
|
126
126
|
- lib/friendly/data_store.rb
|
127
127
|
- lib/friendly/document.rb
|
128
|
+
- lib/friendly/document/associations.rb
|
129
|
+
- lib/friendly/document/attributes.rb
|
130
|
+
- lib/friendly/document/convenience.rb
|
131
|
+
- lib/friendly/document/mixin.rb
|
132
|
+
- lib/friendly/document/scoping.rb
|
133
|
+
- lib/friendly/document/storage.rb
|
128
134
|
- lib/friendly/document_table.rb
|
129
135
|
- lib/friendly/index.rb
|
130
136
|
- lib/friendly/memcached.rb
|
131
|
-
- lib/friendly/named_scope.rb
|
132
137
|
- lib/friendly/newrelic.rb
|
133
138
|
- lib/friendly/query.rb
|
134
139
|
- lib/friendly/scope.rb
|
@@ -156,6 +161,7 @@ files:
|
|
156
161
|
- spec/integration/convenience_api_spec.rb
|
157
162
|
- spec/integration/count_spec.rb
|
158
163
|
- spec/integration/default_value_spec.rb
|
164
|
+
- spec/integration/dirty_tracking_spec.rb
|
159
165
|
- spec/integration/find_via_cache_spec.rb
|
160
166
|
- spec/integration/finder_spec.rb
|
161
167
|
- spec/integration/has_many_spec.rb
|
@@ -172,14 +178,13 @@ files:
|
|
172
178
|
- spec/unit/attribute_spec.rb
|
173
179
|
- spec/unit/cache_by_id_spec.rb
|
174
180
|
- spec/unit/cache_spec.rb
|
175
|
-
- spec/unit/config_spec.rb
|
176
181
|
- spec/unit/data_store_spec.rb
|
182
|
+
- spec/unit/document/attributes_spec.rb
|
177
183
|
- spec/unit/document_spec.rb
|
178
184
|
- spec/unit/document_table_spec.rb
|
179
185
|
- spec/unit/friendly_spec.rb
|
180
186
|
- spec/unit/index_spec.rb
|
181
187
|
- spec/unit/memcached_spec.rb
|
182
|
-
- spec/unit/named_scope_spec.rb
|
183
188
|
- spec/unit/query_spec.rb
|
184
189
|
- spec/unit/scope_proxy_spec.rb
|
185
190
|
- spec/unit/scope_spec.rb
|
@@ -271,6 +276,7 @@ test_files:
|
|
271
276
|
- spec/integration/convenience_api_spec.rb
|
272
277
|
- spec/integration/count_spec.rb
|
273
278
|
- spec/integration/default_value_spec.rb
|
279
|
+
- spec/integration/dirty_tracking_spec.rb
|
274
280
|
- spec/integration/find_via_cache_spec.rb
|
275
281
|
- spec/integration/finder_spec.rb
|
276
282
|
- spec/integration/has_many_spec.rb
|
@@ -286,14 +292,13 @@ test_files:
|
|
286
292
|
- spec/unit/attribute_spec.rb
|
287
293
|
- spec/unit/cache_by_id_spec.rb
|
288
294
|
- spec/unit/cache_spec.rb
|
289
|
-
- spec/unit/config_spec.rb
|
290
295
|
- spec/unit/data_store_spec.rb
|
296
|
+
- spec/unit/document/attributes_spec.rb
|
291
297
|
- spec/unit/document_spec.rb
|
292
298
|
- spec/unit/document_table_spec.rb
|
293
299
|
- spec/unit/friendly_spec.rb
|
294
300
|
- spec/unit/index_spec.rb
|
295
301
|
- spec/unit/memcached_spec.rb
|
296
|
-
- spec/unit/named_scope_spec.rb
|
297
302
|
- spec/unit/query_spec.rb
|
298
303
|
- spec/unit/scope_proxy_spec.rb
|
299
304
|
- spec/unit/scope_spec.rb
|
data/lib/friendly/config.rb
DELETED
data/lib/friendly/named_scope.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'friendly/scope'
|
2
|
-
|
3
|
-
module Friendly
|
4
|
-
class NamedScope
|
5
|
-
attr_reader :klass, :parameters, :scope_klass
|
6
|
-
|
7
|
-
def initialize(klass, parameters, scope_klass = Scope)
|
8
|
-
@klass = klass
|
9
|
-
@parameters = parameters
|
10
|
-
@scope_klass = scope_klass
|
11
|
-
end
|
12
|
-
|
13
|
-
def scope
|
14
|
-
@scope_klass.new(@klass, @parameters)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
data/spec/unit/config_spec.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
require File.expand_path("../../spec_helper", __FILE__)
|
2
|
-
|
3
|
-
describe "Friendly::NamedScope" do
|
4
|
-
before do
|
5
|
-
@klass = stub
|
6
|
-
@scope = stub
|
7
|
-
@scope_klass = stub
|
8
|
-
@parameters = {:name => "James"}
|
9
|
-
@scope_klass.stubs(:new).with(@klass, @parameters).returns(@scope)
|
10
|
-
@named_scope = Friendly::NamedScope.new(@klass, @parameters, @scope_klass)
|
11
|
-
end
|
12
|
-
|
13
|
-
it "provides scope instances with the given parameters" do
|
14
|
-
@named_scope.scope.should == @scope
|
15
|
-
end
|
16
|
-
end
|