dorian-to_struct 0.6.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/to_struct +12 -0
- data/lib/dorian/to_struct.rb +2 -10
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e94fed03af12d2dde58f30d58269be8660b31c6d34676c12e578171e55046a8
|
4
|
+
data.tar.gz: 8623cad9f317985b9e89a18ddc16d0764cb39eb0f6d4d6d100fa84eadfd0cddf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5c11c0f204b936a5424a1567245fb005679a3582e353fbaf4a05cf92129b930150e89f6352db8d0bb00ff28f66deb6461e908665bb5b8095921ea9e5ce337fe
|
7
|
+
data.tar.gz: d8823c92d7278b39a06829aacad8f51d90310da4e23fa0f577cef225c04028774f1e5e93c9f97e708f999ade06adb86c62044e32f9c3070b8b99f0894cdf6665
|
data/bin/to_struct
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "dorian/arguments"
|
5
|
+
|
6
|
+
parsed = Dorian::Arguments.parse(version: { alias: :v }, help: { alias: :h })
|
7
|
+
|
8
|
+
if parsed.options.version
|
9
|
+
abort File.read(File.expand_path("../../VERSION", __FILE__))
|
10
|
+
else
|
11
|
+
abort parsed.help
|
12
|
+
end
|
data/lib/dorian/to_struct.rb
CHANGED
@@ -10,19 +10,11 @@ end
|
|
10
10
|
|
11
11
|
class Hash
|
12
12
|
def to_struct
|
13
|
-
Struct.new(
|
14
|
-
*keys.map(&:to_sym)
|
15
|
-
).new(
|
16
|
-
*values
|
17
|
-
)
|
13
|
+
Struct.new(*keys.map(&:to_sym)).new(*values)
|
18
14
|
end
|
19
15
|
|
20
16
|
def to_deep_struct
|
21
|
-
Struct.new(
|
22
|
-
*keys.map(&:to_sym)
|
23
|
-
).new(
|
24
|
-
*values.map(&:to_deep_struct)
|
25
|
-
)
|
17
|
+
Struct.new(*keys.map(&:to_sym)).new(*values.map(&:to_deep_struct))
|
26
18
|
end
|
27
19
|
end
|
28
20
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dorian-to_struct
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dorian Marié
|
@@ -12,10 +12,12 @@ date: 2024-08-24 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
13
13
|
description: makes structs
|
14
14
|
email: dorian@dorianmarie.com
|
15
|
-
executables:
|
15
|
+
executables:
|
16
|
+
- to_struct
|
16
17
|
extensions: []
|
17
18
|
extra_rdoc_files: []
|
18
19
|
files:
|
20
|
+
- bin/to_struct
|
19
21
|
- lib/dorian-to_struct.rb
|
20
22
|
- lib/dorian/to_struct.rb
|
21
23
|
homepage: https://github.com/dorianmariecom/dorian-to_struct
|