leml 0.1.2.1 → 0.2.0
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/leml/core.rb +7 -7
- data/lib/leml/railtie.rb +11 -5
- data/lib/leml/version.rb +1 -1
- 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: 9203db353aaaa297b99e9a288feaf73317cf03ab
|
4
|
+
data.tar.gz: 0fb30539a3e9d4498e589cf148774b4bde70ca9f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a597c10bdf5e94c4f12db9f947fdff68b04996583bc642a55d154248ca2390db156a5291e9feb6f77c6e9f0b527887ced55cec44b040cb9e25cad8083dddcb9
|
7
|
+
data.tar.gz: e0d7f671d3fc991371dc7c7133363dccf823458e3c7c8e82031ebdd38af50591d38221c0ab96370ddd9097eece996f8e3988f991afe6b581ecc93220e67d811d
|
data/lib/leml/core.rb
CHANGED
@@ -2,7 +2,7 @@ require 'rails'
|
|
2
2
|
|
3
3
|
module Leml
|
4
4
|
class Core
|
5
|
-
|
5
|
+
KEY_FILE = Rails.root.join('config', 'leml.key')
|
6
6
|
SECRETS = Rails.root.join('config', 'leml.yml')
|
7
7
|
|
8
8
|
class << self
|
@@ -15,8 +15,8 @@ module Leml
|
|
15
15
|
private
|
16
16
|
|
17
17
|
def key_initialize
|
18
|
-
confirm_initialize(
|
19
|
-
File.open(
|
18
|
+
confirm_initialize(KEY_FILE) if File.exist?(KEY_FILE)
|
19
|
+
File.open(KEY_FILE, 'w') do |file|
|
20
20
|
file.puts(SecureRandom.hex(16))
|
21
21
|
end
|
22
22
|
end
|
@@ -62,14 +62,14 @@ module Leml
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def initialize
|
65
|
-
|
66
|
-
|
67
|
-
@encryptor = ActiveSupport::MessageEncryptor.new(key, cipher: 'aes-256-cbc')
|
65
|
+
@key = File.exist?(KEY_FILE) ? File.read(KEY_FILE).chop : ENV['LEML_KEY']
|
66
|
+
return if @key.blank?
|
67
|
+
@encryptor = ActiveSupport::MessageEncryptor.new(@key, cipher: 'aes-256-cbc')
|
68
68
|
@secrets = YAML.load_file(SECRETS)
|
69
69
|
end
|
70
70
|
|
71
71
|
def merge_secrets
|
72
|
-
return unless
|
72
|
+
return unless @key.present? && File.exists?(SECRETS)
|
73
73
|
Rails.application.secrets.merge!(decrypt(@secrets)[Rails.env].deep_symbolize_keys) if @secrets
|
74
74
|
end
|
75
75
|
|
data/lib/leml/railtie.rb
CHANGED
@@ -1,10 +1,16 @@
|
|
1
|
-
require 'rails'
|
1
|
+
require 'rails/railtie'
|
2
2
|
|
3
3
|
module Leml
|
4
|
-
class Railtie < Rails::
|
5
|
-
initializer '
|
6
|
-
|
7
|
-
|
4
|
+
class Railtie < Rails::Railtie
|
5
|
+
initializer 'leml.merge_secrets' do
|
6
|
+
config.before_initialize do
|
7
|
+
require 'leml/core'
|
8
|
+
Leml::Core.new.merge_secrets
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
rake_tasks do
|
13
|
+
load 'tasks/leml_tasks.rake'
|
8
14
|
end
|
9
15
|
end
|
10
16
|
end
|
data/lib/leml/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: leml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- onunu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-09-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|