geekdict 0.2.1 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3ce49995415783d264d2993a3f815a7155e4b2a117f5fae350db4b95860c96f8
4
- data.tar.gz: 02fc16dd11252e493b0072fb81fc4cb345d1fc0334b0cde51dfb09e8c8acbe01
3
+ metadata.gz: 79674ee73ec2b4189c9138e0d253073cc5285c223a453f1351201e1bd34902fc
4
+ data.tar.gz: f2ae50474dc2ebfe68a54ff136fbb16a20b5f65db760b68e7a1074c784c9c9ff
5
5
  SHA512:
6
- metadata.gz: 6cb588fef60055e7814131811eb4147fcc1894f4c3d9b918e43732b5e2804d78d4b06ba57989eece6fd0a3a2dee1cbbf74565a586464b8d5332fefab1b683274
7
- data.tar.gz: 570f2f163ff7e424a783ea606aad2cd0e4cf138cdbbec0e2c4a432124b0d9f91b244d60a4fdb254101d59e9fefa615a589ac7b1843b7403cd04568dee31b7b83
6
+ metadata.gz: 2b1b1f07c8ed87acb57b93013215823c22a940009be05ccc8ee3e9345a301029f7059b4ca13e397ac5f378fb21c81032a1194f939110952eb41c5a3dd710b409
7
+ data.tar.gz: 33d73ecfff491ab71703e2738018fea8cdc391299ddcd06aaae0721a53cb25c69336b86499894764adae1606e31e82cba27fea03e373b24b1ccbff162827ea25
@@ -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-preview"
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
@@ -1,3 +1,3 @@
1
1
  module GeekDict
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
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.1
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: 2025-04-22 00:00:00.000000000 Z
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.5.22
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: