utils 0.56.1 → 0.57.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c084e3a5580950140252810adfa52663324149594e25ce6e3ed6f94329bab624
4
- data.tar.gz: 0d3a709885df968bd9111f3b1c303cb23c5ff5f00519e2982a565f8d568403ac
3
+ metadata.gz: 4aac57a70b356647de0bdd6dd93ef4f327f58935e28cb85d3d40efc855a13c16
4
+ data.tar.gz: 0d12e68efae607546f43d287c67f1b02d70dd4d56a73367d434ab8748d6390fb
5
5
  SHA512:
6
- metadata.gz: 0bc1513dc0ca75893424dc0ed6b85b6671cc32ee52bef80797f9915a092550cd3636fbf5fc4fa65576d0f2b066b728d6995f7ec4a5a669a9f9294a8a0df37d55
7
- data.tar.gz: 88fc874d4f5255029a586e8c9b05123f211cade072814405085e617492dddc0d0e363823fd4b1068fd95c8b138d1568d678e7f8532b111486642e7bd7e4075e6
6
+ metadata.gz: 9f730b4ec5bb32fa151a759f3d9e5638e090d7497dabecc5d5535b62dfe4c056a1176004c69b4fea83bf63f508666abc4048b99f0341c11b830d57d6ac0e0fea
7
+ data.tar.gz: 03507d0cffb9bdf7c93eb923d50ff9b1824acdea35f03ab0c658255f1290768e224f22da3e1743a28f0f4f4be3cb494820cde007d39b0cdc48e6cd2bb21e8bc2
data/bin/changes CHANGED
@@ -5,7 +5,7 @@ include Ollama
5
5
  require 'tins/xt'
6
6
 
7
7
  def x(cmd)
8
- output=`#{cmd}`
8
+ output = `#{cmd}`
9
9
  $?.success? or fail "failed to execute #{cmd.inspect}"
10
10
  output
11
11
  end
@@ -31,10 +31,10 @@ def compute_change(range_from, range_to)
31
31
  range = "#{range_from}..#{range_to}"
32
32
  end
33
33
 
34
- log=x("git log #{range}")
34
+ log = x("git log #{range}")
35
35
  $?.success? or exit 1
36
36
 
37
- date=x("git log -n1 --pretty='format:%cd' --date=short #{range_to}")
37
+ date = x("git log -n1 --pretty='format:%cd' --date=short #{range_to}")
38
38
 
39
39
  if log.strip.empty?
40
40
  return <<~EOT
@@ -80,7 +80,8 @@ def compute_change(range_from, range_to)
80
80
  )
81
81
 
82
82
  ollama = Client.new(base_url:, read_timeout: 120)
83
- changes = ollama.generate(model:, system:, prompt:, options:, stream: false).response
83
+ changes = ollama.generate(model:, system:, prompt:, options:, stream: false)
84
+ changes = changes.response.gsub(/\t/, ' ')
84
85
 
85
86
  return <<~EOT
86
87
 
@@ -125,7 +126,7 @@ when 'full', 'add'
125
126
  _1.sub(/\Av/, '').version
126
127
  }.sort
127
128
  if command == 'full'
128
- date=x("git log -n1 --pretty='format:%cd' --date=short v#{tags.first}").chomp
129
+ date = x("git log -n1 --pretty='format:%cd' --date=short v#{tags.first}").chomp
129
130
  ary << <<~EOT
130
131
 
131
132
  ## #{date} v#{tags.first}
data/bin/git-md CHANGED
@@ -1,29 +1,37 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'ollama'
3
+ require 'utils/markdown'
4
+ include Utils::Markdown
5
+ require 'utils/pager'
4
6
  require 'shellwords'
5
7
 
6
- def markdown(message)
7
- Ollama::Utils::ANSIMarkdown.parse(message)
8
- end
9
-
10
8
  cmd = %{git log --color=always --pretty=format:"commit %C(auto)%H%d%nDate: %Cgreen%cD (%cr)%Creset%nAuthor: %Cblue%an <%ae>%Creset%n%nMARKUP%n%s%n%n%b%nMARKDOWN%n"}
11
9
 
12
- IO.popen("#{cmd} #{Shellwords.join(ARGV)}") do |log|
13
- until log.eof?
14
- message = nil
15
- log.each do |line|
16
- case line
17
- when /^MARKUP$/
18
- message = ''
19
- when /^MARKDOWN$/
20
- puts markdown(message + "\n---\n")
21
- message = nil
22
- else
23
- if message
24
- message << line
10
+ core_pager = `git config get core.pager`.chomp.full?
11
+ git_pager = ENV['GIT_PAGER'].full?
12
+ default_pager = ENV['PAGER'].full?
13
+ if fallback_pager = `which less`.chomp.full? || `which more`.chomp.full?
14
+ fallback_pager << ' -r'
15
+ end
16
+ my_pager = git_pager || core_pager || default_pager || fallback_pager
17
+
18
+ Utils::Pager.pager(command: my_pager) do |output|
19
+ IO.popen("#{cmd} #{Shellwords.join(ARGV)}") do |log|
20
+ until log.eof?
21
+ message = nil
22
+ log.each do |line|
23
+ case line
24
+ when /^MARKUP$/
25
+ message = ''
26
+ when /^MARKDOWN$/
27
+ output.puts markdown(message + "\n---\n")
28
+ message = nil
25
29
  else
26
- puts line
30
+ if message
31
+ message << line
32
+ else
33
+ output.puts line
34
+ end
27
35
  end
28
36
  end
29
37
  end
data/bin/md ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'utils/markdown'
4
+ include Utils::Markdown
5
+ require 'utils/pager'
6
+
7
+ rendered = markdown(ARGF.read)
8
+ default_pager = ENV['PAGER'].full?
9
+ if fallback_pager = `which less`.chomp.full? || `which more`.chomp.full?
10
+ fallback_pager << ' -r'
11
+ end
12
+ my_pager = default_pager || fallback_pager
13
+
14
+ Utils::Pager.pager(lines: rendered.count(?\n), command: my_pager) do |output|
15
+ output.puts rendered
16
+ end
@@ -0,0 +1,11 @@
1
+ require 'ollama'
2
+
3
+ module Utils
4
+ module Markdown
5
+ module_function
6
+
7
+ def markdown(message)
8
+ Ollama::Utils::ANSIMarkdown.parse(message)
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,30 @@
1
+ require 'tins'
2
+
3
+ module Utils
4
+ module Pager
5
+ module_function
6
+
7
+ def pager(command: nil, lines: nil, &block)
8
+ if block
9
+ if my_pager = pager(command:, lines:)
10
+ IO.popen(my_pager, 'w') do |output|
11
+ output.sync = true
12
+ yield output
13
+ output.close
14
+ end
15
+ else
16
+ yield STDOUT
17
+ end
18
+ else
19
+ return unless STDOUT.tty?
20
+ if lines
21
+ if lines >= Tins::Terminal.lines
22
+ pager(command:)
23
+ end
24
+ else
25
+ command
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
data/lib/utils/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Utils
2
2
  # Utils version
3
- VERSION = '0.56.1'
3
+ VERSION = '0.57.1'
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:
data/lib/utils.rb CHANGED
@@ -10,6 +10,8 @@ module Utils
10
10
  require 'utils/probe_server'
11
11
  require 'utils/ssh_tunnel_specification'
12
12
  require 'utils/line_blamer'
13
+ require 'utils/markdown'
14
+ require 'utils/pager'
13
15
 
14
16
  require 'utils/xt/source_location_extension'
15
17
  class ::Object
data/utils.gemspec CHANGED
@@ -1,19 +1,19 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: utils 0.56.1 ruby lib
2
+ # stub: utils 0.57.1 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "utils".freeze
6
- s.version = "0.56.1".freeze
6
+ s.version = "0.57.1".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]
10
10
  s.authors = ["Florian Frank".freeze]
11
- s.date = "2024-09-30"
11
+ s.date = "2024-10-03"
12
12
  s.description = "This ruby gem provides some useful command line utilities".freeze
13
13
  s.email = "flori@ping.de".freeze
