geekdict 0.2.2 → 0.2.3
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 +4 -4
- data/lib/geekdict/openrouter/api.rb +2 -0
- data/lib/geekdict/version.rb +1 -1
- data/spec/openrouter/api_spec.rb +24 -0
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: eff23b6e34e7eb5c9a36430dab91a144290175c92419e434a73b10805182f1b9
|
|
4
|
+
data.tar.gz: 392b150951352cb80c6fa8035e248e1f6c3e5255b314ce6f74f17ba3a87d96ac
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e4d4ea6ddb6d3701a6f9d5feed9b192ed080f87ac427263e1aa5480e04521dfe65670c6a3e22f798d9386f65eaa188ed2c15f0539e821e42a88d345dbadb07d6
|
|
7
|
+
data.tar.gz: e99e68f27c568c5eeb4564e5593f1b9fac733f4ca799b7858a7819726f0dbc1f471595e552b5e875dcc5ba0e64fd6472c85b717e1e28bac0e7773fb5605eab09
|
|
@@ -13,6 +13,8 @@ module GeekDict
|
|
|
13
13
|
effective_model = model || 'google/gemini-2.5-flash-preview' # Fallback, though CLI provides default
|
|
14
14
|
|
|
15
15
|
client = HTTPClient.new
|
|
16
|
+
# OpenRouter is stateless; avoid parsing unsupported SameSite cookie attributes.
|
|
17
|
+
client.cookie_manager = nil
|
|
16
18
|
headers = {
|
|
17
19
|
'Content-Type' => 'application/json',
|
|
18
20
|
'Authorization' => "Bearer #{ENV.fetch('OPENROUTER_API_KEY')}",
|
data/lib/geekdict/version.rb
CHANGED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require 'geekdict'
|
|
2
|
+
|
|
3
|
+
describe GeekDict::OpenRouter do
|
|
4
|
+
describe '.translate' do
|
|
5
|
+
it 'disables cookies before posting to OpenRouter' do
|
|
6
|
+
client = double('HTTPClient')
|
|
7
|
+
response = double(
|
|
8
|
+
'response',
|
|
9
|
+
status: 200,
|
|
10
|
+
body: { choices: [{ message: { content: 'Theory' } }] }.to_json
|
|
11
|
+
)
|
|
12
|
+
original_api_key = ENV['OPENROUTER_API_KEY']
|
|
13
|
+
ENV['OPENROUTER_API_KEY'] = 'test-api-key'
|
|
14
|
+
|
|
15
|
+
HTTPClient.stub(:new).and_return(client)
|
|
16
|
+
client.should_receive(:cookie_manager=).with(nil).ordered
|
|
17
|
+
client.should_receive(:post).ordered.and_return(response)
|
|
18
|
+
|
|
19
|
+
expect(described_class.translate('理论')).to eq('Theory')
|
|
20
|
+
ensure
|
|
21
|
+
ENV['OPENROUTER_API_KEY'] = original_api_key
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: geekdict
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Wenbing Li
|
|
@@ -119,6 +119,7 @@ files:
|
|
|
119
119
|
- lib/geekdict/youdao/config.rb
|
|
120
120
|
- spec/cli_spec.rb
|
|
121
121
|
- spec/debugger_spec.rb
|
|
122
|
+
- spec/openrouter/api_spec.rb
|
|
122
123
|
- spec/youdao/api_spec.rb
|
|
123
124
|
homepage: https://github.com/wbinglee/geekdict
|
|
124
125
|
licenses:
|
|
@@ -144,4 +145,5 @@ summary: A command line tool for translation.
|
|
|
144
145
|
test_files:
|
|
145
146
|
- spec/cli_spec.rb
|
|
146
147
|
- spec/debugger_spec.rb
|
|
148
|
+
- spec/openrouter/api_spec.rb
|
|
147
149
|
- spec/youdao/api_spec.rb
|