llm_translator 0.0.3 → 0.0.4

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/llm_translator.rb +11 -3
  3. metadata +2 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f3f1b58e414568d0d96d6955c6b0cb92fd9a4e15da6c2164ba27404c5ffffd79
4
- data.tar.gz: 75210c017e5cfd1e89f6fba9730a29bc00d875b071a74db187578d361fcbbe89
3
+ metadata.gz: 2eaa70543efe06ebcff7a1eca548dc36e8ab0983a7d3b180b5953fec12c2c71f
4
+ data.tar.gz: 249fc33eb499585ac53bb95bbd1c4156c6c562d411752befd34c3946df0fd5f4
5
5
  SHA512:
6
- metadata.gz: a868ed54d37c22b4913c45a41b907f935f7fc4830198dfa30a6f0f8da9b01b3fc3bad62b0828a0529114fd9fa1333ccf2b0fd9aa91d9998e0c4a1b1bd84ac021
7
- data.tar.gz: 00cb71780f92b061628260cbc8cc4a69662c2e519ceddb3ce7e0e1cc3f38c3b40c4c7d60a71d4c6fcf4e8ebc5a7fe65c49f5d2aa7968208631ae995cb6a4f60a
6
+ metadata.gz: 390b2f53bb562d431eb203aa007a1a46dbb9ad2a079abaa116de33007769eac1dadc30576650e411057ff0699d6dd19dff5aee27ab97647c225ce9b83e66b7a8
7
+ data.tar.gz: 423480766fcc286f93840540fc75bead95bcbb6a7a2cf7ded757faeb0c55393bbdc8c0e777abd33ade79457e9c1ab5ea6cfa1cea107c44c537df39f2039589a3
@@ -121,14 +121,20 @@ LANG_CODE = %|
121
121
 
122
122
  class LlmTranslator
123
123
 
124
- attr_accessor :text,
124
+ CONFIG_PATH = File.expand_path('~/.llm_translator')
125
+ attr_accessor :text,
126
+ :history,
125
127
  :auto, # 自动中英互译
126
128
  :detail, # 详细翻译
127
129
  :from, # 源语言
128
130
  :to # 目标语言
129
131
 
130
132
  def initialize(text)
133
+ if !Dir.exists?(CONFIG_PATH)
134
+ Dir.mkdir(CONFIG_PATH)
135
+ end
131
136
  @text = text
137
+ @history= File.open("#{CONFIG_PATH}/history.csv", 'a+')
132
138
  @url = 'https://openapi.youdao.com/api'
133
139
  @appkey = '0b53e81a10846a3a'
134
140
  @appscr = 'JLKxQO22jBft6w3PgLBh5as5iNJ1w5wS'
@@ -156,9 +162,11 @@ class LlmTranslator
156
162
  end
157
163
 
158
164
  def run
159
- return to_result if @detail
165
+ result = to_result()
166
+ history.write("#{text} #{result['translation'][0]} #{Time.now}\n") if @history
167
+ return result if @detail
160
168
 
161
- to_result['translation'][0]
169
+ result['translation'][0]
162
170
  end
163
171
 
164
172
  def command(args)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: llm_translator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Liuliming
@@ -39,8 +39,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  requirements: []
42
- rubyforge_project:
43
- rubygems_version: 2.7.6.2
42
+ rubygems_version: 3.2.3
44
43
  signing_key:
45
44
  specification_version: 4
46
45
  summary: a simple translator!