figjam 2.0.1 → 2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 553e785849c51c3e893343d8ce74a05039f66b5629c1049a15430f183d7e03b5
4
- data.tar.gz: 15daa5db7054cfa6a5e63829307c18725926ade03d7843a9f6c8a808d1020d5a
3
+ metadata.gz: eb55c0209ee029e45d1868e1eb32d159ac3b50b6bdbc8ba469a818c1058c4f00
4
+ data.tar.gz: 3c7febb9ba1368b82458221f2914348a344474cf50c5ef1bbbfd4247d853d18d
5
5
  SHA512:
6
- metadata.gz: 928a8b0694bfd5511aaeeaed69780b7465550ce02f92df06df1db79f39811a76531950be14ba503f8bdc0c9c73871831ed85a1b2af25ab260c1c7d2566e4965e
7
- data.tar.gz: 22d5358affb2da7fda4e02c080239fffe933aaff10d6c6bea8dc04aeedca9dbec6eeb2ae49892ae7bc1b3ddbc97875d1635a4de521db9e4703836246ee235684
6
+ metadata.gz: 1ba7fd124b00dcaa9f789a43556ab4725d1f7a8f0ed4b4112eafe6dfad72fefb583f4779df2a5a7fed1b8062764a149890ae952d16c7dcb03680a4531d13a390
7
+ data.tar.gz: b18b0f948baf4005b858cf38c162d66fd9620c62992f52a738c682be1b3abc7548529e03de36114123ebf89d060ccd3cba11877e11c8655bf33c461d342de79e
data/README.md CHANGED
@@ -59,15 +59,26 @@ overrides.
59
59
 
60
60
  Figjam is perfect for Rails engines. They can have their own configuration file, and
61
61
  they can be loaded independently or in addition of the main application. To do this,
62
- you can create a `config/application.yml` file in your engine, and add this initializer:
62
+ you can create a `config/application.yml` file in your engine, and add this to the `Rails::Engine`:
63
63
 
64
64
  ```ruby
65
- Figjam::Application.new(
66
- environment: ::Rails.env,
67
- path: File.expand_path("../application.yml", __dir__)
68
- ).load
65
+ module MyEngine
66
+ class Engine < ::Rails::Engine
67
+ Figjam::Rails::Engine.configure(self)
68
+ end
69
+ end
70
+
71
+ # Or if you wish to pass in a specific value for the environment:
72
+ module MyEngine
73
+ class Engine < ::Rails::Engine
74
+ Figjam::Rails::Engine.configure(self, "my_engine_environment")
75
+ end
76
+ end
69
77
  ```
70
78
 
79
+ This will ensure that the engine's configuration is loaded when the Rails application starts, and
80
+ before any other initializers run.
81
+
71
82
  ### Usage without Rails
72
83
 
73
84
  If you are not using Rails, you can load Figjam in your gem. Note, you can
@@ -69,7 +69,9 @@ module Figjam
69
69
  end
70
70
 
71
71
  private def parse(path)
72
- (File.exist?(path) && load_yaml(ERB.new(File.read(path)).result)) || {} # nosemgrep
72
+ raise ArgumentError, "Figjam config path #{path} not found" unless File.exist?(path)
73
+
74
+ load_yaml(ERB.new(File.read(path)).result) # nosemgrep
73
75
  end
74
76
 
75
77
  # rubocop:disable Security/YAMLLoad
@@ -96,8 +98,8 @@ module Figjam
96
98
  non_string_configuration(value) unless value.is_a?(String) || value.nil?
97
99
  end
98
100
 
99
- ::ENV[key.to_s] = value.nil? ? nil : value.to_s
100
- ::ENV[FIGARO_ENV_PREFIX + key.to_s] = value.nil? ? nil : value.to_s
101
+ ::ENV[key.to_s] = value&.to_s
102
+ ::ENV[FIGARO_ENV_PREFIX + key.to_s] = value&.to_s
101
103
  end
102
104
 
103
105
  private def skip?(key)
data/lib/figjam/env.rb CHANGED
@@ -29,11 +29,11 @@ module Figjam
29
29
  method.to_s.downcase.match(/^(.+?)([!?=])?$/).captures
30
30
  end
31
31
 
32
- # rubocop:disable Naming/PredicateName
32
+ # rubocop:disable Naming/PredicatePrefix
33
33
  private def has_key?(key)
