dwca_hunter 0.5.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 2a7db63e8ed5cb5d28892c4f43adaa015e52ae012a0363b6fe50aaa230038f04
4
+ data.tar.gz: 3b8bde91aeec03e927ec7811c0ccfba4c411e5f1a3c7521415bc359add68b8e1
5
+ SHA512:
6
+ metadata.gz: 2992334297d7add2ad3875180b080c7278b7ab934440a5376a8fffb6943bcef9c585187ec67e1bf8737405e7153222bd65df494e4805ace843cfbfd07adf73c1
7
+ data.tar.gz: 91218db042979509afd377008df68c82d04a08fe39b653119cdbe3b187a27202e5da11f173310617535c2acabc1aef65aec142d4e6226d0abb250dcec2d38eab
data/.byebug_history ADDED
@@ -0,0 +1,31 @@
1
+ q
2
+ c
3
+ q
4
+ resource.title =>q
5
+ resource.title
6
+ resource
7
+ search
8
+ q
9
+ n
10
+ data
11
+ q
12
+ d.first.keys.map { |k| k.to_s.capitalize }
13
+ d.first.keys.mtp { |k| k.to_s.capitalize }
14
+ d.map(&:values)
15
+ d.first.keys
16
+ d.first
17
+ d = res.sort_by { |r| r[:command] }
18
+ res.sort_by { |r| r[:command] }
19
+ res.sort_by(command)
20
+ res.sort_by(&:command)
21
+ res
22
+ q
23
+ ObjectSpace.each_object(Class) {|c| puts c}q
24
+ ObjectSpace.each_object(Class) {|c| puts c}
25
+ ObjectSpace
26
+ c
27
+ subject.version
28
+ subject
29
+ q
30
+ subject
31
+ q
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.gitignore ADDED
@@ -0,0 +1,58 @@
1
+ *.gem
2
+
3
+ # rcov generated
4
+ coverage
5
+ binold
6
+
7
+ # rdoc generated
8
+ rdoc
9
+
10
+ # yard generated
11
+ doc
12
+ .yardoc
13
+
14
+ # bundler
15
+ .bundle
16
+ bundle_bin
17
+
18
+ # jeweler generated
19
+ pkg
20
+
21
+ # Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
22
+ #
23
+ # * Create a file at ~/.gitignore
24
+ # * Include files you want ignored
25
+ # * Run: git config --global core.excludesfile ~/.gitignore
26
+ #
27
+ # After doing this, these files will be ignored in all your git projects,
28
+ # saving you from having to 'pollute' every project you touch with them
29
+ #
30
+ # Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
31
+ #
32
+ For MacOS:
33
+
34
+ .DS_Store
35
+ .vim.custom
36
+
37
+ # For TextMate
38
+ #*.tmproj
39
+ #tmtags
40
+
41
+ # For emacs:
42
+ #*~
43
+ #\#*
44
+ #.\#*
45
+
46
+ For vim:
47
+ *.swp
48
+
49
+ # For redcar:
50
+ #.redcar
51
+
52
+ # For rubinius:
53
+ #*.rbc
54
+ problems.txt
55
+ tags
56
+
57
+ # vscode
58
+ .vs
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,33 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.4
3
+ Exclude:
4
+ - bin/**/*
5
+ - db/**/*
6
+ - bundle_bin/**/*
7
+ Include:
8
+ - dwca_hunter.gemspec
9
+ - exe/dwcahunter
10
+
11
+ Style/StringLiterals:
12
+ EnforcedStyle: double_quotes
13
+
14
+ Layout/DotPosition:
15
+ EnforcedStyle: trailing
16
+
17
+ Metrics/BlockLength:
18
+ Exclude:
19
+ - Rakefile
20
+ - "*.gemspec"
21
+ - "**/*.rake"
22
+ - "spec/**/*spec.rb"
23
+
24
+ Metrics/ClassLength:
25
+ Enabled: false
26
+
27
+ Metrics/MethodLength:
28
+ Enabled: false
29
+
30
+ Naming/FileName:
31
+ Exclude:
32
+ - Gemfile
33
+ - Rakefile
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.5.1
data/CHANGELOG.md ADDED
@@ -0,0 +1,15 @@
1
+ # Changelog
2
+
3
+ ## Unreleased (placeholder for the next version)
4
+
5
+ ## [v0.5.0]
6
+ - Add [#8] convert project to a `Ruby gem`
7
+
8
+ ## Footnotes
9
+
10
+ This document follows [changelog guidelines]
11
+
12
+ [#8]: https://github.com/GlobalNamesArchitecture/dwca_hunter/issues/8
13
+ [v0.5.0]: https://github.com/gnames/dwca_hunter/compare/v0.4.0...v0.5.0
14
+
15
+ [changelog guidelines]: https://github.com/olivierlacan/keep-a-changelog
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,133 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ dwca_hunter (0.5.0)
5
+ dwc-archive (~> 1.0)
6
+ gn_uuid (~> 0.5)
7
+ nokogiri (~> 1.8)
8
+ rest-client (~> 2.0)
9
+ thor (~> 0.19)
10
+
11
+ GEM
12
+ remote: http://rubygems.org/
13
+ specs:
14
+ ast (2.4.0)
15
+ biodiversity (3.5.0)
16
+ gn_uuid (~> 0.5)
17
+ parallel (~> 1.12)
18
+ treetop (~> 1.6)
19
+ unicode_utils (~> 1.4)
20
+ byebug (10.0.2)
21
+ coderay (1.1.2)
22
+ coveralls (0.8.22)
23
+ json (>= 1.8, < 3)
24
+ simplecov (~> 0.16.1)
25
+ term-ansicolor (~> 1.3)
26
+ thor (~> 0.19.4)
27
+ tins (~> 1.6)
28
+ diff-lcs (1.3)
29
+ docile (1.3.1)
30
+ domain_name (0.5.20180417)
31
+ unf (>= 0.0.5, < 1.0.0)
32
+ dwc-archive (1.0.1)
33
+ nokogiri (~> 1.8)
34
+ parsley-store (~> 0.3)
35
+ eventmachine (1.2.7)
36
+ gn_uuid (0.5.0)
37
+ htmlentities (4.3.4)
38
+ http-cookie (1.0.3)
39
+ domain_name (~> 0.5)
40
+ jaro_winkler (1.5.1)
41
+ json (2.1.0)
42
+ kramdown (1.17.0)
43
+ mime-types (3.1)
44
+ mime-types-data (~> 3.2015)
45
+ mime-types-data (3.2016.0521)
46
+ mini_portile2 (2.3.0)
47
+ netrc (0.11.0)
48
+ nokogiri (1.8.4)
49
+ mini_portile2 (~> 2.3.0)
50
+ parallel (1.12.1)
51
+ parser (2.5.1.2)
52
+ ast (~> 2.4.0)
53
+ parsley-store (0.3.6)
54
+ biodiversity (~> 3.1)
55
+ redis (~> 3.0)
56
+ polyglot (0.3.5)
57
+ powerpack (0.1.2)
58
+ rainbow (3.0.0)
59
+ rake (12.3.1)
60
+ redis (3.3.5)
61
+ rest-client (2.0.2)
62
+ http-cookie (>= 1.0.2, < 2.0)
63
+ mime-types (>= 1.16, < 4.0)
64
+ netrc (~> 0.8)
65
+ reverse_markdown (1.1.0)
66
+ nokogiri
67
+ rspec (3.7.0)
68
+ rspec-core (~> 3.7.0)
69
+ rspec-expectations (~> 3.7.0)
70
+ rspec-mocks (~> 3.7.0)
71
+ rspec-core (3.7.1)
72
+ rspec-support (~> 3.7.0)
73
+ rspec-expectations (3.7.0)
74
+ diff-lcs (>= 1.2.0, < 2.0)
75
+ rspec-support (~> 3.7.0)
76
+ rspec-mocks (3.7.0)
77
+ diff-lcs (>= 1.2.0, < 2.0)
78
+ rspec-support (~> 3.7.0)
79
+ rspec-support (3.7.1)
80
+ rubocop (0.58.1)
81
+ jaro_winkler (~> 1.5.1)
82
+ parallel (~> 1.10)
83
+ parser (>= 2.5, != 2.5.1.1)
84
+ powerpack (~> 0.1)
85
+ rainbow (>= 2.2.2, < 4.0)
86
+ ruby-progressbar (~> 1.7)
87
+ unicode-display_width (~> 1.0, >= 1.0.1)
88
+ ruby-progressbar (1.9.0)
89
+ simplecov (0.16.1)
90
+ docile (~> 1.1)
91
+ json (>= 1.8, < 3)
92
+ simplecov-html (~> 0.10.0)
93
+ simplecov-html (0.10.2)
94
+ solargraph (0.23.5)
95
+ coderay (~> 1.1)
96
+ eventmachine (~> 1.2, >= 1.2.5)
97
+ htmlentities (~> 4.3, >= 4.3.4)
98
+ kramdown (~> 1.16)
99
+ parser (~> 2.4)
100
+ reverse_markdown (~> 1.0, >= 1.0.5)
101
+ rubocop (~> 0.52)
102
+ thor (~> 0.19, >= 0.19.4)
103
+ tilt (~> 2.0)
104
+ yard (~> 0.9)
105
+ term-ansicolor (1.6.0)
106
+ tins (~> 1.0)
107
+ thor (0.19.4)
108
+ tilt (2.0.8)
109
+ tins (1.16.3)
110
+ treetop (1.6.10)
111
+ polyglot (~> 0.3)
112
+ unf (0.1.4)
113
+ unf_ext
114
+ unf_ext (0.0.7.5)
115
+ unicode-display_width (1.4.0)
116
+ unicode_utils (1.4.0)
117
+ yard (0.9.15)
118
+
119
+ PLATFORMS
120
+ ruby
121
+
122
+ DEPENDENCIES
123
+ bundler (~> 1.16)
124
+ byebug (~> 10.0)
125
+ coveralls (~> 0.8)
126
+ dwca_hunter!
127
+ rake (~> 12.3)
128
+ rspec (~> 3.7)
129
+ rubocop (~> 0.58)
130
+ solargraph (~> 0.23)
131
+
132
+ BUNDLED WITH
133
+ 1.16.3
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Marine Biological Laboratory
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # DarwinCoreArchive Hunter
2
+
3
+ [![dwca_hunter][code-climate-img]][code-climate]
4
+
5
+ DarwinCoreArchive Hunter is an application designed for reformatting publicly
6
+ accessable scientific name sources into [Dawrin Core Archive format][dwca]
7
+
8
+ Currently we have DWCA generators for
9
+
10
+ * NCBI
11
+ * ITIS
12
+ * Wikispecies
13
+ * WoRMS
14
+ * Freebase
15
+
16
+ See dwca_hunter/bin/dwca-hunt.rb as a example how to use the code.
17
+
18
+ ## Contributing to dwca_hunter
19
+
20
+ * Check out the latest master to make sure the feature hasn't been implemented
21
+ or the bug hasn't been fixed yet
22
+ * Check out the issue tracker to make sure someone already hasn't requested it
23
+ and/or contributed it
24
+ * Fork the project
25
+ * Start a feature/bugfix branch
26
+ * Commit and push until you are happy with your contribution
27
+ * Make sure to add tests for it. This is important so I don't break it in a
28
+ future version unintentionally.
29
+ * Please try not to mess with the Rakefile, version, or history. If you want to
30
+ have your own version, or is otherwise necessary, that is fine, but please
31
+ isolate to its own commit so I can cherry-pick around it.
32
+
33
+ ## Copyright
34
+
35
+ Copyright (c) 2011-2016 Dmitry Mozzherin. See LICENSE.txt for further details.
36
+
37
+ [code-climate-img]: https://codeclimate.com/badge.png
38
+ [code-climate]: https://codeclimate.com/github/GlobalNamesArchitecture/dwca_hunter
39
+ [dwca]: http://code.google.com/p/gbif-ecat/wiki/DwCArchive
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+ require "rubocop/rake_task"
6
+
7
+ RSpec::Core::RakeTask.new(:rspec)
8
+
9
+ RuboCop::RakeTask.new
10
+
11
+ task default: %i[rubocop rspec]
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path("lib", __dir__)
4
+
5
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
6
+ require "dwca_hunter/version"
7
+
8
+ Gem::Specification.new do |gem|
9
+ gem.required_ruby_version = ">= 2.4"
10
+ gem.name = "dwca_hunter"
11
+ gem.version = DwcaHunter.version
12
+ gem.license = "MIT"
13
+ gem.authors = ["Dmitry Mozzherin"]
14
+ gem.email = ["dmozzherin@gmail.com"]
15
+
16
+ gem.summary = "Converts a variety of available online resources to " \
17
+ "DarwinCore Archive files."
18
+ gem.description = "Gem harvests data from a variety of formats and " \
19
+ "converts incoming data to DwCA format."
20
+ gem.homepage = "https://github.com/GlobalNamesArchitecture/dwca_hunter"
21
+
22
+ gem.files = `git ls-files -z`.
23
+ split("\x0").
24
+ reject { |f| f.match(%r{^(test|spec|features)/}) }
25
+ gem.bindir = "exe"
26
+ gem.executables = gem.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
+ gem.require_paths = ["lib"]
28
+
29
+ gem.add_dependency "dwc-archive", "~> 1.0"
30
+ gem.add_dependency "gn_uuid", "~> 0.5"
31
+ gem.add_dependency "nokogiri", "~> 1.8"
32
+ gem.add_dependency "rest-client", "~> 2.0"
33
+ gem.add_dependency "thor", "~> 0.19"
34
+
35
+ gem.add_development_dependency "bundler", "~> 1.16"
36
+ gem.add_development_dependency "byebug", "~> 10.0"
37
+ gem.add_development_dependency "coveralls", "~> 0.8"
38
+ gem.add_development_dependency "rake", "~> 12.3"
39
+ gem.add_development_dependency "rspec", "~> 3.7"
40
+ gem.add_development_dependency "rubocop", "~> 0.58"
41
+ gem.add_development_dependency "solargraph", "~> 0.23"
42
+ end
data/exe/dwcahunter ADDED
@@ -0,0 +1,77 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "thor"
5
+ require "dwca_hunter"
6
+
7
+ # DwcaHunterCLI determines command line interface to the gem functionality
8
+ class DwcaHunterCLI < Thor
9
+ desc "list [SEARCH]", "lists available sources to convert filtered by search"
10
+ def list(search = nil)
11
+ printf("List of available resources to convert to DwCA.\n\n" \
12
+ "For conversion use 'dwcahunter convert resource_command'\n\n")
13
+ print_table(collect_resources(search))
14
+ end
15
+
16
+ desc "version", "returns version of the package"
17
+ def version
18
+ puts DwcaHunter.version
19
+ end
20
+
21
+ desc "convert source_command", "converts a datasource to a DarwinCore Archive"
22
+ def convert(command)
23
+ resource = DwcaHunter.resources.select { |r| r.new.command == command }
24
+ if resource.empty?
25
+ puts "Unknown data source. Use 'dwcahunter list [SEARCH]' command" \
26
+ "to see available data sources."
27
+ else
28
+ DwcaHunter.process(resource[0].new)
29
+ end
30
+ end
31
+
32
+ private
33
+
34
+ def collect_resources(search)
35
+ res = []
36
+ DwcaHunter.resources.each do |resource|
37
+ r = resource.new
38
+ if add_resource?(search, r)
39
+ res << { n: nil, command: r.command, resource: r.title }
40
+ end
41
+ end
42
+ res.sort_by { |r| r[:command] }.each_with_object([]) do |r, a|
43
+ r[:n] = a.size + 1
44
+ a << r
45
+ end
46
+ end
47
+
48
+ def add_resource?(search, resource)
49
+ !search || (resource.title =~ /#{search}/i ||
50
+ resource.command =~ /#{search}/i ||
51
+ resource.abbr =~ /#{search}/i)
52
+ end
53
+
54
+ # rubocop:disable Metrics/AbcSize
55
+ def print_table(data)
56
+ table = [data.first.keys.map { |k| k.to_s.capitalize }] + data.map(&:values)
57
+ widths = table_widths(table)
58
+ table.insert(1, widths.map { |n| "-" * n })
59
+ format = widths.collect { |n| "%-#{n}s" }.join(" ")
60
+ table.each { |line| printf " #{format} \n", *line }
61
+ end
62
+ # rubocop:enable Metrics/AbcSize
63
+
64
+ def table_widths(table)
65
+ table.each_with_object([]) do |line, widths|
66
+ c = 0
67
+ line.each do |col|
68
+ col = col.to_s
69
+ wide_enough = widths[c] && widths[c] > col.length
70
+ widths[c] = wide_enough ? widths[c] : col.length
71
+ c += 1
72
+ end
73
+ end
74
+ end
75
+ end
76
+
77
+ DwcaHunterCLI.start(ARGV)