xvert 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ff0b4a5b08f0fb5ffc8f9bd9c4a2f13ee5ddeca7c09f7c2687146ed0ddff165e
4
- data.tar.gz: 9a2dc105504df2c32c3467341eccb7cee0f9407625431ebc272df3dad3656a2a
3
+ metadata.gz: 1f3a39e3dbf8e60d7966f13c9191eabbbc3eff872f8371bf4eb61e79d61d113c
4
+ data.tar.gz: 7138515754cfbd83bb61b8ad32e6998928bc4b84a1087593b1960d6bacbbb757
5
5
  SHA512:
6
- metadata.gz: 81f03e5fdb5751c48fbc4e7cfaa7e7524f903560a886fcd39315a8c91163f9a198a871328fb6579ccbae1c8bd25d596f59ad18a22519c1f76605be1150cc0a2a
7
- data.tar.gz: 6df53e051e6e1fc0a234ea88857aa979b256faa2999ba503ad8cd03c54ae304e221fba6b9bb60edabec7bfbcb6cdcd2ef97b32e047a62255fcaf77f5368d280d
6
+ metadata.gz: 1fdbe1355d42520c33a072350aa3cd279ee34489c8c5d20fc7a6388dc9fe0dbcb210cde1b23e9341d2d18d89bd576d0e2432524f1fa67e4110fc8b3ee389912c
7
+ data.tar.gz: 9942a4f3cda3e6a9901bb70718b7b045c1bcd4899bfbb477f140659a14102a8eb68abb85818309d507c37ef23a29d3d185cdaa83d69d2993986d5e5f014a0acf
data/Gemfile CHANGED
@@ -5,8 +5,8 @@ source "https://rubygems.org"
5
5
  # Specify your gem's dependencies in xvert.gemspec
6
6
  gemspec
7
7
 
8
- gem "rake", "~> 13.0"
9
-
10
8
  gem "minitest", "~> 5.0"
11
-
9
+ gem "rake", "~> 13.0"
12
10
  gem "rubocop", "~> 1.21"
11
+ gem "simplecov", "~> 0.22.0"
12
+ gem "simplecov-cobertura", "~> 2.1.0"
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- xvert (0.1.0)
4
+ xvert (0.2.0)
5
5
  json (~> 2.6.0)
6
6
  thor (~> 1.2.0)
7
7
  toml-rb (~> 2.2.0)
@@ -12,6 +12,7 @@ GEM
12
12
  specs:
13
13
  ast (2.4.2)
14
14
  citrus (3.0.2)
15
+ docile (1.4.0)
15
16
  json (2.6.3)
16
17
  minitest (5.18.0)
17
18
  parallel (1.23.0)
@@ -34,6 +35,15 @@ GEM
34
35
  rubocop-ast (1.28.1)
35
36
  parser (>= 3.2.1.0)
36
37
  ruby-progressbar (1.13.0)
38
+ simplecov (0.22.0)
39
+ docile (~> 1.1)
40
+ simplecov-html (~> 0.11)
41
+ simplecov_json_formatter (~> 0.1)
42
+ simplecov-cobertura (2.1.0)
43
+ rexml
44
+ simplecov (~> 0.19)
45
+ simplecov-html (0.12.3)
46
+ simplecov_json_formatter (0.1.4)
37
47
  thor (1.2.1)
38
48
  toml-rb (2.2.0)
39
49
  citrus (~> 3.0, > 3.0)
@@ -48,6 +58,8 @@ DEPENDENCIES
48
58
  minitest (~> 5.0)
49
59
  rake (~> 13.0)
50
60
  rubocop (~> 1.21)
61
+ simplecov (~> 0.22.0)
62
+ simplecov-cobertura (~> 2.1.0)
51
63
  xvert!
52
64
 
53
65
  BUNDLED WITH
