Sutto-perennial 1.0.0.1 → 1.0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. data/lib/perennial.rb +1 -1
  2. data/lib/perennial/nash.rb +19 -2
  3. metadata +2 -2
@@ -9,7 +9,7 @@ require 'perennial/exceptions'
9
9
 
10
10
  module Perennial
11
11
 
12
- VERSION = "1.0.0.1"
12
+ VERSION = "1.0.0.2"
13
13
 
14
14
  has_library :dispatchable, :hookable, :loader, :logger, :nash,
15
15
  :loggable, :manifest, :settings, :argument_parser,
@@ -1,8 +1,13 @@
1
1
  require 'yaml'
2
+ require 'time'
3
+
2
4
  module Perennial
3
5
  # A ninja hash. Like OpenStruct, but better
4
6
  class Nash
5
7
 
8
+ cattr_accessor :parse_times
9
+ @@parse_times = true
10
+
6
11
  def self.load_file(path)
7
12
  n = self.new
8
13
  if File.file?(path) && File.readable?(path)
@@ -19,7 +24,10 @@ module Perennial
19
24
 
20
25
  def initialize(initial = {})
21
26
  @table = {}
22
- initial.to_hash.each_pair { |k,v| self[k] = v }
27
+ initial.to_hash.each_pair do |k,v|
28
+ v = Time.parse(v) if @@parse_times && k.to_s =~ /_at$/ && v.is_a?(String)
29
+ self[k] = v
30
+ end
23
31
  end
24
32
 
25
33
  def [](key)
@@ -165,6 +173,10 @@ module Perennial
165
173
  end
166
174
  item
167
175
  end
176
+
177
+ def to_nash
178
+ self
179
+ end
168
180
 
169
181
  protected
170
182
 
@@ -206,7 +218,6 @@ module Perennial
206
218
  name.to_sym
207
219
  end
208
220
 
209
-
210
221
  end
211
222
  end
212
223
 
@@ -214,4 +225,10 @@ class Hash
214
225
  def to_nash
215
226
  Perennial::Nash.new(self)
216
227
  end
228
+ end
229
+
230
+ class NilClass
231
+ def to_nash
232
+ Perennial::Nash.new
233
+ end
217
234
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Sutto-perennial
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.1
4
+ version: 1.0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Darcy Laycock
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-09-19 00:00:00 -07:00
12
+ date: 2009-09-25 00:00:00 -07:00
13
13
  default_executable: perennial
14
14
  dependencies: []
15
15