xvert 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -0
- data/Gemfile.lock +16 -3
- data/README.md +96 -0
- data/assets/jj.gif +0 -0
- data/assets/jt.gif +0 -0
- data/assets/jx.gif +0 -0
- data/assets/jy.gif +0 -0
- data/assets/tj.gif +0 -0
- data/assets/tt.gif +0 -0
- data/assets/tx.gif +0 -0
- data/assets/ty.gif +0 -0
- data/assets/xj.gif +0 -0
- data/assets/xt.gif +0 -0
- data/assets/xx.gif +0 -0
- data/assets/xy.gif +0 -0
- data/assets/yj.gif +0 -0
- data/assets/yt.gif +0 -0
- data/assets/yx.gif +0 -0
- data/assets/yy.gif +0 -0
- data/lib/xvert/cli/json.rb +31 -0
- data/lib/xvert/cli/toml.rb +31 -0
- data/lib/xvert/cli/xml.rb +31 -0
- data/lib/xvert/cli/yaml.rb +31 -0
- data/lib/xvert/cli.rb +6 -43
- data/lib/xvert/version.rb +1 -1
- data/lib/xvert.rb +26 -12
- data/tapes/foo.json +1 -1
- data/tapes/foo.toml +2 -1
- data/tapes/foo.xml +1 -0
- data/tapes/foo.yaml +2 -1
- data/tapes/jj.tape +21 -0
- data/tapes/jx.tape +21 -0
- data/tapes/tt.tape +21 -0
- data/tapes/tx.tape +21 -0
- data/tapes/update.rb +99 -0
- data/tapes/xj.tape +21 -0
- data/tapes/xt.tape +21 -0
- data/tapes/xx.tape +21 -0
- data/tapes/xy.tape +21 -0
- data/tapes/yx.tape +21 -0
- data/tapes/yy.tape +21 -0
- data/xvert.gemspec +3 -1
- metadata +58 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9231fe692aff9177333abefe1e4897344e7fad25bc23f5a2d1ae727e426074ae
|
4
|
+
data.tar.gz: a22c41ca45fca4f9fea325d2681abbe9860b190ef4bd19ca624898428dbafdd7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dee6203944dce7aa431e2b224098cd86123e9bc6a1c1b3ea48f03827fad2d87c87d72408ad26b8d3640d4f37e36cf1a4e7c5bff8cfe6565dc5956992e2419dc4
|
7
|
+
data.tar.gz: 7dbcfbba081b4d14e29393f1360ec4bc2f12784cf07788f02c0e03104e29ff0772328dca3c42eee62d321b315b60ea1ffdc612f3f54d6ddc2f3d96cc71d7b496
|
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
xvert (0.
|
4
|
+
xvert (0.4.0)
|
5
|
+
activesupport (~> 7.0.0)
|
6
|
+
builder (~> 3.2.0)
|
5
7
|
json (~> 2.6.0)
|
6
|
-
rouge (~>
|
8
|
+
rouge (~> 4.1.0)
|
7
9
|
thor (~> 1.2.0)
|
8
10
|
toml-rb (~> 2.2.0)
|
9
11
|
yaml (~> 0.2.0)
|
@@ -11,9 +13,18 @@ PATH
|
|
11
13
|
GEM
|
12
14
|
remote: https://rubygems.org/
|
13
15
|
specs:
|
16
|
+
activesupport (7.0.4.3)
|
17
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
18
|
+
i18n (>= 1.6, < 2)
|
19
|
+
minitest (>= 5.1)
|
20
|
+
tzinfo (~> 2.0)
|
14
21
|
ast (2.4.2)
|
22
|
+
builder (3.2.4)
|
15
23
|
citrus (3.0.2)
|
24
|
+
concurrent-ruby (1.2.2)
|
16
25
|
docile (1.4.0)
|
26
|
+
i18n (1.13.0)
|
27
|
+
concurrent-ruby (~> 1.0)
|
17
28
|
json (2.6.3)
|
18
29
|
minitest (5.18.0)
|
19
30
|
parallel (1.23.0)
|
@@ -23,7 +34,7 @@ GEM
|
|
23
34
|
rake (13.0.6)
|
24
35
|
regexp_parser (2.8.0)
|
25
36
|
rexml (3.2.5)
|
26
|
-
rouge (
|
37
|
+
rouge (4.1.0)
|
27
38
|
rubocop (1.50.2)
|
28
39
|
json (~> 2.3)
|
29
40
|
parallel (~> 1.10)
|
@@ -49,6 +60,8 @@ GEM
|
|
49
60
|
thor (1.2.1)
|
50
61
|
toml-rb (2.2.0)
|
51
62
|
citrus (~> 3.0, > 3.0)
|
63
|
+
tzinfo (2.0.6)
|
64
|
+
concurrent-ruby (~> 1.0)
|
52
65
|
unicode-display_width (2.4.2)
|
53
66
|
yaml (0.2.1)
|
54
67
|
|
data/README.md
CHANGED
@@ -22,19 +22,43 @@ Commands:
|
|
22
22
|
xvert --version, -v # Print Xvert version
|
23
23
|
xvert help [COMMAND] # Describe available commands or one specific command
|
24
24
|
xvert jt # Convert JSON to TOML
|
25
|
+
xvert jx # Convert JSON to XML
|
25
26
|
xvert jy # Convert JSON to YAML
|
26
27
|
xvert tj # Convert TOML to JSON
|
28
|
+
xvert tx # Convert TOML to XML
|
27
29
|
xvert ty # Convert TOML to YAML
|
30
|
+
xvert xj # Convert XML to JSON
|
31
|
+
xvert xt # Convert XML to TOML
|
32
|
+
xvert xy # Convert XML to YAML
|
28
33
|
xvert yj # Convert YAML to JSON
|
29
34
|
xvert yt # Convert YAML to TOML
|
35
|
+
xvert yx # Convert YAML to XML
|
30
36
|
```
|
31
37
|
|
38
|
+
- [JSON to JSON](#json-to-json)
|
32
39
|
- [JSON to TOML](#json-to-toml)
|
40
|
+
- [JSON to XML](#json-to-xml)
|
33
41
|
- [JSON to YAML](#json-to-yaml)
|
34
42
|
- [TOML to JSON](#toml-to-json)
|
43
|
+
- [TOML to TOML](#toml-to-toml)
|
44
|
+
- [TOML to XML](#toml-to-xml)
|
35
45
|
- [TOML to YAML](#toml-to-yaml)
|
46
|
+
- [XML to JSON](#xml-to-json)
|
47
|
+
- [XML to TOML](#xml-to-toml)
|
48
|
+
- [XML to XML](#xml-to-xml)
|
49
|
+
- [XML to YAML](#xml-to-yaml)
|
36
50
|
- [YAML to JSON](#yaml-to-json)
|
37
51
|
- [YAML to TOML](#yaml-to-toml)
|
52
|
+
- [YAML to XML](#yaml-to-xml)
|
53
|
+
- [YAML to YAML](#yaml-to-yaml)
|
54
|
+
|
55
|
+
### JSON to JSON
|
56
|
+
|
57
|
+
```console
|
58
|
+
$ xvert jj < foo.json
|
59
|
+
```
|
60
|
+
|
61
|
+
![](./assets/jj.gif)
|
38
62
|
|
39
63
|
### JSON to TOML
|
40
64
|
|
@@ -44,6 +68,14 @@ $ xvert jt < foo.json
|
|
44
68
|
|
45
69
|
![](./assets/jt.gif)
|
46
70
|
|
71
|
+
### JSON to XML
|
72
|
+
|
73
|
+
```console
|
74
|
+
$ xvert jx < foo.json
|
75
|
+
```
|
76
|
+
|
77
|
+
![](./assets/jx.gif)
|
78
|
+
|
47
79
|
### JSON to YAML
|
48
80
|
|
49
81
|
```console
|
@@ -60,6 +92,22 @@ $ xvert tj < foo.toml
|
|
60
92
|
|
61
93
|
![](./assets/tj.gif)
|
62
94
|
|
95
|
+
### TOML to TOML
|
96
|
+
|
97
|
+
```console
|
98
|
+
$ xvert tt < foo.toml
|
99
|
+
```
|
100
|
+
|
101
|
+
![](./assets/tt.gif)
|
102
|
+
|
103
|
+
### TOML to XML
|
104
|
+
|
105
|
+
```console
|
106
|
+
$ xvert tx < foo.toml
|
107
|
+
```
|
108
|
+
|
109
|
+
![](./assets/tx.gif)
|
110
|
+
|
63
111
|
### TOML to YAML
|
64
112
|
|
65
113
|
```console
|
@@ -68,6 +116,38 @@ $ xvert ty < foo.toml
|
|
68
116
|
|
69
117
|
![](./assets/ty.gif)
|
70
118
|
|
119
|
+
### XML to JSON
|
120
|
+
|
121
|
+
```console
|
122
|
+
$ xvert xj < foo.xml
|
123
|
+
```
|
124
|
+
|
125
|
+
![](./assets/xj.gif)
|
126
|
+
|
127
|
+
### XML to TOML
|
128
|
+
|
129
|
+
```console
|
130
|
+
$ xvert xt < foo.xml
|
131
|
+
```
|
132
|
+
|
133
|
+
![](./assets/xt.gif)
|
134
|
+
|
135
|
+
### XML to XML
|
136
|
+
|
137
|
+
```console
|
138
|
+
$ xvert xx < foo.xml
|
139
|
+
```
|
140
|
+
|
141
|
+
![](./assets/xx.gif)
|
142
|
+
|
143
|
+
### XML to YAML
|
144
|
+
|
145
|
+
```console
|
146
|
+
$ xvert xy < foo.xml
|
147
|
+
```
|
148
|
+
|
149
|
+
![](./assets/xy.gif)
|
150
|
+
|
71
151
|
### YAML to JSON
|
72
152
|
|
73
153
|
```console
|
@@ -84,6 +164,22 @@ $ xvert yt < foo.yaml
|
|
84
164
|
|
85
165
|
![](./assets/yt.gif)
|
86
166
|
|
167
|
+
### YAML to XML
|
168
|
+
|
169
|
+
```console
|
170
|
+
$ xvert yx < foo.yaml
|
171
|
+
```
|
172
|
+
|
173
|
+
![](./assets/yx.gif)
|
174
|
+
|
175
|
+
### YAML to YAML
|
176
|
+
|
177
|
+
```console
|
178
|
+
$ xvert yy < foo.yaml
|
179
|
+
```
|
180
|
+
|
181
|
+
![](./assets/yy.gif)
|
182
|
+
|
87
183
|
## License
|
88
184
|
|
89
185
|
[MIT License](./LICENSE.txt)
|
data/assets/jj.gif
ADDED
Binary file
|
data/assets/jt.gif
CHANGED
Binary file
|
data/assets/jx.gif
ADDED
Binary file
|
data/assets/jy.gif
CHANGED
Binary file
|
data/assets/tj.gif
CHANGED
Binary file
|
data/assets/tt.gif
ADDED
Binary file
|
data/assets/tx.gif
ADDED
Binary file
|
data/assets/ty.gif
CHANGED
Binary file
|
data/assets/xj.gif
ADDED
Binary file
|
data/assets/xt.gif
ADDED
Binary file
|
data/assets/xx.gif
ADDED
Binary file
|
data/assets/xy.gif
ADDED
Binary file
|
data/assets/yj.gif
CHANGED
Binary file
|
data/assets/yt.gif
CHANGED
Binary file
|
data/assets/yx.gif
ADDED
Binary file
|
data/assets/yy.gif
ADDED
Binary file
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Xvert
|
4
|
+
class CLI < Thor
|
5
|
+
desc "jj", "Convert JSON to JSON"
|
6
|
+
def jj
|
7
|
+
j(:json)
|
8
|
+
end
|
9
|
+
|
10
|
+
desc "jy", "Convert JSON to YAML"
|
11
|
+
def jy
|
12
|
+
j(:yaml)
|
13
|
+
end
|
14
|
+
|
15
|
+
desc "jt", "Convert JSON to TOML"
|
16
|
+
def jt
|
17
|
+
j(:toml)
|
18
|
+
end
|
19
|
+
|
20
|
+
desc "jx", "Convert JSON to XML"
|
21
|
+
def jx
|
22
|
+
j(:xml)
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def j(format)
|
28
|
+
run(from: :json, to: format)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Xvert
|
4
|
+
class CLI < Thor
|
5
|
+
desc "tj", "Convert TOML to JSON"
|
6
|
+
def tj
|
7
|
+
t(:json)
|
8
|
+
end
|
9
|
+
|
10
|
+
desc "tt", "Convert TOML to TOML"
|
11
|
+
def tt
|
12
|
+
t(:toml)
|
13
|
+
end
|
14
|
+
|
15
|
+
desc "ty", "Convert TOML to YAML"
|
16
|
+
def ty
|
17
|
+
t(:yaml)
|
18
|
+
end
|
19
|
+
|
20
|
+
desc "tx", "Convert TOML to XML"
|
21
|
+
def tx
|
22
|
+
t(:xml)
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def t(format)
|
28
|
+
run(from: :toml, to: format)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Xvert
|
4
|
+
class CLI < Thor
|
5
|
+
desc "xj", "Convert XML to JSON"
|
6
|
+
def xj
|
7
|
+
x(:json)
|
8
|
+
end
|
9
|
+
|
10
|
+
desc "xt", "Convert XML to TOML"
|
11
|
+
def xt
|
12
|
+
x(:toml)
|
13
|
+
end
|
14
|
+
|
15
|
+
desc "xx", "Convert XML to XML"
|
16
|
+
def xx
|
17
|
+
x(:xml)
|
18
|
+
end
|
19
|
+
|
20
|
+
desc "xy", "Convert XML to YAML"
|
21
|
+
def xy
|
22
|
+
x(:yaml)
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def x(format)
|
28
|
+
run(from: :xml, to: format)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Xvert
|
4
|
+
class CLI < Thor
|
5
|
+
desc "yj", "Convert YAML to JSON"
|
6
|
+
def yj
|
7
|
+
y(:json)
|
8
|
+
end
|
9
|
+
|
10
|
+
desc "yt", "Convert YAML to TOML"
|
11
|
+
def yt
|
12
|
+
y(:toml)
|
13
|
+
end
|
14
|
+
|
15
|
+
desc "yx", "Convert YAML to XML"
|
16
|
+
def yx
|
17
|
+
y(:xml)
|
18
|
+
end
|
19
|
+
|
20
|
+
desc "yy", "Convert YAML to YAML"
|
21
|
+
def yy
|
22
|
+
y(:yaml)
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def y(format)
|
28
|
+
run(from: :yaml, to: format)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/xvert/cli.rb
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
require "rouge"
|
4
4
|
require "thor"
|
5
|
+
require_relative "cli/json"
|
6
|
+
require_relative "cli/toml"
|
7
|
+
require_relative "cli/xml"
|
8
|
+
require_relative "cli/yaml"
|
5
9
|
|
6
10
|
module Xvert
|
7
11
|
class CLI < Thor
|
@@ -18,48 +22,6 @@ module Xvert
|
|
18
22
|
puts ::Xvert::VERSION
|
19
23
|
end
|
20
24
|
|
21
|
-
#
|
22
|
-
# JSON => X
|
23
|
-
#
|
24
|
-
|
25
|
-
desc "jy", "Convert JSON to YAML"
|
26
|
-
def jy
|
27
|
-
run(from: :json, to: :yaml)
|
28
|
-
end
|
29
|
-
|
30
|
-
desc "jt", "Convert JSON to TOML"
|
31
|
-
def jt
|
32
|
-
run(from: :json, to: :toml)
|
33
|
-
end
|
34
|
-
|
35
|
-
#
|
36
|
-
# YAML => X
|
37
|
-
#
|
38
|
-
|
39
|
-
desc "yj", "Convert YAML to JSON"
|
40
|
-
def yj
|
41
|
-
run(from: :yaml, to: :json)
|
42
|
-
end
|
43
|
-
|
44
|
-
desc "yt", "Convert YAML to TOML"
|
45
|
-
def yt
|
46
|
-
run(from: :yaml, to: :toml)
|
47
|
-
end
|
48
|
-
|
49
|
-
#
|
50
|
-
# TOML => X
|
51
|
-
#
|
52
|
-
|
53
|
-
desc "tj", "Convert TOML to JSON"
|
54
|
-
def tj
|
55
|
-
run(from: :toml, to: :json)
|
56
|
-
end
|
57
|
-
|
58
|
-
desc "ty", "Convert TOML to YAML"
|
59
|
-
def ty
|
60
|
-
run(from: :toml, to: :yaml)
|
61
|
-
end
|
62
|
-
|
63
25
|
private
|
64
26
|
|
65
27
|
def run(from:, to:)
|
@@ -80,8 +42,9 @@ module Xvert
|
|
80
42
|
def lexer(format)
|
81
43
|
case format
|
82
44
|
when :json then Rouge::Lexers::JSON.new
|
83
|
-
when :yaml then Rouge::Lexers::YAML.new
|
84
45
|
when :toml then Rouge::Lexers::TOML.new
|
46
|
+
when :yaml then Rouge::Lexers::YAML.new
|
47
|
+
when :xml then Rouge::Lexers::XML.new
|
85
48
|
else raise UnsupportedFormatError, format
|
86
49
|
end
|
87
50
|
end
|
data/lib/xvert/version.rb
CHANGED
data/lib/xvert.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "active_support"
|
4
|
+
require "active_support/core_ext/hash"
|
3
5
|
require "json"
|
4
6
|
require "toml-rb"
|
5
7
|
require "yaml"
|
@@ -22,8 +24,9 @@ module Xvert
|
|
22
24
|
def to_object(text, format:)
|
23
25
|
case format
|
24
26
|
when :json then json_to_object(text)
|
25
|
-
when :yaml then yaml_to_object(text)
|
26
27
|
when :toml then toml_to_object(text)
|
28
|
+
when :yaml then yaml_to_object(text)
|
29
|
+
when :xml then xml_to_object(text)
|
27
30
|
else raise UnsupportedFormatError, format
|
28
31
|
end
|
29
32
|
end
|
@@ -31,8 +34,9 @@ module Xvert
|
|
31
34
|
def to_text(object, format:)
|
32
35
|
case format
|
33
36
|
when :json then object_to_json(object)
|
34
|
-
when :yaml then object_to_yaml(object)
|
35
37
|
when :toml then object_to_toml(object)
|
38
|
+
when :yaml then object_to_yaml(object)
|
39
|
+
when :xml then object_to_xml(object)
|
36
40
|
else raise UnsupportedFormatError, format
|
37
41
|
end
|
38
42
|
end
|
@@ -49,16 +53,6 @@ module Xvert
|
|
49
53
|
JSON.pretty_generate(object)
|
50
54
|
end
|
51
55
|
|
52
|
-
# YAML
|
53
|
-
|
54
|
-
def yaml_to_object(text)
|
55
|
-
YAML.unsafe_load(text)
|
56
|
-
end
|
57
|
-
|
58
|
-
def object_to_yaml(object)
|
59
|
-
YAML.dump(object)
|
60
|
-
end
|
61
|
-
|
62
56
|
# TOML
|
63
57
|
|
64
58
|
def toml_to_object(text)
|
@@ -68,5 +62,25 @@ module Xvert
|
|
68
62
|
def object_to_toml(object)
|
69
63
|
TomlRB.dump(object)
|
70
64
|
end
|
65
|
+
|
66
|
+
# XML
|
67
|
+
|
68
|
+
def xml_to_object(text)
|
69
|
+
Hash.from_xml(text)
|
70
|
+
end
|
71
|
+
|
72
|
+
def object_to_xml(object)
|
73
|
+
object.to_xml(root: :root)
|
74
|
+
end
|
75
|
+
|
76
|
+
# YAML
|
77
|
+
|
78
|
+
def yaml_to_object(text)
|
79
|
+
YAML.unsafe_load(text)
|
80
|
+
end
|
81
|
+
|
82
|
+
def object_to_yaml(object)
|
83
|
+
YAML.dump(object)
|
84
|
+
end
|
71
85
|
end
|
72
86
|
end
|
data/tapes/foo.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"
|
1
|
+
{"foo":"bar","baz":"qux"}
|
data/tapes/foo.toml
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
|
1
|
+
foo="bar"
|
2
|
+
baz="qux"
|
data/tapes/foo.xml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?><root><foo>bar</foo><baz>qux</baz></root>
|
data/tapes/foo.yaml
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
|
1
|
+
foo: bar
|
2
|
+
baz: qux
|
data/tapes/jj.tape
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
Output assets/jj.gif
|
2
|
+
|
3
|
+
Require xvert
|
4
|
+
|
5
|
+
Set Shell "bash"
|
6
|
+
Set FontSize 32
|
7
|
+
Set Width 1200
|
8
|
+
Set Height 600
|
9
|
+
|
10
|
+
Hide
|
11
|
+
Type "cd ./tapes" Enter
|
12
|
+
Ctrl+l
|
13
|
+
Show
|
14
|
+
|
15
|
+
Type "cat foo.json" Sleep 500ms Enter Sleep 500ms
|
16
|
+
Sleep 1s
|
17
|
+
Type "clear" Sleep 500ms Enter Sleep 500ms
|
18
|
+
|
19
|
+
Type "xvert jj < foo.json" Sleep 500ms Enter
|
20
|
+
|
21
|
+
Sleep 5s
|
data/tapes/jx.tape
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
Output assets/jx.gif
|
2
|
+
|
3
|
+
Require xvert
|
4
|
+
|
5
|
+
Set Shell "bash"
|
6
|
+
Set FontSize 32
|
7
|
+
Set Width 1200
|
8
|
+
Set Height 600
|
9
|
+
|
10
|
+
Hide
|
11
|
+
Type "cd ./tapes" Enter
|
12
|
+
Ctrl+l
|
13
|
+
Show
|
14
|
+
|
15
|
+
Type "cat foo.json" Sleep 500ms Enter Sleep 500ms
|
16
|
+
Sleep 1s
|
17
|
+
Type "clear" Sleep 500ms Enter Sleep 500ms
|
18
|
+
|
19
|
+
Type "xvert jx < foo.json" Sleep 500ms Enter
|
20
|
+
|
21
|
+
Sleep 5s
|
data/tapes/tt.tape
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
Output assets/tt.gif
|
2
|
+
|
3
|
+
Require xvert
|
4
|
+
|
5
|
+
Set Shell "bash"
|
6
|
+
Set FontSize 32
|
7
|
+
Set Width 1200
|
8
|
+
Set Height 600
|
9
|
+
|
10
|
+
Hide
|
11
|
+
Type "cd ./tapes" Enter
|
12
|
+
Ctrl+l
|
13
|
+
Show
|
14
|
+
|
15
|
+
Type "cat foo.toml" Sleep 500ms Enter Sleep 500ms
|
16
|
+
Sleep 1s
|
17
|
+
Type "clear" Sleep 500ms Enter Sleep 500ms
|
18
|
+
|
19
|
+
Type "xvert tt < foo.toml" Sleep 500ms Enter
|
20
|
+
|
21
|
+
Sleep 5s
|
data/tapes/tx.tape
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
Output assets/tx.gif
|
2
|
+
|
3
|
+
Require xvert
|
4
|
+
|
5
|
+
Set Shell "bash"
|
6
|
+
Set FontSize 32
|
7
|
+
Set Width 1200
|
8
|
+
Set Height 600
|
9
|
+
|
10
|
+
Hide
|
11
|
+
Type "cd ./tapes" Enter
|
12
|
+
Ctrl+l
|
13
|
+
Show
|
14
|
+
|
15
|
+
Type "cat foo.toml" Sleep 500ms Enter Sleep 500ms
|
16
|
+
Sleep 1s
|
17
|
+
Type "clear" Sleep 500ms Enter Sleep 500ms
|
18
|
+
|
19
|
+
Type "xvert tx < foo.toml" Sleep 500ms Enter
|
20
|
+
|
21
|
+
Sleep 5s
|
data/tapes/update.rb
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
COMMANDS = [
|
4
|
+
# JSON
|
5
|
+
"jj", "jt", "jx", "jy",
|
6
|
+
# TOML
|
7
|
+
"tj", "tt", "tx", "ty",
|
8
|
+
# XML
|
9
|
+
"xj", "xt", "xx", "xy",
|
10
|
+
# YAML
|
11
|
+
"yj", "yt", "yx", "yy"
|
12
|
+
].sort
|
13
|
+
|
14
|
+
def update_tapes
|
15
|
+
COMMANDS.each do |command|
|
16
|
+
from_format, = extract_formats(command)
|
17
|
+
foo_filename = "foo.#{from_format}"
|
18
|
+
|
19
|
+
tape = <<~TAPE
|
20
|
+
Output assets/#{command}.gif
|
21
|
+
|
22
|
+
Require xvert
|
23
|
+
|
24
|
+
Set Shell "bash"
|
25
|
+
Set FontSize 32
|
26
|
+
Set Width 1200
|
27
|
+
Set Height 600
|
28
|
+
|
29
|
+
Hide
|
30
|
+
Type "cd ./tapes" Enter
|
31
|
+
Ctrl+l
|
32
|
+
Show
|
33
|
+
|
34
|
+
Type "cat #{foo_filename}" Sleep 500ms Enter Sleep 500ms
|
35
|
+
Sleep 1s
|
36
|
+
Type "clear" Sleep 500ms Enter Sleep 500ms
|
37
|
+
|
38
|
+
Type "xvert #{command} < #{foo_filename}" Sleep 500ms Enter
|
39
|
+
|
40
|
+
Sleep 5s
|
41
|
+
TAPE
|
42
|
+
tape_filename = "tapes/#{command}.tape"
|
43
|
+
|
44
|
+
File.write(tape_filename, tape)
|
45
|
+
`vhs < #{tape_filename}`
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def print_usage
|
50
|
+
puts <<~TEXT
|
51
|
+
## Usage
|
52
|
+
|
53
|
+
```console
|
54
|
+
$ xvert help
|
55
|
+
#{`xvert help`.strip}
|
56
|
+
```
|
57
|
+
|
58
|
+
#{
|
59
|
+
COMMANDS.map do |command|
|
60
|
+
from, to = extract_formats(command)
|
61
|
+
"- [#{from.upcase} to #{to.upcase}](##{from}-to-#{to})"
|
62
|
+
end.join("\n")
|
63
|
+
}
|
64
|
+
|
65
|
+
#{
|
66
|
+
COMMANDS.map do |command|
|
67
|
+
from, to = extract_formats(command)
|
68
|
+
|
69
|
+
<<~TEXT
|
70
|
+
### #{from.upcase} to #{to.upcase}
|
71
|
+
|
72
|
+
```console
|
73
|
+
$ xvert #{command} < foo.#{from}
|
74
|
+
```
|
75
|
+
|
76
|
+
![](./assets/#{command}.gif)
|
77
|
+
TEXT
|
78
|
+
end.join("\n")
|
79
|
+
}
|
80
|
+
TEXT
|
81
|
+
end
|
82
|
+
|
83
|
+
def extract_formats(command)
|
84
|
+
[extract_format(command[0]), extract_format(command[1])]
|
85
|
+
end
|
86
|
+
|
87
|
+
def extract_format(char)
|
88
|
+
{
|
89
|
+
"j" => "json",
|
90
|
+
"t" => "toml",
|
91
|
+
"y" => "yaml",
|
92
|
+
"x" => "xml"
|
93
|
+
}[char]
|
94
|
+
end
|
95
|
+
|
96
|
+
case ARGV[0]
|
97
|
+
when "tapes" then update_tapes
|
98
|
+
when "usage" then print_usage
|
99
|
+
end
|
data/tapes/xj.tape
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
Output assets/xj.gif
|
2
|
+
|
3
|
+
Require xvert
|
4
|
+
|
5
|
+
Set Shell "bash"
|
6
|
+
Set FontSize 32
|
7
|
+
Set Width 1200
|
8
|
+
Set Height 600
|
9
|
+
|
10
|
+
Hide
|
11
|
+
Type "cd ./tapes" Enter
|
12
|
+
Ctrl+l
|
13
|
+
Show
|
14
|
+
|
15
|
+
Type "cat foo.xml" Sleep 500ms Enter Sleep 500ms
|
16
|
+
Sleep 1s
|
17
|
+
Type "clear" Sleep 500ms Enter Sleep 500ms
|
18
|
+
|
19
|
+
Type "xvert xj < foo.xml" Sleep 500ms Enter
|
20
|
+
|
21
|
+
Sleep 5s
|
data/tapes/xt.tape
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
Output assets/xt.gif
|
2
|
+
|
3
|
+
Require xvert
|
4
|
+
|
5
|
+
Set Shell "bash"
|
6
|
+
Set FontSize 32
|
7
|
+
Set Width 1200
|
8
|
+
Set Height 600
|
9
|
+
|
10
|
+
Hide
|
11
|
+
Type "cd ./tapes" Enter
|
12
|
+
Ctrl+l
|
13
|
+
Show
|
14
|
+
|
15
|
+
Type "cat foo.xml" Sleep 500ms Enter Sleep 500ms
|
16
|
+
Sleep 1s
|
17
|
+
Type "clear" Sleep 500ms Enter Sleep 500ms
|
18
|
+
|
19
|
+
Type "xvert xt < foo.xml" Sleep 500ms Enter
|
20
|
+
|
21
|
+
Sleep 5s
|
data/tapes/xx.tape
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
Output assets/xx.gif
|
2
|
+
|
3
|
+
Require xvert
|
4
|
+
|
5
|
+
Set Shell "bash"
|
6
|
+
Set FontSize 32
|
7
|
+
Set Width 1200
|
8
|
+
Set Height 600
|
9
|
+
|
10
|
+
Hide
|
11
|
+
Type "cd ./tapes" Enter
|
12
|
+
Ctrl+l
|
13
|
+
Show
|
14
|
+
|
15
|
+
Type "cat foo.xml" Sleep 500ms Enter Sleep 500ms
|
16
|
+
Sleep 1s
|
17
|
+
Type "clear" Sleep 500ms Enter Sleep 500ms
|
18
|
+
|
19
|
+
Type "xvert xx < foo.xml" Sleep 500ms Enter
|
20
|
+
|
21
|
+
Sleep 5s
|
data/tapes/xy.tape
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
Output assets/xy.gif
|
2
|
+
|
3
|
+
Require xvert
|
4
|
+
|
5
|
+
Set Shell "bash"
|
6
|
+
Set FontSize 32
|
7
|
+
Set Width 1200
|
8
|
+
Set Height 600
|
9
|
+
|
10
|
+
Hide
|
11
|
+
Type "cd ./tapes" Enter
|
12
|
+
Ctrl+l
|
13
|
+
Show
|
14
|
+
|
15
|
+
Type "cat foo.xml" Sleep 500ms Enter Sleep 500ms
|
16
|
+
Sleep 1s
|
17
|
+
Type "clear" Sleep 500ms Enter Sleep 500ms
|
18
|
+
|
19
|
+
Type "xvert xy < foo.xml" Sleep 500ms Enter
|
20
|
+
|
21
|
+
Sleep 5s
|
data/tapes/yx.tape
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
Output assets/yx.gif
|
2
|
+
|
3
|
+
Require xvert
|
4
|
+
|
5
|
+
Set Shell "bash"
|
6
|
+
Set FontSize 32
|
7
|
+
Set Width 1200
|
8
|
+
Set Height 600
|
9
|
+
|
10
|
+
Hide
|
11
|
+
Type "cd ./tapes" Enter
|
12
|
+
Ctrl+l
|
13
|
+
Show
|
14
|
+
|
15
|
+
Type "cat foo.yaml" Sleep 500ms Enter Sleep 500ms
|
16
|
+
Sleep 1s
|
17
|
+
Type "clear" Sleep 500ms Enter Sleep 500ms
|
18
|
+
|
19
|
+
Type "xvert yx < foo.yaml" Sleep 500ms Enter
|
20
|
+
|
21
|
+
Sleep 5s
|
data/tapes/yy.tape
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
Output assets/yy.gif
|
2
|
+
|
3
|
+
Require xvert
|
4
|
+
|
5
|
+
Set Shell "bash"
|
6
|
+
Set FontSize 32
|
7
|
+
Set Width 1200
|
8
|
+
Set Height 600
|
9
|
+
|
10
|
+
Hide
|
11
|
+
Type "cd ./tapes" Enter
|
12
|
+
Ctrl+l
|
13
|
+
Show
|
14
|
+
|
15
|
+
Type "cat foo.yaml" Sleep 500ms Enter Sleep 500ms
|
16
|
+
Sleep 1s
|
17
|
+
Type "clear" Sleep 500ms Enter Sleep 500ms
|
18
|
+
|
19
|
+
Type "xvert yy < foo.yaml" Sleep 500ms Enter
|
20
|
+
|
21
|
+
Sleep 5s
|
data/xvert.gemspec
CHANGED
@@ -25,8 +25,10 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.executables = spec.files.grep(%r{\Abin/}) { |f| File.basename(f) }
|
26
26
|
spec.require_paths = ["lib"]
|
27
27
|
|
28
|
+
spec.add_runtime_dependency "activesupport", "~> 7.0.0"
|
29
|
+
spec.add_runtime_dependency "builder", "~> 3.2.0"
|
28
30
|
spec.add_runtime_dependency "json", "~> 2.6.0"
|
29
|
-
spec.add_runtime_dependency "rouge", "~>
|
31
|
+
spec.add_runtime_dependency "rouge", "~> 4.1.0"
|
30
32
|
spec.add_runtime_dependency "thor", "~> 1.2.0"
|
31
33
|
spec.add_runtime_dependency "toml-rb", "~> 2.2.0"
|
32
34
|
spec.add_runtime_dependency "yaml", "~> 0.2.0"
|
metadata
CHANGED
@@ -1,15 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xvert
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- koki-develop
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-05-
|
11
|
+
date: 2023-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 7.0.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 7.0.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: builder
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 3.2.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 3.2.0
|
13
41
|
- !ruby/object:Gem::Dependency
|
14
42
|
name: json
|
15
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -30,14 +58,14 @@ dependencies:
|
|
30
58
|
requirements:
|
31
59
|
- - "~>"
|
32
60
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
61
|
+
version: 4.1.0
|
34
62
|
type: :runtime
|
35
63
|
prerelease: false
|
36
64
|
version_requirements: !ruby/object:Gem::Requirement
|
37
65
|
requirements:
|
38
66
|
- - "~>"
|
39
67
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
68
|
+
version: 4.1.0
|
41
69
|
- !ruby/object:Gem::Dependency
|
42
70
|
name: thor
|
43
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -95,27 +123,53 @@ files:
|
|
95
123
|
- LICENSE.txt
|
96
124
|
- README.md
|
97
125
|
- Rakefile
|
126
|
+
- assets/jj.gif
|
98
127
|
- assets/jt.gif
|
128
|
+
- assets/jx.gif
|
99
129
|
- assets/jy.gif
|
100
130
|
- assets/tj.gif
|
131
|
+
- assets/tt.gif
|
132
|
+
- assets/tx.gif
|
101
133
|
- assets/ty.gif
|
134
|
+
- assets/xj.gif
|
135
|
+
- assets/xt.gif
|
136
|
+
- assets/xx.gif
|
137
|
+
- assets/xy.gif
|
102
138
|
- assets/yj.gif
|
103
139
|
- assets/yt.gif
|
140
|
+
- assets/yx.gif
|
141
|
+
- assets/yy.gif
|
104
142
|
- bin/xvert
|
105
143
|
- lib/xvert.rb
|
106
144
|
- lib/xvert/cli.rb
|
145
|
+
- lib/xvert/cli/json.rb
|
146
|
+
- lib/xvert/cli/toml.rb
|
147
|
+
- lib/xvert/cli/xml.rb
|
148
|
+
- lib/xvert/cli/yaml.rb
|
107
149
|
- lib/xvert/version.rb
|
108
150
|
- renovate.json
|
109
151
|
- sig/xvert.rbs
|
110
152
|
- tapes/foo.json
|
111
153
|
- tapes/foo.toml
|
154
|
+
- tapes/foo.xml
|
112
155
|
- tapes/foo.yaml
|
156
|
+
- tapes/jj.tape
|
113
157
|
- tapes/jt.tape
|
158
|
+
- tapes/jx.tape
|
114
159
|
- tapes/jy.tape
|
115
160
|
- tapes/tj.tape
|
161
|
+
- tapes/tt.tape
|
162
|
+
- tapes/tx.tape
|
116
163
|
- tapes/ty.tape
|
164
|
+
- tapes/update.rb
|
165
|
+
- tapes/xj.tape
|
166
|
+
- tapes/xt.tape
|
167
|
+
- tapes/xx.tape
|
168
|
+
- tapes/xy.tape
|
117
169
|
- tapes/yj.tape
|
118
170
|
- tapes/yt.tape
|
171
|
+
- tapes/yx.tape
|
172
|
+
- tapes/yy.tape
|
119
173
|
- xvert.gemspec
|
120
174
|
homepage: https://github.com/koki-develop/xvert
|
121
175
|
licenses:
|