14
- s.executables = ["ascii7".freeze, "blameline".freeze, "changes".freeze, "classify".freeze, "code_comment".freeze, "commit_message".freeze, "create_cstags".freeze, "create_tags".freeze, "discover".freeze, "edit".freeze, "edit_wait".freeze, "enum".freeze, "git-empty".freeze, "git-md".freeze, "git-versions".freeze, "json_check".freeze, "long_lines".freeze, "myex".freeze, "number_files".freeze, "on_change".freeze, "path".freeze, "print_method".freeze, "probe".freeze, "rd2md".freeze, "search".freeze, "sedit".freeze, "serve".freeze, "ssh-tunnel".freeze, "strip_spaces".freeze, "sync_dir".freeze, "untest".freeze, "utils-utilsrc".freeze, "vcf2alias".freeze, "yaml_check".freeze]
15
- s.extra_rdoc_files = ["README.md".freeze, "lib/utils.rb".freeze, "lib/utils/config_file.rb".freeze, "lib/utils/editor.rb".freeze, "lib/utils/file_xt.rb".freeze, "lib/utils/finder.rb".freeze, "lib/utils/grepper.rb".freeze, "lib/utils/irb.rb".freeze, "lib/utils/line_blamer.rb".freeze, "lib/utils/line_formatter.rb".freeze, "lib/utils/md5.rb".freeze, "lib/utils/patterns.rb".freeze, "lib/utils/probe_server.rb".freeze, "lib/utils/ssh_tunnel_specification.rb".freeze, "lib/utils/version.rb".freeze, "lib/utils/xt/source_location_extension.rb".freeze]
16
- s.files = [".github/dependabot.yml".freeze, ".github/workflows/codeql-analysis.yml".freeze, "COPYING".freeze, "Gemfile".freeze, "README.md".freeze, "Rakefile".freeze, "bin/ascii7".freeze, "bin/blameline".freeze, "bin/changes".freeze, "bin/classify".freeze, "bin/code_comment".freeze, "bin/commit_message".freeze, "bin/create_cstags".freeze, "bin/create_tags".freeze, "bin/discover".freeze, "bin/edit".freeze, "bin/edit_wait".freeze, "bin/enum".freeze, "bin/git-empty".freeze, "bin/git-md".freeze, "bin/git-versions".freeze, "bin/json_check".freeze, "bin/long_lines".freeze, "bin/myex".freeze, "bin/number_files".freeze, "bin/on_change".freeze, "bin/path".freeze, "bin/print_method".freeze, "bin/probe".freeze, "bin/rd2md".freeze, "bin/search".freeze, "bin/sedit".freeze, "bin/serve".freeze, "bin/ssh-tunnel".freeze, "bin/strip_spaces".freeze, "bin/sync_dir".freeze, "bin/untest".freeze, "bin/utils-utilsrc".freeze, "bin/vcf2alias".freeze, "bin/yaml_check".freeze, "lib/utils.rb".freeze, "lib/utils/config_file.rb".freeze, "lib/utils/editor.rb".freeze, "lib/utils/file_xt.rb".freeze, "lib/utils/finder.rb".freeze, "lib/utils/grepper.rb".freeze, "lib/utils/irb.rb".freeze, "lib/utils/line_blamer.rb".freeze, "lib/utils/line_formatter.rb".freeze, "lib/utils/md5.rb".freeze, "lib/utils/patterns.rb".freeze, "lib/utils/probe_server.rb".freeze, "lib/utils/ssh_tunnel_specification.rb".freeze, "lib/utils/version.rb".freeze, "lib/utils/xt/source_location_extension.rb".freeze, "utils.gemspec".freeze]
14
+ s.executables = ["ascii7".freeze, "blameline".freeze, "changes".freeze, "classify".freeze, "code_comment".freeze, "commit_message".freeze, "create_cstags".freeze, "create_tags".freeze, "discover".freeze, "edit".freeze, "edit_wait".freeze, "enum".freeze, "git-empty".freeze, "git-md".freeze, "git-versions".freeze, "json_check".freeze, "long_lines".freeze, "md".freeze, "myex".freeze, "number_files".freeze, "on_change".freeze, "path".freeze, "print_method".freeze, "probe".freeze, "rd2md".freeze, "search".freeze, "sedit".freeze, "serve".freeze, "ssh-tunnel".freeze, "strip_spaces".freeze, "sync_dir".freeze, "untest".freeze, "utils-utilsrc".freeze, "vcf2alias".freeze, "yaml_check".freeze]
15
+ s.extra_rdoc_files = ["README.md".freeze, "lib/utils.rb".freeze, "lib/utils/config_file.rb".freeze, "lib/utils/editor.rb".freeze, "lib/utils/file_xt.rb".freeze, "lib/utils/finder.rb".freeze, "lib/utils/grepper.rb".freeze, "lib/utils/irb.rb".freeze, "lib/utils/line_blamer.rb".freeze, "lib/utils/line_formatter.rb".freeze, "lib/utils/markdown.rb".freeze, "lib/utils/md5.rb".freeze, "lib/utils/pager.rb".freeze, "lib/utils/patterns.rb".freeze, "lib/utils/probe_server.rb".freeze, "lib/utils/ssh_tunnel_specification.rb".freeze, "lib/utils/version.rb".freeze, "lib/utils/xt/source_location_extension.rb".freeze]
16
+ s.files = [".github/dependabot.yml".freeze, ".github/workflows/codeql-analysis.yml".freeze, "COPYING".freeze, "Gemfile".freeze, "README.md".freeze, "Rakefile".freeze, "bin/ascii7".freeze, "bin/blameline".freeze, "bin/changes".freeze, "bin/classify".freeze, "bin/code_comment".freeze, "bin/commit_message".freeze, "bin/create_cstags".freeze, "bin/create_tags".freeze, "bin/discover".freeze, "bin/edit".freeze, "bin/edit_wait".freeze, "bin/enum".freeze, "bin/git-empty".freeze, "bin/git-md".freeze, "bin/git-versions".freeze, "bin/json_check".freeze, "bin/long_lines".freeze, "bin/md".freeze, "bin/myex".freeze, "bin/number_files".freeze, "bin/on_change".freeze, "bin/path".freeze, "bin/print_method".freeze, "bin/probe".freeze, "bin/rd2md".freeze, "bin/search".freeze, "bin/sedit".freeze, "bin/serve".freeze, "bin/ssh-tunnel".freeze, "bin/strip_spaces".freeze, "bin/sync_dir".freeze, "bin/untest".freeze, "bin/utils-utilsrc".freeze, "bin/vcf2alias".freeze, "bin/yaml_check".freeze, "lib/utils.rb".freeze, "lib/utils/config_file.rb".freeze, "lib/utils/editor.rb".freeze, "lib/utils/file_xt.rb".freeze, "lib/utils/finder.rb".freeze, "lib/utils/grepper.rb".freeze, "lib/utils/irb.rb".freeze, "lib/utils/line_blamer.rb".freeze, "lib/utils/line_formatter.rb".freeze, "lib/utils/markdown.rb".freeze, "lib/utils/md5.rb".freeze, "lib/utils/pager.rb".freeze, "lib/utils/patterns.rb".freeze, "lib/utils/probe_server.rb".freeze, "lib/utils/ssh_tunnel_specification.rb".freeze, "lib/utils/version.rb".freeze, "lib/utils/xt/source_location_extension.rb".freeze, "utils.gemspec".freeze]
17
17
  s.homepage = "http://github.com/flori/utils".freeze
18
18
  s.licenses = ["GPL-2.0".freeze]
19
19
  s.rdoc_options = ["--title".freeze, "Utils - Some useful command line utilities".freeze, "--main".freeze, "README.md".freeze]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.56.1
4
+ version: 0.57.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Frank
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-09-30 00:00:00.000000000 Z
11
+ date: 2024-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gem_hadar
@@ -212,6 +212,7 @@ executables:
212
212
  - git-versions
213
213
  - json_check
214
214
  - long_lines
215
+ - md
215
216
  - myex
216
217
  - number_files
217
218
  - on_change
@@ -241,7 +242,9 @@ extra_rdoc_files:
241
242
  - lib/utils/irb.rb
242
243
  - lib/utils/line_blamer.rb
243
244
  - lib/utils/line_formatter.rb
245
+ - lib/utils/markdown.rb
244
246
  - lib/utils/md5.rb
247
+ - lib/utils/pager.rb
245
248
  - lib/utils/patterns.rb
246
249
  - lib/utils/probe_server.rb
247
250
  - lib/utils/ssh_tunnel_specification.rb
@@ -271,6 +274,7 @@ files:
271
274
  - bin/git-versions
272
275
  - bin/json_check
273
276
  - bin/long_lines
277
+ - bin/md
274
278
  - bin/myex
275
279
  - bin/number_files
276
280
  - bin/on_change
@@ -297,7 +301,9 @@ files:
297
301
  - lib/utils/irb.rb
298
302
  - lib/utils/line_blamer.rb
299
303
  - lib/utils/line_formatter.rb
304
+ - lib/utils/markdown.rb
300
305
  - lib/utils/md5.rb
306
+ - lib/utils/pager.rb
301
307
  - lib/utils/patterns.rb
302
308
  - lib/utils/probe_server.rb
303
309
  - lib/utils/ssh_tunnel_specification.rb