data/README.md CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  [![Gem](https://img.shields.io/gem/v/xvert?logo=ruby&logoColor=%23CC342D)](https://rubygems.org/gems/xvert)
4
4
  [![Code Climate maintainability](https://img.shields.io/codeclimate/maintainability/koki-develop/xvert?logo=codeclimate)](https://codeclimate.com/github/koki-develop/xvert)
5
+ [![Codecov](https://img.shields.io/codecov/c/github/koki-develop/xvert?logo=codecov)](https://app.codecov.io/gh/koki-develop/xvert)
5
6
  [![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/koki-develop/xvert/main.yml?logo=github)](https://github.com/koki-develop/xvert/actions/workflows/main.yml)
6
7
  [![GitHub](https://img.shields.io/github/license/koki-develop/xvert)](./LICENSE.txt)
7
8
 
@@ -15,7 +16,7 @@ $ gem install xvert
15
16
 
16
17
  ## Usage
17
18
 
18
- ```
19
+ ```console
19
20
  $ xvert help
20
21
  Commands:
21
22
  xvert help [COMMAND] # Describe available commands or one specific command
@@ -27,6 +28,61 @@ Commands:
27
28
  xvert yt # Convert YAML to TOML
28
29
  ```
29
30
 
31
+ - [JSON to TOML](#json-to-toml)
32
+ - [JSON to YAML](#json-to-yaml)
33
+ - [TOML to JSON](#toml-to-json)
34
+ - [TOML to YAML](#toml-to-yaml)
35
+ - [YAML to JSON](#yaml-to-json)
36
+ - [YAML to TOML](#yaml-to-toml)
37
+
38
+ ### JSON to TOML
39
+
40
+ ```console
41
+ $ xvert jt < foo.json
42
+ ```
43
+
44
+ ![](./assets/jt.gif)
45
+
46
+ ### JSON to YAML
47
+
48
+ ```console
49
+ $ xvert jy < foo.json
50
+ ```
51
+
52
+ ![](./assets/jy.gif)
53
+
54
+ ### TOML to JSON
55
+
56
+ ```console
57
+ $ xvert tj < foo.toml
58
+ ```
59
+
60
+ ![](./assets/tj.gif)
61
+
62
+ ### TOML to YAML
63
+
64
+ ```console
65
+ $ xvert ty < foo.toml
66
+ ```
67
+
68
+ ![](./assets/ty.gif)
69
+
70
+ ### YAML to JSON
71
+
72
+ ```console
73
+ $ xvert yj < foo.yaml
74
+ ```
75
+
76
+ ![](./assets/yj.gif)
77
+
78
+ ### YAML to TOML
79
+
80
+ ```console
81
+ $ xvert yt < foo.yaml
82
+ ```
83
+
84
+ ![](./assets/yt.gif)
85
+
30
86
  ## License
31
87
 
32
88
  [MIT License](./LICENSE.txt)
data/assets/jt.gif ADDED
Binary file
data/assets/jy.gif ADDED
Binary file
data/assets/tj.gif ADDED
Binary file
data/assets/ty.gif ADDED
Binary file
data/assets/yj.gif ADDED
Binary file
data/assets/yt.gif ADDED
Binary file
data/lib/xvert/cli.rb CHANGED
@@ -10,6 +10,13 @@ module Xvert
10
10
  end
11
11
  end
12
12
 
13
+ map %w[-v --version] => :version
14
+
15
+ desc "--version, -v", "Print Xvert version"
16
+ def version
17
+ puts ::Xvert::VERSION
18
+ end
19
+
13
20
  #
14
21
  # JSON => X
15
22
  #
data/lib/xvert/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Xvert
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
data/lib/xvert.rb CHANGED
@@ -7,19 +7,7 @@ require_relative "xvert/version"
7
7
  require_relative "xvert/cli"
8
8
 
9
9
  module Xvert
10
- TO_OBJECT_MAP = {
11
- json: :json_to_object,
12
- yaml: :yaml_to_object,
13
- toml: :toml_to_object
14
- }.freeze
15
-
16
- TO_TEXT_MAP = {
17
- json: :object_to_json,
18
- yaml: :object_to_yaml,
19
- toml: :object_to_toml
20
- }.freeze
21
-
22
- private_constant :TO_OBJECT_MAP, :TO_TEXT_MAP
10
+ class UnsupportedFormatError < StandardError; end
23
11
 
24
12
  class << self
25
13
  def convert(text, from:, to:)
@@ -28,11 +16,21 @@ module Xvert
28
16
  end
29
17
 
30
18
  def to_object(text, format:)
31
- send(TO_OBJECT_MAP[format], text)
19
+ case format
20
+ when :json then json_to_object(text)
21
+ when :yaml then yaml_to_object(text)
22
+ when :toml then toml_to_object(text)
23
+ else raise UnsupportedFormatError, "Unsupported format: #{format}"
24
+ end
32
25
  end
33
26
 
34
27
  def to_text(object, format:)
35
- send(TO_TEXT_MAP[format], object)
28
+ case format
29
+ when :json then object_to_json(object)
30
+ when :yaml then object_to_yaml(object)
31
+ when :toml then object_to_toml(object)
32
+ else raise UnsupportedFormatError, "Unsupported format: #{format}"
33
+ end
36
34
  end
37
35
 
38
36
  private
data/tapes/foo.json ADDED
@@ -0,0 +1 @@
1
+ {"message":"hello world"}
data/tapes/foo.toml ADDED
@@ -0,0 +1 @@
1
+ message = "hello world"
data/tapes/foo.yaml ADDED
@@ -0,0 +1 @@
1
+ message: hello world
data/tapes/jt.tape ADDED
@@ -0,0 +1,21 @@
1
+ Output assets/jt.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 jt < foo.json" Sleep 500ms Enter
20
+
21
+ Sleep 5s
data/tapes/jy.tape ADDED
@@ -0,0 +1,21 @@
1
+ Output assets/jy.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 jy < foo.json" Sleep 500ms Enter
20
+
21
+ Sleep 5s
data/tapes/tj.tape ADDED
@@ -0,0 +1,21 @@
1
+ Output assets/tj.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 tj < foo.toml" Sleep 500ms Enter
20
+
21
+ Sleep 5s
data/tapes/ty.tape ADDED
@@ -0,0 +1,21 @@
1
+ Output assets/ty.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 ty < foo.toml" Sleep 500ms Enter
20
+
21
+ Sleep 5s
data/tapes/yj.tape ADDED
@@ -0,0 +1,21 @@
1
+ Output assets/yj.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 yj < foo.yaml" Sleep 500ms Enter
20
+
21
+ Sleep 5s
data/tapes/yt.tape ADDED
@@ -0,0 +1,21 @@
1
+ Output assets/yt.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 yt < foo.yaml" Sleep 500ms Enter
20
+
21
+ Sleep 5s
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xvert
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - koki-develop
@@ -81,12 +81,27 @@ files:
81
81
  - LICENSE.txt
82
82
  - README.md
83
83
  - Rakefile
84
+ - assets/jt.gif
85
+ - assets/jy.gif
86
+ - assets/tj.gif
87
+ - assets/ty.gif
88
+ - assets/yj.gif
89
+ - assets/yt.gif
84
90
  - bin/xvert
85
91
  - lib/xvert.rb
86
92
  - lib/xvert/cli.rb
87
93
  - lib/xvert/version.rb
88
94
  - renovate.json
89
95
  - sig/xvert.rbs
96
+ - tapes/foo.json
97
+ - tapes/foo.toml
98
+ - tapes/foo.yaml
99
+ - tapes/jt.tape
100
+ - tapes/jy.tape
101
+ - tapes/tj.tape
102
+ - tapes/ty.tape
103
+ - tapes/yj.tape
104
+ - tapes/yt.tape
90
105
  - xvert.gemspec
91
106
  homepage: https://github.com/koki-develop/xvert
92
107
  licenses: