proto-convert 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/proto-convert +12 -13
- metadata +12 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f67f667815700542bc0c6521ea0e4fff322ecfb22d13a0786d21cfef2b20bce
|
4
|
+
data.tar.gz: 93f0f6e903b2fc6611d639a03d466dc7a5c0634e0a63220e66c5d8c1446616b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d534c44b363c47b670b76b54e36dbc5e2460418ab18d43c243c5ed256d133a216c14916ca75e0b4d78e14da7e9611e8d33f74b08370b78066bbca21379ac3c1e
|
7
|
+
data.tar.gz: 7f455edf6d20dd47cc3800c44cad5a98b6ed2642f36cbc24ef9b7539a117c101b4b6c45827741f9571ef2e0294851e416a7e2719c15f2517d0f077025dc97125
|
data/bin/proto-convert
CHANGED
@@ -32,20 +32,20 @@
|
|
32
32
|
require 'optparse'
|
33
33
|
require 'English'
|
34
34
|
|
35
|
-
VERSION =
|
35
|
+
VERSION = '0.2.0'
|
36
36
|
AUTHOR_NAME = 'Azeem Sajid'
|
37
|
-
AUTHOR_EMAIL = 'azeem.sajid@gmail.com'
|
38
|
-
AUTHOR_INFO = "
|
39
|
-
|
37
|
+
AUTHOR_EMAIL = '<azeem.sajid@gmail.com>'
|
38
|
+
AUTHOR_INFO = "Author: #{AUTHOR_NAME} #{AUTHOR_EMAIL}"
|
39
|
+
AUTHOR_GITHUB = 'GitHub: https://github.com/iamAzeem/proto-convert'
|
40
40
|
|
41
41
|
def compile_proto(filename)
|
42
42
|
file_path = File.expand_path(filename)
|
43
43
|
file_dir = File.dirname(file_path)
|
44
44
|
|
45
|
-
`protoc --ruby_out
|
45
|
+
`protoc --ruby_out=#{file_dir} --proto_path=#{file_dir} #{file_path}`
|
46
46
|
raise StandardError, "Invalid schema! [#{filename}] Resolve error(s)." unless $CHILD_STATUS.success?
|
47
47
|
|
48
|
-
compiled_proto = file_dir
|
48
|
+
compiled_proto = "#{file_dir}/#{File.basename(file_path, '.proto')}_pb.rb"
|
49
49
|
raise StandardError, "Compiled schema not found! [#{compiled_proto}]" unless File.file?(compiled_proto)
|
50
50
|
|
51
51
|
compiled_proto
|
@@ -115,9 +115,10 @@ def start
|
|
115
115
|
opts.on('-m', '--mode [MODE]', modes, "conversion mode #{modes.map(&:to_s)}") do |mode|
|
116
116
|
raise OptionParser::InvalidArgument unless modes.include?(mode)
|
117
117
|
|
118
|
-
|
118
|
+
case mode
|
119
|
+
when :b2j
|
119
120
|
mode = :binary2json
|
120
|
-
|
121
|
+
when :j2b
|
121
122
|
mode = :json2binary
|
122
123
|
end
|
123
124
|
|
@@ -145,14 +146,12 @@ def start
|
|
145
146
|
end
|
146
147
|
|
147
148
|
opts.on('-v', '--version', 'prints version information') do
|
148
|
-
puts "#{VERSION}\n#{AUTHOR_INFO}"
|
149
|
-
puts "GitHub URL: #{REPO_URL}"
|
149
|
+
puts "#{$PROGRAM_NAME} #{VERSION}\n#{AUTHOR_INFO}\n#{AUTHOR_GITHUB}"
|
150
150
|
exit
|
151
151
|
end
|
152
152
|
|
153
153
|
opts.on('-h', '--help', 'prints help') do
|
154
|
-
puts "#{VERSION}\n\n#{opts}\n#{AUTHOR_INFO}"
|
155
|
-
puts "GitHub URL: #{REPO_URL}"
|
154
|
+
puts "#{$PROGRAM_NAME} #{VERSION}\n\n#{opts}\n#{AUTHOR_INFO}\n#{AUTHOR_GITHUB}"
|
156
155
|
exit
|
157
156
|
end
|
158
157
|
end
|
@@ -177,7 +176,7 @@ def start
|
|
177
176
|
convert(compiled_proto, msg_type, conversion_mode, input_file, output_file)
|
178
177
|
rescue OptionParser::InvalidOption, OptionParser::InvalidArgument, OptionParser::MissingArgument
|
179
178
|
puts $ERROR_INFO
|
180
|
-
puts "\n#{VERSION}\n\n#{parser}\n#{AUTHOR_INFO}"
|
179
|
+
puts "\n#{$PROGRAM_NAME} #{VERSION}\n\n#{parser}\n#{AUTHOR_INFO}"
|
181
180
|
exit 1
|
182
181
|
rescue LoadError
|
183
182
|
puts "Possible 'import' issue! Use a single self-contianed .proto file! #{$ERROR_INFO}"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: proto-convert
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Azeem Sajid
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-05-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,14 +16,20 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1
|
19
|
+
version: '2.1'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 2.1.0
|
20
23
|
type: :development
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
27
|
- - "~>"
|
25
28
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1
|
29
|
+
version: '2.1'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 2.1.0
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: google-protobuf
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,7 +50,7 @@ dependencies:
|
|
44
50
|
- - ">="
|
45
51
|
- !ruby/object:Gem::Version
|
46
52
|
version: 3.12.2
|
47
|
-
description: A command
|
53
|
+
description: A command-line tool to convert protobuf messages from binary to JSON
|
48
54
|
and vice versa
|
49
55
|
email:
|
50
56
|
- azeem.sajid@gmail.com
|
@@ -58,7 +64,7 @@ homepage: https://github.com/iamAzeem/proto-convert
|
|
58
64
|
licenses:
|
59
65
|
- MIT
|
60
66
|
metadata: {}
|
61
|
-
post_install_message:
|
67
|
+
post_install_message: Thanks for installing! :)
|
62
68
|
rdoc_options: []
|
63
69
|
require_paths:
|
64
70
|
- lib
|