thy 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 +4 -4
- data/lib/thy/types.rb +35 -0
- data/lib/thy.rb +3 -26
- data/thy.gemspec +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c5aadd3586867c71c7898b826f50b095508d1970208e4a621f69128c62b3f84f
|
4
|
+
data.tar.gz: c366b9fad12c61d8cfc228d3f10f02c82468895cc66cf0e2ea47f20f95a790d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c452ec7674c375fb0d5ba7408cce8c9d6e45d1a6b0101961cbdc5f09c96cfaefa704a6ce959d93454e453b3e196006a44d4103a4b51a8469f4f5e772a68a39fd
|
7
|
+
data.tar.gz: 818d142c82ed6fc29e66dbf6e4ccd039232f335b87a732b66cb4001c910d0f2389e96a09d24758a106a9dc99a9f1f898dba6bd2a380b4715422740f3a25f2267
|
data/lib/thy/types.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Thy::Types
|
4
|
+
def self.included(mod)
|
5
|
+
mod.extend(ClassMethods)
|
6
|
+
end
|
7
|
+
|
8
|
+
module ClassMethods
|
9
|
+
# rubocop:disable Naming/MethodName
|
10
|
+
def Array(type)
|
11
|
+
Array.new(type)
|
12
|
+
end
|
13
|
+
|
14
|
+
def Hash(schema)
|
15
|
+
Hash.new(schema)
|
16
|
+
end
|
17
|
+
|
18
|
+
def Map(key_type, value_type)
|
19
|
+
Map.new(key_type, value_type)
|
20
|
+
end
|
21
|
+
|
22
|
+
def Enum(*types)
|
23
|
+
Enum.new(types)
|
24
|
+
end
|
25
|
+
|
26
|
+
def Variant(*values)
|
27
|
+
Variant.new(values)
|
28
|
+
end
|
29
|
+
|
30
|
+
def Option(type)
|
31
|
+
Option.new(type)
|
32
|
+
end
|
33
|
+
# rubocop:enable Naming/MethodName
|
34
|
+
end
|
35
|
+
end
|
data/lib/thy.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'thy/type'
|
4
|
+
require 'thy/types'
|
4
5
|
|
5
6
|
require 'thy/types/string'
|
6
7
|
require 'thy/types/symbol'
|
@@ -34,6 +35,8 @@ module Thy
|
|
34
35
|
Integer = Types::Integer
|
35
36
|
Boolean = Types::Boolean
|
36
37
|
|
38
|
+
include Types
|
39
|
+
|
37
40
|
class << self
|
38
41
|
def refine_type(type_1, type_2)
|
39
42
|
Type.new do |value|
|
@@ -45,31 +48,5 @@ module Thy
|
|
45
48
|
end
|
46
49
|
end
|
47
50
|
end
|
48
|
-
|
49
|
-
# rubocop:disable Naming/MethodName
|
50
|
-
def Array(type)
|
51
|
-
Types::Array.new(type)
|
52
|
-
end
|
53
|
-
|
54
|
-
def Hash(schema)
|
55
|
-
Types::Hash.new(schema)
|
56
|
-
end
|
57
|
-
|
58
|
-
def Map(key_type, value_type)
|
59
|
-
Types::Map.new(key_type, value_type)
|
60
|
-
end
|
61
|
-
|
62
|
-
def Enum(*types)
|
63
|
-
Types::Enum.new(types)
|
64
|
-
end
|
65
|
-
|
66
|
-
def Variant(*values)
|
67
|
-
Types::Variant.new(values)
|
68
|
-
end
|
69
|
-
|
70
|
-
def Option(type)
|
71
|
-
Types::Option.new(type)
|
72
|
-
end
|
73
|
-
# rubocop:enable Naming/MethodName
|
74
51
|
end
|
75
52
|
end
|
data/thy.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: thy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Komarov <ak@akxcv.com>
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-09-
|
11
|
+
date: 2019-09-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -102,6 +102,7 @@ files:
|
|
102
102
|
- lib/thy/result/failure.rb
|
103
103
|
- lib/thy/result/success.rb
|
104
104
|
- lib/thy/type.rb
|
105
|
+
- lib/thy/types.rb
|
105
106
|
- lib/thy/types/array.rb
|
106
107
|
- lib/thy/types/boolean.rb
|
107
108
|
- lib/thy/types/enum.rb
|