gn_crossmap 2.2.3 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +3 -0
- data/lib/gn_crossmap.rb +23 -6
- data/lib/gn_crossmap/resolver.rb +5 -5
- data/lib/gn_crossmap/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c84cc9c99fe6e3a70510415998c826928c4b7013
|
4
|
+
data.tar.gz: 870651fe4c32fbded76f3fb2cc60d94878b19150
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd3bbc558395d43e713bd35a58f2eee7bd40f24f37399095c08c3186de004df2752ea6180d4d02b9fd83b0d3419648e58c68a281f2ead4d88e90863e917ae048
|
7
|
+
data.tar.gz: 5d6a973a2bc965ae5015ced006a880e38b6c51231e73e6eabb6182dbc4e88849b2341097397436d7fdaabcf45f02d38ad92e0477a74baba53c75c3c66fd1bda0
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -92,6 +92,9 @@ all original data is preserved
|
|
92
92
|
: (array) empty array by default. If `alt_headers` are not empty they are used
|
93
93
|
instead of the headers supplied with the file
|
94
94
|
|
95
|
+
``resolver_url``
|
96
|
+
: URL to globalnames' resolver. Default is ``http://resolver.globalnames.org``
|
97
|
+
|
95
98
|
#### `GnCrossmap.logger=`
|
96
99
|
|
97
100
|
Allows to set logger to a custom logger (default is `STDERR`)
|
data/lib/gn_crossmap.rb
CHANGED
@@ -37,14 +37,12 @@ module GnCrossmap
|
|
37
37
|
# rubocop:disable Metrics/AbcSize
|
38
38
|
|
39
39
|
def run(opts)
|
40
|
-
opts =
|
40
|
+
opts = opts_struct(opts)
|
41
41
|
input_io, output_io = io(opts.input, opts.output)
|
42
|
-
reader =
|
43
|
-
opts.skip_original, opts.alt_headers, opts.stats)
|
42
|
+
reader = create_reader(input_io, opts)
|
44
43
|
data = block_given? ? reader.read(&Proc.new) : reader.read
|
45
|
-
writer =
|
46
|
-
|
47
|
-
resolver = Resolver.new(writer, opts.data_source_id, opts.stats)
|
44
|
+
writer = create_writer(reader, output_io, opts)
|
45
|
+
resolver = create_resolver(writer, opts)
|
48
46
|
block_given? ? resolver.resolve(data, &Proc.new) : resolver.resolve(data)
|
49
47
|
opts.output
|
50
48
|
end
|
@@ -61,6 +59,25 @@ module GnCrossmap
|
|
61
59
|
|
62
60
|
private
|
63
61
|
|
62
|
+
def create_resolver(writer, opts)
|
63
|
+
Resolver.new(writer, opts.data_source_id, opts.resolver_url, opts.stats)
|
64
|
+
end
|
65
|
+
|
66
|
+
def create_writer(reader, output_io, opts)
|
67
|
+
Writer.new(output_io, reader.original_fields, output_name(opts.output))
|
68
|
+
end
|
69
|
+
|
70
|
+
def create_reader(input_io, opts)
|
71
|
+
Reader.new(input_io, input_name(opts.input),
|
72
|
+
opts.skip_original, opts.alt_headers, opts.stats)
|
73
|
+
end
|
74
|
+
|
75
|
+
def opts_struct(opts)
|
76
|
+
resolver_url = "http://resolver.globalnames.org/name_resolvers.json"
|
77
|
+
OpenStruct.new({ stats: Stats.new, alt_headers: [],
|
78
|
+
resolver_url: resolver_url }.merge(opts))
|
79
|
+
end
|
80
|
+
|
64
81
|
def io(input, output)
|
65
82
|
io_in = iogen(input, INPUT_MODE)
|
66
83
|
io_out = iogen(output, OUTPUT_MODE)
|
data/lib/gn_crossmap/resolver.rb
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
module GnCrossmap
|
2
2
|
# Sends data to GN Resolver and collects results
|
3
3
|
class Resolver
|
4
|
-
|
5
|
-
|
6
|
-
def initialize(writer, data_source_id, stats)
|
4
|
+
def initialize(writer, data_source_id, resolver_url, stats)
|
7
5
|
@stats = stats
|
6
|
+
@resolver_url = resolver_url
|
8
7
|
@processor = GnCrossmap::ResultProcessor.new(writer, @stats)
|
9
8
|
@ds_id = data_source_id
|
10
9
|
@count = 0
|
@@ -65,7 +64,7 @@ module GnCrossmap
|
|
65
64
|
|
66
65
|
def remote_resolve(names)
|
67
66
|
batch_start = Time.now
|
68
|
-
res = RestClient.post(
|
67
|
+
res = RestClient.post(@resolver_url, data: names, data_source_ids: @ds_id)
|
69
68
|
@processor.process(res, @current_data)
|
70
69
|
rescue RestClient::Exception
|
71
70
|
single_remote_resolve(names)
|
@@ -83,7 +82,8 @@ module GnCrossmap
|
|
83
82
|
def single_remote_resolve(names)
|
84
83
|
names.split("\n").each do |name|
|
85
84
|
begin
|
86
|
-
res = RestClient.post(
|
85
|
+
res = RestClient.post(@resolver_url, data: name,
|
86
|
+
data_source_ids: @ds_id)
|
87
87
|
@processor.process(res, @current_data)
|
88
88
|
rescue RestClient::Exception => e
|
89
89
|
process_resolver_error(e, name)
|
data/lib/gn_crossmap/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gn_crossmap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitry Mozzherin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: trollop
|