candy 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/HISTORY.markdown +25 -11
- data/VERSION +1 -1
- data/candy.gemspec +2 -2
- data/lib/candy/collection.rb +3 -6
- data/lib/candy/crunch.rb +2 -1
- data/spec/candy/crunch_spec.rb +2 -2
- metadata +3 -3
data/.gitignore
CHANGED
data/HISTORY.markdown
CHANGED
@@ -1,18 +1,29 @@
|
|
1
|
-
|
1
|
+
Candy History
|
2
|
+
=============
|
2
3
|
|
3
4
|
This document aims to provide only an overview. Further, we've only really been tracking things since **v0.2**. For obsessive detail, just check out the `git log`.
|
4
5
|
|
5
|
-
|
6
|
+
v0.2.5 - 2010-05-02 (the "John::Jacob::Jingleheimer::Schmidt" release)
|
7
|
+
----------------------------------------------------------------------
|
8
|
+
As I was building an app based on several Sinatra building blocks, I realized that Candy was creating collection names like **Login::Person** and **Profile::Person** with complete module namespaces. I wanted both of those **Person** classes to be different views on the same data, and having to override the collection name each time was becoming a pain. I'm not sure that fully namespacing the collection names inside Mongo has much value, and we weren't really documenting that it was happening, so I've simplified things.
|
6
9
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
+
* Default collection names no longer include module namespace paths
|
11
|
+
|
12
|
+
|
13
|
+
v0.2.4 - 2010-04-21 (the "No shortcuts!" release)
|
14
|
+
-------------------------------------------------
|
15
|
+
While building validations and custom behavior on a new app, I realized that
|
16
|
+
any method overrides in my classes were being bypassed if I passed the values
|
17
|
+
in a hash to .new() -- it was just setting everything straight in Mongo.
|
18
|
+
Inconsistent behavior is uncool. So now every hash key calls the relevant
|
19
|
+
assignment method in the class.
|
10
20
|
|
11
21
|
* Values passed in hash to new objects call the relevant assignment methods
|
12
22
|
* Fixed typo in README (thanks, kfl62)
|
13
23
|
|
14
|
-
## v0.2.3 - 2010-04-13 (the "around and around we go") release
|
15
24
|
|
25
|
+
v0.2.3 - 2010-04-13 (the "around and around we go") release
|
26
|
+
-----------------------------------------------------------
|
16
27
|
Turns out some Rails environments get really ornery if you introduce circular dependencies into your code. Like, say, requiring 'candy/hash' inside 'candy/piece' and 'candy/piece' inside 'candy/hash'. Who knew?
|
17
28
|
|
18
29
|
(Rhetorical question. _I_ should have known. I'll restructure later to remove the breakage.)
|
@@ -20,22 +31,24 @@ Turns out some Rails environments get really ornery if you introduce circular de
|
|
20
31
|
* Stubbed out Candy::Piece to resolve circular dependency issue
|
21
32
|
|
22
33
|
|
23
|
-
|
24
|
-
|
34
|
+
v0.2.2 - 2010-04-12 (the "I hate reporting bugs to the MongoDB team" release)
|
35
|
+
-----------------------------------------------------------------------------
|
25
36
|
The Mongo gem has broken the BSON functions out into a separate bson gem, so I had to fix things. This means Candy is no longer compatible with the Mongo gem < 0.20.1. Que sera. (Also, the bson_ext gem **must** be installed due to a bug. I'll remove the dependency when they fix it.) Additional minor bonus: authentication.
|
26
37
|
|
27
38
|
* New BSON::* classes correctly referenced in Candy::Wrapper
|
28
39
|
* Candy.username and Candy.password properties to automatically authenticate at the global level
|
29
40
|
* Class-specific .username and .password properties for class-specific databases
|
30
41
|
|
31
|
-
## v0.2.1 - 2010-04-04 (the "Oops" release)
|
32
42
|
|
43
|
+
v0.2.1 - 2010-04-04 (the "Oops" release)
|
44
|
+
----------------------------------------
|
33
45
|
I screwed up in my use of Jeweler, and managed to get my versions out of sync between Github and Rubygems.org. I tried to `gem yank` the one from Rubygems, but it won't let me push again with the same version number. To justify bumping the patch number, I added this changelog. Yeah, I know. Pathetic.
|
34
46
|
|
35
47
|
* The HISTORY file you're reading
|
36
48
|
|
37
|
-
## v0.2.0 - 2010-04-04 (the "Candy for Easter" release)
|
38
49
|
|
50
|
+
v0.2.0 - 2010-04-04 (the "Candy for Easter" release)
|
51
|
+
----------------------------------------------------
|
39
52
|
A nearly total rewrite. Some specs still remain from v0.1, but very little actual code. Added in this release were:
|
40
53
|
|
41
54
|
* Candy::Collection
|
@@ -48,6 +61,7 @@ A nearly total rewrite. Some specs still remain from v0.1, but very little actu
|
|
48
61
|
* The Don't Be a Dick License
|
49
62
|
* Other stuff I've surely forgotten about
|
50
63
|
|
51
|
-
## v0.1 - 2010-02-16
|
52
64
|
|
65
|
+
v0.1 - 2010-02-16
|
66
|
+
-----------------
|
53
67
|
Let's just call this one a "proof of concept" release. It worked, but clumsily. Only Candy::Piece was really implemented, with no embedding, and the bulk of the code was directly in `method_missing`. Global variables like **$MONGO_HOST** were used instead of module properties, and the separation of driver and framework concerns was nonexistent. Please don't look at it. You'll make me blush.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.5
|
data/candy.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{candy}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.5"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Stephen Eley"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-05-03}
|
13
13
|
s.description = %q{Candy provides simple, transparent object persistence for the MongoDB database. Classes that
|
14
14
|
include Candy modules save all properties to Mongo automatically, can be recursively embedded,
|
15
15
|
and can retrieve records with chainable open-ended class methods, eliminating the need for
|
data/lib/candy/collection.rb
CHANGED
@@ -16,16 +16,13 @@ module Candy
|
|
16
16
|
|
17
17
|
attr_reader :_candy_piece
|
18
18
|
|
19
|
-
# Sets the collection that all queries run against
|
20
|
-
# the namespace of the current class. (I.e., if this class is
|
21
|
-
# BigModule::LittleModule::People, `collects :person` will look for
|
22
|
-
# a collection named "BigModule::LittleModule::Person".) You can also
|
19
|
+
# Sets the collection that all queries run against. You can also
|
23
20
|
# specify a class that includes Candy::Piece that will be instantiated
|
24
21
|
# for all found records. Otherwise the collection name is used as a
|
25
22
|
# default, and CandyHash is a fallback.
|
26
23
|
def collects(collection, piece = nil)
|
27
|
-
collectible =
|
28
|
-
piecemeal = (piece ?
|
24
|
+
collectible = camelcase(collection)
|
25
|
+
piecemeal = namespace + (piece ? camelcase(piece) : collectible)
|
29
26
|
self.collection = collectible
|
30
27
|
@_candy_piece = Kernel.qualified_const_get(piecemeal) || CandyHash
|
31
28
|
end
|
data/lib/candy/crunch.rb
CHANGED
@@ -172,8 +172,9 @@ module Candy
|
|
172
172
|
end
|
173
173
|
|
174
174
|
# Returns the collection you gave, or creates a default collection named for the current class.
|
175
|
+
# (By which we mean _just_ the class name, not the full module namespace.)
|
175
176
|
def collection
|
176
|
-
@collection ||= db.collection(name)
|
177
|
+
@collection ||= db.collection(name.sub(/^.*::/,''))
|
177
178
|
end
|
178
179
|
|
179
180
|
# Creates an index on the specified property, with an optional direction specified as either :asc or :desc.
|
data/spec/candy/crunch_spec.rb
CHANGED
@@ -95,7 +95,7 @@ describe Candy::Crunch do
|
|
95
95
|
|
96
96
|
it "clears the collection when you set it" do
|
97
97
|
PeanutBrittle.db = 'candy_test'
|
98
|
-
PeanutBrittle.collection.name.should == PeanutBrittle
|
98
|
+
PeanutBrittle.collection.name.should == 'PeanutBrittle'
|
99
99
|
PeanutBrittle.db = nil
|
100
100
|
PeanutBrittle.instance_variable_get(:@collection).should be_nil
|
101
101
|
end
|
@@ -151,7 +151,7 @@ describe Candy::Crunch do
|
|
151
151
|
end
|
152
152
|
|
153
153
|
it "defaults to the class name" do
|
154
|
-
PeanutBrittle.collection.name.should == PeanutBrittle
|
154
|
+
PeanutBrittle.collection.name.should == 'PeanutBrittle'
|
155
155
|
end
|
156
156
|
|
157
157
|
it "throws an exception if you give it a type it can't recognize" do
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
version: 0.2.
|
8
|
+
- 5
|
9
|
+
version: 0.2.5
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Stephen Eley
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-05-03 00:00:00 -04:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|