rake_secrets 0.1.0.pre.3 → 0.1.0.pre.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/rake_secrets/errors/no_such_path_error.rb +8 -0
- data/lib/rake_secrets/errors/remove_error.rb +8 -0
- data/lib/rake_secrets/errors/retrieve_error.rb +8 -0
- data/lib/rake_secrets/errors/store_error.rb +8 -0
- data/lib/rake_secrets/errors/unsupported_operation_error.rb +8 -0
- data/lib/rake_secrets/errors.rb +12 -0
- data/lib/rake_secrets/storage/base.rb +5 -8
- data/lib/rake_secrets/storage/file_system.rb +52 -0
- data/lib/rake_secrets/storage/in_memory.rb +8 -3
- data/lib/rake_secrets/storage.rb +1 -0
- data/lib/rake_secrets/version.rb +1 -1
- data/lib/rake_secrets.rb +1 -0
- metadata +8 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 100abe0dc35580a1e91253c092dcea4d8beb79899f90aa8addf82b6854a6dcb3
|
4
|
+
data.tar.gz: 8659c46791c6434d9d187b1f3233e6a25f0f61cc99f9d9182ba616ef950454ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d43fdad6d0f931f43e5f480db007705f8bc4c62c37824652b8e78dc08b6f4f02dfeddfd9c7f61f97addc6fc0d0cabb86f03949afd1103f027ff5103f9cfcd215
|
7
|
+
data.tar.gz: b6116f103ac51326ff0244119710b56d13d706bfd14d624b011624698fa2aa513361dd8c4233bdd3c14e9922173c1e751bcc9c1dac3b681bb7000a63ea7a28f5
|
data/Gemfile.lock
CHANGED
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'errors/unsupported_operation_error'
|
4
|
+
require_relative 'errors/no_such_path_error'
|
5
|
+
require_relative 'errors/store_error'
|
6
|
+
require_relative 'errors/remove_error'
|
7
|
+
require_relative 'errors/retrieve_error'
|
8
|
+
|
9
|
+
module RakeSecrets
|
10
|
+
module Errors
|
11
|
+
end
|
12
|
+
end
|
@@ -1,23 +1,20 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require_relative '../errors'
|
4
4
|
|
5
5
|
module RakeSecrets
|
6
6
|
module Storage
|
7
|
-
class UnsupportedOperationError < StandardError
|
8
|
-
end
|
9
|
-
|
10
7
|
class Base
|
11
8
|
def store(_path, _content)
|
12
|
-
raise(UnsupportedOperationError, '#store not supported.')
|
9
|
+
raise(Errors::UnsupportedOperationError, '#store not supported.')
|
13
10
|
end
|
14
11
|
|
15
12
|
def remove(_path)
|
16
|
-
raise(UnsupportedOperationError, '#remove not supported.')
|
13
|
+
raise(Errors::UnsupportedOperationError, '#remove not supported.')
|
17
14
|
end
|
18
15
|
|
19
|
-
def
|
20
|
-
raise(UnsupportedOperationError, '#
|
16
|
+
def retrieve(_path)
|
17
|
+
raise(Errors::UnsupportedOperationError, '#retrieve not supported.')
|
21
18
|
end
|
22
19
|
end
|
23
20
|
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
require_relative './base'
|
6
|
+
require_relative '../errors'
|
7
|
+
|
8
|
+
module RakeSecrets
|
9
|
+
module Storage
|
10
|
+
class FileSystem < Base
|
11
|
+
def store(path, content)
|
12
|
+
FileUtils.mkdir_p(File.dirname(path))
|
13
|
+
File.write(path, content)
|
14
|
+
rescue SystemCallError, IOError
|
15
|
+
raise(
|
16
|
+
RakeSecrets::Errors::StoreError,
|
17
|
+
"Failed to store at path: '#{path}'."
|
18
|
+
)
|
19
|
+
end
|
20
|
+
|
21
|
+
def remove(path)
|
22
|
+
ensure_path_exists(path)
|
23
|
+
|
24
|
+
File.delete(path)
|
25
|
+
rescue SystemCallError
|
26
|
+
raise(
|
27
|
+
RakeSecrets::Errors::RemoveError,
|
28
|
+
"Failed to remove from path: '#{path}'."
|
29
|
+
)
|
30
|
+
end
|
31
|
+
|
32
|
+
def retrieve(path)
|
33
|
+
ensure_path_exists(path)
|
34
|
+
|
35
|
+
File.read(path)
|
36
|
+
rescue SystemCallError
|
37
|
+
raise(
|
38
|
+
RakeSecrets::Errors::RetrieveError,
|
39
|
+
"Failed to retrieve from path: '#{path}'."
|
40
|
+
)
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def ensure_path_exists(path)
|
46
|
+
return if File.exist?(path)
|
47
|
+
|
48
|
+
raise(Errors::NoSuchPathError, "Path '#{path}' not in storage.")
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -1,13 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative './base'
|
4
|
+
require_relative '../errors'
|
4
5
|
|
5
6
|
module RakeSecrets
|
6
7
|
module Storage
|
7
8
|
class InMemory < Base
|
8
|
-
def initialize(
|
9
|
+
def initialize(opts = {})
|
9
10
|
super()
|
10
|
-
@persistence =
|
11
|
+
@persistence = opts[:contents] || {}
|
11
12
|
end
|
12
13
|
|
13
14
|
def store(path, content)
|
@@ -18,7 +19,11 @@ module RakeSecrets
|
|
18
19
|
@persistence.delete(path)
|
19
20
|
end
|
20
21
|
|
21
|
-
def
|
22
|
+
def retrieve(path)
|
23
|
+
unless @persistence.include?(path)
|
24
|
+
raise(Errors::NoSuchPathError, "Path '#{path}' not in storage.")
|
25
|
+
end
|
26
|
+
|
22
27
|
@persistence[path]
|
23
28
|
end
|
24
29
|
end
|
data/lib/rake_secrets/storage.rb
CHANGED
data/lib/rake_secrets/version.rb
CHANGED
data/lib/rake_secrets.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rake_secrets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.pre.
|
4
|
+
version: 0.1.0.pre.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- InfraBlocks Maintainers
|
@@ -54,9 +54,16 @@ files:
|
|
54
54
|
- bin/console
|
55
55
|
- bin/setup
|
56
56
|
- lib/rake_secrets.rb
|
57
|
+
- lib/rake_secrets/errors.rb
|
58
|
+
- lib/rake_secrets/errors/no_such_path_error.rb
|
59
|
+
- lib/rake_secrets/errors/remove_error.rb
|
60
|
+
- lib/rake_secrets/errors/retrieve_error.rb
|
61
|
+
- lib/rake_secrets/errors/store_error.rb
|
62
|
+
- lib/rake_secrets/errors/unsupported_operation_error.rb
|
57
63
|
- lib/rake_secrets/mixins/support.rb
|
58
64
|
- lib/rake_secrets/storage.rb
|
59
65
|
- lib/rake_secrets/storage/base.rb
|
66
|
+
- lib/rake_secrets/storage/file_system.rb
|
60
67
|
- lib/rake_secrets/storage/in_memory.rb
|
61
68
|
- lib/rake_secrets/tasks.rb
|
62
69
|
- lib/rake_secrets/tasks/generate.rb
|