utils 0.44.0 → 0.46.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: 825b9fd0dbbb5410f80f85ecec639484f6e96bd1c240d8f830a7e85961c6e1c3
4
- data.tar.gz: 93d42d80cbbf23773c93cc41feaac88f0ae5e7ca44e791ed8faff6363eaa53b2
3
+ metadata.gz: c70230878e670eb2201ade57a3d70154ae068aa3b5aefa3719369666bc94bffd
4
+ data.tar.gz: c318827db3a29b112459662eb776ba0fc623ec6e35025fdc8206ac74f4dcc9c8
5
5
  SHA512:
6
- metadata.gz: b33cc91d12d7e0141e08ee7f83bef104ede6fb32df27ab4ecd29575932a4197a3172e6e90acb7647aeac27ef64d24a7969b73e98f32ebf1b4e10c9716ac1f950
7
- data.tar.gz: fc980bc204f19f9ed4492f15c8b692b1ab3ae98e069a7e0687cb53dbba66e4df866cefe5110e5caa9d7ad69be473b896583b3023660aaa3cbf64700e08e2cba6
6
+ metadata.gz: b50150d35c6c70132a78c390fbd6fc4433bd060dd5b249907481d977ccd7a4a8d379896beef8892e0b663bb467ee7354e923b2e63641bdc57c7544a651654d6e
7
+ data.tar.gz: 3f4fd29351c28b694b07331f586d23ad0bee687ef0759454880e00e59a059bf2b230fea7986a8df08f36fe223b342d087df30c36ef6e2a82c5062aa2b0d00233
data/bin/print_method ADDED
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'utils'
4
+
5
+ inputs = ARGV.empty? ? STDIN : ARGV
6
+
7
+ inputs.each do |filename_linenumber|
8
+ source_location = filename_linenumber.source_location
9
+ lf = Tins::LinesFile.for_filename(source_location.filename, source_location.linenumber)
10
+ if spaces = lf.match_backward(/^(\s*)def\s+(?:\S+?)(?:\(|\s*$)/)&.first
11
+ line_number_begin = lf.line_number
12
+ lf.match_forward(/^#{spaces}end/)
13
+ line_number_end = lf.line_number
14
+ line_number_begin.upto(line_number_end) do |line_number|
15
+ lf.line_number = line_number
16
+ puts lf.line
17
+ end
18
+ end
19
+ end
data/lib/utils/irb.rb CHANGED
@@ -11,8 +11,6 @@ $pager = ENV['PAGER'] || 'less -r'
11
11
 
12
12
  module Utils
13
13
  module IRB
14
- require 'utils/irb/service'
15
-
16
14
  module Shell
17
15
  require 'fileutils'
18
16
  include FileUtils
@@ -71,16 +69,6 @@ module Utils
71
69
  end
72
70
  end
73
71
 
74
- # Start an irb server.
75
- def irb_server(uri = nil)
76
- Utils::IRB::Service.start(uri) {}
77
- end
78
-
79
- # Connect to an irb server.
80
- def irb_connect(uri = nil)
81
- Utils::IRB::Service.connect(uri)
82
- end
83
-
84
72
  # TODO: change the API of this stuff
85
73
 
86
74
  # Return all instance methods of obj's class.
@@ -241,6 +229,10 @@ module Utils
241
229
  temp.read
242
230
  end
243
231
 
232
+ def le(with_stderr = false, &block)
233
+ less(with_stderr) { block.call(self) }
234
+ end
235
+
244
236
  # Use pager on the output of the commands given in the block.
245
237
  def less(with_stderr = false, &block)
246
238
  IO.popen($pager, 'w') do |f|
data/lib/utils/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Utils
2
2
  # Utils version
3
- VERSION = '0.44.0'
3
+ VERSION = '0.46.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,28 +1,28 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: utils 0.44.0 ruby lib
2
+ # stub: utils 0.46.0 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "utils".freeze
6
- s.version = "0.44.0".freeze
6
+ s.version = "0.46.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-07-03"
11
+ s.date = "2024-08-20"
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, "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]
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/irb/service.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/check-yaml".freeze, "bin/classify".freeze, "bin/create_cstags".freeze, "bin/create_tags".freeze, "bin/discover".freeze, "bin/edit".freeze, "bin/edit_wait".freeze, "bin/enum".freeze, "bin/fix-brew".freeze, "bin/git-empty".freeze, "bin/git-versions".freeze, "bin/irb_connect".freeze, "bin/json_check".freeze, "bin/long_lines".freeze, "bin/myex".freeze, "bin/number_files".freeze, "bin/on_change".freeze, "bin/path".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, "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/irb/service.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, "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, "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]
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/check-yaml".freeze, "bin/classify".freeze, "bin/create_cstags".freeze, "bin/create_tags".freeze, "bin/discover".freeze, "bin/edit".freeze, "bin/edit_wait".freeze, "bin/enum".freeze, "bin/fix-brew".freeze, "bin/git-empty".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, "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]
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.11".freeze
20
+ s.rubygems_version = "3.5.16".freeze
21
21
  s.summary = "Some useful command line utilities".freeze
