stanford-mods 1.3.0 → 1.3.1

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
  SHA1:
3
- metadata.gz: ad8829d81dcdd467e55484dbcad16b10ad129399
4
- data.tar.gz: cdd05ca0ef149eb382efca02cb5b0a33e8656dd2
3
+ metadata.gz: 78de4ef412a944f30348ca304d532bc275806ee4
4
+ data.tar.gz: 3127f3b4e900620d2a130292733957bdb63a685a
5
5
  SHA512:
6
- metadata.gz: 0afd49e19a7585bb2bc07b9409479aab2d458cb502d38a3aa356326cbc1bebcb5e7beac8ee0d075307274124826802ff8c6af97f4c7aa2cc8e75a1e349419bb4
7
- data.tar.gz: 1eb35fb09de5c39ad6631dc5f8e2676d7aff58b83a10e170035cae7063d6a42432f0bd64a7b81c33392ab3ab3dae2579fea2bb1dd5f34148379c1c8e76686c32
6
+ metadata.gz: 9d65a7dc751eaff5edc2238935a469c32d1c25d5e3965464e4c56c7019a3f865c4103025188a767e56fd58c01b772a6485945c07e81a6ceeff4b133e1878d4d0
7
+ data.tar.gz: abf7f4068718169e8afcc61accb4d652c90b18ec8caa1eb7bf0f08740386b39dbbb14a962e00831bbb14a1b211e1eba05b18fb03e804d1ab0be887aec788b086
data/.rubocop.yml CHANGED
@@ -1,3 +1,6 @@
1
1
  inherit_from: .rubocop_todo.yml
2
2
 
3
3
  require: rubocop-rspec
4
+
5
+ Metrics/LineLength:
6
+ Max: 120
@@ -23,16 +23,21 @@ module Stanford
23
23
  private
24
24
 
25
25
  def coord_to_bbox(coord)
26
- lng, lat = coord.split('/')
26
+ matches = coord.match %r{(?<lat>.+--.+)\s*/\s*(?<lng>.+--.+)}
27
+ return unless matches
28
+
29
+ min_x, max_x = matches['lat'].split('--').map { |x| coord_to_decimal(x) }
30
+ max_y, min_y = matches['lng'].split('--').map { |y| coord_to_decimal(y) }
27
31
 
28
- min_x, max_x = lng.split('--').map { |x| coord_to_decimal(x) }
29
- max_y, min_y = lat.split('--').map { |y| coord_to_decimal(y) }
30
32
  "#{min_x} #{min_y} #{max_x} #{max_y}"
31
33
  end
32
34
 
33
35
  def coord_to_decimal(point)
34
36
  regex = /(?<dir>[NESW])\s*(?<deg>\d+)°(?:(?<sec>\d+)ʹ)?/
35
37
  match = regex.match(point)
38
+
39
+ return unless match
40
+
36
41
  dec = 0
37
42
 
38
43
  dec += match['deg'].to_i
@@ -1,6 +1,6 @@
1
1
  module Stanford
2
2
  module Mods
3
3
  # this is the Ruby Gem version
4
- VERSION = "1.3.0"
4
+ VERSION = "1.3.1"
5
5
  end
6
6
  end
@@ -29,6 +29,19 @@ describe "Cartographic coordinates" do
29
29
  EOF
30
30
  end
31
31
 
32
+ let(:with_bad_data) do
33
+ <<-EOF
34
+ <mods xmlns="#{Mods::MODS_NS}">
35
+ <subject>
36
+ <cartographics>
37
+ <scale>Scale 1:500,000</scale>
38
+ <coordinates>(Unknown).</coordinates>
39
+ </cartographics>
40
+ </subject>
41
+ </mods>
42
+ EOF
43
+ end
44
+
32
45
  context "coordinates" do
33
46
  it "returns empty array if no coordinates in the mods" do
34
47
  smods_rec.from_str(no_coord)
@@ -45,6 +58,10 @@ describe "Cartographic coordinates" do
45
58
  smods_rec.from_str(no_coord)
46
59
  expect(smods_rec.point_bbox).to eq([])
47
60
  end
61
+ it "returns empty array if bad data is in the mods" do
62
+ smods_rec.from_str(with_bad_data)
63
+ expect(smods_rec.point_bbox).to eq([])
64
+ end
48
65
  it "returns decimal representation of latitude and longitude" do
49
66
  smods_rec.from_str(with_coords)
50
67
  expect(smods_rec.point_bbox).to eq(["-16.0 -15.0 28.0 13.0"])
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stanford-mods
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naomi Dushay
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-11-24 00:00:00.000000000 Z
12
+ date: 2015-12-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mods