typ 0.0.0 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/typ.rb +39 -31
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e38d74e0f2bb298612cbc9c76ce190d53537d1a204d00821f7d28a3afcc9ab6
|
4
|
+
data.tar.gz: 17d1212f324b8da8f7170d19e94f144f308d1dca53bf5b6697a68d742b79b52c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a96d036cc19728923e36e888663f6ba35ed18c1e168180f52344024be92c4d6f66a6480c8037fa7cfc644e166e10f6128f2973286eb88746681683b582489a11
|
7
|
+
data.tar.gz: fae6fb96a7f0ce79a5ceec290c597f1801e20647c438fcf5fbd3a06a252126cd17b5eae51008a3c4db0e1a76995a8f24699d2f525419b061194748e68b784052
|
data/lib/typ.rb
CHANGED
@@ -1,44 +1,56 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
def is type
|
5
|
-
case type
|
6
|
-
when Array
|
7
|
-
gates << Gate::FromArray[type]
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
def gates
|
13
|
-
@gates ||= []
|
14
|
-
end
|
15
|
-
|
16
|
-
include DSL
|
1
|
+
module Typ
|
2
|
+
def self.included mod
|
3
|
+
mod.extend DSL
|
17
4
|
end
|
18
|
-
|
19
|
-
def initialize
|
20
|
-
@
|
21
|
-
@gates = self.class.gates.map { |gate| gate.new
|
5
|
+
|
6
|
+
def initialize it
|
7
|
+
@it = it
|
8
|
+
@gates = self.class.gates.map { |gate| gate.new it }
|
22
9
|
@fails = gates.reject &:ok?
|
23
10
|
end
|
24
11
|
|
25
|
-
attr_reader :
|
12
|
+
attr_reader :it, :gates, :fails
|
26
13
|
|
27
14
|
def ok?
|
28
15
|
fails.empty?
|
29
16
|
end
|
30
|
-
|
31
|
-
extend Singleton
|
32
17
|
|
33
|
-
|
18
|
+
module DSL
|
19
|
+
def gates
|
20
|
+
@gates ||= []
|
21
|
+
end
|
22
|
+
|
23
|
+
def is type
|
24
|
+
case type
|
25
|
+
when Array
|
26
|
+
gates << Is::Array[type]
|
27
|
+
when Class
|
28
|
+
if type.include? Typ
|
29
|
+
gates << type
|
30
|
+
else
|
31
|
+
fail "don't know how to create a Gate from #{type}"
|
32
|
+
end
|
33
|
+
else
|
34
|
+
fail "don't know how to create a Gate from #{type}"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
class Is
|
40
|
+
class << self
|
41
|
+
attr_accessor :check
|
42
|
+
end
|
43
|
+
|
44
|
+
def initialize object
|
45
|
+
@ok = self.class.check[object]
|
46
|
+
end
|
47
|
+
|
34
48
|
def ok?
|
35
49
|
@ok
|
36
50
|
end
|
37
51
|
|
38
|
-
class
|
52
|
+
class Array < self
|
39
53
|
class << self
|
40
|
-
attr_accessor :check
|
41
|
-
|
42
54
|
def [] array
|
43
55
|
check = if array[0].is_a?(Symbol)
|
44
56
|
method, *arguments = array
|
@@ -55,10 +67,6 @@ class Typ
|
|
55
67
|
gate
|
56
68
|
end
|
57
69
|
end
|
58
|
-
|
59
|
-
def initialize object
|
60
|
-
@ok = self.class.check[object]
|
61
|
-
end
|
62
70
|
end
|
63
71
|
end
|
64
72
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: typ
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anatoly Chernow
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-04-
|
11
|
+
date: 2018-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|