rubyBHL 0.2.1 → 0.3.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
- SHA1:
3
- metadata.gz: 4fe4ab96d43bf545970f210e8206eade90e44ae1
4
- data.tar.gz: fad6f419ccccf43eed88fbb6161194fa40f84f17
2
+ SHA256:
3
+ metadata.gz: f45ae0534cfb0d139e96fd1ea96d919b3f59c100c7444ac01ec48afd7d6df4b5
4
+ data.tar.gz: e6b2226c62d548157bcd5f8b98784b320bb3662cab0f491504b1dcf399720e42
5
5
  SHA512:
6
- metadata.gz: 1d7c31281e01a8bd1c1dcf7ffc3b7c8d1d0ec7633302a0b58fccf40e85ef06abf5790694d55c54a0daac9162c40874039f43b29df33a8e72e941bd30536206d2
7
- data.tar.gz: 5c7a705dd079fb25288b2fdf46ae70ecdebe295150ef15cc1cebdf5844e40a2ee78f4fe8176c3a5890965f80c9610180683952befd2c44c71ddd3bfe10e6be52
6
+ metadata.gz: 8a229d4c2408e1bc75c744f38f847e3296a984d405604f23a61424c57038b187d81972d702b845cd74b410df4988260d57dedb1ac557b0af75a4769a47a5db5d
7
+ data.tar.gz: c5fa4c22b8a04dcce27df4d42c1432ccf15589a7257f72ba32f26eb26338623a0b864864dd99a0d32384b2ef80eafb5f8a55c8a67b3069789785343da00b02a0
data/.rspec CHANGED
@@ -1,2 +1,2 @@
1
- --format nested
1
+ --format documentation
2
2
  --color
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.0.0-p353
1
+ 2.5
data/Gemfile.lock CHANGED
@@ -1,44 +1,45 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rubyBHL (0.2.1)
5
- dotenv
6
- json (~> 1.8)
4
+ rubyBHL (0.3.0)
5
+ dotenv (~> 2.7)
6
+ json (~> 2.2)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- awesome_print (1.2.0)
12
- columnize (0.3.6)
13
- debugger (1.6.5)
14
- columnize (>= 0.3.1)
15
- debugger-linecache (~> 1.2.0)
16
- debugger-ruby_core_source (~> 1.3.1)
17
- debugger-linecache (1.2.0)
18
- debugger-ruby_core_source (1.3.1)
19
- diff-lcs (1.2.5)
20
- dotenv (0.9.0)
21
- git (1.2.6)
22
- json (1.8.1)
23
- rake (10.1.1)
24
- rspec (2.14.1)
25
- rspec-core (~> 2.14.0)
26
- rspec-expectations (~> 2.14.0)
27
- rspec-mocks (~> 2.14.0)
28
- rspec-core (2.14.7)
29
- rspec-expectations (2.14.5)
30
- diff-lcs (>= 1.1.3, < 2.0)
31
- rspec-mocks (2.14.5)
11
+ awesome_print (1.8.0)
12
+ byebug (11.0.1)
13
+ diff-lcs (1.3)
14
+ dotenv (2.7.2)
15
+ git (1.5.0)
16
+ json (2.2.0)
17
+ rake (12.3.2)
18
+ rspec (3.8.0)
19
+ rspec-core (~> 3.8.0)
20
+ rspec-expectations (~> 3.8.0)
21
+ rspec-mocks (~> 3.8.0)
22
+ rspec-core (3.8.1)
23
+ rspec-support (~> 3.8.0)
24
+ rspec-expectations (3.8.4)
25
+ diff-lcs (>= 1.2.0, < 2.0)
26
+ rspec-support (~> 3.8.0)
27
+ rspec-mocks (3.8.1)
28
+ diff-lcs (>= 1.2.0, < 2.0)
29
+ rspec-support (~> 3.8.0)
30
+ rspec-support (3.8.2)
32
31
 
