utils 0.6.4 → 0.8.0

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.
data/lib/utils/grepper.rb CHANGED
@@ -31,8 +31,8 @@ class Utils::Grepper
31
31
 
32
32
  def initialize(opts = {})
33
33
  @args = opts[:args] || {}
34
- @roots = opts[:roots] || []
35
- @config = opts[:config] || Utils::Config::ConfigFile.new
34
+ @roots = discover_roots(opts[:roots])
35
+ @config = opts[:config] || Utils::ConfigFile.new
36
36
  if n = @args.values_at(*%w[A B C]).compact.first
37
37
  if n.to_s =~ /\A\d+\Z/ and (n = n.to_i) >= 1
38
38
  @queue = Queue.new n
@@ -94,6 +94,16 @@ class Utils::Grepper
94
94
  end
95
95
  unless @output.empty?
96
96
  case
97
+ when @args['b']
98
+ @output.uniq!
99
+ @output.each do |l|
100
+ blamer = LineBlamer.for_line(l)
101
+ if blame = blamer.perform
102
+ blame.sub!(/^[0-9a-f^]+/) { Term::ANSIColor.yellow($&) }
103
+ blame.sub!(/\(([^)]+)\)/) { "(#{Term::ANSIColor.red($1)})" }
104
+ puts "#{l} #{blame}"
105
+ end
106
+ end
97
107
  when @args['l'], @args['e'], @args['E'], @args['r']
98
108
  @output.uniq!
99
109
  @paths.concat @output
@@ -114,7 +124,7 @@ class Utils::Grepper
114
124
  case
115
125
  when @args['l']
116
126
  @output << @filename
117
- when @args['L'], @args['r']
127
+ when @args['L'], @args['r'], @args['b']
118
128
  @output << "#{@filename}:#{file.lineno}"
119
129
  when @args['e'], @args['E']
120
130
  @output << "#{@filename}:#{file.lineno}"
@@ -153,4 +163,11 @@ class Utils::Grepper
153
163
  @paths = @paths.sort_by(&:source_location)
154
164
  self
155
165
  end
166
+
167
+ private
168
+
169
+ def discover_roots(roots)
170
+ roots ||= []
171
+ roots.inject([]) { |rs, r| rs.concat Dir[r] }
172
+ end
156
173
  end
@@ -9,7 +9,7 @@ module Utils
9
9
  end
10
10
 
11
11
  def perform(options = '')
12
- `git blame #{options} -L #@lineno,+1 "#@file"`
12
+ `git 2>/dev/null blame #{options} -L #@lineno,+1 "#@file"`.full?
13
13
  end
14
14
  end
15
15
  end
@@ -19,7 +19,9 @@ module Utils
19
19
  class FuzzyPattern < Pattern
20
20
  def initialize(opts ={})
21
21
  super
