gnparser 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 3de92fedd5756bac2008b9c19d5bae808c06c9c0378cebe8043cd55bd51f92d2
4
+ data.tar.gz: f7bd1e0560c55c017264db2c31a4c2a24795c665b81a3be734a72f57791d224b
5
+ SHA512:
6
+ metadata.gz: ef2153da882800576c72fc7566efa5d469c04fe36601ba7c694b8025e778d85465c601533fe19ac19fe9c6a723710d08e875bdc64f87e31f3b16b2fa26064eb3
7
+ data.tar.gz: a9db4da41466dbde6cda459bd2dddd3a9b65b4a036b39d6d6c221fba49eb630bf94aca5b82642994a13c3e2dfd93df327a4d6d40c0da66edb4464900e328fa44
data/.byebug_history ADDED
@@ -0,0 +1,16 @@
1
+ q
2
+ res.next
3
+ q
4
+ res.next
5
+ res
6
+ q
7
+ res.each {|r| puts r}
8
+ res.next
9
+ p res
10
+ q
11
+ res.next
12
+ res
13
+ c
14
+ q
15
+ puts res.next
16
+ res
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format progress
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,10 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.5
3
+ Exclude:
4
+ - 'lib/gnparser_pb.rb'
5
+ - 'lib/gnparser_services_pb.rb'
6
+ Style/StringLiterals:
7
+ EnforcedStyle: single_quotes
8
+ Metrics/BlockLength:
9
+ Exclude:
10
+ - 'spec/**/*'
@@ -0,0 +1,10 @@
1
+ {
2
+ "spellright.language": [
3
+ "en_US"
4
+ ],
5
+ "spellright.documentTypes": [
6
+ "markdown",
7
+ "latex",
8
+ "plaintext"
9
+ ]
10
+ }
data/CHANGELOG.md ADDED
@@ -0,0 +1,19 @@
1
+ # Changelog
2
+
3
+ ## Unreleased
4
+
5
+
6
+ ## [v0.1.0]
7
+
8
+ - Add [#1]: connect to gRPC server of `gnparser` (Go version).
9
+
10
+ ## Footnotes
11
+
12
+ This document follows [changelog guidelines]
13
+
14
+ [v0.1.0]: https://gitlab.com/gnames/gnparser_rb/tree/v0.1.0
15
+
16
+ [#1]: https://gitlab.com/gnames/gnparser_rb/issues/1
17
+
18
+
19
+ [changelog guidelines]: https://github.com/olivierlacan/keep-a-changelog
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,64 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ gnparser (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ ast (2.4.0)
10
+ byebug (10.0.2)
11
+ diff-lcs (1.3)
12
+ google-protobuf (3.6.1-x86_64-linux)
13
+ googleapis-common-protos-types (1.0.2)
14
+ google-protobuf (~> 3.0)
15
+ grpc (1.16.0-x86_64-linux)
16
+ google-protobuf (~> 3.1)
17
+ googleapis-common-protos-types (~> 1.0.0)
18
+ grpc-tools (1.16.0)
19
+ jaro_winkler (1.5.1)
20
+ parallel (1.12.1)
21
+ parser (2.5.1.2)
22
+ ast (~> 2.4.0)
23
+ powerpack (0.1.2)
24
+ rainbow (3.0.0)
25
+ rake (12.3.1)
26
+ rspec (3.8.0)
27
+ rspec-core (~> 3.8.0)
28
+ rspec-expectations (~> 3.8.0)
29
+ rspec-mocks (~> 3.8.0)
30
+ rspec-core (3.8.0)
31
+ rspec-support (~> 3.8.0)
32
+ rspec-expectations (3.8.2)
33
+ diff-lcs (>= 1.2.0, < 2.0)
34
+ rspec-support (~> 3.8.0)
35
+ rspec-mocks (3.8.0)
36
+ diff-lcs (>= 1.2.0, < 2.0)
37
+ rspec-support (~> 3.8.0)
38
+ rspec-support (3.8.0)
39
+ rubocop (0.60.0)
40
+ jaro_winkler (~> 1.5.1)
41
+ parallel (~> 1.10)
42
+ parser (>= 2.5, != 2.5.1.1)
43
+ powerpack (~> 0.1)
44
+ rainbow (>= 2.2.2, < 4.0)
45
+ ruby-progressbar (~> 1.7)
46
+ unicode-display_width (~> 1.4.0)
47
+ ruby-progressbar (1.10.0)
48
+ unicode-display_width (1.4.0)
49
+
50
+ PLATFORMS
51
+ ruby
52
+
53
+ DEPENDENCIES
54
+ bundler (~> 1.16)
55
+ byebug (~> 10.0)
56
+ gnparser!
57
+ grpc (~> 1.15)
58
+ grpc-tools (~> 1.15)
59
+ rake (~> 12.3)
60
+ rspec (~> 3.8)
61
+ rubocop (~> 0.59)
62
+
63
+ BUNDLED WITH
64
+ 1.16.4
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018 Global Names
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,10 @@
1
+ # gnparser_rb
2
+
3
+ gRPC client to [gnparser] project
4
+
5
+ ## Overview
6
+
7
+ ``gnparser_rb`` is a Ruby gem that allows to parse scientific names extremely
8
+ fast using remote method calls to [gnparser].
9
+
10
+ [gnparser]: https://gitlab.com/gogna/gnparser
data/Rakefile ADDED
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ require 'bundler/gem_tasks'
6
+
7
+ begin
8
+ Bundler.setup(:default, :development)
9
+ rescue Bundler::BundlerError => e
10
+ warn e.message
11
+ warn 'Run `bundle install` to install missing gems'
12
+ exit e.status_code
13
+ end
14
+ require 'rake'
15
+
16
+ require 'rspec/core'
17
+ require 'rspec/core/rake_task'
18
+ RSpec::Core::RakeTask.new(:spec) do |spec|
19
+ spec.pattern = FileList['spec/**/*_spec.rb']
20
+ end
21
+
22
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
23
+ spec.pattern = 'spec/**/*_spec.rb'
24
+ spec.rcov = true
25
+ end
26
+
27
+ task :grpc do
28
+ cmd = 'grpc_tools_ruby_protoc ' \
29
+ '-I $GOPATH/src/gitlab.com/gogna/gnparser/grpc ' \
30
+ '--ruby_out=lib --grpc_out=lib ' \
31
+ '$GOPATH/src/gitlab.com/gogna/gnparser/grpc/gnparser.proto'
32
+ puts cmd
33
+ `#{cmd}`
34
+ end
35
+
36
+ require 'rubocop/rake_task'
37
+ RuboCop::RakeTask.new
38
+
39
+ task default: %i[rubocop grpc spec]
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH.push File.expand_path('lib', __dir__)
4
+
5
+ require 'gnparser_rb/version'
6
+
7
+ Gem::Specification.new do |gem|
8
+ gem.name = 'gnparser'
9
+ gem.homepage = 'http://gitlab.com/gnames/gnparser_rb'
10
+ gem.version = GNparser::VERSION
11
+ gem.authors = ['Dmitry Mozzherin']
12
+ gem.license = 'MIT'
13
+ gem.summary = 'Scientific name parser'
14
+ gem.description = %(The gem parses scientific names into semantic elements
15
+ using gRPC of gnparser app written in Go.)
16
+ gem.email = 'dmozzherin@gmail.com'
17
+
18
+ gem.files = `git ls-files -z`
19
+ .split("\x0")
20
+ .reject { |f| f.match(%r{^(test|spec|features)/}) }
21
+
22
+ gem.require_paths = ['lib']
23
+ gem.required_ruby_version = '~> 2.5'
24
+ gem.add_development_dependency 'bundler', '~> 1.16'
25
+ gem.add_development_dependency 'byebug', '~> 10.0'
26
+ gem.add_development_dependency 'grpc', '~> 1.15'
27
+ gem.add_development_dependency 'grpc-tools', '~> 1.15'
28
+ gem.add_development_dependency 'rake', '~> 12.3'
29
+ gem.add_development_dependency 'rspec', '~> 3.8'
30
+ gem.add_development_dependency 'rubocop', '~> 0.59'
31
+ end
@@ -0,0 +1,66 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # source: gnparser.proto
3
+
4
+ require 'google/protobuf'
5
+
6
+ Google::Protobuf::DescriptorPool.generated_pool.build do
7
+ add_message "grpc.Version" do
8
+ optional :value, :string, 1
9
+ optional :build_time, :string, 2
10
+ end
11
+ add_message "grpc.Void" do
12
+ end
13
+ add_message "grpc.Input" do
14
+ oneof :content do
15
+ optional :format, :enum, 1, "grpc.Format"
16
+ optional :name, :string, 2
17
+ end
18
+ end
19
+ add_message "grpc.Name" do
20
+ optional :parsed, :bool, 1
21
+ optional :quality, :int32, 2
22
+ optional :verbatim, :string, 3
23
+ optional :normalized, :string, 4
24
+ optional :canonical_simple, :string, 5
25
+ optional :canonical_full, :string, 6
26
+ optional :genus, :message, 7, "grpc.Entry"
27
+ optional :subgenus, :message, 8, "grpc.Entry"
28
+ optional :species, :message, 9, "grpc.Entry"
29
+ optional :subspicies, :message, 10, "grpc.Entry"
30
+ optional :variety, :message, 11, "grpc.Entry"
31
+ optional :form, :message, 12, "grpc.Entry"
32
+ end
33
+ add_message "grpc.Entry" do
34
+ optional :value, :string, 1
35
+ optional :norm_value, :string, 2
36
+ optional :position, :message, 3, "grpc.Pos"
37
+ optional :authors, :string, 4
38
+ optional :year, :string, 5
39
+ optional :score, :string, 6
40
+ end
41
+ add_message "grpc.Pos" do
42
+ optional :start, :int32, 1
43
+ optional :end, :int32, 2
44
+ end
45
+ add_message "grpc.Output" do
46
+ optional :value, :string, 1
47
+ optional :error, :string, 2
48
+ end
49
+ add_enum "grpc.Format" do
50
+ value :Compact, 0
51
+ value :Pretty, 1
52
+ value :Simple, 2
53
+ value :Debug, 3
54
+ end
55
+ end
56
+
57
+ module Grpc
58
+ Version = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.Version").msgclass
59
+ Void = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.Void").msgclass
60
+ Input = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.Input").msgclass
61
+ Name = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.Name").msgclass
62
+ Entry = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.Entry").msgclass
63
+ Pos = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.Pos").msgclass
64
+ Output = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.Output").msgclass
65
+ Format = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.Format").enummodule
66
+ end
@@ -0,0 +1,77 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GNparser
4
+ FORMATS = {
5
+ compact: Grpc::Format::Compact,
6
+ pretty: Grpc::Format::Pretty,
7
+ simple: Grpc::Format::Simple,
8
+ debug: Grpc::Format::Debug
9
+ }.freeze
10
+ # Gnfinder::Client connects to gnfinder server
11
+ class Client
12
+ def initialize(host = '0.0.0.0', port = '8778')
13
+ @stub = Grpc::GNparser::Stub.new("#{host}:#{port}",
14
+ :this_channel_is_insecure)
15
+ end
16
+
17
+ def version
18
+ @stub.ver(Grpc::Void.new)
19
+ end
20
+
21
+ def parse(name, format = :compact)
22
+ enum = InputEnum.new([name], format)
23
+ @stub.parse(enum.each_item).next
24
+ end
25
+
26
+ def parse_ary(ary, format = :compact)
27
+ enum = InputEnum.new(ary, format)
28
+ @stub.parse(enum.each_item)
29
+ end
30
+
31
+ def parse_file(path, format = :compact)
32
+ f = File.open(path)
33
+ enum = InputEnum.new(f, format)
34
+ @stub.parse(enum.each_item)
35
+ end
36
+
37
+ end
38
+
39
+ # InputEnum yields names one after another
40
+ class InputEnum
41
+ def initialize(iter, format = nil)
42
+ @iter = iter
43
+ @format = format
44
+ end
45
+
46
+ def each_item
47
+ return enum_for(:each_item) unless block_given?
48
+
49
+ yield input_format if @format
50
+
51
+ @iter.each do |l|
52
+ input = Grpc::Input.new
53
+ input.name = l.strip
54
+ yield input
55
+ end
56
+ end
57
+
58
+ private
59
+
60
+ def input_format
61
+ frm = find_format
62
+ @format = nil
63
+ input = Grpc::Input.new
64
+ input.format = frm
65
+ input
66
+ end
67
+
68
+ def find_format
69
+ format = @format.to_sym
70
+ if FORMATS.key?(format)
71
+ FORMATS[format]
72
+ else
73
+ FORMATS[:compact]
74
+ end
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ # GNparser is a namespace module for gnparser_rb gem.
4
+ module GNparser
5
+ VERSION = '0.1.0'
6
+
7
+ def self.version
8
+ VERSION
9
+ end
10
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'json'
4
+ require_relative 'gnparser_rb/version'
5
+ require_relative 'gnparser_pb.rb'
6
+ require_relative 'gnparser_services_pb.rb'
7
+ require_relative 'gnparser_rb/client'
8
+
9
+ # GNparser is a namespace module for gnparser_rb gem.
10
+ module GNparser
11
+ end
@@ -0,0 +1,23 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # Source: gnparser.proto for package 'grpc'
3
+
4
+ require 'grpc'
5
+ require 'gnparser_pb'
6
+
7
+ module Grpc
8
+ module GNparser
9
+ class Service
10
+
11
+ include GRPC::GenericService
12
+
13
+ self.marshal_class_method = :encode
14
+ self.unmarshal_class_method = :decode
15
+ self.service_name = 'grpc.GNparser'
16
+
17
+ rpc :Ver, Void, Version
18
+ rpc :Parse, stream(Input), stream(Output)
19
+ end
20
+
21
+ Stub = Service.rpc_stub_class
22
+ end
23
+ end
metadata ADDED
@@ -0,0 +1,159 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gnparser
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Dmitry Mozzherin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-01-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: byebug
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: grpc
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.15'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.15'
55
+ - !ruby/object:Gem::Dependency
56
+ name: grpc-tools
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.15'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.15'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '12.3'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '12.3'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.8'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.8'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0.59'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '0.59'
111
+ description: |-
112
+ The gem parses scientific names into semantic elements
113
+ using gRPC of gnparser app written in Go.
114
+ email: dmozzherin@gmail.com
115
+ executables: []
116
+ extensions: []
117
+ extra_rdoc_files: []
118
+ files:
119
+ - ".byebug_history"
120
+ - ".rspec"
121
+ - ".rubocop.yml"
122
+ - ".vscode/settings.json"
123
+ - CHANGELOG.md
124
+ - Gemfile
125
+ - Gemfile.lock
126
+ - LICENSE
127
+ - README.md
128
+ - Rakefile
129
+ - gnparser_rb.gemspec
130
+ - lib/gnparser_pb.rb
131
+ - lib/gnparser_rb.rb
132
+ - lib/gnparser_rb/client.rb
133
+ - lib/gnparser_rb/version.rb
134
+ - lib/gnparser_services_pb.rb
135
+ homepage: http://gitlab.com/gnames/gnparser_rb
136
+ licenses:
137
+ - MIT
138
+ metadata: {}
139
+ post_install_message:
140
+ rdoc_options: []
141
+ require_paths:
142
+ - lib
143
+ required_ruby_version: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - "~>"
146
+ - !ruby/object:Gem::Version
147
+ version: '2.5'
148
+ required_rubygems_version: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ requirements: []
154
+ rubyforge_project:
155
+ rubygems_version: 2.7.6
156
+ signing_key:
157
+ specification_version: 4
158
+ summary: Scientific name parser
159
+ test_files: []