saviour 0.4.7 → 0.4.8
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/lib/saviour/local_storage.rb +9 -4
- data/lib/saviour/version.rb +1 -1
- data/spec/models/local_storage_spec.rb +22 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 709681c9a25bc91c834cdf0d2ad1027fbd64a458
|
4
|
+
data.tar.gz: 21ba25beeb98a5aa4ff061f96143896ec7006d5a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e2f3746a2455e442ae5920f65244eb8ba596ca6a77864e30d4bb24a388ee14fb2bf17c806112071f7c80310bcaee3fb05077484fb1bd97fd83ca6d2a2b95f0d
|
7
|
+
data.tar.gz: db8b60ee46c478b21faa237ed688c5a53a8526e022df2962cd8ad162948322ae3aa6c6850af5876d7c5fe4dcb01fe5f442559137a84e8f713bd5927a901b72fa
|
@@ -7,21 +7,22 @@ module Saviour
|
|
7
7
|
def initialize(opts = {})
|
8
8
|
@local_prefix = opts[:local_prefix]
|
9
9
|
@public_url_prefix = opts[:public_url_prefix]
|
10
|
+
@permissions = opts.fetch(:permissions, 0644)
|
10
11
|
end
|
11
12
|
|
12
13
|
def write(contents, path)
|
13
14
|
ensure_dir!(path)
|
14
15
|
|
15
|
-
::File.
|
16
|
-
|
17
|
-
|
18
|
-
end
|
16
|
+
::File.write real_path(path), contents, mode: "wb"
|
17
|
+
|
18
|
+
ensure_file_permissions!(path)
|
19
19
|
end
|
20
20
|
|
21
21
|
def write_from_file(file, path)
|
22
22
|
ensure_dir!(path)
|
23
23
|
|
24
24
|
FileUtils.cp file.path, real_path(path)
|
25
|
+
ensure_file_permissions!(path)
|
25
26
|
end
|
26
27
|
|
27
28
|
def read_to_file(path, dest_file)
|
@@ -65,6 +66,10 @@ module Saviour
|
|
65
66
|
|
66
67
|
private
|
67
68
|
|
69
|
+
def ensure_file_permissions!(path)
|
70
|
+
::File.chmod @permissions, real_path(path)
|
71
|
+
end
|
72
|
+
|
68
73
|
def ensure_dir!(path)
|
69
74
|
dir = ::File.dirname(real_path(path))
|
70
75
|
FileUtils.mkdir_p(dir) unless ::File.directory?(dir)
|
data/lib/saviour/version.rb
CHANGED
@@ -36,6 +36,28 @@ describe Saviour::LocalStorage do
|
|
36
36
|
expect(File.read(path)).to eq contents
|
37
37
|
end
|
38
38
|
end
|
39
|
+
|
40
|
+
describe "permissions" do
|
41
|
+
it "are 0644 by default" do
|
42
|
+
file_destination = File.join(@tmpdir, destination_path)
|
43
|
+
subject.write "Some contents", destination_path
|
44
|
+
expect(File.file?(file_destination)).to be_truthy
|
45
|
+
|
46
|
+
expect(File.stat(file_destination).mode.to_s(8)).to match /0644$/
|
47
|
+
end
|
48
|
+
|
49
|
+
context do
|
50
|
+
subject { Saviour::LocalStorage.new(local_prefix: @tmpdir, permissions: 0600) }
|
51
|
+
|
52
|
+
it "can be changed by config" do
|
53
|
+
file_destination = File.join(@tmpdir, destination_path)
|
54
|
+
subject.write "Some contents", destination_path
|
55
|
+
expect(File.file?(file_destination)).to be_truthy
|
56
|
+
|
57
|
+
expect(File.stat(file_destination).mode.to_s(8)).to match /0600$/
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
39
61
|
end
|
40
62
|
|
41
63
|
describe "#read" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: saviour
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roger Campos
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-01-
|
11
|
+
date: 2018-01-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|