convert-serialization 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +18 -0
  3. data/bin/convert-serialization +16 -7
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 73503bd0fdb0d1578e3a1c2cb46ca0ecb3e479e867a37ffd858e219c104bfaa3
4
- data.tar.gz: e72e78b2f314ce010f1dbdfea5aca9cd4e0a479be956cfaeaf7ca19f2cab2fbd
3
+ metadata.gz: b5b01a68267da31477f68a90baf242da8578c3c437b967033c3e122d0ea53d53
4
+ data.tar.gz: 026cb7ee8263f881e784511e2d06a367ad3485f3bb25e6f4202312fa72e4eb1b
5
5
  SHA512:
6
- metadata.gz: b762692cb670950c9325b7cfb2dfb6bb3634e55c2e83c3f43b33151f6ce0ab41c8e5e931603bba2fc4939fd41679c025ffee283d2eb927bfc60ff407978dbb19
7
- data.tar.gz: a9d4f04cb660010a4d3139f26bdb920655c79fe56698d380806ee186b912fa16fa85a1467d9e77d93330cf0b38c2852b675cde76a7d4aa9827ba1c8ea26f240c
6
+ metadata.gz: dfbb91b8151139278914d1fc25c0a1d6cfe3a98ff07c3561d1bc9a066041a040fec4a47ea1f835a21918a985691c8a891ad5016cb474efd5c450527df598fe3f
7
+ data.tar.gz: 013e29910eed6aeaf083b9df42c8a0bce3f2754e74b820dcd3acd44d0d3c254707b697d521631c27899cff421ed0365a49175522b048c2e0c34e9c7d8cc56cdb
data/README.md CHANGED
@@ -1,3 +1,21 @@
1
1
  # convert-serialization
2
2
 
3
3
  A simple Ruby script that can convert between different formats (msgpack / json / yaml / toml).
4
+
5
+ ## Usage
6
+
7
+ ```
8
+ $ cat test.json
9
+ {"hello":"world","numbers":[1,2,3,4,5]}
10
+ $ convert-serialization -s json -d toml -i test.json -o test.toml
11
+ Conversion successful!
12
+ $ cat test.toml
13
+ hello = "world"
14
+ numbers = [ 1, 2, 3, 4, 5 ]
15
+ $ convert-serialization -s toml -d msgpack -i test.toml -o test.msgpack
16
+ Conversion successful!
17
+ $ hexdump -C test.msgpack
18
+ 00000000 82 a5 68 65 6c 6c 6f a5 77 6f 72 6c 64 a7 6e 75 |..hello.world.nu|
19
+ 00000010 6d 62 65 72 73 95 01 02 03 04 05 |mbers......|
20
+ 0000001b
21
+ ```
@@ -7,32 +7,41 @@ begin
7
7
 
8
8
  input_format = nil
9
9
  output_format = nil
10
+ input_file = nil
11
+ output_file = nil
10
12
  OptionParser.new do |opts|
11
13
  opts.banner = 'Usage: convert-serialization [options] input_file output_file'
12
14
 
13
- opts.on('-i', '--in INPUT_FORMAT', 'Specifies the input format (msgpack / json / yaml / toml).') do |format|
15
+ opts.on('-s', '--inf INPUT_FORMAT', 'Specifies the input format (msgpack / json / yaml / toml).') do |format|
14
16
  input_format = format
15
17
  end
16
18
 
17
- opts.on('-o', '--out OUTPUT_FORMAT', 'Specifies the output format (msgpack / json / yaml / toml).') do |format|
19
+ opts.on('-d', '--outf OUTPUT_FORMAT', 'Specifies the output format (msgpack / json / yaml / toml).') do |format|
18
20
  output_format = format
19
21
  end
22
+
23
+ opts.on('-i', '--in INPUT_FILE', 'Specifies the input file.') do |file|
24
+ input_file = file
25
+ end
26
+
27
+ opts.on('-o', '--out OUTPUT_FILE', 'Specifies the output file.') do |file|
28
+ output_file = file
29
+ end
20
30
  end.parse!
21
31
 
22
32
  raise ArgumentError, 'Input format missing.' unless input_format
23
33
  raise ArgumentError, 'Output format missing.' unless output_format
24
-
25
- input_file = ARGV.shift
26
- output_file = ARGV.shift
27
-
28
34
  raise ArgumentError, 'Input file is missing.' unless input_file
29
35
  raise ArgumentError, 'Output file is missing.' unless output_file
30
36
 
31
37
  input_format.strip!
32
38
  input_format.downcase!
33
-
34
39
  output_format.strip!
35
40
  output_format.downcase!
41
+ input_file.strip!
42
+ input_file.downcase!
43
+ output_file.strip!
44
+ output_file.downcase!
36
45
 
37
46
  in_handler = case input_format
38
47
  when 'msgpack'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: convert-serialization
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marek Küthe