22
22
 
23
23
  s.specification_version = 4
24
24
 
25
- s.add_development_dependency(%q<gem_hadar>.freeze, ["~> 1.15.0".freeze])
25
+ s.add_development_dependency(%q<gem_hadar>.freeze, ["~> 1.16.1".freeze])
26
26
  s.add_development_dependency(%q<debug>.freeze, [">= 0".freeze])
27
27
  s.add_runtime_dependency(%q<tins>.freeze, ["~> 1.14".freeze])
28
28
  s.add_runtime_dependency(%q<term-ansicolor>.freeze, ["~> 1.3".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.44.0
4
+ version: 0.46.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-07-03 00:00:00.000000000 Z
11
+ date: 2024-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gem_hadar
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.15.0
19
+ version: 1.16.1
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.15.0
26
+ version: 1.16.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: debug
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -166,13 +166,13 @@ executables:
166
166
  - fix-brew
167
167
  - git-empty
168
168
  - git-versions
169
- - irb_connect
170
169
  - json_check
171
170
  - long_lines
172
171
  - myex
173
172
  - number_files
174
173
  - on_change
175
174
  - path
175
+ - print_method
176
176
  - probe
177
177
  - rd2md
178
178
  - search
@@ -194,7 +194,6 @@ extra_rdoc_files:
194
194
  - lib/utils/finder.rb
195
195
  - lib/utils/grepper.rb
196
196
  - lib/utils/irb.rb
197
- - lib/utils/irb/service.rb
198
197
  - lib/utils/line_blamer.rb
199
198
  - lib/utils/line_formatter.rb
200
199
  - lib/utils/md5.rb
@@ -223,13 +222,13 @@ files:
223
222
  - bin/fix-brew
224
223
  - bin/git-empty
225
224
  - bin/git-versions
226
- - bin/irb_connect
227
225
  - bin/json_check
228
226
  - bin/long_lines
229
227
  - bin/myex
230
228
  - bin/number_files
231
229
  - bin/on_change
232
230
  - bin/path
231
+ - bin/print_method
233
232
  - bin/probe
234
233
  - bin/rd2md
235
234
  - bin/search
@@ -248,7 +247,6 @@ files:
248
247
  - lib/utils/finder.rb
249
248
  - lib/utils/grepper.rb
250
249
  - lib/utils/irb.rb
251
- - lib/utils/irb/service.rb
252
250
  - lib/utils/line_blamer.rb
253
251
  - lib/utils/line_formatter.rb
254
252
  - lib/utils/md5.rb
@@ -281,7 +279,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
281
279
  - !ruby/object:Gem::Version
282
280
  version: '0'
283
281
  requirements: []
284
- rubygems_version: 3.5.11
282
+ rubygems_version: 3.5.16
285
283
  signing_key:
286
284
  specification_version: 4
287
285
  summary: Some useful command line utilities
data/bin/irb_connect DELETED
@@ -1,37 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # encoding: UTF-8
3
-
4
- require 'tins/xt'
5
- include Tins::GO
6
- require 'utils/irb'
7
- require 'drb'
8
-
9
- def usage
10
- puts <<-EOT
11
- Usage: #{File.basename($0)} [OPTS]
12
-
13
- Options are
14
-
15
- -e CODE CODE is execute on the remote irb
16
- -l PATH load file PATH into remote irb context
17
- -u URL druby url to connect to
18
- -h display this help
19
-
20
- Version is #{File.basename($0)} #{Utils::VERSION}.
21
- EOT
22
- exit 1
23
- end
24
-
25
-
26
- $opts = go 'e:u:l:h'
27
- $opts[?h] and usage
28
-
29
- proxy = Utils::IRB::Service.connect($opts[?u])
30
- case
31
- when load_path = $opts[?l]
32
- proxy.load(load_path)
33
- when code = $opts[?e]
34
- p proxy.eval(code)
35
- else
36
- puts proxy.eval(STDIN.read)
37
- end
@@ -1,39 +0,0 @@
1
- require 'drb'
2
-
3
- module Utils::IRB::Service
4
- class << self
5
- attr_accessor :hostname
6
-
7
- attr_accessor :port
8
-
9
- def start(uri = nil, &block)
10
- uri ||= "druby://localhost:6642"
11
- block ||= proc {}
12
- puts "Starting IRB server listening to #{uri.inspect}."
13
- DRb.start_service(uri, eval('irb_current_working_binding', block.binding))
14
- end
15
-
16
- def connect(uri = nil)
17
- uri ||= "druby://localhost:6642"
18
- irb = DRbObject.new_with_uri(uri)
19
- Proxy.new(irb)
20
- end
21
- end
22
-
23
- class Proxy
24
- def initialize(irb)
25
- @irb = irb
26
- end
27
-
28
- def eval(code)
29
- @irb.conf.workspace.evaluate nil, code
30
- end
31
-
32
- def load(filename)
33
- unless filename.start_with?('/')
34
- filename = File.expand_path filename
35
- end
36
- @irb.load filename
37
- end
38
- end
39
- end