recsym 1.0.0.alpha.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/recsym.rb +46 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8e4425bf7d2147fb8d985414100bf082819a26b1
|
4
|
+
data.tar.gz: 258c36d3de076001af2b61cd0b813ba5ffa2872b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 523ecc564ebe4014fe11895c3ecc53097fc213319a30c92fb29d300f629af623e7b4795f551357efe14b7070526882445ff12e769bf9bcd4d7d5301427932476
|
7
|
+
data.tar.gz: de9c23056c8fd1de74fd96ba271b6ec2c24713b14f3b6290eb6b357b4fbbc046e7766a3f3b5e36ed2c8e31f234f2e434bf9e797e8e3f2e864e47d4a6e9cd70dc
|
data/lib/recsym.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
|
2
|
+
module RecSym
|
3
|
+
|
4
|
+
def self.this(thing)
|
5
|
+
s = Symbolizer.new
|
6
|
+
s.symbolized(thing)
|
7
|
+
end
|
8
|
+
|
9
|
+
class Symbolizer
|
10
|
+
|
11
|
+
attr_reader :known
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
@known = {}
|
15
|
+
end
|
16
|
+
|
17
|
+
def symbolized(thing)
|
18
|
+
k = thing.object_id
|
19
|
+
return known[k] if known.key? k
|
20
|
+
|
21
|
+
if thing.is_a? Hash
|
22
|
+
retval = {}
|
23
|
+
known[k] = retval
|
24
|
+
|
25
|
+
thing.each do |k, v|
|
26
|
+
key = (k.respond_to? :to_sym) ? k.to_sym : k
|
27
|
+
value = symbolized(v)
|
28
|
+
retval[key] = value
|
29
|
+
end
|
30
|
+
|
31
|
+
elsif thing.is_a? Array
|
32
|
+
retval = []
|
33
|
+
known[k] = retval
|
34
|
+
|
35
|
+
thing.each do |x|
|
36
|
+
retval.push symbolized(x)
|
37
|
+
end
|
38
|
+
|
39
|
+
else
|
40
|
+
known[k] = thing
|
41
|
+
end
|
42
|
+
|
43
|
+
known[k]
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: recsym
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0.alpha.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Brian Lauber
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-12-24 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Recursively symbolize Hashes
|
14
|
+
email: constructible.truth@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/recsym.rb
|
20
|
+
homepage:
|
21
|
+
licenses:
|
22
|
+
- MIT
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">"
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 1.3.1
|
38
|
+
requirements: []
|
39
|
+
rubyforge_project:
|
40
|
+
rubygems_version: 2.2.2
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: Recursively symbolize Hashes
|
44
|
+
test_files: []
|