storable 0.8.4 → 0.8.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,6 +3,15 @@ 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.5 (2010-12-29) #############################
7
+
8
+ * FIXED: Added calls to preprocess in the to_FORMAT methods.
9
+ * FIXED: Added calls to postprocess in from_delimited
10
+ * CHANGE: Remove initialize completely
11
+ * ADDED: Storable#from_array (instance method)
12
+ * ADDED: Storable#init (a default for Familia objects)
13
+
14
+
6
15
  #### 0.8.4 (2010-12-23) #############################
7
16
 
8
17
  * CHANGE: Moved initialize logic to Storable.from_array.
@@ -1,4 +1,4 @@
1
- = Storable - v0.7
1
+ = Storable - v0.8
2
2
 
3
3
  Marshal Ruby classes into and out of multiple formats (yaml, json, csv, tsv)
4
4
 
@@ -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.4"
38
+ VERSION = "0.8.5"
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
@@ -125,12 +125,6 @@ class Storable
125
125
  # See SUPPORTED_FORMATS for available values.
126
126
  attr_reader :format
127
127
 
128
- # +args+ is a list of values to set amongst the fields.
129
- # It's assumed that the order values matches the order
130
- def initialize(*args)
131
- preprocess if respond_to? :preprocess
132
- end
133
-
134
128
  # See SUPPORTED_FORMATS for available values
135
129
  def format=(v)
136
130
  v &&= v.to_sym
@@ -203,14 +197,23 @@ class Storable
203
197
  end
204
198
  end
205
199
 
206
- def self.from_array(*from)
207
- from = from.flatten.compact
208
- return nil if !from || from.empty?
209
- me = new
200
+ def init *args
201
+ from_array *args
202
+ end
203
+
204
+ def from_array *from
210
205
  (self.field_names || []).each_with_index do |n,index|
211
206
  break if index >= from.size
212
- me.send("#{n}=", from[index])
207
+ send("#{n}=", from[index])
213
208
  end
209
+ end
210
+
211
+ def self.from_array *from
212
+ from = from.flatten.compact
213
+ return nil if !from || from.empty?
214
+ me = new
215
+ me.from_array *from
216
+ me.postprocess
214
217
  me
215
218
  end
216
219
 
@@ -289,6 +292,7 @@ class Storable
289
292
  # Return the object data as a hash
290
293
  # +with_titles+ is ignored.
291
294
  def to_hash
295
+ preprocess if respond_to? :preprocess
292
296
  tmp = USE_ORDERED_HASH ? Storable::OrderedHash.new : {}
293
297
  field_names.each do |fname|
294
298
  next if sensitive? && self.class.sensitive_field?(fname)
@@ -303,6 +307,7 @@ class Storable
303
307
  end
304
308
 
305
309
  def to_array
310
+ preprocess if respond_to? :preprocess
306
311
  fields = sensitive? ? (field_names-sensitive_fields) : field_names
307
312
  fields.collect do |fname|
308
313
  next if sensitive? && self.class.sensitive_field?(fname)
@@ -316,6 +321,7 @@ class Storable
316
321
  end
317
322
 
318
323
  def to_json(*from, &blk)
324
+ preprocess if respond_to? :preprocess
319
325
  hash = to_hash
320
326
  if YAJL_LOADED # set by Storable
321
327
  ret = Yajl::Encoder.encode(hash)
@@ -331,6 +337,7 @@ class Storable
331
337
  end
332
338
 
333
339
  def to_yaml(*from, &blk)
340
+ preprocess if respond_to? :preprocess
334
341
  to_hash.to_yaml(*from, &blk)
335
342
  end
336
343
 
@@ -376,6 +383,7 @@ class Storable
376
383
  # +with_titles+ specifiy whether to include field names (default: false)
377
384
  # +delim+ is the field delimiter.
378
385
  def to_delimited(with_titles=false, delim=',')
386
+ preprocess if respond_to? :preprocess
379
387
  values = []
380
388
  fields = sensitive? ? (field_names-sensitive_fields) : field_names
381
389
  fields.each do |fname|
@@ -1,12 +1,12 @@
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"
4
+ s.version = "0.8.5"
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"
8
8
  s.email = "delano@solutious.com"
9
- s.homepage = "http://solutious.com/"
9
+ s.homepage = "http://github.com/delano/storable/"
10
10
 
11
11
 
12
12
  # = EXECUTABLES =
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: 55
4
+ hash: 53
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 8
9
- - 4
10
- version: 0.8.4
9
+ - 5
10
+ version: 0.8.5
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-12-23 00:00:00 -05:00
18
+ date: 2010-12-30 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -38,7 +38,7 @@ files:
38
38
  - lib/storable/orderedhash.rb
39
39
  - storable.gemspec
40
40
  has_rdoc: true
41
- homepage: http://solutious.com/
41
+ homepage: http://github.com/delano/storable/
42
42
  licenses: []
43
43
 
44
44
  post_install_message: