ravioli 0.1.5 → 0.1.9

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: 7531708baaf2764477fc99c00343d6ccb10873695ccd6d20c56cb38a21f6520d
4
- data.tar.gz: 13b46317a8d6b9fa5f167cab39c3cef998889951fb99b44d0177612798c087e8
3
+ metadata.gz: bdb5c361547c4d60716b512dc80eb81fb0ba897c898416eb6a70dbbca33200fa
4
+ data.tar.gz: c62de7b31a55d07c27ca894bce1698ac12477a7f12f4501260682d184bf7b25b
5
5
  SHA512:
6
- metadata.gz: 79ba9026307074c13efb196b3fd3213ac76668def0064bb4c13a1abf0244c74be128bd259ec472aa09ef36b0bd26f4f5097f097206e42def11b59e04e9f01d25
7
- data.tar.gz: ea102e1c1ad70d0fe6b6cfa9460804cf726a8bde10c404dc7eb03e598f6d6e03f7c9d4aca848c5f1f8b9642f906155af7feed4cde336d0328b4f137d1839bc4e
6
+ metadata.gz: 41fb4047b0d97c117e7714d9e8d8e5e2a01f85628d4828d0ddf5e590c3d66d02813d919e9d7f8290d949a0277dfbabc6acf02c9b0029060bce802ab16ae14416
7
+ data.tar.gz: 9736ba87ea128c55ac03dcda8f6f6a9172fdf549356b7642c14a02136092c262086468cd905d5d592407995e216264ebaed7c7fc2a82603c115c137e0f8d8e64
data/lib/ravioli.rb CHANGED
@@ -40,4 +40,4 @@ module Ravioli
40
40
  end
41
41
  end
42
42
 
43
- require_relative "ravioli/engine" if defined?(Rails)
43
+ require_relative "ravioli/railtie" if defined?(Rails)
@@ -99,6 +99,7 @@ module Ravioli
99
99
  load_credentials(
100
100
  key_path: "config/master.key",
101
101
  env_names: %w[master root],
102
+ quiet: true,
102
103
  )
103
104
 
104
105
  # Load any environment-specific configuration on top of it. Since Rails will try
@@ -107,6 +108,7 @@ module Ravioli
107
108
  "config/credentials/#{Rails.env}",
108
109
  key_path: "config/credentials/#{Rails.env}.key",
109
110
  env_names: ["master"],
111
+ quiet: true,
110
112
  )
111
113
 
112
114
  # Apply staging configuration on top of THAT, if need be
@@ -115,6 +117,7 @@ module Ravioli
115
117
  "config/credentials/staging",
116
118
  env_names: %w[staging master],
117
119
  key_path: "config/credentials/staging.key",
120
+ quiet: true,
118
121
  )
119
122
  end
120
123
  end
@@ -145,11 +148,11 @@ module Ravioli
145
148
  end
146
149
 
147
150
  # Load secure credentials using a key either from a file or the ENV
148
- def load_credentials(path = "credentials", key_path: path, env_names: path.split("/").last)
151
+ def load_credentials(path = "credentials", key_path: path, env_names: path.split("/").last, quiet: false)
149
152
  error = nil
150
153
  env_names = Array(env_names).map { |env_name| parse_env_name(env_name) }
151
154
  env_names.each do |env_name|
152
- credentials = parse_credentials(path, env_name: env_name, key_path: key_path)
155
+ credentials = parse_credentials(path, env_name: env_name, key_path: key_path, quiet: quiet)
153
156
  if credentials.present?
154
157
  configuration.append(credentials)
155
158
  return credentials
@@ -262,14 +265,14 @@ module Ravioli
262
265
  env_name.match?(/^RAILS_/) ? env_name : "RAILS_#{env_name.upcase}_KEY"
263
266
  end
264
267
 
265
- def parse_credentials(path, key_path: path, env_name: path.split("/").last)
268
+ def parse_credentials(path, key_path: path, env_name: path.split("/").last, quiet: false)
266
269
  @current_credentials = path
267
270
  env_name = parse_env_name(env_name)
268
271
  key_path = path_to_config_file_path(key_path, extnames: "key", quiet: true)
269
272
  options = {key_path: key_path.to_s}
270
273
  options[:env_key] = ENV[env_name].present? ? env_name : "__RAVIOLI__#{SecureRandom.hex(6)}"
271
274
 
272
- path = path_to_config_file_path(path, extnames: "yml.enc")
275
+ path = path_to_config_file_path(path, extnames: "yml.enc", quiet: quiet)
273
276
  (Rails.application.encrypted(path, **options)&.config || {}).tap do
274
277
  @current_credentials = nil
275
278
  end
@@ -92,9 +92,13 @@ module Ravioli
92
92
  # rubocop:disable Style/MethodMissingSuper
93
93
  # rubocop:disable Style/MissingRespondToMissing
94
94
  def method_missing(method, *args, &block)
95
+ return super unless args.empty?
96
+
95
97
  # Return proper booleans from query methods
96
- return send(method.to_s.chomp("?")).present? if args.empty? && method.to_s.ends_with?("?")
97
- super
98
+ return send(method.to_s.chomp("?")).present? if method.to_s.ends_with?("?")
99
+
100
+ # Try to find a matching ENV key
101
+ fetch_env_key_for(method) { super(method, *args, &block) }
98
102
  end
99
103
  # rubocop:enable Style/MissingRespondToMissing
100
104
  # rubocop:enable Style/MethodMissingSuper
@@ -1,18 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "./staging_inquirer"
4
- Rails.env.class.prepend Ravioli::StagingInquirer
5
4
 
6
5
  module Ravioli
7
- class Engine < ::Rails::Engine
8
- # Bootstrap Ravioli onto the Rails app
9
- initializer "ravioli", before: :load_environment_config do |app|
10
- Rails.extend Ravioli::RailsConfig unless Rails.respond_to?(:config)
11
- end
12
- end
13
-
14
- private
15
-
16
6
  module RailsConfig
17
7
  def config
18
8
  Ravioli.default || Ravioli.build(namespace: Rails.application&.class&.module_parent, strict: Rails.env.production?) do |config|
@@ -22,4 +12,10 @@ module Ravioli
22
12
  end
23
13
  end
24
14
  end
15
+
16
+ class Railtie < ::Rails::Railtie
17
+ # Bootstrap Ravioli onto the Rails app
18
+ Rails.env.class.prepend Ravioli::StagingInquirer
19
+ Rails.extend Ravioli::RailsConfig unless Rails.respond_to?(:config)
20
+ end
25
21
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ravioli
4
- VERSION = "0.1.5"
4
+ VERSION = "0.1.9"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ravioli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Flip Sasser
@@ -270,7 +270,7 @@ files:
270
270
  - lib/ravioli.rb
271
271
  - lib/ravioli/builder.rb
272
272
  - lib/ravioli/configuration.rb
273
- - lib/ravioli/engine.rb
273
+ - lib/ravioli/railtie.rb
274
274
  - lib/ravioli/staging_inquirer.rb
275
275
  - lib/ravioli/version.rb
276
276
  homepage: https://github.com/flipsasser/ravioli