spatial_features 2.10.1 → 2.10.2

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
  SHA256:
3
- metadata.gz: db03e1d3f48e6c65a11830da75d6b201f623db3a60ae355e2f640f8acaa236e0
4
- data.tar.gz: 62d9c5b620f02a8b7db5374697c10e398d1f896a245d95646bb34e4a6c0598fb
3
+ metadata.gz: a81032b4deadb06258e344a37d5a165179a88582641c493ce7826fa4f1911ef1
4
+ data.tar.gz: 14b10756cdd9e97ab19418813c8fea4acee09436f7311cab69ae70f99c09bb1a
5
5
  SHA512:
6
- metadata.gz: 33508968c4ed148c9f73dbccca0a0b4f2931e665fa9b921ffc2389f2f9ca1673287667ef0802922acf706860565b6196bd8e097da387b7b37111fd7daa07f995
7
- data.tar.gz: 219d7656e568dbb2f34d55cbddda7f616ffc4e78fdcd8630a2be1255f17b652c52871a0a68a74ed0505ce91eaea7f611f289766eb82aea1d7d2d95d764486c86
6
+ metadata.gz: c6d4b2e281363aecd61250885e85f9919cf7e42bc5bdcb95a4928bd9d9e4cb8b7e4bbe03b3f64363bfe0ea0967abc1cafe074aed452031cbd407e91c893f85d6
7
+ data.tar.gz: 364f0877b4b40c408548cb193214a4c9389dd2a054b874f6cf394125994a3ce0d61ce154682902c6069a230f47ad50acc3bd5db4f0aadb03967d0025f2448852
@@ -3,16 +3,18 @@ require 'open-uri'
3
3
  module SpatialFeatures
4
4
  module Download
5
5
  # file can be a url, path, or file, any of which can return be a zipped archive
6
- def self.read(file, unzip: nil)
7
- file = open(file, unzip: unzip)
6
+ def self.read(file, unzip: nil, **unzip_options)
7
+ file = open(file, unzip: unzip, **unzip_options)
8
8
  path = ::File.path(file)
9
9
  return ::File.read(path)
10
10
  end
11
11
 
12
- def self.open(file, unzip: nil)
12
+ def self.open(file, unzip: nil, **unzip_options)
13
13
  file = Kernel.open(file)
14
14
  file = normalize_file(file) if file.is_a?(StringIO)
15
- file = find_in_zip(file, unzip) if Unzip.is_zip?(file)
15
+ if Unzip.is_zip?(file)
16
+ file = find_in_zip(file, find: unzip, **unzip_options)
17
+ end
16
18
  return file
17
19
  end
18
20
 
@@ -24,9 +26,8 @@ module SpatialFeatures
24
26
  end
25
27
  end
26
28
 
27
- def self.find_in_zip(file, unzip)
28
- raise "Must specify an :unzip option if opening a zip file. e.g. open(file, :find => '.shp')" unless unzip
29
- return File.open(Unzip.paths(file, :find => unzip))
29
+ def self.find_in_zip(file, find:, **unzip_options)
30
+ return File.open(Unzip.paths(file, :find => find, **unzip_options))
30
31
  end
31
32
  end
32
33
  end
@@ -4,7 +4,7 @@ module SpatialFeatures
4
4
  module Importers
5
5
  class File < SimpleDelegator
6
6
  def initialize(data, *args)
7
- file = Download.open(data, unzip: [/\.kml$/, /\.shp$/])
7
+ file = Download.open(data, unzip: [/\.kml$/, /\.shp$/], downcase: true)
8
8
 
9
9
  case ::File.extname(file.path.downcase)
10
10
  when '.kml'
@@ -43,7 +43,7 @@ module SpatialFeatures
43
43
  end
44
44
 
45
45
  def file
46
- @file ||= Download.open(@data, unzip: /\.shp$/)
46
+ @file ||= Download.open(@data, unzip: /\.shp$/, downcase: true)
47
47
  end
48
48
 
49
49
 
@@ -2,8 +2,8 @@ require 'fileutils'
2
2
 
3
3
  module SpatialFeatures
4
4
  module Unzip
5
- def self.paths(file_path, find: nil)
6
- paths = extract(file_path)
5
+ def self.paths(file_path, find: nil, **extract_options)
6
+ paths = extract(file_path, **extract_options)
7
7
 
8
8
  if find = Array.wrap(find).presence
9
9
  paths = paths.detect {|path| find.any? {|pattern| path.index(pattern) } }
@@ -13,10 +13,12 @@ module SpatialFeatures
13
13
  return paths
14
14
  end
15
15
 
16
- def self.extract(file_path, output_dir = Dir.mktmpdir)
16
+ def self.extract(file_path, output_dir = Dir.mktmpdir, downcase: false)
17
17
  [].tap do |paths|
18
18
  entries(file_path).each do |entry|
19
- path = "#{output_dir}/#{entry.name}"
19
+ output_filename = entry.name
20
+ output_filename = output_filename.downcase if downcase
21
+ path = "#{output_dir}/#{output_filename}"
20
22
  FileUtils.mkdir_p(File.dirname(path))
21
23
  entry.extract(path)
22
24
  paths << path
@@ -1,3 +1,3 @@
1
1
  module SpatialFeatures
2
- VERSION = "2.10.1"
2
+ VERSION = "2.10.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spatial_features
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.10.1
4
+ version: 2.10.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Wallace
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-04-27 00:00:00.000000000 Z
12
+ date: 2020-04-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails