gnfinder 0.15.4.1 → 0.15.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5d4e2adc23e4ffd6a025c50ff224e30a788a68ed82230a2df3056c5c6ec6181d
4
- data.tar.gz: 8eb3c0c31d94e69abebdffcbad11fcab26ee2aaa83571ae7cdd4be1e8efa6d2c
3
+ metadata.gz: fbac598ce79e8e9db5ad0fd4f24b5004b2cf4f91d3f5fae0ece871b525d1f488
4
+ data.tar.gz: 36abaa471d385f27ae6bfa32f6f960bb7bc3a1b258b0b2a5402826e41d629d6f
5
5
  SHA512:
6
- metadata.gz: 7557354c2fe98ed21eedd0ff461a44eb9cc8f1415a8b23f9acc894d50f9568a1b290ef4b12d21e5e883f7aae1c0fb8ada990fa2a122ebe2a95f13f13a45bb6fe
7
- data.tar.gz: 0ede5ae354bca00835a7a31ee274cb9a266df7a73850ea98c29b3708adbb7eb06dbe19b7546d05fe2948f0d9ee5d3b17d4828c895fe3cc5d9ee0d001d03f4612
6
+ metadata.gz: 5e6a3e825edfaa873e0d178a7323d7a9b6124292e940e504834b48d8127e18ae08298044458b15fc1125abf9b98afcd1faa292eadfb6edf64f80d6b3d89d43d7
7
+ data.tar.gz: 68e7871b2ce105ca751c63b391ca7477a33ce965c88d6ef87235635fd8aebbfba18e856c549d0e0a26d2a4228f0a0bf46ab8cce58892c677824273f6c1f9d259
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## [v0.15.5]
6
+
7
+ - Add [#16]: Search names using URL.
8
+
5
9
  ## [v0.15.4]
6
10
 
7
11
  - Add [#14]: Compatibility with gnfider v0.15.4, switching to REST API.
data/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # gnfinder
2
2
 
3
- Ruby gem to access functionality of [gnfinder] project written in Go. This gem
3
+ Ruby gem to access functionality of [GNfinder] project written in Go. This gem
4
4
  allows to perform fast and accurate scientific name finding in UTF-8 encoded
5
5
  plain texts for Ruby-based projects.
6
6
 
7
- - [gnfinder](#gnfinder)
7
+ - [GNfinder](#gnfinder)
8
8
  - [Requirements](#requirements)
9
9
  - [Installation](#installation)
10
10
  - [Usage](#usage)
@@ -19,12 +19,12 @@ plain texts for Ruby-based projects.
19
19
 
20
20
  ## Requirements
21
21
 
22
- This gem uses gRPC to access a running [gnfinder] server. You can find how
23
- to run it in [gnfinder] README file.
22
+ This gem uses REST API to access a running [GNfinder] server. You can find how
23
+ to run it in [GNfinder] README file.
24
24
 
25
25
  ## Installation
26
26
 
27
- To use the gem from Ruby proect install it using Gemfile, or manually:
27
+ To use the gem from a Ruby proect install it using Gemfile, or manually:
28
28
 
29
29
  ```bash
30
30
  gem install gnfinder
@@ -32,10 +32,10 @@ gem install gnfinder
32
32
 
33
33
  ## Usage
34
34
 
35
- The purpose of this gem is to access [gnfinder] functionality out of Ruby
35
+ The purpose of this gem is to access [GNfinder] functionality from Ruby
36
36
  applications. If you need to find names using other languages, use the
37
37
  [source code][client] of this gem for reference. For other usages read
38
- the original Go-lang [gnfinder] README file.
38
+ the original Go-lang [GNfinder] README file.
39
39
 
40
40
  First you need to create a instance of a `gnfinder` client
41
41
 
@@ -63,7 +63,7 @@ gf = Gnfinder::Client.new(host = '0.0.0.0', port = 8000)
63
63
 
64
64
  ### Finding names in a text using default settings
65
65
 
66
- You can find format of returning result in [proto file] or in [tests]
66
+ You can find format of returning result in [GNfinder API docs]
67
67
 
68
68
  ```ruby
69
69
  txt = File.read('utf8-text-with-names.txt')
@@ -73,6 +73,18 @@ puts res.names[0].value
73
73
  puts res.names[0].odds
74
74
  ```
75
75
 
76
+ ### Finding names by a URL
77
+
78
+ If you need to find names in an HTML page, or a PDF document available on
79
+ Internet, use `find_url` method.
80
+
81
+ ```ruby
82
+ url = 'https://en.wikipedia.org/wiki/Monochamus_galloprovincialis'
83
+ res = gf.find_url(url)
84
+ puts res.names[0].value
85
+ puts res.names[0].odds
86
+ ```
87
+
76
88
  Returned result will have the following methods for each name:
77
89
 
78
90
  * value: name-string cleaned up for verification.
@@ -173,21 +185,6 @@ res = gf.find_names(txt, language: 'eng', sources: [1, 4, 179])
173
185
 
174
186
  ## Development
175
187
 
176
- This gem uses gRPC to access [gnfinder] server. gRPC in turn depends on a
177
- protobuf library. If you need to compile Ruby programs with protobuf you need
178
- to install [Go] language and download [gnfinder] project.
179
-
180
- ```bash
181
- go get github.com/gnames/gnfinder
182
- ```
183
- Then you need to run bundle from the root of the project and generate
184
- grpc files:
185
-
186
- ```bash
187
- bundle
188
- rake grpc
189
- ```
190
-
191
188
  If you get an error, you might need to set a ``GOPATH`` environment variable.
192
189
 
193
190
  After starting the server with default host and port (localhost:8778) you will
@@ -208,10 +205,10 @@ To run tests without rubocop
208
205
  bundle exec rspec
209
206
  ```
210
207
 
211
- [gnfinder]: https://github.com/gnames/gnfinder
208
+ [GNfinder]: https://github.com/gnames/gnfinder
212
209
  [gnfinder recent release]: https://github.com/gnames/gnfinder/releases
213
210
  [Go]: https://golang.org/doc/install
214
211
  [client]: https://github.com/GlobalNamesArchitecture/gnfinder/blob/master/lib/gnfinder/client.rb
215
212
  [data-source list]: http://index.globalnames.org/datasource
216
- [proto file]: https://github.com/GlobalNamesArchitecture/gnfinder/blob/master/lib/protob_pb.rb
217
213
  [tests]: https://github.com/GlobalNamesArchitecture/gnfinder/blob/master/spec/lib/client_spec.rb
214
+ [GNfinder API docs]: https://apidoc.globalnames.org/gnfinder
@@ -21,13 +21,24 @@ module Gnfinder
21
21
  @site['/ping'].get.body
22
22
  end
23
23
 
24
- # rubocop:disable all
24
+ def find_url(url, opts = {})
25
+ return to_open_struct({ "names": [] }) if url.to_s.strip == ''
26
+
27
+ params = { url: url }
28
+ find(params, opts)
29
+ end
30
+
25
31
  def find_names(text, opts = {})
26
- if text.to_s.strip == ''
27
- return to_open_struct({ "names": [] })
28
- end
32
+ return to_open_struct({ "names": [] }) if text.to_s.strip == ''
29
33
 
30
34
  params = { text: text }
35
+ find(params, opts)
36
+ end
37
+
38
+ private
39
+
40
+ # rubocop:disable all
41
+ def find(params, opts = {})
31
42
  params[:noBayes] = true if opts[:no_bayes]
32
43
  params[:oddsDetails] = true if opts[:odds_details]
33
44
  params[:language] = opts[:language] if opts[:language].to_s.strip != ''
@@ -54,8 +65,6 @@ module Gnfinder
54
65
  end
55
66
  # rubocop:enable all
56
67
 
57
- private
58
-
59
68
  def to_open_struct(obj)
60
69
  case obj
61
70
  when Hash
@@ -3,7 +3,7 @@
3
3
  # Gnfinder is a namespace module for gndinfer gem.
4
4
  module Gnfinder
5
5
  # Version corresponds to the minimal supported version of Go gnfinder
6
- VERSION = '0.15.4.1'
6
+ VERSION = '0.15.5'
7
7
 
8
8
  def self.version
9
9
  VERSION
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gnfinder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.4.1
4
+ version: 0.15.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Mozzherin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-16 00:00:00.000000000 Z
11
+ date: 2021-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client