From e411207b790249fd69e4fd4184f3b3e01d377034 Mon Sep 17 00:00:00 2001 From: Chris Anderson Date: Thu, 11 Sep 2008 21:00:44 -0700 Subject: [PATCH] more sweeping changes --- lib/couchrest.rb | 17 +++++++++++++ lib/couchrest/couchrest.rb | 29 ---------------------- lib/{couch_rest.rb => couchrest/server.rb} | 0 lib/monkeypatches.rb | 22 ++++++++++++++++ 4 files changed, 39 insertions(+), 29 deletions(-) create mode 100644 lib/couchrest.rb delete mode 100644 lib/couchrest/couchrest.rb rename lib/{couch_rest.rb => couchrest/server.rb} (100%) create mode 100644 lib/monkeypatches.rb diff --git a/lib/couchrest.rb b/lib/couchrest.rb new file mode 100644 index 0000000..d3a5366 --- /dev/null +++ b/lib/couchrest.rb @@ -0,0 +1,17 @@ +require "rubygems" +require 'json' +require 'rest_client' + +$:.unshift File.expand_path(File.dirname(__FILE__)) + + +require 'monkeypatches' +require 'lib/server' +require 'lib/database' + + +module CouchRest + def self.new(*opts) + Server.new(*opts) + end +end \ No newline at end of file diff --git a/lib/couchrest/couchrest.rb b/lib/couchrest/couchrest.rb deleted file mode 100644 index 3cb4b03..0000000 --- a/lib/couchrest/couchrest.rb +++ /dev/null @@ -1,29 +0,0 @@ -require "rubygems" -require 'json' -require 'rest_client' - -require File.dirname(__FILE__) + '/couch_rest' -require File.dirname(__FILE__) + '/database' -require File.dirname(__FILE__) + '/pager' -require File.dirname(__FILE__) + '/file_manager' -require File.dirname(__FILE__) + '/streamer' - -# this has to come after the JSON gem - -# this date format sorts lexicographically -# and is compatible with Javascript's new Date(time_string) constructor -# note that sorting will break if you store times from multiple timezones -# I like to add a ENV['TZ'] = 'UTC' to my apps -class Time - def to_json(options = nil) - %("#{strftime("%Y/%m/%d %H:%M:%S %z")}") - end - # this works to decode the outputted time format - # from ActiveSupport - # def self.parse string, fallback=nil - # d = DateTime.parse(string).new_offset - # self.utc(d.year, d.month, d.day, d.hour, d.min, d.sec) - # rescue - # fallback - # end -end \ No newline at end of file diff --git a/lib/couch_rest.rb b/lib/couchrest/server.rb similarity index 100% rename from lib/couch_rest.rb rename to lib/couchrest/server.rb diff --git a/lib/monkeypatches.rb b/lib/monkeypatches.rb new file mode 100644 index 0000000..b35dce2 --- /dev/null +++ b/lib/monkeypatches.rb @@ -0,0 +1,22 @@ + +# this file must be loaded after the JSON gem + +class Time + # this date format sorts lexicographically + # and is compatible with Javascript's new Date(time_string) constructor + # note that sorting will break if you store times from multiple timezones + # I like to add a ENV['TZ'] = 'UTC' to my apps + + def to_json(options = nil) + %("#{strftime("%Y/%m/%d %H:%M:%S %z")}") + end + + # this works to decode the outputted time format + # copied from ActiveSupport + # def self.parse string, fallback=nil + # d = DateTime.parse(string).new_offset + # self.utc(d.year, d.month, d.day, d.hour, d.min, d.sec) + # rescue + # fallback + # end +end \ No newline at end of file