utils 0.41.0 → 0.43.0

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: 88af92dc7e32b6d24fef9951b3cac7ee7a053c2b803e03f56e14a67db59e947e
4
- data.tar.gz: 282bde2c79a6f3bb47f84aee99bf8a3bd3dc234034f548088c15647f7a8b1592
3
+ metadata.gz: b3583ce3465c67920f1657f0abf6755c0fc9f901bca1c52caa0c87cd9a75ae37
4
+ data.tar.gz: 77c44067f0bb95ebdeb1a7fdade018d335b949b63c1727e15f4afb67246b2e20
5
5
  SHA512:
6
- metadata.gz: 971526eb0818d727a0810720c6d25647dcac76336276c9465064f5288700fc10d36f1ef42e5903704f1208670ed318c0c58c55d48c8155f8957d972636074280
7
- data.tar.gz: 4b63131b02ab4865237b2438fb1be38e9fff1f6c2730067ae95386e94329569790611b55d71f4a563c9a79e18a10179733a16ec31aac9b12dfe59326bdc90dd9
6
+ metadata.gz: '09ceb99122db1b754ae147d6ad0f6a002e26b6c21f99554e5f2a448b98cbc5618a74f988ca09138e8528b9ad766430296faa30a59a41c7e38c91ae33945f03ed'
7
+ data.tar.gz: 70481a4a7a41bf70546b53b4d2d942682e3f3756d8a4088790ce126a2bfeb2d84c337cfe762dc236a085f37e2b073206b7b1fe31940d32fe026968cbdbaa9b83
data/bin/create_tags CHANGED
@@ -3,8 +3,8 @@
3
3
  require 'infobar'
4
4
 
5
5
  paths = %w[ . ] + `bundle list --paths`.lines.map(&:chomp)
6
- cmd = %w[ ctags --recurse=yes --languages=Ruby,C ] + paths
7
- Infobar.busy(label: 'Creating tags') { system *cmd }
6
+ cmd = %w[ ctags --recurse=yes --exclude=pkg --languages=Ruby,C ] + paths
7
+ Infobar.busy(label: 'Creating tags') { system(*cmd) }
8
8
  if megabytes = File.size('tags').to_f / 1024 ** 2 rescue nil
9
9
  infobar.puts 'Created %.3fM of tags.' % megabytes
10
10
  end
data/bin/discover CHANGED
@@ -12,7 +12,7 @@ def edit_files(*paths, pick: false, wait: true)
12
12
  if pick
13
13
  if paths.size > 1
14
14
  path = complete(prompt: 'Pick? ') do |p|
15
- paths.grep /#{p}/
15
+ paths.grep(/#{p}/)
16
16
  end
17
17
  else
18
18
  path = paths.first
@@ -83,7 +83,6 @@ search = -> * {
83
83
  f = nil
84
84
  pattern = pattern.dup
85
85
  args[?n] = Term::ANSIColor.terminal_lines - 1
86
- path = nil
87
86
  found = Search.new(
88
87
  match: -> answer {
89
88
  pattern.replace answer
@@ -95,9 +94,7 @@ search = -> * {
95
94
  matches.each_with_index.map { |l, i| (i == selector ? '> ' : ' ') + l }.join(?\n)
96
95
  },
97
96
  found: -> _answer, matches, selector {
98
- if f
99
- path = f.paths[selector]
100
- end
97
+ f.paths[selector] if f
101
98
  },
102
99
  output: STDERR
103
100
  ).start
@@ -117,9 +114,9 @@ case
117
114
  when args[?s]
118
115
  search.()
119
116
  when args[?E]
120
- edit_files *finder.().paths, pick: true
117
+ edit_files(*finder.().paths, pick: true)
121
118
  when args[?e]
122
- edit_files *finder.().search.paths
119
+ edit_files(*finder.().search.paths)
123
120
  when args[?D]
124
121
  args[?d] = true
125
122
  paths = finder.().load_paths.select { |p| File.directory?(p) }.reverse
data/bin/json_check CHANGED
@@ -5,6 +5,6 @@ require 'json'
5
5
  begin
6
6
  JSON.parse(ARGF.read)
7
7
  exit 0
8
- rescue JSON::ParserError => e
8
+ rescue JSON::ParserError
9
9
  exit 1
10
10
  end
data/bin/search CHANGED
@@ -18,7 +18,7 @@ end
18
18
 
19
19
  def read_line(path)
20
20
  filename, lineno = path.source_location
21
- line = File.open(filename) do |file|
21
+ File.open(filename) do |file|
22
22
  file.lazy.each_with_index.select { |l, n| n + 1 == lineno }.first&.first
23
23
  end
24
24
  end
@@ -71,8 +71,6 @@ def replace_ask(editor, path, pattern, replace, all)
71
71
  when ?e
72
72
  editor.edit(path.strip)
73
73
  break false
74
- when ?a
75
- break true
76
74
  else
77
75
  next
78
76
  end
@@ -95,7 +93,7 @@ def edit_files(pattern, paths, pick: false, replace: nil)
95
93
  when pick
96
94
  if paths.size > 1
97
95
  path = complete(prompt: 'Pick? ') do |p|
98
- paths.grep /#{p}/
96
+ paths.grep(/#{p}/)
99
97
  end
100
98
  else
101
99
  path = paths.first
@@ -139,6 +137,7 @@ Options are
139
137
  -r REPLACE replace the searched match with REPLACE
140
138
  -b also search binary files
141
139
  -g use git to determine author of the line
140
+ -G AUTHOR only display lines authored by AUTHOR
142
141
  -a CSET use only character set CSET from PATTERN
143
142
  -v be verbose
144
143
  -h display this help
@@ -148,7 +147,7 @@ Version is #{File.basename($0)} #{Utils::VERSION}.
148
147
  exit 1
149
148
  end
150
149
 
151
- args = go 'r:p:I:A:B:C:s:S:n:N:a:i:cfFlLeEvbgh'
150
+ args = go 'r:p:I:A:B:C:s:S:n:N:a:i:G:cfFlLeEvbgh'
152
151
  args[?h] and usage
153
152
  pattern = ARGV.shift or usage
154
153
  roots = (ARGV.empty? ? [ Dir.pwd ] : ARGV).map { |f| File.expand_path(f) }
data/lib/utils/grepper.rb CHANGED
@@ -97,9 +97,12 @@ class Utils::Grepper
97
97
  @output.each do |l|
98
98
  blamer = LineBlamer.for_line(l)
99
99
  if blame = blamer.perform
100
+ author = nil
100
101
  blame.sub!(/^[0-9a-f^]+/) { Term::ANSIColor.yellow($&) }
101
- blame.sub!(/\(([^)]+)\)/) { "(#{Term::ANSIColor.red($1)})" }
102
- puts "#{blame.chomp} #{Term::ANSIColor.blue(l)}"
102
+ blame.sub!(/\(([^)]+)\)/) { author = $1; "(#{Term::ANSIColor.red($1)})" }
103
+ if !@args[?G] || author&.downcase&.match?(@args[?G].downcase)
104
+ puts "#{blame.chomp} #{Term::ANSIColor.blue(l)}"
105
+ end
103
106
  end
104
107
  end
105
108
  when @args[?l], @args[?e], @args[?E], @args[?r]
data/lib/utils/irb.rb CHANGED
@@ -51,7 +51,7 @@ module Utils
51
51
  end
52
52
 
53
53
  def yri(*patterns)
54
- ri *patterns, doc: 'yri'
54
+ ri(*patterns, doc: 'yri')
55
55
  end
56
56
 
57
57
  def irb_open(url = nil, &block)
@@ -5,15 +5,7 @@ module Utils
5
5
  end
6
6
 
7
7
  def self.for_line(line)
8
- location = line.source_location and new *location
9
- end
10
-
11
- def self.blame(line)
12
- blamer = for_line(line)
13
- if blame = blamer.perform
14
- blame.sub!(/^[0-9a-f^]+/) { Term::ANSIColor.yellow($&) }
15
- blame.sub!(/\(([^)]+)\)/) { "(#{Term::ANSIColor.red($1)})" }
16
- end
8
+ location = line.source_location and new(*location)
17
9
  end
18
10
 
19
11
  def perform(options = '')
@@ -89,7 +89,7 @@ module Utils
89
89
  def help
90
90
  docs = doc_annotations.sort_by(&:first)
91
91
  docs_size = docs.map { |a| a.first.size }.max
92
- format = '%-20s %-3s %s'
92
+ format = "%-#{docs_size}s %-3s %s"
93
93
  output_message [
94
94
  (format % %w[ command sho description ]).on_color(20).white
95
95
  ] << docs.map { |cmd, doc|
@@ -198,7 +198,7 @@ module Utils
198
198
 
199
199
  def run_job(job)
200
200
  output_message " → #{job.inspect} now running.", type: :info
201
- system *cmd(job.args)
201
+ system(*cmd(job.args))
202
202
  message = " → #{job.inspect} was just run"
203
203
  if $?.success?
204
204
  job.ok = true
data/lib/utils/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Utils
2
2
  # Utils version
3
- VERSION = '0.41.0'
3
+ VERSION = '0.43.0'
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/utils.gemspec CHANGED
@@ -1,14 +1,14 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: utils 0.41.0 ruby lib
2
+ # stub: utils 0.43.0 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "utils".freeze
6
- s.version = "0.41.0".freeze
6
+ s.version = "0.43.0".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-04-17"
11
+ s.date = "2024-06-05"
12
12
  s.description = "This ruby gem provides some useful command line utilities".freeze
13
13
  s.email = "flori@ping.de".freeze
14
14
  s.executables = ["ascii7".freeze, "blameline".freeze, "check-yaml".freeze, "classify".freeze, "create_cstags".freeze, "create_tags".freeze, "discover".freeze, "edit".freeze, "edit_wait".freeze, "enum".freeze, "fix-brew".freeze, "git-empty".freeze, "git-versions".freeze, "irb_connect".freeze, "json_check".freeze, "long_lines".freeze, "myex".freeze, "number_files".freeze, "on_change".freeze, "path".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]
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
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]
20
- s.rubygems_version = "3.5.3".freeze
20
+ s.rubygems_version = "3.5.9".freeze
21
21
  s.summary = "Some useful command line utilities".freeze
22
22
 
23
23
  s.specification_version = 4
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.41.0
4
+ version: 0.43.0
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-04-17 00:00:00.000000000 Z
11
+ date: 2024-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gem_hadar
@@ -281,7 +281,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
281
281
  - !ruby/object:Gem::Version
282
282
  version: '0'
283
283
  requirements: []
284
- rubygems_version: 3.5.3
284
+ rubygems_version: 3.5.9
285
285
  signing_key:
286
286
  specification_version: 4
287
287
  summary: Some useful command line utilities