rake_secrets 0.1.0.pre.2 → 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/types/alphabetic.rb +32 -0
- data/lib/rake_secrets/types/numeric.rb +22 -0
- data/lib/rake_secrets/types.rb +10 -0
- data/lib/rake_secrets/version.rb +1 -1
- data/lib/rake_secrets.rb +1 -0
- metadata +10 -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
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative './character_set'
|
4
|
+
|
5
|
+
module RakeSecrets
|
6
|
+
module Types
|
7
|
+
class Alphabetic
|
8
|
+
LOWERCASE_CHARACTERS = ('a'..'z').to_a
|
9
|
+
UPPERCASE_CHARACTERS = ('A'..'Z').to_a
|
10
|
+
|
11
|
+
def initialize(opts = {})
|
12
|
+
@delegate = CharacterSet.new(
|
13
|
+
character_set(opts[:case]),
|
14
|
+
length: opts[:length] || 32
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
def generate
|
19
|
+
@delegate.generate
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def character_set(case_type)
|
25
|
+
characters = []
|
26
|
+
characters += UPPERCASE_CHARACTERS if %i[upper both].include?(case_type)
|
27
|
+
characters += LOWERCASE_CHARACTERS unless case_type == :upper
|
28
|
+
characters
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative './character_set'
|
4
|
+
|
5
|
+
module RakeSecrets
|
6
|
+
module Types
|
7
|
+
class Numeric
|
8
|
+
NUMBER_CHARACTERS = ('0'..'9').to_a
|
9
|
+
|
10
|
+
def initialize(opts = {})
|
11
|
+
@delegate = CharacterSet.new(
|
12
|
+
NUMBER_CHARACTERS,
|
13
|
+
length: opts[:length] || 32
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
17
|
+
def generate
|
18
|
+
@delegate.generate
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/rake_secrets/types.rb
CHANGED
@@ -2,7 +2,9 @@
|
|
2
2
|
|
3
3
|
require_relative 'types/constant'
|
4
4
|
require_relative 'types/character_set'
|
5
|
+
require_relative 'types/alphabetic'
|
5
6
|
require_relative 'types/alphanumeric'
|
7
|
+
require_relative 'types/numeric'
|
6
8
|
|
7
9
|
module RakeSecrets
|
8
10
|
module Types
|
@@ -15,9 +17,17 @@ module RakeSecrets
|
|
15
17
|
CharacterSet.new(set, opts)
|
16
18
|
end
|
17
19
|
|
20
|
+
def alphabetic(opts = {})
|
21
|
+
Alphabetic.new(opts)
|
22
|
+
end
|
23
|
+
|
18
24
|
def alphanumeric(opts = {})
|
19
25
|
Alphanumeric.new(opts)
|
20
26
|
end
|
27
|
+
|
28
|
+
def numeric(opts = {})
|
29
|
+
Numeric.new(opts)
|
30
|
+
end
|
21
31
|
end
|
22
32
|
end
|
23
33
|
end
|
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
|
@@ -65,9 +72,11 @@ files:
|
|
65
72
|
- lib/rake_secrets/transformers/erb_template.rb
|
66
73
|
- lib/rake_secrets/transformers/identity.rb
|
67
74
|
- lib/rake_secrets/types.rb
|
75
|
+
- lib/rake_secrets/types/alphabetic.rb
|
68
76
|
- lib/rake_secrets/types/alphanumeric.rb
|
69
77
|
- lib/rake_secrets/types/character_set.rb
|
70
78
|
- lib/rake_secrets/types/constant.rb
|
79
|
+
- lib/rake_secrets/types/numeric.rb
|
71
80
|
- lib/rake_secrets/version.rb
|
72
81
|
- rake_secrets.gemspec
|
73
82
|
homepage: https://github.com/infrablocks/rake_secrets
|