ollama_chat 0.0.39 → 0.0.41

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: 1889968881db471ab1e18058241170ca20b6b0c4933b5f230796b61100d3fc65
4
- data.tar.gz: 9c62ba5958195194cdb562d041d62785304928eab15849e4cb562a3e3fbb9e60
3
+ metadata.gz: 16c8e58cb6a7d268d4473262095f974045d683d44225e39861ce363c412f224b
4
+ data.tar.gz: 8205ee4aa5b7eb1c1493d4d3990a122dfbd05c978c2b8b316d21457c92003920
5
5
  SHA512:
6
- metadata.gz: e02db941ef17c62a5dc8107fc189ea3fe13f20ba4936d22245f3f732e84bf9c697b98a33372300d0f3270aff4e0d7cbb93971d3c4d8a0cdeb246e308b27ef631
7
- data.tar.gz: 31e70f4b3b9c4cd2ab990f41b4642818de01127b3c5ad700172a9a030cca86e27189287c4a4fbdbf6eeb46f5546cf77da847f1f331d14ea83f9e242673312c92
6
+ metadata.gz: f46f9beaee69da2fa7d3a2801d7f9abf51204018756503b785dcac5afcb54e8c6f5ccd36cc71e4a4aba8a4f2fd159c20c064b7cc1ad41afef685356f93646082
7
+ data.tar.gz: 36ff245dbcbaa5f58297b3db76884eb779076a641bb79eca2997dce674a91832695fdf8ffaa8891f1e20e20af6fc48d045e2c58c5cc71555421319c47ea88d80
data/CHANGES.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # Changes
2
2
 
3
+ ## 2025-11-20 v0.0.41
4
+
5
+ - Fixed message output specification and removed duplicate expectation
6
+ - Added `clientserver` configuration option to `vim` section in `default_config.yml`
7
+ - Updated `OllamaChat::Vim` to accept `clientserver:` keyword argument in `initialize`
8
+ - Modified `insert` and `col` methods in `vim.rb` to use `--clientserver` flag
9
+ - Passed `clientserver` from `chat.rb` when creating `OllamaChat::Vim` instance
10
+ - Set default `clientserver` value to **socket**
11
+
12
+ ## 2025-11-20 v0.0.40
13
+
14
+ - Improved Vim server name generation to ensure uniqueness by replacing
15
+ `Pathname.pwd.to_s.upcase` with `File.basename` and `Digest::MD5.hexdigest`
16
+ - Modified `default_server_name` method to create server names in the format
17
+ `MYAPP-3F2B4D8A` instead of just `MYAPP`
18
+ - Enhanced documentation for `OllamaChat::Vim#initialize` and `OllamaChat::Vim.default_server_name` methods
19
+
3
20
  ## 2025-11-14 v0.0.39
4
21
 
5
22
  - Updated `tins` dependency version from `~> 1.41` to `~> 1.47` in `Rakefile` and `ollama_chat.gemspec`
@@ -340,7 +340,8 @@ class OllamaChat::Chat
340
340
  :next
341
341
  when %r(^/vim(?:\s+(.+))?$)
342
342
  if message = messages.last
343
- OllamaChat::Vim.new($1).insert message.content
343
+ clientserver = config.vim?&.clientserver
344
+ OllamaChat::Vim.new($1, clientserver:).insert message.content
344
345
  else
345
346
  STDERR.puts "Warning: No message found to insert into Vim"
346
347
  end
@@ -78,3 +78,5 @@ web_search:
78
78
  url: 'https://www.duckduckgo.com/html/?q=%{query}'
79
79
  searxng:
80
80
  url: <%= OllamaChat::EnvConfig::OLLAMA::SEARXNG_URL %>
81
+ vim:
82
+ clientserver: socket
@@ -1,6 +1,6 @@
1
1
  module OllamaChat
2
2
  # OllamaChat version
3
- VERSION = '0.0.39'
3
+ VERSION = '0.0.41'
4
4
  VERSION_ARRAY = VERSION.split('.').map(&:to_i) # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
@@ -1,5 +1,4 @@
1
1
  require 'tempfile'
2
- require 'pathname'
3
2
 
4
3
  # A class that provides functionality for inserting text into Vim buffers via
5
4
  # remote communication.
@@ -11,23 +10,41 @@ class OllamaChat::Vim
11
10
  # Initializes a new Vim server connection
12
11
  #
13
12
  # Creates a new OllamaChat::Vim instance for interacting with a specific Vim
14
- # server. If no server name is provided, it defaults to using the current
15
- # working directory as the server identifier.
13
+ # server. If no server name is provided, it derives a standardized server
14
+ # name based on the current working directory using the default_server_name
15
+ # method.
16
16
  #
