phraseapp-in-context-editor-ruby 2.1.2 → 3.0.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: bc5405ba5aa6a41f6c21d509eeaa00d6d5f62fb5bfae1578c16695b252931dcc
4
- data.tar.gz: 73d0e561de9a0426dfe11b3f0f6f941af7ad1e1dba3de9695add6954eee5af5a
3
+ metadata.gz: '09476e9967528243584d88b2eab3153a64e77e7c6287bb4044d93f5b8d7535b0'
4
+ data.tar.gz: cfbdb848d7157a8ca3214db1288c43790548e4bb834c016b9ee5dd8473340810
5
5
  SHA512:
6
- metadata.gz: ff58eb5b36a68c9b9cc03d495f33dd86d0a831fc90b073ca52dff774a6efffe4e89e21053b25ebf20920dd0696c06148a3028204f4fd6063d53dabd234f3c62d
7
- data.tar.gz: e76bc4e76e5733d8d666f9a5c1e63a6f1954a5d636b4a9237a60b9e845269c1d95120f0d1e8ba167ec3e0d455c26846a65be5b975152444d9f66c5f55424e207
6
+ metadata.gz: fea36910dec30f4b064ebdf5b1d9a0a155db20edd586498606a8c1fc1e925c7360cbf13a152c9b592696658ea6f73997cce5d701eca853497f2f512f3cc88375
7
+ data.tar.gz: d0d529d0f425c97c992196448ac9c3865f688259b245db12dd7e4be9d1a2d9271f261b97f2e3ecc924402dbe50cd0e37789b97e3a0b8cb3ea938e9771d1c9498
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ # [3.0.0](https://github.com/phrase/phraseapp-in-context-editor-ruby/compare/v2.1.2...v3.0.0) (2024-05-21)
2
+
3
+
4
+ * BREAKING CHANGE: Use ruby 2.7 'Forward all arguments' syntax: (...) to forward arguments (#78) ([99ae28e](https://github.com/phrase/phraseapp-in-context-editor-ruby/commit/99ae28e2f6fea0ba2ba0eec6eca54a043e21d121)), closes [#78](https://github.com/phrase/phraseapp-in-context-editor-ruby/issues/78)
5
+
6
+
7
+ ### BREAKING CHANGES
8
+
9
+ * Hash arguments will throw an error. Keyword arguments must be used instead.
10
+
1
11
  ## [2.1.2](https://github.com/phrase/phraseapp-in-context-editor-ruby/compare/v2.1.1...v2.1.2) (2024-05-21)
2
12
 
3
13
 
@@ -1,8 +1,8 @@
1
1
  if defined?(I18n)
2
2
  module I18n
3
3
  class << self
4
- def translate_with_phraseapp(*args)
5
- PhraseApp::InContextEditor.backend.translate(*args)
4
+ def translate_with_phraseapp(...)
5
+ PhraseApp::InContextEditor.backend.translate(...)
6
6
  end
7
7
  alias_method :translate_without_phraseapp, :translate
8
8
  alias_method :translate, :translate_with_phraseapp
@@ -9,41 +9,21 @@ module PhraseApp
9
9
  self
10
10
  end
11
11
 
12
- def translate(*args)
13
- if to_be_translated_without_phraseapp?(args)
14
- # *Ruby 2.7+ keyword arguments warning*
15
- #
16
- # This method uses keyword arguments.
17
- # There is a breaking change in ruby that produces warning with ruby 2.7 and won't work as expected with ruby 3.0
18
- # The "hash" parameter must be passed as keyword argument.
19
- #
20
- # Good:
21
- # I18n.t(:salutation, :gender => 'w', :name => 'Smith')
22
- # I18n.t(:salutation, **{ :gender => 'w', :name => 'Smith' })
23
- # I18n.t(:salutation, **any_hash)
24
- #
25
- # Bad:
26
- # I18n.t(:salutation, { :gender => 'w', :name => 'Smith' })
27
- # I18n.t(:salutation, any_hash)
28
- #
29
- kw_args = args[1]
30
- if kw_args.present?
31
- I18n.translate_without_phraseapp(args[0], **kw_args)
32
- else
33
- I18n.translate_without_phraseapp(args[0])
34
- end
12
+ def translate(...)
13
+ if to_be_translated_without_phraseapp?(...)
14
+ I18n.translate_without_phraseapp(...)
35
15
  else
36
- phraseapp_delegate_for(args)
16
+ phraseapp_delegate_for(...)
37
17
  end
38
18
  end
39
19
 
40
20
  protected
41
21
 
42
- def to_be_translated_without_phraseapp?(args)
43
- PhraseApp::InContextEditor.disabled? || has_been_forced_to_resolve_with_phraseapp?(args)
22
+ def to_be_translated_without_phraseapp?(...)
23
+ PhraseApp::InContextEditor.disabled? || has_been_forced_to_resolve_with_phraseapp?(...)
44
24
  end
45
25
 
46
- def has_been_forced_to_resolve_with_phraseapp?(args)
26
+ def has_been_forced_to_resolve_with_phraseapp?(*args)
47
27
  (args.last.is_a?(Hash) && args.last[:resolve] == false)
48
28
  end
49
29
 
@@ -51,7 +31,7 @@ module PhraseApp
51
31
  extract_normalized_key_from_args(args)
52
32
  end
53
33
 
54
- def phraseapp_delegate_for(args)
34
+ def phraseapp_delegate_for(*args)
55
35
  key = given_key_from_args(args)
56
36
  return nil unless present?(key)
57
37
 
@@ -1,3 +1,3 @@
1
1
  module PhraseApp
2
- VERSION = "2.1.2"
2
+ VERSION = "3.0.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phraseapp-in-context-editor-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.2
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Phrase