everythingrb 0.8.0 → 0.8.2

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: 0b3c80f8891826722af0d521a4dad5ba31e90540ad46cc31e25d6fc0ed34cd52
4
- data.tar.gz: 8e7f1daa4a9db4e31b2c4c3f58d3573ed36d833ab98e51d2daa997839f28eefd
3
+ metadata.gz: f1dea4517af697abde3f07ffb40d62a7ec40b3f8c0b91cc74eb93edde92e5aac
4
+ data.tar.gz: bb3888fac39b4d3138ddfb5f7d36504d3df28c274b4d9a950772aca0c5d5f0fc
5
5
  SHA512:
6
- metadata.gz: 9bc88ea3c150c7e6cb6b55364d78f2eb863ec368c39b40f1f7d855dbaa43a3f3c7cde240971e649ca2b0eeded6c639179614d472446f37a5a89ae59cd026616d
7
- data.tar.gz: 0327b5ae60b07e38ac81a292ca34639b6295beb23dab45410e0420350c3451e14745d1660e08520bcda2c92bc74a796bfdd12ecea1036414f01f1375218de1f1
6
+ metadata.gz: 341bf18d8e774f882b01b5ab50a7d262d113ecdbefab288c4e373cc6bb89b9f86a3ddf8a67d7a842016e6f62d04816db136c658106cf11685c50bd7d35693264
7
+ data.tar.gz: d7d3f73c40cec2555958de71452af51945f681d7e9731edc477c6428e316e71c607e22d00abd9257a1b4dd6ee0be0ee33b067a745c996593109621251464c8ea
data/CHANGELOG.md CHANGED
@@ -15,14 +15,32 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
15
15
  ### Removed
16
16
  -->
17
17
 
18
- ## [Unreleased]
18
+ ## [0.8.2] - 12025-05-25
19
19
 
20
20
  ### Added
21
21
 
22
22
  ### Changed
23
23
 
24
+ - Fixed `Hash#rename_key_unordered` and `Hash#rename_key_unordered!` to not create new key-value pairs when the original key doesn't exist. Previously, these methods would incorrectly add the `new_key` to the hash even when `old_key` was missing.
25
+
24
26
  ### Removed
25
27
 
28
+ ## [0.8.1] - 12025-05-21
29
+
30
+ ### Added
31
+
32
+ - Added configuration option for Rails for granular control
33
+ ```ruby
34
+ # In config/initializers/everythingrb.rb
35
+ Rails.application.configure do
36
+ config.everythingrb.extensions = [:array, :string, :hash]
37
+ end
38
+ ```
39
+
40
+ ### Fixed
41
+
42
+ - Fixed Rails compatibility with a Railtie to resolve a crash caused by load order
43
+
26
44
  ## [0.8.0] - 12025-05-11
27
45
 
28
46
  ### Added
@@ -283,7 +301,9 @@ This change aligns our method signatures with Ruby's conventions and matches our
283
301
 
284
302
  - Added alias `each` to `each_pair` in OpenStruct for better enumerable compatibility
285
303
 
286
- [unreleased]: https://github.com/itsthedevman/everythingrb/compare/v0.8.0...HEAD
304
+ [unreleased]: https://github.com/itsthedevman/everythingrb/compare/v0.8.2...HEAD
305
+ [0.8.2]: https://github.com/itsthedevman/everythingrb/compare/v0.8.1...v0.8.2
306
+ [0.8.1]: https://github.com/itsthedevman/everythingrb/compare/v0.8.0...v0.8.1
287
307
  [0.8.0]: https://github.com/itsthedevman/everythingrb/compare/v0.7.0...v0.8.0
288
308
  [0.7.0]: https://github.com/itsthedevman/everythingrb/compare/v0.6.1...v0.7.0
289
309
  [0.6.1]: https://github.com/itsthedevman/everythingrb/compare/v0.6.0...v0.6.1
data/README.md CHANGED
@@ -12,11 +12,15 @@ We've all been there - writing the same tedious patterns over and over:
12
12
 
13
13
  ```ruby
14
14
  # BEFORE
15
- users = [{ name: "Alice", role: "admin" }, { name: "Bob", role: "user" }]
15
+ users = [
16
+ { name: "Alice", role: "admin" },
17
+ { name: "Bob", role: "user" },
18
+ { name: "Charlie", role: "admin" }
19
+ ]
16
20
  admin_users = users.select { |u| u[:role] == "admin" }
17
21
  admin_names = admin_users.map { |u| u[:name] }
18
22
  result = admin_names.join(", ")
19
- # => "Alice"
23
+ # => "Alice, Charlie"
20
24
  ```
21
25
 
22
26
  With EverythingRB, you can write code that actually says what you mean:
@@ -24,7 +28,7 @@ With EverythingRB, you can write code that actually says what you mean:
24
28
  ```ruby
25
29
  # AFTER
26
30
  users.join_map(", ") { |u| u[:name] if u[:role] == "admin" }
27
- # => "Alice"
31
+ # => "Alice, Charlie"
28
32
  ```