34
34
  ::ENV.any? { |k, _| k.downcase == key }
35
35
  end
36
- # rubocop:enable Naming/PredicateName
36
+ # rubocop:enable Naming/PredicatePrefix
37
37
 
38
38
  private def missing_key!(key)
39
39
  raise MissingKey, key
@@ -0,0 +1,16 @@
1
+ module Figjam
2
+ module Rails
3
+ module Engine
4
+ class << self
5
+ def configure(engine_context, environment = ::Rails.env)
6
+ engine_context.config.before_configuration do
7
+ Figjam::Application.new(
8
+ environment: environment,
9
+ path: "#{engine_context.root}/config/application.yml"
10
+ ).load
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
data/lib/figjam/rails.rb CHANGED
@@ -6,6 +6,7 @@ rescue LoadError
6
6
  # Cater for no Rails
7
7
  else
8
8
  require "figjam/rails/application"
9
+ require "figjam/rails/engine"
9
10
 
10
11
  Figjam.adapter = Figjam::Rails::Application
11
12
  require "figjam/rails/railtie"
@@ -1,3 +1,3 @@
1
1
  module Figjam
2
- VERSION = "2.0.1".freeze
2
+ VERSION = "2.2.0".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: figjam
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Harry Lascelles
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-06-03 00:00:00.000000000 Z
11
+ date: 2025-07-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -212,6 +212,20 @@ dependencies:
212
212
  - - ">="
213
213
  - !ruby/object:Gem::Version
214
214
  version: '0'
215
+ - !ruby/object:Gem::Dependency
216
+ name: rubocop-magic_numbers
217
+ requirement: !ruby/object:Gem::Requirement
218
+ requirements:
219
+ - - ">="
220
+ - !ruby/object:Gem::Version
221
+ version: '0'
222
+ type: :development
223
+ prerelease: false
224
+ version_requirements: !ruby/object:Gem::Requirement
225
+ requirements:
226
+ - - ">="
227
+ - !ruby/object:Gem::Version
228
+ version: '0'
215
229
  - !ruby/object:Gem::Dependency
216
230
  name: rubocop-performance
217
231
  requirement: !ruby/object:Gem::Requirement
@@ -227,7 +241,7 @@ dependencies:
227
241
  - !ruby/object:Gem::Version
228
242
  version: '0'
229
243
  - !ruby/object:Gem::Dependency
230
- name: rubocop-rake
244
+ name: rubocop-rails
231
245
  requirement: !ruby/object:Gem::Requirement
232
246
  requirements:
233
247
  - - ">="
@@ -240,8 +254,36 @@ dependencies:
240
254
  - - ">="
241
255
  - !ruby/object:Gem::Version
242
256
  version: '0'
257
+ - !ruby/object:Gem::Dependency
258
+ name: rubocop-rake
259
+ requirement: !ruby/object:Gem::Requirement
260
+ requirements:
261
+ - - ">"
262
+ - !ruby/object:Gem::Version
263
+ version: 0.7.0
264
+ type: :development
265
+ prerelease: false
266
+ version_requirements: !ruby/object:Gem::Requirement
267
+ requirements:
268
+ - - ">"
269
+ - !ruby/object:Gem::Version
270
+ version: 0.7.0
243
271
  - !ruby/object:Gem::Dependency
244
272
  name: rubocop-rspec
273
+ requirement: !ruby/object:Gem::Requirement
274
+ requirements:
275
+ - - ">"
276
+ - !ruby/object:Gem::Version
277
+ version: 3.5.0
278
+ type: :development
279
+ prerelease: false
280
+ version_requirements: !ruby/object:Gem::Requirement
281
+ requirements:
282
+ - - ">"
283
+ - !ruby/object:Gem::Version
284
+ version: 3.5.0
285
+ - !ruby/object:Gem::Dependency
286
+ name: rubocop-thread_safety
245
287
  requirement: !ruby/object:Gem::Requirement
246
288
  requirements:
247
289
  - - ">="
@@ -294,6 +336,7 @@ files:
294
336
  - lib/figjam/figaro_alias.rb
295
337
  - lib/figjam/rails.rb
296
338
  - lib/figjam/rails/application.rb
339
+ - lib/figjam/rails/engine.rb
297
340
  - lib/figjam/rails/railtie.rb
298
341
  - lib/figjam/version.rb
299
342
  homepage: https://github.com/hlascelles/figjam