geekdict 0.2.0 → 0.2.2
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/config.rb +31 -1
- data/lib/geekdict/openrouter/api.rb +3 -1
- data/lib/geekdict/version.rb +1 -1
- metadata +3 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79674ee73ec2b4189c9138e0d253073cc5285c223a453f1351201e1bd34902fc
|
4
|
+
data.tar.gz: f2ae50474dc2ebfe68a54ff136fbb16a20b5f65db760b68e7a1074c784c9c9ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b1b1f07c8ed87acb57b93013215823c22a940009be05ccc8ee3e9345a301029f7059b4ca13e397ac5f378fb21c81032a1194f939110952eb41c5a3dd710b409
|
7
|
+
data.tar.gz: 33d73ecfff491ab71703e2738018fea8cdc391299ddcd06aaae0721a53cb25c69336b86499894764adae1606e31e82cba27fea03e373b24b1ccbff162827ea25
|
data/lib/geekdict/config.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
require "yaml"
|
2
|
+
require "fileutils"
|
2
3
|
|
3
4
|
module GeekDict
|
4
5
|
module Config
|
5
6
|
CONFIG_PATH = File.expand_path("~/.geekdict.config")
|
6
7
|
DEFAULT_PROVIDER = "openrouter"
|
7
|
-
DEFAULT_MODEL = "google/gemini-2.5-flash-
|
8
|
+
DEFAULT_MODEL = "google/gemini-2.5-flash-lite"
|
8
9
|
ALLOWED_PROVIDERS = ['openai', 'openrouter', 'youdao'].freeze
|
9
10
|
|
10
11
|
module_function
|
@@ -12,6 +13,12 @@ module GeekDict
|
|
12
13
|
# Method to load configuration from ~/.geekdict.config
|
13
14
|
def load_config
|
14
15
|
config = {}
|
16
|
+
|
17
|
+
# If config file doesn't exist, create it with default values
|
18
|
+
unless File.exist?(CONFIG_PATH)
|
19
|
+
create_default_config
|
20
|
+
end
|
21
|
+
|
15
22
|
if File.exist?(CONFIG_PATH)
|
16
23
|
begin
|
17
24
|
loaded_config = YAML.load_file(CONFIG_PATH)
|
@@ -29,5 +36,28 @@ module GeekDict
|
|
29
36
|
model: config[:model]
|
30
37
|
}
|
31
38
|
end
|
39
|
+
|
40
|
+
# Method to create default configuration file
|
41
|
+
def create_default_config
|
42
|
+
default_config = {
|
43
|
+
'provider' => DEFAULT_PROVIDER,
|
44
|
+
'model' => DEFAULT_MODEL
|
45
|
+
}
|
46
|
+
|
47
|
+
begin
|
48
|
+
# Ensure the directory exists
|
49
|
+
config_dir = File.dirname(CONFIG_PATH)
|
50
|
+
FileUtils.mkdir_p(config_dir) unless Dir.exist?(config_dir)
|
51
|
+
|
52
|
+
# Write the default config
|
53
|
+
File.open(CONFIG_PATH, 'w') do |file|
|
54
|
+
file.write(YAML.dump(default_config))
|
55
|
+
end
|
56
|
+
|
57
|
+
puts "Created default config file at #{CONFIG_PATH}"
|
58
|
+
rescue => e
|
59
|
+
warn "Warning: Could not create config file #{CONFIG_PATH}: #{e.message}"
|
60
|
+
end
|
61
|
+
end
|
32
62
|
end
|
33
63
|
end
|
@@ -15,7 +15,9 @@ module GeekDict
|
|
15
15
|
client = HTTPClient.new
|
16
16
|
headers = {
|
17
17
|
'Content-Type' => 'application/json',
|
18
|
-
'Authorization' => "Bearer #{ENV.fetch('OPENROUTER_API_KEY')}"
|
18
|
+
'Authorization' => "Bearer #{ENV.fetch('OPENROUTER_API_KEY')}",
|
19
|
+
'HTTP-Referer' => 'https://github.com/wbingli/geekdict/', # Identify app
|
20
|
+
'X-Title' => 'GeekDict' # Set app title
|
19
21
|
}
|
20
22
|
|
21
23
|
body = {
|
data/lib/geekdict/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
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.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wenbing Li
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: rake
|
@@ -125,7 +124,6 @@ homepage: https://github.com/wbinglee/geekdict
|
|
125
124
|
licenses:
|
126
125
|
- MIT
|
127
126
|
metadata: {}
|
128
|
-
post_install_message:
|
129
127
|
rdoc_options: []
|
130
128
|
require_paths:
|
131
129
|
- lib
|
@@ -140,8 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
138
|
- !ruby/object:Gem::Version
|
141
139
|
version: '0'
|
142
140
|
requirements: []
|
143
|
-
rubygems_version: 3.
|
144
|
-
signing_key:
|
141
|
+
rubygems_version: 3.6.9
|
145
142
|
specification_version: 4
|
146
143
|
summary: A command line tool for translation.
|
147
144
|
test_files:
|