29
33
 
30
34
  *Methods used: [`join_map`](https://itsthedevman.com/docs/everythingrb/Array.html#join_map-instance_method)*
@@ -45,7 +49,9 @@ gem install everythingrb
45
49
 
46
50
  There are two ways to use EverythingRB:
47
51
 
48
- ### Load Everything (Default)
52
+ ### Standard Ruby Projects
53
+
54
+ #### Load Everything (Default)
49
55
 
50
56
  The simplest approach - just require and go:
51
57
 
@@ -60,7 +66,7 @@ config = {server: {port: 443}}.to_ostruct
60
66
  config.server.port # => 443
61
67
  ```
62
68
 
63
- ### Cherry-Pick Extensions
69
+ #### Cherry-Pick Extensions
64
70
 
65
71
  If you only need specific extensions (or you're a minimalist at heart):
66
72
 
@@ -96,6 +102,21 @@ Available modules:
96
102
  - `symbol`: Symbol extensions (with_quotes)
97
103
  - `time`: Time extensions (in_quotes)
98
104
 
105
+ ### Rails Applications
106
+
107
+ EverythingRB works out of the box with Rails! Just add it to your Gemfile and you're all set.
108
+
109
+ If you only want specific extensions, configure them in an initializer:
110
+
111
+ ```ruby
112
+ # In config/initializers/everythingrb.rb
113
+ Rails.application.configure do
114
+ config.everythingrb.extensions = [:array, :string, :hash]
115
+ end
116
+ ```
117
+
118
+ By default (when `config.everythingrb.extensions` is not set), all extensions are loaded. Setting this to an empty array would effectively disable the gem.
119
+
99
120
  ## What's Included
100
121
 
101
122
  ### Data Structure Conversions
@@ -629,6 +629,10 @@ class Hash
629
629
  # But as the hash becomes larger, the performance improvements become diminished until they're roughly the same.
630
630
  # Neat!
631
631
  hash = except(old_key)
632
+
633
+ # Only modify the hash if the old key exists
634
+ return hash unless key?(old_key)
635
+
632
636
  hash[new_key] = self[old_key]
633
637
  hash
634
638
  end
@@ -650,6 +654,9 @@ class Hash
650
654
  # # => {a: 1, c: 3, middle: 2} # Order may differ
651
655
  #
652
656
  def rename_key_unordered!(old_key, new_key)
657
+ # Only modify the hash if the old key exists
658
+ return self unless key?(old_key)
659
+
653
660
  self[new_key] = delete(old_key)
654
661
  self
655
662
  end
@@ -7,5 +7,5 @@
7
7
  #
8
8
  module Everythingrb
9
9
  # Current version of the everythingrb gem
10
- VERSION = "0.8.0"
10
+ VERSION = "0.8.2"
11
11
  end
data/lib/everythingrb.rb CHANGED
@@ -1,4 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "everythingrb/prelude"
4
- require_relative "everythingrb/all"
4
+
5
+ if defined?(Rails::Railtie)
6
+ require_relative "railtie"
7
+ else
8
+ require_relative "everythingrb/all"
9
+ end
data/lib/railtie.rb ADDED
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Everythingrb
4
+ #
5
+ # Rails integration for EverythingRB
6
+ #
7
+ # This Railtie handles proper loading of EverythingRB extensions in a Rails environment,
8
+ # ensuring that everything works correctly with ActiveSupport and other Rails components.
9
+ #
10
+ # @example Configure which extensions to load in an initializer
11
+ # # config/initializers/everythingrb.rb
12
+ # Rails.application.configure do
13
+ # config.everythingrb.extensions = [:array, :string, :hash]
14
+ # end
15
+ #
16
+ # @note By default, all extensions are loaded. Setting `extensions` to an empty array
17
+ # effectively disables the gem.
18
+ #
19
+ class Railtie < Rails::Railtie
20
+ config.everythingrb = ActiveSupport::OrderedOptions.new
21
+ config.everythingrb.extensions = nil # Default to loading all
22
+
23
+ initializer "everythingrb.initialize" do
24
+ # I learned that, whereas ActiveSupport is defined at this point, the core_ext files are
25
+ # required later down the line.
26
+ ActiveSupport.on_load(:active_record) do
27
+ extensions = Rails.configuration.everythingrb.extensions
28
+
29
+ if extensions.is_a?(Array)
30
+ # Allow selective loading
31
+ extensions.each { |ext| require_relative "everythingrb/#{ext}" }
32
+ else
33
+ require_relative "everythingrb/all"
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: everythingrb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bryan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-05-11 00:00:00.000000000 Z
11
+ date: 2025-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ostruct
@@ -79,6 +79,7 @@ files:
79
79
  - lib/everythingrb/symbol.rb
80
80
  - lib/everythingrb/time.rb
81
81
  - lib/everythingrb/version.rb
82
+ - lib/railtie.rb
82
83
  homepage: https://github.com/itsthedevman/everythingrb
83
84
  licenses:
84
85
  - MIT