fog-local 0.3.0 → 0.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: 6de6094d73b2a0014751ef203cc33a8d590ce990
4
- data.tar.gz: cfa04eef4ac8c4a770416c898c06ac16878b9dca
3
+ metadata.gz: 0e0b4af75c75344097e40217e3f1ec9e84c3043d
4
+ data.tar.gz: 7d9e80f6f2e4ccc7f33d2fa2f5e51b700d4dfe0d
5
5
  SHA512:
6
- metadata.gz: 06ab581be51ec5b35aaf9490b8009875adb9144e984969f7ae2847523ad34b3a9e174779cf7471a6c5610ba7f6c41da84223c6c0b907abe4f6e11babd612e153
7
- data.tar.gz: f2df07d4bb2ff57f19eed3663560050fd864c56eb443414f0ad20ba76bc7b58e96a943ed62c3860ff32be8870875106a98a07b0a011ba81a9eb34fb00bd4ed58
6
+ metadata.gz: 4f32c1dc249f2bc2a88b9f631b9c65a39cf2752f2ab721a1424d9a683e77be4e9d30f7b43236fe55d27a6b92a4797d5d8911ff2728f3b5a1d0bb6af9537a5c78
7
+ data.tar.gz: 63f0bf2753a1d7ad7ee77cad0179768d6906bdbef7d6cc71b881aa3bb82a38eaf3c157f6aef373162cbc64e9c9b71e88e855109cf2ef357886ab80e9c47eabe3
@@ -4,9 +4,11 @@ script: bundle exec rake test
4
4
  rvm:
5
5
  - 1.9.3
6
6
  - 2.0.0
7
- - 2.1.5
8
- - 2.2.0
7
+ - 2.1.10
8
+ - 2.2.5
9
+ - 2.3.1
9
10
  - jruby-19mode
11
+ - jruby-9.0.5.0
10
12
  env:
11
13
  - FOG_MOCK=true
12
14
  - FOG_MOCK=false
@@ -1,5 +1,6 @@
1
1
  require 'fog/core'
2
2
  require 'fileutils'
3
+ require 'tempfile'
3
4
  require File.expand_path('../local/version', __FILE__)
4
5
 
5
6
  module Fog
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module Local
3
- VERSION = '0.3.0'
3
+ VERSION = '0.3.1'
4
4
  end
5
5
  end
@@ -55,7 +55,7 @@ module Fog
55
55
  break
56
56
  end
57
57
  pwd = Dir.pwd
58
- if ::File.exist?(dir_path) && ::File.directory?(dir_path)
58
+ if ::File.directory?(dir_path)
59
59
  Dir.chdir(dir_path)
60
60
  if Dir.glob('*').empty?
61
61
  Dir.rmdir(dir_path)
@@ -85,20 +85,16 @@ module Fog
85
85
 
86
86
  def save(options = {})
87
87
  requires :body, :directory, :key
88
+
89
+ # Once 1.9.3 support is dropped, the following two lines
90
+ # can be replaced with `File.dirname(path)`
88
91
  dirs = path.split(::File::SEPARATOR)[0...-1]
89
- dirs.length.times do |index|
90
- dir_path = dirs[0..index].join(::File::SEPARATOR)
91
- if dir_path.empty? # path starts with ::File::SEPARATOR
92
- next
93
- end
94
- # create directory if it doesn't already exist
95
- begin
96
- Dir.mkdir(dir_path)
97
- rescue Errno::EEXIST
98
- raise unless ::File.directory?(dir_path)
99
- end
100
- end
101
- if body.kind_of? ::File and ::File.exist?(body.path)
92
+ dir_path = dirs.join(::File::SEPARATOR)
93
+
94
+ # Create all directories in file path that do not yet exist
95
+ FileUtils.mkdir_p(dir_path)
96
+
97
+ if (body.is_a?(::File) || body.is_a?(Tempfile)) && ::File.exist?(body.path)
102
98
  FileUtils.cp(body.path, path)
103
99
  else
104
100
  write_file(path, body)
@@ -44,4 +44,36 @@ Shindo.tests('Storage[:local] | file', ["local"]) do
44
44
  file.public_url
45
45
  end
46
46
  end
47
+
48
+ tests('#save') do
49
+ tests('creates non-existent subdirs') do
50
+ returns(true) do
51
+ connection = Fog::Storage::Local.new(@options)
52
+ directory = connection.directories.new(:key => 'path1')
53
+ file = directory.files.new(:key => 'path2/file.rb', :body => "my contents")
54
+ file.save
55
+ File.exists?(@options[:local_root] + "/path1/path2/file.rb")
56
+ end
57
+ end
58
+
59
+ tests('with tempfile').returns('tempfile') do
60
+ connection = Fog::Storage::Local.new(@options)
61
+ directory = connection.directories.create(:key => 'directory')
62
+
63
+ tempfile = Tempfile.new(['file', '.txt'])
64
+ tempfile.write('tempfile')
65
+ tempfile.rewind
66
+
67
+ tempfile.instance_eval do
68
+ def read
69
+ raise 'must not be read'
70
+ end
71
+ end
72
+ file = directory.files.new(:key => 'tempfile.txt', :body => tempfile)
73
+ file.save
74
+ tempfile.close
75
+ tempfile.unlink
76
+ directory.files.get('tempfile.txt').body
77
+ end
78
+ end
47
79
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fog-local
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wesley Beary
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-03-03 00:00:00.000000000 Z
12
+ date: 2016-10-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -130,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
130
130
  version: '0'
131
131
  requirements: []
132
132
  rubyforge_project:
133
- rubygems_version: 2.4.6
133
+ rubygems_version: 2.5.1
134
134
  signing_key:
135
135
  specification_version: 4
136
136
  summary: Module for the 'fog' gem to support local filesystem storage.