exel 1.5.1 → 1.5.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: d6f13f47962fc1df5ff720757b50fa151d1662f64fd3ce57a4cb3d7feeb8d6fd
4
- data.tar.gz: 5d3ff9f75bf80727e7d98f83166267259472ed57a18aaaa860d6210098d6ebeb
3
+ metadata.gz: 546280a360b5092ca3cca1b0e0ae670560c60fb87e0c143b04405f9a5a3de9f9
4
+ data.tar.gz: 1b4b4f78ae5797c82f12abdd61057f915d1f06f53e775b4b1f502b06e1bea463
5
5
  SHA512:
6
- metadata.gz: 22fe9e83f165cd1d5840e18c469d6adaf086ac12eb6c8c134c6224505da20a9ccd2313470560b684ee23ea22dfc828ee1082c2d020418fc6ac7a12fa8bf63767
7
- data.tar.gz: 274d1750e588dfb03635cf0a614b11852e590567f6938c30a299b096c5bf01d4270f10f52db927fb35d96da86530274ee0fe188b0cbb779077318c908ec09a0e
6
+ metadata.gz: 0117f598e372c74606421159b405fdd4aa4fa1be3d2d658741ed4163b8c223cc3f75ce68ab0e67adbd495cd53a72b47b8411cf74135b067f2c430f00a3ff70da
7
+ data.tar.gz: 7a40ed7071070e4799681b750595c78b07326d72859f3824b9e411d94a782147fc94101b0c9466795270b41126a0ad0bbdb3a137185db7ae0ef825a90f3f5f5d
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- exel (1.5.1)
4
+ exel (1.5.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -6,16 +6,17 @@ module EXEL
6
6
  # just works with local files.
7
7
  class LocalFileProvider
8
8
  def upload(file)
9
- "file://#{file.path}"
9
+ RemoteValue.new(URI("file://#{File.absolute_path(file)}"))
10
10
  end
11
11
 
12
- def download(uri)
13
- raise 'URI must begin with "file://"' unless uri.start_with? 'file://'
14
- File.open(uri.split('file://').last)
12
+ def download(remote_value)
13
+ scheme = remote_value.uri.scheme
14
+ raise "Unsupported URI scheme '#{scheme}'" unless scheme == 'file'
15
+ File.open(remote_value.uri.path)
15
16
  end
16
17
 
17
- def self.remote?(uri)
18
- uri.to_s =~ %r{file://}
18
+ def self.remote?(value)
19
+ value.is_a?(RemoteValue)
19
20
  end
20
21
  end
21
22
  end
@@ -0,0 +1,11 @@
1
+ class RemoteValue
2
+ attr_reader :uri
3
+
4
+ def initialize(uri)
5
+ @uri = uri
6
+ end
7
+
8
+ def ==(other)
9
+ other.class == self.class && other.uri == @uri
10
+ end
11
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EXEL
4
- VERSION = '1.5.1'
4
+ VERSION = '1.5.2'
5
5
  end
@@ -1,28 +1,28 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  describe EXEL::Providers::LocalFileProvider do
4
- let(:file) { instance_double(File, path: '/path/to/file') }
4
+ let(:file) { File.open(File.expand_path('../../../fixtures/sample.csv', __FILE__)) }
5
5
 
6
- describe '#upload' do
7
- it 'returns a file:// URI for the file' do
8
- expect(subject.upload(file)).to eq('file:///path/to/file')
9
- end
10
- end
6
+ it 'can upload/download a file' do
7
+ remote_value = subject.upload(file)
8
+ expect(remote_value.uri.path).to eq(file.path)
11
9
 
12
- describe '#download' do
13
- it 'returns the file indicated by the URI' do
14
- expect(File).to receive(:open).with('/path/to/file').and_return(file)
15
- expect(subject.download('file:///path/to/file')).to eq(file)
16
- end
10
+ restored_file = subject.download(remote_value)
11
+ expect(restored_file.path).to eq(file.path)
12
+ end
17
13
 
18
- it 'doesn`t accept URIs for schemes other than file://' do
19
- expect { subject.download('s3://') }.to raise_error 'URI must begin with "file://"'
20
- end
14
+ it 'doesn`t accept URIs for schemes other than file://' do
15
+ expect { subject.download(RemoteValue.new(URI('s3://bucket/file'))) }.to raise_error "Unsupported URI scheme 's3'"
21
16
  end
22
17
 
23
18
  describe '.remote?' do
24
- it 'returns true for file:// URIs' do
25
- expect(EXEL::Providers::LocalFileProvider.remote?('file:///path/to/file')).to be_truthy
19
+ it 'returns true for remote values' do
20
+ expect(EXEL::Providers::LocalFileProvider.remote?(RemoteValue.new(URI('file:///path/to/file')))).to be_truthy
21
+ end
22
+
23
+ it 'returns false for file:// URIs' do
24
+ expect(EXEL::Providers::LocalFileProvider.remote?('file:///path/to/file')).to be_falsey
25
+ expect(EXEL::Providers::LocalFileProvider.remote?(URI('file:///path/to/file'))).to be_falsey
26
26
  end
27
27
 
28
28
  it 'returns false for anything else' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: exel
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.1
4
+ version: 1.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - yroo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-23 00:00:00.000000000 Z
11
+ date: 2020-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -193,6 +193,7 @@ files:
193
193
  - lib/exel/processors/split_processor.rb
194
194
  - lib/exel/providers/local_file_provider.rb
195
195
  - lib/exel/providers/threaded_async_provider.rb
196
+ - lib/exel/remote_value.rb
196
197
  - lib/exel/sequence_node.rb
197
198
  - lib/exel/value.rb
198
199
  - lib/exel/version.rb