storable 0.8.0 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES.txt +5 -0
- data/lib/storable.rb +10 -9
- data/storable.gemspec +1 -1
- metadata +4 -4
data/CHANGES.txt
CHANGED
@@ -3,6 +3,11 @@ 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.1 (2010-07-31) #############################
|
7
|
+
|
8
|
+
* CHANGE: to_delimited and from_delimited are sensitive. This means you need to keep
|
9
|
+
track of data that is sensitive.
|
10
|
+
|
6
11
|
#### 0.8.0 (2010-07-28) #############################
|
7
12
|
|
8
13
|
* FIXED: from_delimited now gracefully handles String input by splitting it by $/
|
data/lib/storable.rb
CHANGED
@@ -40,7 +40,7 @@ class Storable
|
|
40
40
|
require 'proc_source'
|
41
41
|
require 'storable/orderedhash' if USE_ORDERED_HASH
|
42
42
|
unless defined?(SUPPORTED_FORMATS) # We can assume all are defined
|
43
|
-
VERSION = "0.8.
|
43
|
+
VERSION = "0.8.1"
|
44
44
|
NICE_TIME_FORMAT = "%Y-%m-%d@%H:%M:%S".freeze
|
45
45
|
SUPPORTED_FORMATS = [:tsv, :csv, :yaml, :json, :s, :string].freeze
|
46
46
|
end
|
@@ -322,7 +322,7 @@ class Storable
|
|
322
322
|
#p [:to, ret.encoding.name] if ret.respond_to?(:encoding)
|
323
323
|
ret
|
324
324
|
elsif JSON_LOADED
|
325
|
-
|
325
|
+
JSON.generate(hash, *from, &blk)
|
326
326
|
else
|
327
327
|
raise "no JSON parser loaded"
|
328
328
|
end
|
@@ -375,7 +375,8 @@ class Storable
|
|
375
375
|
# +delim+ is the field delimiter.
|
376
376
|
def to_delimited(with_titles=false, delim=',')
|
377
377
|
values = []
|
378
|
-
field_names
|
378
|
+
fields = sensitive? ? (field_names-sensitive_fields) : field_names
|
379
|
+
fields.each do |fname|
|
379
380
|
values << self.send(fname.to_s) # TODO: escape values
|
380
381
|
end
|
381
382
|
output = values.join(delim)
|
@@ -394,24 +395,24 @@ class Storable
|
|
394
395
|
end
|
395
396
|
# Create a new instance from tab-delimited data.
|
396
397
|
# +from+ a JSON string split into an array by line.
|
397
|
-
def self.from_tsv(from=[])
|
398
|
-
self.from_delimited(from, "\t")
|
398
|
+
def self.from_tsv(from=[], sensitive=false)
|
399
|
+
self.from_delimited(from, "\t", sensitive)
|
399
400
|
end
|
400
401
|
# Create a new instance of the object from comma-delimited data.
|
401
402
|
# +from+ a JSON string split into an array by line.
|
402
|
-
def self.from_csv(from=[])
|
403
|
-
self.from_delimited(from, ',')
|
403
|
+
def self.from_csv(from=[], sensitive=false)
|
404
|
+
self.from_delimited(from, ',', sensitive)
|
404
405
|
end
|
405
406
|
|
406
407
|
# Create a new instance of the object from a delimited string.
|
407
408
|
# +from+ a JSON string split into an array by line.
|
408
409
|
# +delim+ is the field delimiter.
|
409
|
-
def self.from_delimited(from=[],delim=',')
|
410
|
+
def self.from_delimited(from=[],delim=',',sensitive=false)
|
410
411
|
return if from.empty?
|
411
412
|
from = from.split($/) if String === from
|
412
413
|
hash = {}
|
413
414
|
|
414
|
-
fnames =
|
415
|
+
fnames = sensitive ? (field_names-sensitive_fields) : field_names
|
415
416
|
values = from[0].chomp.split(delim)
|
416
417
|
|
417
418
|
fnames.each_with_index do |key,index|
|
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.1"
|
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: 61
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 8
|
9
|
-
-
|
10
|
-
version: 0.8.
|
9
|
+
- 1
|
10
|
+
version: 0.8.1
|
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-07-
|
18
|
+
date: 2010-07-31 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|