33
32
  PLATFORMS
34
33
  ruby
35
34
 
36
35
  DEPENDENCIES
37
36
  awesome_print (~> 1.2)
38
- bundler (~> 1.3)
39
- debugger (~> 1.6)
40
- dotenv
41
- git (~> 1.2)
42
- rake (~> 10.1)
43
- rspec (~> 2.14)
37
+ bundler (~> 2.0)
38
+ byebug
39
+ git (~> 1.5)
40
+ rake (~> 12.3.2)
41
+ rspec (~> 3.8.0)
44
42
  rubyBHL!
43
+
44
+ BUNDLED WITH
45
+ 2.0.2
data/Rakefile CHANGED
@@ -6,4 +6,3 @@ RSpec::Core::RakeTask.new(:spec) do |spec|
6
6
  end
7
7
 
8
8
  task :default => :spec
9
-
data/lib/rubyBHL.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # encoding: UTF-8
2
2
 
3
- recent_ruby = RUBY_VERSION >= '2.0.0'
4
- raise "IMPORTANT: gem requires ruby >= 2.0.0" unless recent_ruby
3
+ recent_ruby = RUBY_VERSION >= '2.5.0'
4
+ raise(RubyBHL::Error, "IMPORTANT: gem requires ruby >= 2.0.0") unless recent_ruby
5
5
 
6
6
  require "json"
7
7
  require 'net/http'
@@ -12,8 +12,6 @@ require_relative 'rubyBHL/mine'
12
12
 
13
13
  class RubyBHL
14
14
 
15
- #DEFAULT_TMP_DIR = "/tmp"
16
-
17
15
  def self.quick_request(options = {})