17
17
  # @param server_name [String, nil] The name of the Vim server to connect to.
18
- # If nil or empty, defaults to the current working directory path in
19
- # uppercase
20
- def initialize(server_name)
21
- server_name.full? or server_name = default_server_name
22
- @server_name = server_name
18
+ # If nil or empty, defaults to a server name derived from the current working
19
+ # directory using {default_server_name}
20
+ # @param clientserver [String] The clientserver protocol to use, defaults to 'socket'
21
+ #
22
+ # @return [OllamaChat::Vim] A new Vim instance configured with the specified
23
+ # server name
24
+ def initialize(server_name, clientserver: nil)
25
+ server_name.full? or server_name = self.class.default_server_name
26
+ @server_name = server_name
27
+ @clientserver = clientserver || 'socket'
23
28
  end
24
29
 
25
- # The default server name is derived from the current working directory It
26
- # converts the absolute path to uppercase for consistent identification This
27
- # approach ensures each working directory gets a unique server identifier The
28
- # server name format makes it easy to distinguish different Vim sessions
29
- def default_server_name
30
- Pathname.pwd.to_s.upcase
30
+ # The default_server_name method generates a standardized server name
31
+ # based on a given name or the current working directory.
32
+ #
33
+ # This method creates a unique server identifier by combining the basename
34
+ # of the provided name (or current working directory) with a truncated
35
+ # MD5 hash digest of the full path. The resulting name is converted to
36
+ # uppercase for consistent formatting.
37
+ #
38
+ # @param name [ String ] the base name to use for server identification
39
+ # defaults to the current working directory
40
+ #
41
+ # @return [ String ] a formatted server name suitable for use with Vim
42
+ # server connections
43
+ def self.default_server_name(name = Dir.pwd)
44
+ prefix = File.basename(name)
45
+ suffix = Digest::MD5.hexdigest(name)[0, 8]
46
+ name = [ prefix, suffix ] * ?-
47
+ name.upcase
31
48
  end
32
49
 
33
50
  # Inserts text at the current cursor position in Vim
@@ -43,7 +60,7 @@ class OllamaChat::Vim
43
60
  Tempfile.open do |tmp|
44
61
  tmp.write(text)
45
62
  tmp.flush
46
- system %{vim --servername "#@server_name" --remote-send "<ESC>:r #{tmp.path}<CR>"}
63
+ system %{vim --clientserver "#@clientserver" --servername "#@server_name" --remote-send "<ESC>:r #{tmp.path}<CR>"}
47
64
  end
48
65
  end
49
66
 
@@ -54,6 +71,6 @@ class OllamaChat::Vim
54
71
  # the result of `col('.')`, which represents the current column number (1-indexed)
55
72
  # of the cursor position.
56
73
  def col
57
- `vim --servername "#@server_name" --remote-expr "col('.')"`.chomp.to_i
74
+ `vim --clientserver "#@clientserver" --servername "#@server_name" --remote-expr "col('.')"`.chomp.to_i
58
75
  end
59
76
  end
data/ollama_chat.gemspec CHANGED
@@ -1,9 +1,9 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: ollama_chat 0.0.39 ruby lib
2
+ # stub: ollama_chat 0.0.41 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "ollama_chat".freeze
6
- s.version = "0.0.39".freeze
6
+ s.version = "0.0.41".freeze
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
9
9
  s.require_paths = ["lib".freeze]
@@ -66,7 +66,6 @@ describe OllamaChat::MessageList do
66
66
 
67
67
  it 'can save conversations' do
68
68
  expect(list.save_conversation('tmp/test-conversation.json')).to eq list
69
- expect(list.save_conversation('tmp/test-conversation.json')).to be_nil
70
69
  ensure
71
70
  FileUtils.rm_f 'tmp/test-conversation.json'
72
71
  end
@@ -11,7 +11,7 @@ describe OllamaChat::MessageOutput do
11
11
  expect(STDERR).to receive(:puts).with(/No response available to write to "foo.txt"/)
12
12
  expect(chat.output('foo.txt')).to be_nil
13
13
  chat.instance_variable_get(:@messages).load_conversation(asset('conversation.json'))
14
- expect(chat).to receive(:write_file_unless_exist).and_return true
14
+ expect(chat).to receive(:attempt_to_write_file).and_return true
15
15
  expect(STDOUT).to receive(:puts).with(/Last response was written to \"foo.txt\"./)
16
16
  expect(chat.output('foo.txt')).to eq chat
17
17
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ollama_chat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.39
4
+ version: 0.0.41
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Frank