Permalink
Browse files

Release 0.7.3 (Storable#call, Storable::Anonymous, Range support)

  • Loading branch information...
1 parent f13def2 commit 87e937b1459de14da92834d0a80b4586ee341eeb @delano committed Apr 9, 2010
Showing with 27 additions and 5 deletions.
  1. +3 −1 CHANGES.txt
  2. +5 −2 README.rdoc
  3. +18 −1 lib/storable.rb
  4. +1 −1 storable.gemspec
View
@@ -3,11 +3,13 @@ STORABLE, CHANGES
* TODO: Handle nested hashes and arrays.
* TODO: to_xml, see: http://codeforpeople.com/lib/ruby/xx/xx-2.0.0/README
-#### 0.7.3 (2010-04-??) #############################
+#### 0.7.3 (2010-04-10) #############################
* ADDED: Allow anonymous objects via Storable.from_json etc.
* ADDED: Enabled support for marshalling Proc objects in IRB sessions.
* ADDED: Storable#call for calling Proc fields via instance_eval
+* ADDED: Support for Range field type (parse from a String when necessary)
+
#### 0.7.2 (2010-04-06) #############################
View
@@ -33,8 +33,8 @@ Storable can also marshal Proc objects to and from their actual source code.
require 'storable'
class Maths < Storable
- field :x => Float
- field :y => Float
+ field :x => Float
+ field :y => Float
field :calculate => Proc
end
@@ -50,6 +50,9 @@ Storable can also marshal Proc objects to and from their actual source code.
mat2.call :calculate # => 6.0
+Anything is possible when you keep your mind open and you use Ruby.
+
+
== Installation
Via Rubygems, one of:
View
@@ -39,7 +39,7 @@ class Storable
require 'proc_source'
require 'storable/orderedhash' if USE_ORDERED_HASH
unless defined?(SUPPORTED_FORMATS) # We can assume all are defined
- VERSION = "0.7.2"
+ VERSION = "0.7.3"
NICE_TIME_FORMAT = "%Y-%m-%d@%H:%M:%S".freeze
SUPPORTED_FORMATS = [:tsv, :csv, :yaml, :json, :s, :string].freeze
end
@@ -211,6 +211,23 @@ def from_hash(from={})
value = value_orig.to_i
elsif ftype == Symbol
value = value_orig.to_s.to_sym
+ elsif ftype == Range
+ if Range === value_orig
+ value = value_orig
+ elsif Numeric === value_orig
+ value = value_orig..value_orig
+ else
+ value_orig = value_orig.to_s
+ if value_orig.match(/\.\.\./)
+ el = value_orig.split('...')
+ value = el.first.to_f...el.last.to_f
+ elsif value_orig.match(/\.\./)
+ el = value_orig.split('..')
+ value = el.first.to_f..el.last.to_f
+ else
+ value = value_orig..value_orig
+ end
+ end
elsif ftype == Proc && String === value_orig
value = Proc.from_string value_orig
end
View
@@ -1,7 +1,7 @@
@spec = Gem::Specification.new do |s|
s.name = "storable"
s.rubyforge_project = "storable"
- s.version = "0.7.2"
+ s.version = "0.7.3"
s.summary = "Storable: Marshal Ruby classes into and out of multiple formats (yaml, json, csv, tsv)"
s.description = s.summary
s.author = "Delano Mandelbaum"

0 comments on commit 87e937b

Please sign in to comment.