paulcarey-relaxdb 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.textile CHANGED
@@ -1,5 +1,7 @@
1
1
  h3. What's New?
2
2
 
3
+ * Time storage changes. All Time objects are now converted to UTC and formatted as %Y/%m/%d %H:%M:%S +0000. Storing all Times as UTC should have been happening anyway. Formatting Times as above (as opposed to ISO 8601 as was done prior to 0.2.3) allows the Time strings to be passed directly to Date.new in a JavaScript interpreter.
4
+
3
5
  * Pagination! CouchDB offers great support for retrieving a subset of data, but the housekeeping is tricky. RelaxDB takes care of it.
4
6
  ** Note that if you invoke paginate_by on an already created view, the necessary reduce function won't be automatically created. Take a look at SortedByView and create the reduce func by hand.
5
7
  * Support for multi key post
data/Rakefile CHANGED
@@ -4,7 +4,7 @@ require 'spec/rake/spectask'
4
4
 
5
5
  PLUGIN = "relaxdb"
6
6
  NAME = "relaxdb"
7
- GEM_VERSION = "0.2.2"
7
+ GEM_VERSION = "0.2.3"
8
8
  AUTHOR = "Paul Carey"
9
9
  EMAIL = "paul.p.carey@gmail.com"
10
10
  HOMEPAGE = "http://github.com/paulcarey/relaxdb/"
@@ -81,7 +81,7 @@ module RelaxDB
81
81
 
82
82
  # If the variable name ends in _at try to convert it to a Time
83
83
  if key =~ /_at$/
84
- val = Time.local(*ParseDate.parsedate(val)) rescue val
84
+ val = Time.parse(val).utc rescue val
85
85
  end
86
86
 
87
87
  # Ignore param keys that don't have a corresponding writer
@@ -1,3 +1,15 @@
1
1
  class Errors < Hash
2
2
  alias_method :on, :[]
3
3
  end
4
+
5
+ class Time
6
+
7
+ # Ensure that all Times are stored as UTC
8
+ # Times in the following format may be passed directly to
9
+ # Date.new in a JavaScript runtime
10
+ def to_json
11
+ utc
12
+ %Q("#{strftime "%Y/%m/%d %H:%M:%S +0000"}")
13
+ end
14
+
15
+ end
@@ -22,7 +22,7 @@ describe RelaxDB::Document do
22
22
  Atom.new._rev.should be_nil
23
23
  end
24
24
 
25
- it "should convert attributes that end in _at to dates" do
25
+ it "should convert attributes that end in _at to Times" do
26
26
  now = Time.now
27
27
  p = Post.new(:viewed_at => now).save
28
28
  p = RelaxDB.load(p._id)
@@ -44,6 +44,13 @@ describe RelaxDB::Document do
44
44
  Atom.new.to_json.should_not include("rev")
45
45
  end
46
46
 
47
+ it "should convert times to '%Y/%m/%d %H:%M:%S +0000' format" do
48
+ s = Time.at(0)
49
+ p = Primitives.new(:created_at => s).save
50
+ json = RelaxDB.get(p._id)
51
+ json["created_at"].should == "1970/01/01 00:00:00 +0000"
52
+ end
53
+
47
54
  end
48
55
 
49
56
  describe "#save" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paulcarey-relaxdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Carey