data_crate 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0ac96e96f7bd14c705dc841ba66b4d6a51eaa8551d0935df49db4d6a990226c9
4
- data.tar.gz: deeef65b54ff7e5ac74d0d74b7f6bfaa5437f860f88f84d5b09e4100d00c0976
3
+ metadata.gz: 9e3ddcfe423a88007b72ca2cefdd511af4d810d915ad1df090b640b1ea8c04ce
4
+ data.tar.gz: 500831be31b52904d059debb6e470fcab23bbe8da785122c38b777bdb5c26008
5
5
  SHA512:
6
- metadata.gz: 5a7b9ab6c37891886b1350e4258a984dd349f7c8d864925ca9c33ff018efababbb516cdd31d25b1621cf09e586f6186b67d035fd64f42071134f853510f18af9
7
- data.tar.gz: 846f0d80cea24fae9cdd3f8336b1acf0fb70b23f82f08b0f750bd41eaf0794c4cbfdbeb1185efe336d6c53ef8b6bd9e02636e5164bc7295dd564cd68d6c287db
6
+ metadata.gz: d756de23b6697dc316f5c08935430e4522114bd067e76760082d0dec7c2e30ca3df2f9abdf5e861fe46f0f5ffc87e70d3cfc35293019409885cf262b9f5a6667
7
+ data.tar.gz: 979b48ab961b5b36fc49206273542be1a55ca0654900fb79acd2e3e73ff1daee617a13b522c80d7400d897a7f3deace5bd6c57895242b3b4761228209c3437c8
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- data_crate (0.1.0)
4
+ data_crate (0.1.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/lib/crate/crate.rb CHANGED
@@ -13,6 +13,10 @@ module Crate
13
13
  @_crate_klasses = []
14
14
  end
15
15
 
16
+ def inherited(subclass)
17
+ subclass._initialize(**_options)
18
+ end
19
+
16
20
  def _class(**options, &initializer)
17
21
  Class.new(self) do
18
22
  _initialize(**options)
data/lib/crate/raw.rb CHANGED
@@ -48,18 +48,29 @@ module Crate
48
48
  end
49
49
  end
50
50
 
51
+ def symbolize(object)
52
+ case object
53
+ when Hash
54
+ object.map { |key, value| [key.to_sym, symbolize(value)] }.to_h
55
+ else
56
+ object
57
+ end
58
+ end
59
+
60
+ def make_hash(raw)
61
+ case raw
62
+ when String
63
+ JSON.parse(gsub(raw), symbolize_names: true)
64
+ when Hash
65
+ raw
66
+ else
67
+ raise
68
+ end
69
+ end
70
+
51
71
  def initialize(raw, **options)
52
72
  @options = { logger: Logger.new(nil), severity: Logger::WARN, **options }
53
-
54
- @raw =
55
- case raw
56
- when String
57
- JSON.parse(gsub(raw), symbolize_names: true)
58
- when Hash
59
- raw
60
- else
61
- raise
62
- end
73
+ @raw = symbolize(make_hash(raw))
63
74
  end
64
75
 
65
76
  def to_hash
data/lib/crate/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Crate
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: data_crate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Minwoo Lee
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-11-29 00:00:00.000000000 Z
11
+ date: 2017-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler