gn_crossmap 1.3.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 47ec0f7527076236262e11f44ad1740c730e05a4
4
- data.tar.gz: 8656e9ce121a47a533f72fe76c23ea312b46e509
3
+ metadata.gz: 26928a347c511599c6e9a967195df956db3c1b87
4
+ data.tar.gz: 9a5208575690e25eee143712db621da7170c2240
5
5
  SHA512:
6
- metadata.gz: cae7ecb4df507bef1fe64c6b9078772a3078d960f2e9af9a1d30ae7e233df85949fe2754c8830bd54dafd0ee2ec36b0788c0a61f7e0f7e8378dd69898465e487
7
- data.tar.gz: 0ab13bc741d0f80b3bbc32d16a4e813a9db7f4954f476be23f1f0ef322bd7f1da782fbf7768fbf4c791f0544521ec9c82de1927d3c04cc22e524eb8b05033df9
6
+ metadata.gz: 00253061383725e4825ab528614b20df2fdfa83932ac725d7dc00a05dd4b3130627d130135a4c1ecacf3fe29c8a40e349cce8730ac6dd8a940cab2fdd27dab1f
7
+ data.tar.gz: 04a4ab00328ed2bb90e31b306a7c73631cf1b3ae70bb8f23ce94b6792f79b696cd5d1e0870ef2079e58d4ddb7dab8b887801cc72ddd2522ae9458042bad8d252
@@ -1,5 +1,13 @@
1
1
  # ``gn_crossmap`` CHANGELOG
2
2
 
3
+ ## 2.0.0
4
+
5
+ * @dimus - #26 change GnCrossmap.run to take opts parameter
6
+
7
+ ## 1.3.0
8
+
9
+ * @dimus - #25 add `alt_headers` parameter
10
+
3
11
  ## 1.2.2
4
12
 
5
13
  * @dimus - fix `resolution_stop` and final status in stats
data/README.md CHANGED
@@ -68,7 +68,10 @@ Compares an input list to a data source from [GN Resolver][resolver] and
68
68
  writes result into an output file.
69
69
 
70
70
  ```ruby
71
- GnCrossmap.run(input, output, data_source_id, skip_original, alt_headers)
71
+
72
+ opts = { input: input, output: output, data_source_id: 1 ,
73
+ skip_original: true, alt_headers: [] }
74
+ GnCrossmap.run(opts)
72
75
  ```
73
76
 
74
77
  ``input``
@@ -102,19 +105,23 @@ require "gn_crossmap"
102
105
 
103
106
  GnCrossmap.logger = MyCustomLogger.new
104
107
 
108
+ opts = { input: "path/to/input.csv", output: "path/to/output.csv,
109
+ data_source_id: 5 , skip_original: true }
105
110
  GnCrossmap.run("path/to/input.csv", "path/to/output.csv", 5, true)
106
111
 
107
112
  # if you want to use alternative headers instead of ones supplied in a file
108
113
 
109
- alt_headers = %w(taxonId, scientificName, rank)
110
- GnCrossmap.run("path/to/input.csv", "path/to/output.csv", 5, true, alt_headers)
114
+ opts = { input: "path/to/input.csv", output: "path/to/output.csv,
115
+ data_source_id: 5 , skip_original: true,
116
+ alt_headers: %w(taxonId, scientificName, rank) }
117
+ GnCrossmap.run(opts)
111
118
  ```
112
119
 
113
120
  If you want to get intermediate statistics for each resolution cycle use a
114
121
  block:
115
122
 
116
123
  ```ruby
117
- GnCrossmap.run("path/to/input.csv", "path/to/output.csv", 5, true) do |stats|
124
+ GnCrossmap.run(opts) do |stats|
118
125
  puts stats
119
126
  puts "Matches:"
120
127
  stats[:matches].each do |key, value|
@@ -26,8 +26,7 @@ unless File.exist?(opts[:input]) || opts[:input] == "-"
26
26
  end
27
27
 
28
28
  begin
29
- GnCrossmap.run(opts[:input], opts[:output], opts[:data_source_id],
30
- opts[:skip_original])
29
+ GnCrossmap.run(opts)
31
30
  rescue GnCrossmapError => e
32
31
  GnCrossmap.logger.error(e.message)
33
32
  end
@@ -1,4 +1,5 @@
1
1
  require "csv"
2
+ require "ostruct"
2
3
  require "rest_client"
3
4
  require "tempfile"
4
5
  require "logger"
@@ -35,17 +36,17 @@ module GnCrossmap
35
36
 
36
37
  # rubocop:disable Metrics/AbcSize
37
38
 
38
- def run(input, output, data_source_id, skip_original, alt_headers = [])
39
- stats = Stats.new
40
- input_io, output_io = io(input, output)
41
- reader = Reader.new(input_io, input_name(input),
42
- skip_original, alt_headers, stats)
39
+ def run(opts)
40
+ opts = OpenStruct.new({ stats: Stats.new, alt_headers: [] }.merge(opts))
41
+ input_io, output_io = io(opts.input, opts.output)
42
+ reader = Reader.new(input_io, input_name(opts.input),
43
+ opts.skip_original, opts.alt_headers, opts.stats)
43
44
  data = block_given? ? reader.read(&Proc.new) : reader.read
44
45
  writer = Writer.new(output_io, reader.original_fields,
45
- output_name(output))
46
- resolver = Resolver.new(writer, data_source_id, stats)
46
+ output_name(opts.output))
47
+ resolver = Resolver.new(writer, opts.data_source_id, opts.stats)
47
48
  block_given? ? resolver.resolve(data, &Proc.new) : resolver.resolve(data)
48
- output
49
+ opts.output
49
50
  end
50
51
 
51
52
  # rubocop:enable all
@@ -1,6 +1,6 @@
1
1
  # Namespace module for crossmapping checklists to GN sources
2
2
  module GnCrossmap
3
- VERSION = "1.3.0".freeze
3
+ VERSION = "2.0.0".freeze
4
4
 
5
5
  def self.version
6
6
  VERSION
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: 1.3.0
4
+ version: 2.0.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-01-20 00:00:00.000000000 Z
11
+ date: 2017-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: trollop