file_loader 0.2.0 → 0.2.1

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
  SHA1:
3
- metadata.gz: c2dba6a88d0bc2a635b05de63555bc3adcc243d5
4
- data.tar.gz: 73a03edea7501fac6e51631781a2e702610fc4fd
3
+ metadata.gz: 47e3a2b572b81ca9882cdd59a9059314e1d79dad
4
+ data.tar.gz: 153b43e86df89f9f54c55269f67e0c0fdec65bd0
5
5
  SHA512:
6
- metadata.gz: fd26b2eb440143655f54ebb1b8ac30a6c7a8c4bd6a71292095c5edff2b741dfab12830a20f99175859766b4a5e96749e1eaa122e8c389943bdb4396da3ba728c
7
- data.tar.gz: 94f0d5faa5a468ab7e1ef49ab68d352ceda17796c4259e4c0b5f7a128ac1749b41b0fa50a9a0342a44f744774b826df121b22cd9fc2e83ec6a5b8bbb1bbbea0c
6
+ metadata.gz: 3b971214bad7c9800bdf42de9a17afb3710ab3efba9b3b92eb3aaa2567416d96bc7bcb6dd4e99507cafd34fdbd8a9cbf99d951714501a084ad860ab8de0f2bcd
7
+ data.tar.gz: 92ee15d1c7a76237307825af678f2d0ec2a0a4048f6382a15f02738ca5f40368045bfca94d62831d557a8a4aa48ef6b3753a04369763ceb5fc0fa337a18b3c60
data/lib/file_loader.rb CHANGED
@@ -39,21 +39,27 @@ module FileLoader
39
39
  end
40
40
 
41
41
  def exists?(url, opts = {})
42
- purl = parse_url(url)
42
+ opts = defaults.merge(opts)
43
+ purl = parse_url(url = url.shellescape)
43
44
  case purl[:protocol]
44
45
  when 'http', 'https', 'ftp'
45
46
  cmd = "curl -I \"#{url}\""
46
47
  when 'scp'
47
- cmd = "ssh -oBatchMode=yes -oStrictHostKeyChecking=no "
48
- cmd += build_url(user: purl[:user] || opts[:user], password: purl[:password] || opts[:password], host: purl[:host])
49
- cmd += ' "test -f '
50
- cmd += purl[:path]
51
- cmd += '"'
48
+ if purl[:host] == Socket.gethostname
49
+ cmd = 'test -f ' + purl[:path]
50
+ else
51
+ cmd = "ssh -oBatchMode=yes -oStrictHostKeyChecking=no "
52
+ cmd += build_url(user: purl[:user] || opts[:user], password: purl[:password] || opts[:password], host: purl[:host])
53
+ cmd += ' "test -f '
54
+ cmd += purl[:path]
55
+ cmd += '"'
56
+ end
52
57
  when nil
53
58
  cmd = 'test -f ' + purl[:path]
54
59
  else
55
60
  return false
56
61
  end
62
+ opts[:logger].debug(cmd) if opts[:logger]
57
63
  system(cmd + ' 2>/dev/null 1>/dev/null')
58
64
  end
59
65
 
@@ -1,3 +1,3 @@
1
1
  module FileLoader
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: file_loader
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - novikov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-12 00:00:00.000000000 Z
11
+ date: 2015-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler