storable 0.8.3 → 0.8.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES.txt +7 -0
- data/lib/storable.rb +13 -6
- data/storable.gemspec +1 -1
- metadata +4 -4
data/CHANGES.txt
CHANGED
@@ -3,6 +3,13 @@ STORABLE, CHANGES
|
|
3
3
|
* TODO: Handle nested hashes and arrays.
|
4
4
|
* TODO: to_xml, see: http://codeforpeople.com/lib/ruby/xx/xx-2.0.0/README
|
5
5
|
|
6
|
+
#### 0.8.4 (2010-12-23) #############################
|
7
|
+
|
8
|
+
* CHANGE: Moved initialize logic to Storable.from_array.
|
9
|
+
|
10
|
+
NOTE: Classes that rely on this logic when creating
|
11
|
+
new instances will need to call from_array instead!
|
12
|
+
|
6
13
|
|
7
14
|
#### 0.8.3 (2010-11-02) #############################
|
8
15
|
|
data/lib/storable.rb
CHANGED
@@ -35,7 +35,7 @@ class Storable
|
|
35
35
|
require 'proc_source'
|
36
36
|
require 'storable/orderedhash' if USE_ORDERED_HASH
|
37
37
|
unless defined?(SUPPORTED_FORMATS) # We can assume all are defined
|
38
|
-
VERSION = "0.8.
|
38
|
+
VERSION = "0.8.4"
|
39
39
|
NICE_TIME_FORMAT = "%Y-%m-%d@%H:%M:%S".freeze
|
40
40
|
SUPPORTED_FORMATS = [:tsv, :csv, :yaml, :json, :s, :string].freeze
|
41
41
|
end
|
@@ -128,11 +128,7 @@ class Storable
|
|
128
128
|
# +args+ is a list of values to set amongst the fields.
|
129
129
|
# It's assumed that the order values matches the order
|
130
130
|
def initialize(*args)
|
131
|
-
|
132
|
-
break if (index+1) > args.size
|
133
|
-
self.send("#{n}=", args[index])
|
134
|
-
end
|
135
|
-
preprocess if respond_to?(:preprocess)
|
131
|
+
preprocess if respond_to? :preprocess
|
136
132
|
end
|
137
133
|
|
138
134
|
# See SUPPORTED_FORMATS for available values
|
@@ -207,6 +203,17 @@ class Storable
|
|
207
203
|
end
|
208
204
|
end
|
209
205
|
|
206
|
+
def self.from_array(*from)
|
207
|
+
from = from.flatten.compact
|
208
|
+
return nil if !from || from.empty?
|
209
|
+
me = new
|
210
|
+
(self.field_names || []).each_with_index do |n,index|
|
211
|
+
break if index >= from.size
|
212
|
+
me.send("#{n}=", from[index])
|
213
|
+
end
|
214
|
+
me
|
215
|
+
end
|
216
|
+
|
210
217
|
def call(fname)
|
211
218
|
unless field_types[fname.to_sym] == Proc &&
|
212
219
|
Proc === self.send(fname)
|
data/storable.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
@spec = Gem::Specification.new do |s|
|
2
2
|
s.name = "storable"
|
3
3
|
s.rubyforge_project = "storable"
|
4
|
-
s.version = "0.8.
|
4
|
+
s.version = "0.8.4"
|
5
5
|
s.summary = "Storable: Marshal Ruby classes into and out of multiple formats (yaml, json, csv, tsv)"
|
6
6
|
s.description = s.summary
|
7
7
|
s.author = "Delano Mandelbaum"
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: storable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 55
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 8
|
9
|
-
-
|
10
|
-
version: 0.8.
|
9
|
+
- 4
|
10
|
+
version: 0.8.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Delano Mandelbaum
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-12-23 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|