translate_self 0.5.0 → 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: 423e2804c606db8a6f62a91f8e0458f9d59ab2dde91db01a21e6ed6af6cec07b
4
- data.tar.gz: b351c1eb545ae152158ae9903e1f367cae4a87196f35a303f05817306c65b295
3
+ metadata.gz: 48a0238d6e09ae494d46da95732914c18c77882cc8a077d1c522a124c985cd62
4
+ data.tar.gz: 84a3fe6ae48a310dabe1fa8952773dd6234cebd03f7b370fd57b1aca44e8add7
5
5
  SHA512:
6
- metadata.gz: dbff90c881adbc6c32996efb968eb9988121529fcdf60931575f1a4f6088e4d474c07244985d6c6ba108b1a1105e0200c5fa11f79040cbbed5cbe4c6c0b10261
7
- data.tar.gz: cc7500f06cd47d90142fb7ff2483890d3d51c2f70c1c8ad8f8e0cd1ff72fbd85fc7e1d60ed231a13cc00b9289b8c9630a27dd6d37d913ba0c393e10209f1060a
6
+ metadata.gz: 13d585250ec562d77cd50d7d175c214ae136069d806d0b584e919a020f7769c1b2df09e7610639d18fd3909065173d02fd44f062f0f6f25636c64b019d4345fc
7
+ data.tar.gz: cf6a84eb4c137084fa8b96f3c6e5dbab24e88499da2b638280eceaef615818b175d363d8de9d70529c82f243760a2750a3d8b7081f69a2e56bf583f7553d72a8
data/CHANGELOG.md CHANGED
@@ -17,4 +17,13 @@ Seems like you need to update it by hand!
17
17
 
18
18
  ## [0.4.0] - 2021-06-05
19
19
 
20
- - The translated new string now knows what language it is.
20
+ - The translated new string now knows what language it is.
21
+
22
+ ## [0.5.0] - 2021-06-06
23
+
24
+ - Add TranslatableString class to work around frozen string literal magic comment.
25
+ Also will not crash with frozen strings now.
26
+
27
+ ## [0.6.0] - 2021-06-08
28
+
29
+ - Add option to use ENV variable DEEPL_HOST
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- translate_self (0.5.0)
4
+ translate_self (0.6.0)
5
5
  deepl-rb
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -19,7 +19,11 @@ Just get a DeepL auth key and export it as follows:
19
19
  export DEEPL_AUTH_KEY="your-api-token"
20
20
  ```
21
21
 
22
- This gem currently hardcodes the free DeepL servers. # TODO
22
+ By default this gem uses the free DeepL servers, but you can also configure your own:
23
+
24
+ ```sh
25
+ export DEEPL_HOST="non-free-host"
26
+ ```
23
27
 
24
28
  Now you can translate it to your language of chose with this gem!
25
29
  ```ruby
@@ -92,6 +96,23 @@ hello.translate
92
96
  # "Moi"
93
97
  ```
94
98
 
99
+ ## Benchmark
100
+
101
+ Create a string 5000000 times.
102
+
103
+ ```shell
104
+ C:\home\sampo\translate_self> ruby benchmark.rb
105
+ Rehearsal -------------------------------------------------------
106
+ normal string 0.252435 0.000000 0.252435 ( 0.252490)
107
+ translatable string 0.299736 0.000000 0.299736 ( 0.299789)
108
+ ---------------------------------------------- total: 0.552171sec
109
+
110
+ user system total real
111
+ normal string 0.237091 0.000000 0.237091 ( 0.237091)
112
+ translatable string 0.237607 0.000000 0.237607 ( 0.237611)
113
+ ```
114
+ So... the overhead might be surprisingly low!
115
+
95
116
  ## Development
96
117
 
97
118
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
data/benchmark.rb ADDED
@@ -0,0 +1,16 @@
1
+ require 'benchmark'
2
+
3
+ n = 5000000
4
+ Benchmark.bmbm do |x|
5
+ x.report("string") do
6
+ n.times do
7
+ 'hello'
8
+ end
9
+ end
10
+ x.report('translatable string') do
11
+ require 'translate_self'
12
+ n.times do
13
+ 'hello'
14
+ end
15
+ end
16
+ end
@@ -9,7 +9,8 @@ module TranslateSelf
9
9
  include Translation
10
10
  class Error < StandardError; end
11
11
  DeepL.configure do |config|
12
- config.host = 'https://api-free.deepl.com' # Default value is 'https://api.deepl.com'
12
+ config.auth_key = ENV['DEEPL_AUTH_KEY']
13
+ config.host = ENV['DEEPL_HOST'] || 'https://api-free.deepl.com' # Default value is 'https://api.deepl.com'
13
14
  end
14
15
  AVAILABLE_LANGUAGES = %w[bg cs da de el en es et fi fr hu it ja lt lv nl pl pt ro ru sk sl sv zh].freeze
15
16
  end
@@ -1,3 +1,3 @@
1
1
  module TranslateSelf
2
- VERSION = '0.5.0'.freeze
2
+ VERSION = '0.6.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: translate_self
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sampo Kuokkanen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-06-06 00:00:00.000000000 Z
11
+ date: 2021-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: deepl-rb
@@ -86,6 +86,7 @@ files:
86
86
  - LICENSE.txt
87
87
  - README.md
88
88
  - Rakefile
89
+ - benchmark.rb
89
90
  - bin/console
90
91
  - bin/setup
91
92
  - lib/ext/string.rb