fog-local 0.3.0 → 0.3.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 +4 -4
- data/.travis.yml +4 -2
- data/lib/fog/local.rb +1 -0
- data/lib/fog/local/version.rb +1 -1
- data/lib/fog/storage/local/models/file.rb +10 -14
- data/tests/local/models/file_tests.rb +32 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e0b4af75c75344097e40217e3f1ec9e84c3043d
|
4
|
+
data.tar.gz: 7d9e80f6f2e4ccc7f33d2fa2f5e51b700d4dfe0d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f32c1dc249f2bc2a88b9f631b9c65a39cf2752f2ab721a1424d9a683e77be4e9d30f7b43236fe55d27a6b92a4797d5d8911ff2728f3b5a1d0bb6af9537a5c78
|
7
|
+
data.tar.gz: 63f0bf2753a1d7ad7ee77cad0179768d6906bdbef7d6cc71b881aa3bb82a38eaf3c157f6aef373162cbc64e9c9b71e88e855109cf2ef357886ab80e9c47eabe3
|
data/.travis.yml
CHANGED
data/lib/fog/local.rb
CHANGED
data/lib/fog/local/version.rb
CHANGED
@@ -55,7 +55,7 @@ module Fog
|
|
55
55
|
break
|
56
56
|
end
|
57
57
|
pwd = Dir.pwd
|
58
|
-
if ::File.
|
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.
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
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.
|
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-
|
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.
|
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.
|