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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 74d4dd4e8fc036cfe4489f8998c46d8841b298cdd0b50583c7233e8fdd5d8aed
4
- data.tar.gz: b1e2cba8af58326856a87aaaa0cc60d494b4892e52b8be21850b17ba1030156e
3
+ metadata.gz: 100abe0dc35580a1e91253c092dcea4d8beb79899f90aa8addf82b6854a6dcb3
4
+ data.tar.gz: 8659c46791c6434d9d187b1f3233e6a25f0f61cc99f9d9182ba616ef950454ed
5
5
  SHA512:
6
- metadata.gz: da7bd3843a0d2bf0515e6c92f00427d97d3d589f7971c406e8b6ee94e5cd73ca8036a73c856525724a6cc8b416e225eb2cd368af540ba42a99f4123887d5463b
7
- data.tar.gz: '080cfd5e18baeee7134bcd6285483b4bfdf0790656842fc28f391e3ec11a34a9ff1f8daf5042bde61077122798008c9cfc0535e5cc65ac0182ab3e04ec73fa12'
6
+ metadata.gz: d43fdad6d0f931f43e5f480db007705f8bc4c62c37824652b8e78dc08b6f4f02dfeddfd9c7f61f97addc6fc0d0cabb86f03949afd1103f027ff5103f9cfcd215
7
+ data.tar.gz: b6116f103ac51326ff0244119710b56d13d706bfd14d624b011624698fa2aa513361dd8c4233bdd3c14e9922173c1e751bcc9c1dac3b681bb7000a63ea7a28f5
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rake_secrets (0.1.0.pre.3)
4
+ rake_secrets (0.1.0.pre.4)
5
5
  colored2 (~> 3.1)
6
6
  rake_factory (= 0.32.0.pre.2)
7
7
 
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RakeSecrets
4
+ module Errors
5
+ class NoSuchPathError < StandardError
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RakeSecrets
4
+ module Errors
5
+ class RemoveError < StandardError
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RakeSecrets
4
+ module Errors
5
+ class RetrieveError < StandardError
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RakeSecrets
4
+ module Errors
5
+ class StoreError < StandardError
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RakeSecrets
4
+ module Errors
5
+ class UnsupportedOperationError < StandardError
6
+ end
7
+ end
8
+ end
@@ -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
- require 'rake_factory'
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 get(_path)
20
- raise(UnsupportedOperationError, '#get not supported.')
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(persistence = {})
9
+ def initialize(opts = {})
9
10
  super()
10
- @persistence = 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 get(path)
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
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'storage/in_memory'
4
+ require_relative 'storage/file_system'
4
5
 
5
6
  module RakeSecrets
6
7
  module Storage
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RakeSecrets
4
- VERSION = '0.1.0.pre.3'
4
+ VERSION = '0.1.0.pre.4'
5
5
  end
data/lib/rake_secrets.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'rake_secrets/errors'
3
4
  require 'rake_secrets/tasks'
4
5
  require 'rake_secrets/storage'
5
6
  require 'rake_secrets/types'
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.3
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