internationalize 0.5.1 → 0.6.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: 3b0cf11a752999e4dbbbc5d4052c919e98958a4cfc9a289b4bada123f9138574
4
- data.tar.gz: adc607000e536c7858b0b3ab1d3071995575bc7482f7d7c97692a3b90f4a9997
3
+ metadata.gz: 669e02f74b620a585a47fff36508f25d15a192dd9aaac8f4e2e5ff87a51b1b0e
4
+ data.tar.gz: dd3fb3052577a917627501f88fe192f725c1e9968e437a9e39d0cd2b58cea4d1
5
5
  SHA512:
6
- metadata.gz: 61a9c88a71bf96370975b5c1f0163b668ff45163f8c75cc0e151518c992866b2194846081a2259ac876e6ce9eb4ff1a38d2ad9628069f421b4232c2ca377d835
7
- data.tar.gz: 946c06a56af45762973f109a50c132573fbdef72fa26c900ca1478bdacd4f945dfb58e670683bbd9bbdb68a9bfeda1a732ab3913178875be518eb8bd172f67cd
6
+ metadata.gz: 82f5388681b2fb6db3d2d8069eeef062514af9c5f306d102a88514140587fba43355c831938155d4c5b2013b82144b07351b4de936afc8131114c129a3757b91
7
+ data.tar.gz: 59f86594b330f856091a9c415fb153878093dd110fc448539f47c7cd61c6b374b57b3f8799b3c507d7b9abc626e5643030bb38e3a0c55b3ac57913c7d0e53c42
data/CHANGELOG.md CHANGED
@@ -5,6 +5,21 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.6.0] - 2025-02-02
9
+
10
+ ### Added
11
+
12
+ - `i18n_pluck` method for efficient plucking of internationalized attributes
13
+ - Automatically handles JSON extraction for translated attributes
14
+ - Non-international attributes pass through to regular pluck
15
+ - Supports explicit locale parameter: `Article.i18n_pluck(:id, :title, locale: :de)`
16
+ - Example: `Article.limit(100).i18n_pluck(:id, :name, :latitude)` for efficient map data
17
+
18
+ ### Fixed
19
+
20
+ - Fixed file permissions issue causing `LoadError: cannot load such file -- internationalize/rich_text` in production environments ([#9](https://github.com/sampokuokkanen/internationalize/issues/9))
21
+ - Gem files now have correct 644 permissions (world-readable)
22
+
8
23
  ## [0.5.1] - 2025-01-27
9
24
 
10
25
  ### Fixed
@@ -157,6 +157,33 @@ module Internationalize
157
157
  scope
158
158
  end
159
159
 
160
+ # Pluck attributes with automatic JSON extraction for internationalized attributes
161
+ #
162
+ # @param attributes [Array<Symbol>] attributes to pluck
163
+ # @param locale [Symbol] locale for internationalized attributes (default: current locale)
164
+ # @return [Array] plucked values
165
+ #
166
+ # @example
167
+ # Article.i18n_pluck(:id, :title)
168
+ # Article.i18n_pluck(:id, :title, :description, locale: :de)
169
+ # Article.limit(10).i18n_pluck(:id, :title, :status)
170
+ #
171
+ def i18n_pluck(*attributes, locale: nil)
172
+ locale ||= I18n.locale
173
+ adapter = Adapters.resolve(connection)
174
+
175
+ pluck_args = attributes.map do |attr|
176
+ if international_attributes.include?(attr.to_sym)
177
+ json_col = "#{attr}_translations"
178
+ Arel.sql(adapter.json_extract(json_col, locale))
179
+ else
180
+ attr
181
+ end
182
+ end
183
+
184
+ pluck(*pluck_args)
185
+ end
186
+
160
187
  # Exclude records matching translated attribute conditions
161
188
  #
162
189
  # @param conditions [Hash] attribute => value pairs to exclude
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Internationalize
4
- VERSION = "0.5.1"
4
+ VERSION = "0.6.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: internationalize
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sampo Kuokkanen