spatial_features 2.10.1 → 2.10.2
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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a81032b4deadb06258e344a37d5a165179a88582641c493ce7826fa4f1911ef1
|
4
|
+
data.tar.gz: 14b10756cdd9e97ab19418813c8fea4acee09436f7311cab69ae70f99c09bb1a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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,
|
28
|
-
|
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'
|
@@ -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
|
-
|
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
|
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.
|
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-
|
12
|
+
date: 2020-04-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|