smart_kv 0.1.1 → 0.1.2

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: 59cbc75d757bbaef98c0cae7421817974595775723a7510d98eb6946eb120174
4
- data.tar.gz: 1e7bcd734e68334b130854c56a07c6c342217d56b2ab04f19c67e3ced4200c98
3
+ metadata.gz: d2f4e9b0792163ebbdc7214f96347f720aff6b0bbebbc96349714593c8f98ad1
4
+ data.tar.gz: 9fbf7f822ea814c20b0d751105a4f4b82a4d975149fe996bc3c66cd56601291b
5
5
  SHA512:
6
- metadata.gz: d398b42576e2649f7a9ea61bac210e236ecb2f7acaec0cdd1f0ff4b3b0b2a972aad6af3615d5b22655b8d6eeca31451aea325b59d2a0468b14b29208d3a57de9
7
- data.tar.gz: b94d548a1ee5839495826c0c7e4c12c53a9dddb55b0aa679ccf6738ba0c45ff9843d4f1dda5e330a494d6036076d606a2279cab8194c5f6980c3accfb03cb626
6
+ metadata.gz: 67d3ae16547ba6236d61bca44185b4f47a3243f669d631520805302f1c7dd19037ce8980cc3d40a9e4c0c394f1d71636450f9de74cb5b25bfc81b9cce127d0c3
7
+ data.tar.gz: 74a4783cd2df32515651fe938384045de8f77d5f43482d97ef0352f84d0b43a7205cc703835e15c5e85dbfa67da35c7b8c18675fa66d38e67af2594a3b6d4b2e
data/Gemfile CHANGED
@@ -2,5 +2,8 @@ source "https://rubygems.org"
2
2
 
3
3
  git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
4
 
5
- # Specify your gem's dependencies in smart_kv.gemspec
6
- gemspec
5
+ gem "bundler", "~> 1.17"
6
+ gem "rake", "~> 10.0"
7
+ gem "rspec", "~> 3.0"
8
+ gem "pry", "~> 0.12"
9
+ gem "pry-byebug", "~> 3.6"
data/Gemfile.lock CHANGED
@@ -1,17 +1,16 @@
1
- PATH
2
- remote: .
3
- specs:
4
- smart_kv (0.1.1)
5
-
6
1
  GEM
7
2
  remote: https://rubygems.org/
8
3
  specs:
4
+ byebug (10.0.2)
9
5
  coderay (1.1.2)
10
6
  diff-lcs (1.3)
11
7
  method_source (0.9.2)
12
8
  pry (0.12.2)
13
9
  coderay (~> 1.1.0)
14
10
  method_source (~> 0.9.0)
11
+ pry-byebug (3.6.0)
12
+ byebug (~> 10.0)
13
+ pry (~> 0.10)
15
14
  rake (10.5.0)
16
15
  rspec (3.8.0)
17
16
  rspec-core (~> 3.8.0)
@@ -33,9 +32,9 @@ PLATFORMS
33
32
  DEPENDENCIES
34
33
  bundler (~> 1.17)
35
34
  pry (~> 0.12)
35
+ pry-byebug (~> 3.6)
36
36
  rake (~> 10.0)
37
37
  rspec (~> 3.0)
38
- smart_kv!
39
38
 
40
39
  BUNDLED WITH
41
40
  1.17.2
data/lib/smart_kv.rb CHANGED
@@ -29,9 +29,18 @@ class SmartKv
29
29
  end
30
30
 
31
31
  def method_missing(m, *args)
32
- @object ||= @object_class <= Hash ? @kv : @object_class.new(@kv)
32
+ @object ||= if @object_class <= Struct
33
+ Struct.new(*@kv.keys).new(*@kv.values)
34
+ elsif @object_class.respond_to?(:members)
35
+ raise "#{ @object_class } struct members don't match" unless (@object_class.members - @kv.keys).empty?
36
+ @object_class.new(*@kv.values)
37
+ elsif @object_class <= Hash
38
+ @kv
39
+ else
40
+ @object_class.new(@kv.to_h)
41
+ end
33
42
  @object.send(m, *args)
34
- end
43
+ end
35
44
 
36
45
  protected
37
46
 
@@ -1,3 +1,3 @@
1
1
  class SmartKv
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
data/smart_kv.gemspec CHANGED
@@ -22,9 +22,4 @@ Gem::Specification.new do |spec|
22
22
  spec.bindir = "exe"
23
23
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
24
  spec.require_paths = ["lib"]
25
-
26
- spec.add_development_dependency "bundler", "~> 1.17"
27
- spec.add_development_dependency "rake", "~> 10.0"
28
- spec.add_development_dependency "rspec", "~> 3.0"
29
- spec.add_development_dependency "pry", "~> 0.12"
30
25
  end
metadata CHANGED
@@ -1,71 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smart_kv
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrian Setyadi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-12-17 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.17'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.17'
27
- - !ruby/object:Gem::Dependency
28
- name: rake
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '10.0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '10.0'
41
- - !ruby/object:Gem::Dependency
42
- name: rspec
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '3.0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '3.0'
55
- - !ruby/object:Gem::Dependency
56
- name: pry
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '0.12'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '0.12'
11
+ date: 2018-12-22 00:00:00.000000000 Z
12
+ dependencies: []
69
13
  description: Best practice of writing configurations by strictly allowing and requiring
70
14
  keys.
71
15
  email: