utils 0.33.1 → 0.35.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/discover +8 -3
- data/bin/probe +4 -0
- data/lib/utils/irb.rb +6 -20
- data/lib/utils/line_formatter.rb +158 -158
- data/lib/utils/version.rb +1 -1
- data/lib/utils.rb +0 -4
- data/utils.gemspec +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '07918bacd055f0bbfac96cd115901ce36b656d9658477a07e11565562b73846e'
|
4
|
+
data.tar.gz: 8016c94eabb23717b14548a2b334a5f2d047808157b803a23980d63a7270847b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d903b3bf6fd56083203e63930036ed0950dbae533cb7560569c920f4d25ef2267aa12f5e35740f61c9210b9b3df7b94f35050895a0c91b34b02309963b4fac2
|
7
|
+
data.tar.gz: c50f439ffe1168cda867f5470b39e9a642363861901f9371ace1eec95c45b7d2a6556c82b5d108582927cffec02ef405fa35f0b6f5e7a9f75382e91a8f87d72f
|
data/bin/discover
CHANGED
@@ -79,8 +79,7 @@ finder = -> * {
|
|
79
79
|
)
|
80
80
|
}
|
81
81
|
|
82
|
-
|
83
|
-
when args[?s]
|
82
|
+
search = -> * {
|
84
83
|
f = nil
|
85
84
|
pattern = pattern.dup
|
86
85
|
args[?n] = Term::ANSIColor.terminal_lines - 1
|
@@ -112,6 +111,11 @@ when args[?s]
|
|
112
111
|
else
|
113
112
|
exit 1
|
114
113
|
end
|
114
|
+
}
|
115
|
+
|
116
|
+
case
|
117
|
+
when args[?s]
|
118
|
+
search.()
|
115
119
|
when args[?E]
|
116
120
|
edit_files *finder.().paths, pick: true
|
117
121
|
when args[?e]
|
@@ -131,7 +135,8 @@ when pattern.empty? && args[?r]
|
|
131
135
|
finder.()
|
132
136
|
exit
|
133
137
|
when pattern.empty?
|
134
|
-
|
138
|
+
args[?e] = true
|
139
|
+
search.()
|
135
140
|
else
|
136
141
|
puts finder.().search.output
|
137
142
|
end
|
data/bin/probe
CHANGED
data/lib/utils/irb.rb
CHANGED
@@ -336,31 +336,17 @@ module Utils
|
|
336
336
|
STDERR.puts "Loaded '#{f}'."
|
337
337
|
end
|
338
338
|
end
|
339
|
-
Find.find('.') do |f|
|
340
|
-
File.directory?(f) and next
|
341
|
-
md5_f = Utils::MD5.md5(f)
|
342
|
-
if f.end_with?(file) and !loaded[md5_f]
|
343
|
-
Kernel.load f
|
344
|
-
loaded[md5_f] = true
|
345
|
-
STDERR.puts "Loaded '#{f}'."
|
346
|
-
end
|
347
|
-
end
|
348
339
|
end
|
349
340
|
end
|
350
341
|
nil
|
351
342
|
end
|
352
343
|
|
353
|
-
def
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
end
|
360
|
-
|
361
|
-
# List contents of directory
|
362
|
-
def ls(*args)
|
363
|
-
puts `ls #{args.map { |x| "'#{x}'" } * ' '}`
|
344
|
+
def ed(*files)
|
345
|
+
if files.empty?
|
346
|
+
$editor.full?(:edit, self)
|
347
|
+
else
|
348
|
+
$editor.full?(:edit, *files)
|
349
|
+
end
|
364
350
|
end
|
365
351
|
|
366
352
|
if defined?(ActiveRecord::Base)
|
data/lib/utils/line_formatter.rb
CHANGED
@@ -9,164 +9,164 @@ rescue LoadError => e
|
|
9
9
|
else
|
10
10
|
module Utils
|
11
11
|
class LineFormatter
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
12
|
+
::RSpec::Core::Formatters.register self, :start, :close,
|
13
|
+
:example_passed, :example_pending, :example_failed, :dump_summary
|
14
|
+
|
15
|
+
def initialize(output)
|
16
|
+
@output = output
|
17
|
+
@output.sync = true
|
18
|
+
filename = 'errors.lst'
|
19
|
+
@errors_lst = File.new(filename, 'w')
|
20
|
+
@errors_lst.sync = true
|
21
|
+
end
|
22
|
+
|
23
|
+
attr_reader :output
|
24
|
+
|
25
|
+
def start(_ignore)
|
26
|
+
output.puts "Storing error list in #{@errors_lst.path.inspect}: "
|
27
|
+
output.puts ?- * Tins::Terminal.columns
|
28
|
+
end
|
29
|
+
|
30
|
+
def close(_ignore)
|
31
|
+
@errors_lst.close
|
32
|
+
end
|
33
|
+
|
34
|
+
def dump_summary(summary)
|
35
|
+
line = summary_line(summary)
|
36
|
+
@errors_lst.puts ?= * 80, line
|
37
|
+
output.puts ?= * Tins::Terminal.columns, line
|
38
|
+
end
|
39
|
+
|
40
|
+
def example_passed(example)
|
41
|
+
output.puts format_line(example)
|
42
|
+
end
|
43
|
+
|
44
|
+
def example_pending(example)
|
45
|
+
output.puts format_line(example)
|
46
|
+
end
|
47
|
+
|
48
|
+
def example_failed(example)
|
49
|
+
dump_failure_to_error_file(example)
|
50
|
+
output.puts format_line(example)
|
51
|
+
dump_failure(example)
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def summary_line(summary)
|
57
|
+
failure_percentage = 100 * summary.failure_count.to_f / summary.example_count
|
58
|
+
failure_percentage.nan? and failure_percentage = 0.0
|
59
|
+
pending_percentage = 100 * summary.pending_count.to_f / summary.example_count
|
60
|
+
pending_percentage.nan? and pending_percentage = 0.0
|
61
|
+
"%u of %u (%.2f %%) failed, %u pending (%.2f %%) in %.3f seconds" % [
|
62
|
+
summary.failure_count,
|
63
|
+
summary.example_count,
|
64
|
+
failure_percentage,
|
65
|
+
summary.pending_count,
|
66
|
+
pending_percentage,
|
67
|
+
summary.duration,
|
68
|
+
]
|
69
|
+
end
|
70
|
+
|
71
|
+
def dump_failure(example)
|
72
|
+
output.puts(
|
73
|
+
description(example, full: true),
|
74
|
+
dump_failure_for_example(example)
|
75
|
+
)
|
76
|
+
end
|
77
|
+
|
78
|
+
def read_failed_line(example)
|
79
|
+
''.strip
|
80
|
+
end
|
81
|
+
|
82
|
+
def dump_failure_for_example(example)
|
83
|
+
result = ''
|
84
|
+
exception = execution_result(example).exception
|
85
|
+
exception_class_name = exception.class.name
|
86
|
+
result << "Failure/Error: #{read_failed_line(example)}\n"
|
87
|
+
result << "#{exception_class_name}:\n" unless exception_class_name =~ /RSpec/
|
88
|
+
if m = exception.message
|
89
|
+
m.to_s.split("\n").each { |line| result << " #{line}\n" }
|
90
|
+
end
|
91
|
+
result
|
92
|
+
end
|
93
|
+
|
94
|
+
def format_backtrace(example, folding: false, limit: nil)
|
95
|
+
backtrace = execution_result(example).exception.backtrace
|
96
|
+
backtrace.nil? and return ''
|
97
|
+
if limit
|
98
|
+
backtrace = backtrace[0, limit]
|
99
|
+
end
|
100
|
+
result = []
|
101
|
+
folding and result << '{{{'
|
102
|
+
for line in backtrace
|
103
|
+
result << RSpec::Core::Metadata::relative_path(line)
|
104
|
+
end
|
105
|
+
folding and result << '}}}'
|
106
|
+
result * ?\n
|
107
|
+
end
|
108
|
+
|
109
|
+
def dump_failure_to_error_file(example)
|
110
|
+
@errors_lst.flock File::LOCK_EX
|
111
|
+
@errors_lst.puts "%s\n%3.3fs %s\n%s\n%s" % [
|
112
|
+
location(example), run_time(example), description(example, full: true),
|
113
|
+
dump_failure_for_example(example), format_backtrace(example, folding: true)
|
114
|
+
]
|
115
|
+
ensure
|
116
|
+
@errors_lst.flock File::LOCK_UN
|
117
|
+
end
|
118
|
+
|
119
|
+
def execution_result(example)
|
120
|
+
example.example.metadata[:execution_result]
|
121
|
+
end
|
122
|
+
|
123
|
+
def description(example, full: ENV['VERBOSE'].to_i == 1)
|
124
|
+
if full
|
125
|
+
example.example.full_description
|
126
|
+
else
|
127
|
+
example.example.description
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
def run_time(example)
|
132
|
+
execution_result(example).run_time
|
133
|
+
end
|
134
|
+
|
135
|
+
def format_line(example)
|
136
|
+
args = [ location(example), run_time(example), description(example) ]
|
137
|
+
uncolored = "%s # S %3.3fs %s" % args
|
138
|
+
uncolored = uncolored[0, Tins::Terminal.columns]
|
139
|
+
case execution_result(example).status
|
140
|
+
when :passed
|
141
|
+
success_color(uncolored)
|
142
|
+
when :failed
|
143
|
+
failure_color(uncolored)
|
144
|
+
when :pending
|
145
|
+
pending_color(uncolored)
|
146
|
+
else
|
147
|
+
uncolored % args
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
def success_color(text)
|
152
|
+
Term::ANSIColor.green(text)
|
153
|
+
end
|
154
|
+
|
155
|
+
def failure_color(text)
|
156
|
+
Term::ANSIColor.red(text)
|
157
|
+
end
|
158
|
+
|
159
|
+
def pending_color(text)
|
160
|
+
Term::ANSIColor.yellow(text)
|
161
|
+
end
|
162
|
+
|
163
|
+
def location(example)
|
164
|
+
location = example.example.metadata[:location]
|
165
|
+
unless location.include?(?/)
|
166
|
+
location = example.example.metadata[:example_group][:location]
|
167
|
+
end
|
168
|
+
RSpec::Core::Metadata::relative_path(location)
|
169
|
+
end
|
170
170
|
end
|
171
171
|
end
|
172
172
|
end
|
data/lib/utils/version.rb
CHANGED
data/lib/utils.rb
CHANGED
@@ -10,10 +10,6 @@ module Utils
|
|
10
10
|
require 'utils/probe_server'
|
11
11
|
require 'utils/ssh_tunnel_specification'
|
12
12
|
require 'utils/line_blamer'
|
13
|
-
begin
|
14
|
-
require 'utils/line_formatter'
|
15
|
-
rescue LoadError
|
16
|
-
end
|
17
13
|
|
18
14
|
require 'utils/xt/source_location_extension'
|
19
15
|
class ::Object
|
data/utils.gemspec
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: utils 0.
|
2
|
+
# stub: utils 0.35.0 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "utils".freeze
|
6
|
-
s.version = "0.
|
6
|
+
s.version = "0.35.0"
|
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 = "
|
11
|
+
s.date = "2023-03-01"
|
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, "untest".freeze, "utils-utilsrc".freeze, "vcf2alias".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.
|
4
|
+
version: 0.35.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:
|
11
|
+
date: 2023-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gem_hadar
|