18
16
  opts = {
19
17
  params: {'name' => 'blorf'},
@@ -25,4 +23,4 @@ class RubyBHL
25
23
 
26
24
  end
27
25
 
28
-
26
+ class RubyBHL::Error < StandardError; end;
data/lib/rubyBHL/mine.rb CHANGED
@@ -10,7 +10,7 @@ class RubyBHL
10
10
  # one column per attribute,
11
11
  # 1 if keyword was found, 0 if not.
12
12
  def self.taxon_attribute_table(taxon_name = nil, attributes = [], page_limit = 10)
13
- name_search = RubyBHL::Request.new(method: :NameGetDetail , params: {'name' => taxon_name})
13
+ name_search = RubyBHL::Request.new(method: :GetNameMetadata, params: {'name' => taxon_name})
14
14
 
15
15
  json = name_search.response.json
16
16
  pages = pages_from_result(json['Result'])
@@ -19,7 +19,8 @@ class RubyBHL
19
19
  csv << [*attributes, 'PageID']
20
20
  pages[0..page_limit - 1].each do |p|
21
21
  result = []
22
- ocr = RubyBHL::Request.new(method: :GetPageOcrText, params: {'pageid' => p['PageID']}).response.json['Result']
22
+ ocr = RubyBHL::Request.new(method: :GetPageMetadata, params: {'pageid' => p['PageID'], 'ocr' => 't'}, ).response.json['Result']
23
+ ocr = ocr.first['OcrText']
23
24
  result += bit_vector_for_keywords(ocr, attributes)
24
25
  result.push p['PageID']
25
26
  csv << [*result]
@@ -36,7 +37,7 @@ class RubyBHL
36
37
  # TODO: Use JSON fu to make this simpler
37
38
  def self.pages_from_result(results = [])
38
39
  pages = []
39
- results['Titles'].each do |t|
40
+ results.first['Titles'].each do |t|
40
41
  t['Items'].each do |i|
41
42
  pages += i['Pages']
42
43
  end
@@ -10,64 +10,42 @@ class RubyBHL
10
10
 
11
11
  warn "\n\n !! API key not set in ~/.bhl_api_key, .env, or ENV. You must pass requests an :api_key. !! \n\n" if API_KEY.nil? || API_KEY == 'sekret_key_here'
12
12
 
13
- # Target API http://www.biodiversitylibrary.org/api2/docs/docs.html
13
+ # Target API https://www.biodiversitylibrary.org/api3
14
14
  class RubyBHL::Request
15
- BASE_URL = 'http://www.biodiversitylibrary.org'
16
- API_VERSION = 'api2'
17
- INTERFACE = 'httpquery.ashx?'
15
+ BASE_URL = 'https://www.biodiversitylibrary.org'
16
+ API_VERSION = 'api3'
18
17
  FORMAT = 'json'
19
- SEARCH_BASE = [BASE_URL, API_VERSION, INTERFACE].join("/")
18
+ SEARCH_BASE = [BASE_URL, API_VERSION].join("/") + '?'
20
19
 
21
20
  METHODS = {
22
- AuthorSearch: %w{name},
23
- BookSearch: %w{title lname volume edition year subject language collectionid},
24
- GetAuthorParts: %w{creatorid},
25
- GetAuthorTitles: %w{creatorid},
26
- GetCollections: %w{}, # no params
27
- GetItemByIdentifier: %w{type value},
28
- GetItemMetadata: %w{itemid pages oc parts},
29
- GetItemPages: %w{itemid ocr},
30
- GetItemParts: %w{itemid},
31
- GetLanguages: %w{}, # no params
21
+ AuthorSearch: %w{authorname},
22
+ GetAuthorMetadata: %w{id idtype pubs},
23
+ GetCollections: %w{}, # no params
24
+ GetInstitutions: %w{}, # no params
25
+ GetItemMetadata: %w{id idtype pages ocr parts},
26
+ GetLanguages: %w{}, # no params
27
+ GetNameMetadata: %w{name idtype id}, # either name or idtype + id is required
32
28
  GetPageMetadata: %w{pageid ocr names},
33
- GetPageNames: %w{pageid},
34
- GetPageOcrText: %w{pageid},
35
- GetPartBibTeX: %w{partid},
36
- GetPartByIdentifier: %w{type value},
37
- GetPartEndNote: %w{partid},
38
- GetPartMetadata: %w{partid},
39
- GetPartNames: %w{partid},
40
- GetSubjectParts: %w{subject},
41
- GetSubjectTitles: %w{subject},
42
- GetTitleBibTex: %w{titleid},
43
- GetTitleByIdentifier: %w{type value},
44
- GetTitleEndNote: %w{titleid},
45
- GetTitleItems: %w{titleid},
46
- GetTitleMetadata: %w{titleid items},
47
- GetUnpublishedItems: %w{}, # No params
48
- GetUnpublishedParts: %w{}, # No params
49
- GetUnpublishedTitles: %w{}, # No params
50
- NameCount: %w{startdate enddate},
51
- NameGetDetail: %w{namebankid name}, # !! Not in list below part of V1, see || criteria
52
- NameCountBetweenDates: %w{}, # !! No documentation provided
53
- # NameGetDetailForName: %w{}, # !! No documentation provided, can't confirm it works
54
- # NameGetDetailForNameBankID: %w{}, # !! No documentation provided, can't confirm it works
55
- NameList: %w{startrow batchsize stardate enddate}, # part of V1 !! may be problems
56
- NameListBetweenDates: %w{}, # !! No documentation provided
57
- NameSearch: %w{name}, # part of V1 !! may be problems
58
- PartSearch: %w{title containerTitle author date volume series issue},
29
+ GetPartMetadata: %w{id idtype names},
30
+ GetSubjectMetadata: %w{subject pubs},
31
+ GetTitleMetadata: %w{id idtype items},
32
+ NameSearch: %w{name}, # part of V1 !! may be problems
33
+ PageSearch: %w{itemid text},
34
+ PublicationSearch: %w{searchterm searchtype page},
35
+ PublicationSearchAdvanced: %w{title titleop authorname year subject language collection text textop page},
59
36
  SubjectSearch: %w{subject},
60
- TitleSearchSimple: %w{title},
61
37
  }
62
38
 
39
+ # See also comments above
63
40
  REQUIRED_PARAMS = {
41
+ 'authorname' => [:AuthorSearch],
64
42
  'name' => [:AuthorSearch, :NameSearch],
65
43
  'creatorid' => [:GetAuthorParts, :GetAuthorTitles],
66
44
  'type' => [:GetItemByIdentifier, :GetPartByIdentifier, :GetTitleByIdentifier],
67
45
  'value' => [:GetItemByIdentifier, :GetPartByIdentifier, :GetTitleByIdentifier],
68
46
  'itemid' => [:GetItemMetadata, :GetItemPages, :GetItemParts],
69
47
  'pageid' => [:GetPageMetadata, :GetPageNames, :GetPageOcrText, :GetPartBibTeX],
70
- 'partid' => [:GetPartBibTeX, :GetPartEndNote, :GetPartMetadata, :GetPartNames],
48
+ 'partid' => [:GetPartBibTeX, :GetPartEndNote, :GetPartMetadata, :GetPartNames],
71
49
  'subject' => [:GetSubjectParts, :GetSubjectTitles, :SubjectSearch],
72
50
  'titleid' => [:GetTitleBibTex, :GetTitleEndNote, :GetTitleItems, :GetTitleMetadata],
73
51
  'title' => [:TitleSearchSimple]
@@ -132,9 +110,10 @@ class RubyBHL
132
110
  end
133
111
 
134
112
  def valid?
135
- raise API_KEY_MESSAGE if @api_key.nil?
136
- raise "Method #{@method} not recognized." if @method && !RubyBHL::Request::METHODS.keys.include?(@method)
137
- raise "Format #{@format} not recognized." if @format && !%w{json xml}.include?(@format)
113
+ raise(RubyBHL::Error, API_KEY_MESSAGE) if @api_key.nil?
114
+ raise(RubyBHL::Error, "Method #{@method} not recognized.") if @method && !RubyBHL::Request::METHODS.keys.include?(@method)
115
+
116
+ raise(RubyBHL::Error, "Format #{@format} not recognized.") if @format && !%w{json xml}.include?(@format)
138
117
 
139
118
  !@method.nil? && !@format.nil? && params_are_supported? && has_required_params?
140
119
  end
@@ -144,7 +123,7 @@ class RubyBHL
144
123
  def build_url
145
124
  @search_url = SEARCH_BASE + 'op=' + @method.to_s +
146
125
  @params.keys.sort{|a,b| a.to_s <=> b.to_s}.collect{|k| "&#{k}=#{@params[k].to_s.gsub(/\s/, "+")}"}.join +
147
- '&format=' + @format + '&apikey=' + @api_key
126
+ '&format=' + @format + '&apikey=' + @api_key
148
127
  end
149
128
 
150
129
  end
@@ -1,6 +1,4 @@
1
-
2
1
  class RubyBHL
3
-
4
2
  class Response
5
3
  attr_reader :json
6
4
 
@@ -9,39 +7,13 @@ class RubyBHL
9
7
  request: nil
10
8
  }.merge!(options)
11
9
 
12
- raise if opts[:request].nil? || opts[:request].class != RubyBHL::Request
10
+ raise RubyBHL::Error if opts[:request].nil? || opts[:request].class != RubyBHL::Request
13
11
 
14
12
  @json = {}
15
- @json = JSON.parse(Net::HTTP.get_response(URI.parse(opts[:request].search_url)).body)
13
+ @json = JSON.parse(
14
+ Net::HTTP.get_response(URI.parse(opts[:request].search_url)).body
15
+ )
16
16
  end
17
17
 
18
18
  end
19
19
  end
20
-
21
-
22
- # Crud from 0.1.0
23
- # # # from the ruby doc
24
- # def fetch(uri_string, limit = 10)
25
- # return nil if !uri_string
26
- # limit = 10 # Justin Case we get in some redirect loop
27
- # raise RbhlError, 'HTTP redirect too deep' if limit == 0 # should tweak
28
- # response = Net::HTTP.get_response(URI.parse(uri_string))
29
- # case response
30
- # when Net::HTTPSuccess then response.body
31
- # when Net::HTTPRedirection then fetch(response['location'], limit - 1)
32
- # else
33
- # response.error!
34
- # end
35
- # end
36
- #
37
- # # this works on a redirect
38
- # def OCR_text(citation_index)
39
- # return nil if !citation_index
40
- # fetch(OCR_url(citation_index))
41
- # end
42
-
43
- # # Since the API doesn't return a link to the OCR we screen scrape the URL
44
- # def OCR_url(citation_index)
45
- # Net::HTTP.get_response(URI.parse(@citations[citation_index]["Url"])).body =~ /http:\/\/.*?\.txt/
46
- # return $& # the matched results
47
- # end
@@ -1,3 +1,3 @@
1
1
  class RubyBHL
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
data/rubyBHL.gemspec CHANGED
@@ -17,15 +17,14 @@ Gem::Specification.new do |gem|
17
17
 
18
18
  gem.required_ruby_version = '~> 2.0'
19
19
 
20
- gem.add_runtime_dependency 'json', '~> 1.8'
21
- gem.add_runtime_dependency 'dotenv'
20
+ gem.add_runtime_dependency 'json', '~> 2.2'
21
+ gem.add_dependency 'dotenv', '~> 2.7'
22
22
 
23
- gem.add_development_dependency 'rake', '~> 10.1'
24
- gem.add_development_dependency 'bundler', '~> 1.3'
25
- gem.add_development_dependency 'rspec', '~> 2.14'
26
- gem.add_development_dependency 'debugger', '~> 1.6'
27
- gem.add_development_dependency 'git', '~> 1.2'
28
- gem.add_development_dependency 'dotenv'
23
+ gem.add_development_dependency 'rake', '~> 12.3.2'
24
+ gem.add_development_dependency 'bundler', '~> 2.0'
25
+ gem.add_development_dependency 'rspec', '~> 3.8.0'
26
+ gem.add_development_dependency 'byebug'
27
+ gem.add_development_dependency 'git', '~> 1.5'
29
28
  gem.add_development_dependency 'awesome_print', '~> 1.2'
30
29
 
31
30
  end
@@ -5,7 +5,7 @@ describe RubyBHL::Mine do
5
5
  describe "`taxon_attribute_table`" do
6
6
 
7
7
  it 'can be called with multiple attributes ' do
8
- expect(RubyBHL::Mine.taxon_attribute_table('Apis melifera', ['honey', 'yellow', 'plant'], 3)).to be_true
8
+ expect(RubyBHL::Mine.taxon_attribute_table('Apis melifera', ['honey', 'yellow', 'plant'], 3)).to be_truthy
9
9
  end
10
10
 
11
11
  it 'can be limited to a number of pages' do
@@ -16,9 +16,7 @@ describe RubyBHL::Mine do
16
16
  it 'returns a CSV formatted text string (tab delimited)' do
17
17
  t = RubyBHL::Mine.taxon_attribute_table('Apis melifera', ['honey'], 1)
18
18
  expect(t.class).to eq(String)
19
- expect(CSV.parse(t, col_sep: "\t", headers: true)).to be_true
19
+ expect(CSV.parse(t, col_sep: "\t", headers: true)).to be_truthy
20
20
  end
21
21
  end
22
-
23
-
24
22
  end
@@ -8,27 +8,22 @@ describe RubyBHL::Request do
8
8
  expect(RubyBHL::Request::FORMAT).to eq('json')
9
9
  end
10
10
 
11
- it 'uses API version 2' do
12
- expect(RubyBHL::Request::API_VERSION).to eq('api2')
13
- end
14
-
15
- it 'uses the http interface' do
16
- expect(RubyBHL::Request::INTERFACE).to eq('httpquery.ashx?')
11
+ it 'uses API version 3' do
12
+ expect(RubyBHL::Request::API_VERSION).to eq('api3')
17
13
  end
18
14
 
19
15
  it 'knows the API methods' do
20
- expect(RubyBHL::Request::METHODS).to have(37).things
16
+ expect(RubyBHL::Request::METHODS.keys.count).to eq(16)
21
17
  end
22
18
 
23
19
  it 'has a base URL' do
24
- expect(RubyBHL::Request::BASE_URL).to eq('http://www.biodiversitylibrary.org')
20
+ expect(RubyBHL::Request::BASE_URL).to eq('https://www.biodiversitylibrary.org')
25
21
  end
26
22
 
27
23
  it 'has a SEARCH_BASE' do
28
- expect(RubyBHL::Request::SEARCH_BASE).to eq('http://www.biodiversitylibrary.org/api2/httpquery.ashx?')
24
+ expect(RubyBHL::Request::SEARCH_BASE).to eq('https://www.biodiversitylibrary.org/api3?')
29
25
  end
30
26
 
31
-
32
27
  describe 'search_url' do
33
28
  before(:each) {
34
29
  @r = RubyBHL::Request.new()
@@ -36,36 +31,36 @@ describe RubyBHL::Request do
36
31
 
37
32
  it 'can validate that "foo" is not a supported param for :NameSearch `params_are_supported?`' do
38
33
  @r.params = {'foo' => 'bar'}
39
- expect(@r.params_are_supported?).to be_false
34
+ expect(@r.params_are_supported?).to be_falsey
40
35
  end
41
36
 
42
37
  it 'can validate that "name" is a supported param for :NameSearch `params_are_supported?`' do
43
38
  @r.params = {"name" => 'bar'}
44
- expect(@r.params_are_supported?).to be_true
39
+ expect(@r.params_are_supported?).to be_truthy
45
40
  end
46
41
 
47
42
  it 'can validate that required params are not present with `has_required_params?`' do
48
43
  @r.params = {'foo' => 'bar'}
49
- expect(@r.has_required_params?).to be_false
44
+ expect(@r.has_required_params?).to be_falsey
50
45
  end
51
46
 
52
47
  it 'can validate that required params are present with `has_required_params?`' do
53
48
  @r.params = {'name' => 'bar'}
54
- expect(@r.has_required_params?).to be_true
49
+ expect(@r.has_required_params?).to be_truthy
55
50
  end
56
51
 
57
52
  it 'can be invalidated with `valid?`' do
58
- expect(@r.valid?).to be_false
53
+ expect(@r.valid?).to be_falsey
59
54
  end
60
55
 
61
56
  it 'can be validated with `valid?`' do
62
57
  @r.params = {'name' => 'bar'}
63
- expect(@r.valid?).to be_true
58
+ expect(@r.valid?).to be_truthy
64
59
  end
65
60
 
66
61
  it 'replaces spaces with plus in params' do
67
62
  @r.params = {'name' => 'Aus bus'}
68
- expect(@r.search_url =~ /\s/).to_not be_true
63
+ expect(@r.search_url =~ /\s/).to_not be_truthy
69
64
  end
70
65
 
71
66
  end
@@ -76,7 +71,7 @@ describe RubyBHL::Request do
76
71
  end
77
72
 
78
73
  it 'are required' do
79
- expect{RubyBHL::Request.new(api_key: nil)}.to raise_error
74
+ expect{RubyBHL::Request.new(api_key: nil)}.to raise_error RubyBHL::Error
80
75
  end
81
76
 
82
77
  it "can come from `ENV['BHL_API_KEY']`" do
@@ -85,9 +80,9 @@ describe RubyBHL::Request do
85
80
 
86
81
  it 'can come from `~/.bhl_api_key`' do
87
82
  if File.exists?(RubyBHL::API_KEY_FILE_PATH)
88
- expect(RubyBHL::Request.new()).to be_true
83
+ expect(RubyBHL::Request.new()).to be_truthy
89
84
  else
90
- expect{RubyBHL::Request.new()}.to raise_error, API_KEY_MESSAGE
85
+ expect{RubyBHL::Request.new()}.to raise_error RubyBHL::Error, API_KEY_MESSAGE
91
86
  end
92
87
  end
93
88
 
@@ -3,19 +3,19 @@ describe RubyBHL::Response do
3
3
  subject { RubyBHL::Response }
4
4
 
5
5
  it 'requires a response' do
6
- expect{ RubyBHL::Response.new() }.to raise_error
6
+ expect{ RubyBHL::Response.new() }.to raise_error RubyBHL::Error
7
7
  end
8
8
 
9
9
  it 'a valid request does not raise' do
10
10
  request = RubyBHL::Request.new(params: {'name' => 'blorf'})
11
- expect(request.valid?).to be_true
12
- expect{ RubyBHL::Response.new(request: request) }.to_not raise_error
11
+ expect(request.valid?).to be_truthy
12
+ expect{ RubyBHL::Response.new(request: request) }.not_to raise_error
13
13
  end
14
14
  end
15
15
 
16
- # def test_OCR_text_scraping
17
- # @bhl = RubyBHL::Rbhl.new(:params => {:title => "Manual of North American Diptera"})
18
- # assert @bhl.OCR_text(0).size > 0
19
- # assert @bhl.OCR_text(0) =~ /Diptera/
20
- # end
16
+ # def test_OCR_text_scraping
17
+ # @bhl = RubyBHL::Rbhl.new(:params => {:title => "Manual of North American Diptera"})
18
+ # assert @bhl.OCR_text(0).size > 0
19
+ # assert @bhl.OCR_text(0) =~ /Diptera/
20
+ # end
21
21
 
@@ -7,12 +7,12 @@ describe RubyBHL do
7
7
  %w{1.8.7 1.9.2 1.9.3}.each do |v|
8
8
  stub_const('RUBY_VERSION', v)
9
9
  expect{load File.expand_path('../../../lib/rubyBHL.rb', __FILE__)}.
10
- to raise_error
10
+ to raise_error RubyBHL::Error
11
11
  end
12
12
  end
13
13
 
14
14
  it 'has version' do
15
- expect(RubyBHL::VERSION =~ /\d+\.\d+\.\d/).to be_true
15
+ expect(RubyBHL::VERSION =~ /\d+\.\d+\.\d/).to be_truthy
16
16
  end
17
17
 
18
18
  it 'has API_KEY_FILE_PATH' do
@@ -21,7 +21,7 @@ describe RubyBHL do
21
21
 
22
22
  describe '`quick_request`' do
23
23
  it 'exists as a class method' do
24
- expect(RubyBHL.public_methods.include?(:quick_request)).to be_true
24
+ expect(RubyBHL.public_methods.include?(:quick_request)).to be_truthy
25
25
  end
26
26
 
27
27
  it 'responds with a RubyBHL::Response' do
@@ -29,7 +29,7 @@ describe RubyBHL do
29
29
  end
30
30
 
31
31
  it 'makes a Net::HTTP request, and turns it into json' do
32
- expect(RubyBHL.quick_request().json).to eq({"Status"=>"ok", "ErrorMessage"=>nil, "Result"=>[]})
32
+ expect(RubyBHL.quick_request().json).to eq({"Status"=>"ok", "ErrorMessage"=>"", "Result"=>[]})
33
33
  end
34
34
 
35
35
  end
data/spec/spec_helper.rb CHANGED
@@ -6,9 +6,7 @@ Dotenv.load
6
6
 
7
7
  require 'rubyBHL'
8
8
  require 'awesome_print'
9
- # require 'rspec'
10
- # require 'rspec/mocks'
11
- # require 'socket'
9
+ require 'byebug'
12
10
 
13
11
  API_KEY_MESSAGE = "Add a key to ~/.bhl_api_key and/or ensure ENV['BHL_API_KEY'] is set for this test to pass or be tested."
14
12
 
metadata CHANGED
@@ -1,139 +1,125 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubyBHL
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Yoder
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-07 00:00:00.000000000 Z
11
+ date: 2019-06-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.8'
19
+ version: '2.2'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.8'
26
+ version: '2.2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: dotenv
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '2.7'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: '2.7'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '10.1'
47
+ version: 12.3.2
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '10.1'
54
+ version: 12.3.2
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '1.3'
61
+ version: '2.0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '1.3'
68
+ version: '2.0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '2.14'
75
+ version: 3.8.0
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ~>
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '2.14'
82
+ version: 3.8.0
83
83
  - !ruby/object:Gem::Dependency
84
- name: debugger
84
+ name: byebug
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ~>
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: '1.6'
89
+ version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ~>
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
- version: '1.6'
96
+ version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: git
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ~>
102
- - !ruby/object:Gem::Version
103
- version: '1.2'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ~>
109
- - !ruby/object:Gem::Version
110
- version: '1.2'
111
- - !ruby/object:Gem::Dependency
112
- name: dotenv
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - '>='
101
+ - - "~>"
116
102
  - !ruby/object:Gem::Version
117
- version: '0'
103
+ version: '1.5'
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
107
  requirements:
122
- - - '>='
108
+ - - "~>"
123
109
  - !ruby/object:Gem::Version
124
- version: '0'
110
+ version: '1.5'
125
111
  - !ruby/object:Gem::Dependency
126
112
  name: awesome_print
127
113
  requirement: !ruby/object:Gem::Requirement
128
114
  requirements:
129
- - - ~>
115
+ - - "~>"
130
116
  - !ruby/object:Gem::Version
131
117
  version: '1.2'
132
118
  type: :development
133
119
  prerelease: false
134
120
  version_requirements: !ruby/object:Gem::Requirement
135
121
  requirements:
136
- - - ~>
122
+ - - "~>"
137
123
  - !ruby/object:Gem::Version
138
124
  version: '1.2'
139
125
  description: RubyBHL is a simple but flexible request/response wrapper for the Biodiversity
@@ -144,10 +130,10 @@ executables: []
144
130
  extensions: []
145
131
  extra_rdoc_files: []
146
132
  files:
147
- - .env
148
- - .gitignore
149
- - .rspec
150
- - .ruby-version
133
+ - ".env"
134
+ - ".gitignore"
135
+ - ".rspec"
136
+ - ".ruby-version"
151
137
  - Gemfile
152
138
  - Gemfile.lock
153
139
  - LICENSE
@@ -174,17 +160,17 @@ require_paths:
174
160
  - lib
175
161
  required_ruby_version: !ruby/object:Gem::Requirement
176
162
  requirements:
177
- - - ~>
163
+ - - "~>"
178
164
  - !ruby/object:Gem::Version
179
165
  version: '2.0'
180
166
  required_rubygems_version: !ruby/object:Gem::Requirement
181
167
  requirements:
182
- - - '>='
168
+ - - ">="
183
169
  - !ruby/object:Gem::Version
184
170
  version: '0'
185
171
  requirements: []
186
172
  rubyforge_project:
187
- rubygems_version: 2.1.11
173
+ rubygems_version: 2.7.9
188
174
  signing_key:
189
175
  specification_version: 4
190
176
  summary: RubyBHL is a simple request/response wrapper for the Biodiversity Heritage