typ-formatter 0.0.0 → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/typ/formatter.rb +7 -6
  3. metadata +16 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9a5439dcb401b6077dc54c879aa4ef4111ab4e95f3b196e471d3913b0064d8b4
4
- data.tar.gz: f4e0d58a682dd2ea51673b5ceed45a92991b4a1d23c83fc0ce0f0876d7b43bf2
3
+ metadata.gz: 6522c7f41d30df7d82236ede88fca85320cd95136dfbff7dc8438a6382d6af57
4
+ data.tar.gz: 558497ea18a4308f1624a7eea1c21cbf5924a6dedf663ac2ce334cf03c75471d
5
5
  SHA512:
6
- metadata.gz: 672e493e75e6764e16fb49673e762bdcb7a2149a6ff554b86dc25ed58aeffe3eea384545e5fbbe62276fd5c96df8136fd528825a0814b07df6957a9821f97231
7
- data.tar.gz: e9d5afd8122b9321f3faa5208250e440550e9f0a678ee25e22adaa2ef1381a305d8d8ba8dedc72213f1781ae119ef7893d86d75b14fd73db6cfbcdc6200dabe5
6
+ metadata.gz: 97b8fc7789164463b01624af3a77f90756bcba5cb782fdac57f5971b6514c73e4d7da5c30a42299a520084e2f420c361fca6058d0f24e6e3f3ae089a925e4f6b
7
+ data.tar.gz: eda281ba1becce128b864f4586a7537668622c5e39094daa59c826fe633f9b31de5f0bdb195d15cde7e75216407759cee6686a25f25dcee3a8d03d02868edff0
data/lib/typ/formatter.rb CHANGED
@@ -1,13 +1,14 @@
1
1
  module Typ
2
2
  class Formatter
3
+ require 'string/indent'
3
4
  require 'rainbow'
4
5
 
5
6
  def initialize typ
6
- name = typ.class.name
7
+ k = typ.class
7
8
  @string = if typ.ok?
8
- Rainbow(name).green
9
+ Rainbow(k).green
9
10
  else
10
- Rainbow(name).red + "\n" + format_gates_of(typ)
11
+ Rainbow(k).red + "\n" + format_gates_of(typ).indent(2)
11
12
  end
12
13
  end
13
14
 
@@ -18,15 +19,15 @@ module Typ
18
19
  private
19
20
  def format_gates_of typ
20
21
  typ.gates.map do |gate|
21
- " #{format_gate gate}"
22
+ format_gate gate
22
23
  end.join "\n"
23
24
  end
24
25
 
25
26
  def format_gate gate
26
27
  case gate
27
28
  when Typ
28
- self.class.new(gate).to_s
29
- when Typ::Is::Array
29
+ self.class.new gate
30
+ when Is::Array
30
31
  format_is_array gate
31
32
  end
32
33
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: typ-formatter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.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-27 00:00:00.000000000 Z
11
+ date: 2018-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rainbow
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: string-indent
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  description:
28
42
  email:
29
43
  executables: []