22
- r = @pattern.split(//).map { |x| "(#{Regexp.quote(x)})" } * '.*?'
22
+ r = @pattern.split(//).grep(/[0-9a-z]/).map { |x|
23
+ "(#{Regexp.quote(x)})"
24
+ } * '.*?'
23
25
  @matcher = Regexp.new(
24
26
  "\\A(?:.*/.*?#{r}|.*#{r})",
25
27
  @icase ? Regexp::IGNORECASE : 0)
data/lib/utils/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Utils
2
2
  # Utils version
3
- VERSION = '0.6.4'
3
+ VERSION = '0.8.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,19 +1,19 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: utils 0.6.4 ruby lib
2
+ # stub: utils 0.8.0 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "utils"
6
- s.version = "0.6.4"
6
+ s.version = "0.8.0"
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
9
9
  s.require_paths = ["lib"]
10
10
  s.authors = ["Florian Frank"]
11
- s.date = "2016-04-11"
11
+ s.date = "2016-09-30"
12
12
  s.description = "This ruby gem provides some useful command line utilities"
13
13
  s.email = "flori@ping.de"
14
- s.executables = ["blameline", "brakeman2err", "chroot-exec", "chroot-libs", "classify", "create_tags", "discover", "edit", "edit_wait", "enum", "errf", "git-empty", "irb_connect", "json_check", "long_lines", "myex", "number_files", "on_change", "path", "probe", "remote_copy", "same_files", "search", "sedit", "ssh-tunnel", "strip_spaces", "unquarantine_apps", "untest", "utils-install-config", "utils-utilsrc", "vacuum_firefox_sqlite", "xmp"]
15
- s.extra_rdoc_files = ["README.md", "lib/utils.rb", "lib/utils/config.rb", "lib/utils/config/config_file.rb", "lib/utils/editor.rb", "lib/utils/file_xt.rb", "lib/utils/finder.rb", "lib/utils/grepper.rb", "lib/utils/irb.rb", "lib/utils/irb/service.rb", "lib/utils/line_blamer.rb", "lib/utils/line_formatter.rb", "lib/utils/md5.rb", "lib/utils/patterns.rb", "lib/utils/probe_server.rb", "lib/utils/ssh_tunnel_specification.rb", "lib/utils/version.rb", "lib/utils/xt/source_location_extension.rb"]
16
- s.files = [".gitignore", "COPYING", "Gemfile", "README.md", "Rakefile", "VERSION", "bin/blameline", "bin/brakeman2err", "bin/chroot-exec", "bin/chroot-libs", "bin/classify", "bin/create_tags", "bin/discover", "bin/edit", "bin/edit_wait", "bin/enum", "bin/errf", "bin/git-empty", "bin/irb_connect", "bin/json_check", "bin/long_lines", "bin/myex", "bin/number_files", "bin/on_change", "bin/path", "bin/probe", "bin/remote_copy", "bin/same_files", "bin/search", "bin/sedit", "bin/ssh-tunnel", "bin/strip_spaces", "bin/unquarantine_apps", "bin/untest", "bin/utils-install-config", "bin/utils-utilsrc", "bin/vacuum_firefox_sqlite", "bin/xmp", "lib/utils.rb", "lib/utils/config.rb", "lib/utils/config/config_file.rb", "lib/utils/config/gdb/asm", "lib/utils/config/gdb/ruby", "lib/utils/config/gdbinit", "lib/utils/config/irbrc", "lib/utils/config/rdebugrc", "lib/utils/config/rvmrc", "lib/utils/config/screenrc", "lib/utils/config/utilsrc", "lib/utils/editor.rb", "lib/utils/file_xt.rb", "lib/utils/finder.rb", "lib/utils/grepper.rb", "lib/utils/irb.rb", "lib/utils/irb/service.rb", "lib/utils/line_blamer.rb", "lib/utils/line_formatter.rb", "lib/utils/md5.rb", "lib/utils/patterns.rb", "lib/utils/probe_server.rb", "lib/utils/ssh_tunnel_specification.rb", "lib/utils/version.rb", "lib/utils/xt/source_location_extension.rb", "utils.gemspec", "utils.gemspec "]
14
+ s.executables = ["blameline", "brakeman2err", "chroot-exec", "chroot-libs", "classify", "create_tags", "dialog-pick", "discover", "edit", "edit_wait", "enum", "errf", "git-empty", "irb_connect", "json_check", "long_lines", "myex", "number_files", "on_change", "path", "probe", "remote_copy", "rssr", "same_files", "search", "sedit", "serve", "ssh-tunnel", "strip_spaces", "unquarantine_apps", "untest", "utils-utilsrc", "vacuum_firefox_sqlite", "xmp"]
15
+ s.extra_rdoc_files = ["README.md", "lib/utils.rb", "lib/utils/config_file.rb", "lib/utils/editor.rb", "lib/utils/file_xt.rb", "lib/utils/finder.rb", "lib/utils/grepper.rb", "lib/utils/irb.rb", "lib/utils/irb/service.rb", "lib/utils/line_blamer.rb", "lib/utils/line_formatter.rb", "lib/utils/md5.rb", "lib/utils/patterns.rb", "lib/utils/probe_server.rb", "lib/utils/ssh_tunnel_specification.rb", "lib/utils/version.rb", "lib/utils/xt/source_location_extension.rb"]
16
+ s.files = [".gitignore", "COPYING", "Gemfile", "README.md", "Rakefile", "VERSION", "bin/blameline", "bin/brakeman2err", "bin/chroot-exec", "bin/chroot-libs", "bin/classify", "bin/create_tags", "bin/dialog-pick", "bin/discover", "bin/edit", "bin/edit_wait", "bin/enum", "bin/errf", "bin/git-empty", "bin/irb_connect", "bin/json_check", "bin/long_lines", "bin/myex", "bin/number_files", "bin/on_change", "bin/path", "bin/probe", "bin/remote_copy", "bin/rssr", "bin/same_files", "bin/search", "bin/sedit", "bin/serve", "bin/ssh-tunnel", "bin/strip_spaces", "bin/unquarantine_apps", "bin/untest", "bin/utils-utilsrc", "bin/vacuum_firefox_sqlite", "bin/xmp", "lib/utils.rb", "lib/utils/config_file.rb", "lib/utils/editor.rb", "lib/utils/file_xt.rb", "lib/utils/finder.rb", "lib/utils/grepper.rb", "lib/utils/irb.rb", "lib/utils/irb/service.rb", "lib/utils/line_blamer.rb", "lib/utils/line_formatter.rb", "lib/utils/md5.rb", "lib/utils/patterns.rb", "lib/utils/probe_server.rb", "lib/utils/ssh_tunnel_specification.rb", "lib/utils/version.rb", "lib/utils/xt/source_location_extension.rb", "utils.gemspec", "utils.gemspec "]
17
17
  s.homepage = "http://github.com/flori/utils"
18
18
  s.rdoc_options = ["--title", "Utils - Some useful command line utilities", "--main", "README.md"]
19
19
  s.rubygems_version = "2.5.1"
@@ -23,20 +23,20 @@ Gem::Specification.new do |s|
23
23
  s.specification_version = 4
24
24
 
25
25
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
26
- s.add_development_dependency(%q<gem_hadar>, ["~> 1.7.0"])
26
+ s.add_development_dependency(%q<gem_hadar>, ["~> 1.8.0"])
27
27
  s.add_runtime_dependency(%q<tins>, ["~> 1.8"])
28
28
  s.add_runtime_dependency(%q<term-ansicolor>, ["~> 1.3"])
29
29
  s.add_runtime_dependency(%q<pstree>, ["~> 0.1"])
30
30
  s.add_runtime_dependency(%q<pry-editline>, [">= 0"])
31
31
  else
32
- s.add_dependency(%q<gem_hadar>, ["~> 1.7.0"])
32
+ s.add_dependency(%q<gem_hadar>, ["~> 1.8.0"])
33
33
  s.add_dependency(%q<tins>, ["~> 1.8"])
34
34
  s.add_dependency(%q<term-ansicolor>, ["~> 1.3"])
35
35
  s.add_dependency(%q<pstree>, ["~> 0.1"])
36
36
  s.add_dependency(%q<pry-editline>, [">= 0"])
37
37
  end
38
38
  else
39
- s.add_dependency(%q<gem_hadar>, ["~> 1.7.0"])
39
+ s.add_dependency(%q<gem_hadar>, ["~> 1.8.0"])
40
40
  s.add_dependency(%q<tins>, ["~> 1.8"])
41
41
  s.add_dependency(%q<term-ansicolor>, ["~> 1.3"])
42
42
  s.add_dependency(%q<pstree>, ["~> 0.1"])
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.6.4
4
+ version: 0.8.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: 2016-04-11 00:00:00.000000000 Z
11
+ date: 2016-09-30 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.7.0
19
+ version: 1.8.0
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.7.0
26
+ version: 1.8.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: tins
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -89,6 +89,7 @@ executables:
89
89
  - chroot-libs
90
90
  - classify
91
91
  - create_tags
92
+ - dialog-pick
92
93
  - discover
93
94
  - edit
94
95
  - edit_wait
@@ -104,14 +105,15 @@ executables:
104
105
  - path
105
106
  - probe
106
107
  - remote_copy
108
+ - rssr
107
109
  - same_files
108
110
  - search
109
111
  - sedit
112
+ - serve
110
113
  - ssh-tunnel
111
114
  - strip_spaces
112
115
  - unquarantine_apps
113
116
  - untest
114
- - utils-install-config
115
117
  - utils-utilsrc
116
118
  - vacuum_firefox_sqlite
117
119
  - xmp
@@ -119,8 +121,7 @@ extensions: []
119
121
  extra_rdoc_files:
120
122
  - README.md
121
123
  - lib/utils.rb
122
- - lib/utils/config.rb
123
- - lib/utils/config/config_file.rb
124
+ - lib/utils/config_file.rb
124
125
  - lib/utils/editor.rb
125
126
  - lib/utils/file_xt.rb
126
127
  - lib/utils/finder.rb
@@ -148,6 +149,7 @@ files:
148
149
  - bin/chroot-libs
149
150
  - bin/classify
150
151
  - bin/create_tags
152
+ - bin/dialog-pick
151
153
  - bin/discover
152
154
  - bin/edit
153
155
  - bin/edit_wait
@@ -163,28 +165,20 @@ files:
163
165
  - bin/path
164
166
  - bin/probe
165
167
  - bin/remote_copy
168
+ - bin/rssr
166
169
  - bin/same_files
167
170
  - bin/search
168
171
  - bin/sedit
172
+ - bin/serve
169
173
  - bin/ssh-tunnel
170
174
  - bin/strip_spaces
171
175
  - bin/unquarantine_apps
172
176
  - bin/untest
173
- - bin/utils-install-config
174
177
  - bin/utils-utilsrc
175
178
  - bin/vacuum_firefox_sqlite
176
179
  - bin/xmp
177
180
  - lib/utils.rb
178
- - lib/utils/config.rb
179
- - lib/utils/config/config_file.rb
180
- - lib/utils/config/gdb/asm
181
- - lib/utils/config/gdb/ruby
182
- - lib/utils/config/gdbinit
183
- - lib/utils/config/irbrc
184
- - lib/utils/config/rdebugrc
185
- - lib/utils/config/rvmrc
186
- - lib/utils/config/screenrc
187
- - lib/utils/config/utilsrc
181
+ - lib/utils/config_file.rb
188
182
  - lib/utils/editor.rb
189
183
  - lib/utils/file_xt.rb
190
184
  - lib/utils/finder.rb
@@ -1,10 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'utils'
4
-
5
- puts 'Install config into home directory? (yes/NO)'
6
- if gets =~ /^yes$/i
7
- Utils::Config.install_config
8
- else
9
- exit 1
10
- end
data/lib/utils/config.rb DELETED
@@ -1,23 +0,0 @@
1
- require 'fileutils'
2
-
3
- module Utils
4
- module Config
5
- extend FileUtils::Verbose
6
-
7
- CONFIG_DIR = File.expand_path(__FILE__).sub(/#{Regexp.quote(File.extname(__FILE__))}\Z/, '')
8
-
9
- def self.install_config
10
- srcs = Dir[File.join(CONFIG_DIR, '*')]
11
- dst_prefix = ENV['HOME'] or fail 'environment variable $HOME is required'
12
- for src in srcs
13
- dst = File.join(dst_prefix, ".#{File.basename(src)}")
14
- if File.exist?(dst)
15
- rm_rf "#{dst}.bak"
16
- mv dst, "#{dst}.bak/", :force => true
17
- end
18
- cp_r src, dst
19
- end
20
- self
21
- end
22
- end
23
- end
@@ -1,179 +0,0 @@
1
-
2
- # ASM DEBUGGING
3
- # define special help command "h" that shows asm related commands only
4
- #
5
- define h
6
- echo -------\n
7
- echo asm debugging commands, see "help" for other gdb comands\n
8
- echo \ \n
9
- echo g <adr> exec & set temp break <adr> u <n> disassemble from pc n times\n
10
- echo c run program (continue) uu <adr> <n> disassemble from adr n times\n
11
- echo n step one instruction ss <n> show stack n locations\n
12
- echo nn step but do not enter calls r show registers\n
13
- echo until step or run to end of loop db <adr> <n> display bytes\n
14
- echo \ dw <adr> <n> display words\n
15
- echo q quit gdb dd <adr> <n> display dword\n
16
- echo \ ds <adr> <n> display string\n
17
- echo bs show breaks \n
18
- echo bc clear breaks \n
19
- echo \n
20
- echo modifying the code within gdb requires reload, recompile easier? \n
21
- echo to change register -> set $eax = 0x123456 \n
22
- echo ------\n
23
- end
24
- #
25
- # set gdb initialization flags - change these as needed
26
- #
27
- # eliminate the pesky exit message that says program is running
28
- set confirm off
29
- set language asm
30
- # set disassembly-flavor intel
31
- # enable the following to work in hex, the default is decimal
32
- set output-radix 16
33
- set input-radix 16
34
- #
35
- # disable pesky hook messages?? this may not be necessary in other versions of gdb
36
- #
37
- define hook-stop
38
- end
39
- define hook-continue
40
- end
41
- #------------- define special commands for assembler -------------------
42
- #
43
- # go (run) to temporary break location "g <label>"
44
- #
45
- define g
46
- tbreak $arg0
47
- continue
48
- x/1i $pc
49
- echo ----------\n
50
- end
51
- #
52
- # show stack "ss <n>" where n is number of entries to show
53
- #
54
- define ss
55
- x/$arg0xh $esp-(4 * $arg0)
56
- end
57
- #
58
- # define nn to single step over calls
59
- #
60
- define nn
61
- echo --------------
62
- nexti
63
- printf "eax=%x ebx=%x ecx=%x edx=%x esi=%x edi=%x ebp=%x esp=%x\n",$eax,$ebx,$ecx,$edx,$esi,$edi,$ebp,$esp
64
- x /4i $pc
65
- end
66
- #
67
- # define n to single step one instruction
68
- #
69
- define n
70
- echo line-
71
- si
72
- printf "eax=%x ebx=%x ecx=%x edx=%x esi=%x edi=%x ebp=%x esp=%x eflags=%x\n",$eax,$ebx,$ecx,$edx,$esi,$edi,$ebp,$esp,$eflags
73
- #disassemble $pc $pc+14
74
- x /4i $pc
75
- end
76
- #
77
- # define "u <n>" to disassemble n locations from $pc
78
- #
79
- define u
80
- # x/$arg0i $eip
81
- disassemble $eip $eip+$arg0
82
- #disassemble $arg0
83
- end
84
- #
85
- # define "uu <label> <n>" to disassemble n locations from given label
86
- #
87
- define uu
88
- x/$arg1i $arg0
89
- # disassemble $arg0 $arg0+$arg1
90
- end
91
- #
92
- # define "bs" show breaks
93
- #
94
- define bs
95
- info break
96
- end
97
- #
98
- # define "bc" clear all breakpoints
99
- #
100
- define bc
101
- delete
102
- end
103
- #
104
- # define "r" show registers
105
- #
106
- define r
107
- echo -----\n
108
- printf "eax=%x ebx=%x ecx=%x edx=%x esi=%x edi=%x ebp=%x\n",$eax,$ebx,$ecx,$edx,$esi,$edi,$ebp
109
- printf "esp=%x eip=%x flag=%x --> O D I T S Z - AC - P - C\n",$esp,$eip,$eflags
110
- echo flags= Overflow, Direction, Interrupt, Trap, Sign, Zero, AuxCarry, Parity, Carry\n
111
- x/i $pc
112
- echo -----\n
113
- end
114
- #
115
- # define "db <adr> <n>" display <n> bytes at <adr>
116
- #
117
- define db
118
- x/$arg1xb $arg0
119
- end
120
- #
121
- # define "dw <adr> <n>" display <n> words at <adr>
122
- #
123
- define dw
124
- x/$arg1xh $arg0
125
- end
126
- #
127
- # define "dd <adr> <n>" display <n> dwords at <adr>
128
- #
129
- define dd
130
- x/$arg1xw $arg0
131
- end
132
- #
133
- # define "ds <adr> <n>" display <n> char(ascii) at <adr>
134
- #
135
- define ds
136
- x/$arg1cb $arg0
137
- end
138
-
139
- # attempt a string display...
140
- define dstr
141
- x /1sb &$arg0
142
- end
143
-
144
-
145
- set $asm_instruction_counter = 0
146
- define icount
147
- print "stepi instructions: %d\n", $asm_instruction_counter
148
- end
149
-
150
- define hook-n
151
- set $asm_instruction_counter = $asm_instruction_counter + 1
152
- end
153
-
154
- define icountreset
155
- set $asm_instruction_counter = 0
156
- end
157
-
158
- #
159
- # start of code initialization ----------------------
160
- #
161
- # to initialize gdb we need to use the "run" command once, first
162
- # we display the current instruction, then set a break at next location.
163
- # Warning - the first instruction must be one byte long.
164
- # Next, we start the program executing (run) then clear all breakpoints.
165
- #
166
-
167
- # x /1i *_start
168
- # echo ---------------
169
- # break *_start+1
170
- # run
171
- # delete
172
- # x /1i *_start+1
173
-
174
- echo \n---------\n
175
- echo for some reason nasm symbols appear as functions? ignore\n
176
- echo symbol related warnings.\n
177
- echo \n
178
- echo -------- type <h> for asm cmds <help> for gdb commands\n
179
-