utils 0.22.1 → 0.23.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: 1467f044dbcbbbc4a271c12d9075aba3eb03f4fef444418eaf03f730450b894d
4
- data.tar.gz: 9955f17eaeddfed9d6130dfe6805f78bebb5265cab3d0597afd4d31e49e91663
3
+ metadata.gz: 5c2e2fbdc130decfb576faf32be9adbc99de6517bd79b752408f6605fc4a9d36
4
+ data.tar.gz: a6d5d6857dd83b51cf9b33dea7dc1bc2d7be22531eb7c25628d4884bb0ef9f5b
5
5
  SHA512:
6
- metadata.gz: a8fee251d57b62a6d255342bc73585256d25dbbf955e9c029c9a600ea2b3a0d419868cb9e652311ee95bcec13c73b0a18298b1f1de930e80b27937fb56b710a8
7
- data.tar.gz: 91747c469da5305344b8b914d79065406bb650a7c3cb786fe87052b69f1164cb01b44d63a194cede1331e39ae6ea74246802208dbd866b805ade8812ac0cd1d0
6
+ metadata.gz: '080b67ed1a27784fbe1368ebf3cbad9865872ccb63b5ce84653dc7fbf08ca31b20e49a19fbaede5f00b0a2dc8a9245b2dd6d5c7b58d5970f5babaa04fa4f8c85'
7
+ data.tar.gz: fd80c9b73e39b2233ea9e36ca2efeb530064c2cc5452098318f9d8f1066e0aeaf2d829c4b099ed091f7a2f901506342fe063cd0b5b371bc82fea6a983b41dbad
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.22.1
1
+ 0.23.0
@@ -14,8 +14,7 @@ Options are
14
14
 
15
15
  -e CODE CODE is execute on the remote irb
16
16
  -l PATH load file PATH into remote irb context
17
- -r HOSTNAME name of the remote host (defaults to #{Utils::IRB::Service.hostname})
18
- -p PORTNUMBER number of the remote port (defaults to #{Utils::IRB::Service.port})
17
+ -u URL druby url to connect to
19
18
  -h display this help
20
19
 
21
20
  Version is #{File.basename($0)} #{Utils::VERSION}.
@@ -24,10 +23,10 @@ Version is #{File.basename($0)} #{Utils::VERSION}.
24
23
  end
25
24
 
26
25
 
27
- $opts = go 'e:r:p:l:h'
26
+ $opts = go 'e:u:l:h'
28
27
  $opts[?h] and usage
29
28
 
30
- proxy = Utils::IRB::Service.connect($opts[?r], $opts[?p])
29
+ proxy = Utils::IRB::Service.connect($opts[?u])
31
30
  case
32
31
  when load_path = $opts[?l]
33
32
  proxy.load(load_path)
data/bin/path CHANGED
@@ -35,4 +35,4 @@ end
35
35
 
36
36
  path.uniq!
37
37
 
38
- puts "#{'export ' if $opt[?e]}PATH=#{path * path_separator}"
38
+ puts "#{'export ' if $opts[?e]}PATH=#{path * path_separator}"
@@ -1,6 +1,6 @@
1
1
  module Utils
2
2
  # Utils version
3
- VERSION = '0.22.1'
3
+ VERSION = '0.23.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:
@@ -1,22 +1,22 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: utils 0.22.1 ruby lib
2
+ # stub: utils 0.23.0 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "utils".freeze
6
- s.version = "0.22.1"
6
+ s.version = "0.23.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 = "2020-02-11"
11
+ s.date = "2020-09-25"
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 = ["discover".freeze, "classify".freeze, "sedit".freeze, "irb_connect".freeze, "ascii7".freeze, "path".freeze, "enum".freeze, "unquarantine_apps".freeze, "ssh-tunnel".freeze, "xmp".freeze, "brakeman2err".freeze, "search".freeze, "chroot-exec".freeze, "edit".freeze, "tmproc".freeze, "json_check".freeze, "edit_wait".freeze, "errf".freeze, "untest".freeze, "blameline".freeze, "remote_copy".freeze, "git-empty".freeze, "create_cstags".freeze, "vacuum_firefox_sqlite".freeze, "same_files".freeze, "chroot-libs".freeze, "git-versions".freeze, "strip_spaces".freeze, "number_files".freeze, "rssr".freeze, "serve".freeze, "vcf2alias".freeze, "on_change".freeze, "utils-utilsrc".freeze, "myex".freeze, "long_lines".freeze, "dialog-pick".freeze, "probe".freeze, "create_tags".freeze]
14
+ s.executables = ["discover".freeze, "classify".freeze, "sedit".freeze, "irb_connect".freeze, "ascii7".freeze, "path".freeze, "enum".freeze, "ssh-tunnel".freeze, "search".freeze, "edit".freeze, "json_check".freeze, "edit_wait".freeze, "untest".freeze, "blameline".freeze, "git-empty".freeze, "create_cstags".freeze, "git-versions".freeze, "strip_spaces".freeze, "number_files".freeze, "serve".freeze, "vcf2alias".freeze, "on_change".freeze, "utils-utilsrc".freeze, "myex".freeze, "long_lines".freeze, "probe".freeze, "create_tags".freeze]
15
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 = [".gitignore".freeze, "COPYING".freeze, "Gemfile".freeze, "README.md".freeze, "Rakefile".freeze, "VERSION".freeze, "bin/ascii7".freeze, "bin/blameline".freeze, "bin/brakeman2err".freeze, "bin/chroot-exec".freeze, "bin/chroot-libs".freeze, "bin/classify".freeze, "bin/create_cstags".freeze, "bin/create_tags".freeze, "bin/dialog-pick".freeze, "bin/discover".freeze, "bin/edit".freeze, "bin/edit_wait".freeze, "bin/enum".freeze, "bin/errf".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/remote_copy".freeze, "bin/rssr".freeze, "bin/same_files".freeze, "bin/search".freeze, "bin/sedit".freeze, "bin/serve".freeze, "bin/ssh-tunnel".freeze, "bin/strip_spaces".freeze, "bin/tmproc".freeze, "bin/unquarantine_apps".freeze, "bin/untest".freeze, "bin/utils-utilsrc".freeze, "bin/vacuum_firefox_sqlite".freeze, "bin/vcf2alias".freeze, "bin/xmp".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]
16
+ s.files = [".gitignore".freeze, "COPYING".freeze, "Gemfile".freeze, "README.md".freeze, "Rakefile".freeze, "VERSION".freeze, "bin/ascii7".freeze, "bin/blameline".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/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/search".freeze, "bin/sedit".freeze, "bin/serve".freeze, "bin/ssh-tunnel".freeze, "bin/strip_spaces".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]
17
17
  s.homepage = "http://github.com/flori/utils".freeze
18
18
  s.rdoc_options = ["--title".freeze, "Utils - Some useful command line utilities".freeze, "--main".freeze, "README.md".freeze]
19
- s.rubygems_version = "3.1.2".freeze
19
+ s.rubygems_version = "3.1.4".freeze
20
20
  s.summary = "Some useful command line utilities".freeze
21
21
 
22
22
  if s.respond_to? :specification_version then
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.22.1
4
+ version: 0.23.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Frank
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-11 00:00:00.000000000 Z
11
+ date: 2020-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gem_hadar
@@ -118,36 +118,24 @@ executables:
118
118
  - ascii7
119
119
  - path
120
120
  - enum
121
- - unquarantine_apps
122
121
  - ssh-tunnel
123
- - xmp
124
- - brakeman2err
125
122
  - search
126
- - chroot-exec
127
123
  - edit
128
- - tmproc
129
124
  - json_check
130
125
  - edit_wait
131
- - errf
132
126
  - untest
133
127
  - blameline
134
- - remote_copy
135
128
  - git-empty
136
129
  - create_cstags
137
- - vacuum_firefox_sqlite
138
- - same_files
139
- - chroot-libs
140
130
  - git-versions
141
131
  - strip_spaces
142
132
  - number_files
143
- - rssr
144
133
  - serve
145
134
  - vcf2alias
146
135
  - on_change
147
136
  - utils-utilsrc
148
137
  - myex
149
138
  - long_lines
150
- - dialog-pick
151
139
  - probe
152
140
  - create_tags
153
141
  extensions: []
@@ -178,18 +166,13 @@ files:
178
166
  - VERSION
179
167
  - bin/ascii7
180
168
  - bin/blameline
181
- - bin/brakeman2err
182
- - bin/chroot-exec
183
- - bin/chroot-libs
184
169
  - bin/classify
185
170
  - bin/create_cstags
186
171
  - bin/create_tags
187
- - bin/dialog-pick
188
172
  - bin/discover
189
173
  - bin/edit
190
174
  - bin/edit_wait
191
175
  - bin/enum
192
- - bin/errf
193
176
  - bin/git-empty
194
177
  - bin/git-versions
195
178
  - bin/irb_connect
@@ -200,21 +183,14 @@ files:
200
183
  - bin/on_change
201
184
  - bin/path
202
185
  - bin/probe
203
- - bin/remote_copy
204
- - bin/rssr
205
- - bin/same_files
206
186
  - bin/search
207
187
  - bin/sedit
208
188
  - bin/serve
209
189
  - bin/ssh-tunnel
210
190
  - bin/strip_spaces
211
- - bin/tmproc
212
- - bin/unquarantine_apps
213
191
  - bin/untest
214
192
  - bin/utils-utilsrc
215
- - bin/vacuum_firefox_sqlite
216
193
  - bin/vcf2alias
217
- - bin/xmp
218
194
  - lib/utils.rb
219
195
  - lib/utils/config_file.rb
220
196
  - lib/utils/editor.rb
@@ -235,7 +211,7 @@ files:
235
211
  homepage: http://github.com/flori/utils
236
212
  licenses: []
237
213
  metadata: {}
238
- post_install_message:
214
+ post_install_message:
239
215
  rdoc_options:
240
216
  - "--title"
241
217
  - Utils - Some useful command line utilities
@@ -254,8 +230,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
254
230
  - !ruby/object:Gem::Version
255
231
  version: '0'
256
232
  requirements: []
257
- rubygems_version: 3.1.2
258
- signing_key:
233
+ rubygems_version: 3.1.4
234
+ signing_key:
259
235
  specification_version: 4
260
236
  summary: Some useful command line utilities
261
237
  test_files: []
@@ -1,33 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'utils'
4
- require 'json'
5
- require 'tins/xt'
6
- require 'tins/go'
7
- include Tins::GO
8
- require 'infobar'
9
-
10
- opts = go 'ce'
11
- if opts[?c]
12
- brakeman = `bundle exec which brakeman`.full? or fail "cannot find brakeman in path"
13
- Infobar.busy(label: 'Computing brakeman results') do
14
- system 'bundle exec brakeman -q -i config/brakeman.yml -o .brakeman.json 2>/dev/null' or fail "calling brakeman failed"
15
- end
16
- else
17
- results = JSON File.read('.brakeman.json'), object_class: JSON::GenericObject
18
- if opts[?e]
19
- puts "Found #{results.errors.size} errors and #{results.warnings.size} warnings.",
20
- "_" * 80
21
- for error in results.errors
22
- puts error.location, "Error #{error.error.inspect}"
23
- end
24
- else
25
- puts "Found #{results.warnings.size} warnings.", "_" * 80
26
- end
27
- for warning in results.warnings
28
- puts "#{warning.file}:#{warning.line}",
29
- "#{warning.warning_type} (#{warning.confidence}) #{warning.message.inspect}",
30
- warning.code, "See: #{warning.link}"
31
- end
32
-
33
- end
@@ -1,15 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'fileutils'
4
- include FileUtils
5
-
6
- dir = ARGV.shift or fail 'require directory to chroot into'
7
- prg = ARGV.shift || '/bin/bash'
8
- system "mount -t proc none #{dir}/proc"
9
- system "mount -o bind /dev #{dir}/dev"
10
- File.exist?(resolv = "#{dir}/etc/resolv.conf") and
11
- cp resolv, resolv + '.bak'
12
- cp '/etc/resolv.conf', resolv
13
- system "chroot #{dir} #{prg}"
14
- system "umount #{dir}/proc"
15
- system "umount #{dir}/dev"
@@ -1,26 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'fileutils'
4
- include FileUtils::Verbose
5
-
6
- msg = "Usage: #$0 EXECUTABLE DIR [LIB ..]"
7
- executable = ARGV.shift or fail msg
8
- dir = ARGV.shift or fail msg
9
- dir = File.expand_path dir
10
- mkdir_p dir
11
-
12
- unless executable.start_with? '/'
13
- executable = `which #{executable}`.chomp
14
- end
15
- libs = `ldd #{executable}`.gsub(/^(?:.*?\s+=>\s+|\s+)(.*?)\(.*/, '\1').lines.grep(/\S/).map { |x| x.strip }
16
- libs.concat ARGV
17
- cd dir do
18
- cp executable, File.basename(executable)
19
- for l in libs
20
- begin
21
- cp l, File.basename(l)
22
- rescue Errno::ENOENT => e
23
- warn "Caught #{e.class}: #{e}"
24
- end
25
- end
26
- end
@@ -1,11 +0,0 @@
1
- #!/bin/bash
2
-
3
- text=${1:-Pick}
4
- tags=`cat`
5
- lines=$(tput lines)
6
- columns=$(tput cols)
7
-
8
- result=$(dialog --no-items --menu "$text" $((lines - 5)) $((columns - 5)) $((lines - 10)) $tags 2>&1 1>/dev/tty)
9
- exitcode=$?
10
- echo $result
11
- exit $exitcode
data/bin/errf DELETED
@@ -1,32 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'term/ansicolor'
4
-
5
- class String
6
- include Term::ANSIColor
7
- end
8
-
9
- file = ARGV.shift
10
- name = ARGV.shift
11
- ENV['RUBYOPT'] = "#{ENV['RUBYOPT']} -Iext:lib:test:tests"
12
-
13
- STDOUT.sync = true
14
- begin
15
- output =
16
- if name
17
- IO.popen("testrb -p '' -n #{name} #{file}", 'r')
18
- else
19
- IO.popen("testrb -p '' #{file}", 'r')
20
- end
21
- until output.eof?
22
- line = output.readline.uncolored
23
- new_line = line.chomp
24
- if new_line.sub!(%r(^(?:\s|[\/\[])*([^:]+):(\d+):(.*))) { "#$1:#$2:#$3" }
25
- puts new_line
26
- else
27
- puts line
28
- end
29
- end
30
- ensure
31
- output and output.close
32
- end
@@ -1,13 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'socket'
4
-
5
- copy_remote_host_port = ENV['COPY_REMOTE_HOST_PORT'] and
6
- copy_remote_host_port =~ /\A([^:]+):([^:]+)\z/ or
7
- fail "environment variable COPY_REMOTE_HOST_PORT of form host:port required"
8
- copy_remote_host, copy_remote_port = $1, $2
9
-
10
- clipboard = TCPSocket.new(copy_remote_host, copy_remote_port)
11
- until STDIN.eof?
12
- clipboard.write STDIN.read(1 << 16)
13
- end
data/bin/rssr DELETED
@@ -1,37 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'rss'
4
- require 'tins'
5
- require 'open-uri'
6
- require 'term/ansicolor'
7
-
8
-
9
- class String
10
- include Term::ANSIColor
11
-
12
- def wrap(cols: Tins::Terminal.cols)
13
- split(?\n).each do |line|
14
- line.size > cols and line.gsub!(/(.{1,#{cols}})(\s+|$)/, "\\1\n")
15
- line.strip!
16
- end * ?\n
17
- end
18
- end
19
-
20
- IO.popen(ENV.fetch('PAGER', `which less`.chomp << ' -r'), 'w') do |pager|
21
- url = ARGV.shift
22
- open(url) do |rss|
23
- feed = RSS::Parser.parse(rss)
24
- pager.puts "Feed: #{feed.channel.title}",
25
- ?– * Tins::Terminal.cols
26
- feed.items.sort_by { |item| -item.date.to_f }.each do |item|
27
- pager.puts(
28
- "Title: #{item.title.bright_blue}",
29
- "Link: #{item.link.red}",
30
- "Date: #{item.date.strftime('%FT%T%z')}",
31
- "",
32
- item.description.wrap.chomp.white,
33
- ?– * Tins::Terminal.cols
34
- )
35
- end
36
- end
37
- end
@@ -1,38 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'utils'
4
- require 'tins/find'
5
- include Utils::MD5
6
-
7
- def find_same(*paths)
8
- files = Hash.new { |h,k| h[k] = {} }
9
- Tins::Find.find(*paths) do |filename|
10
- file_stat = File.stat(filename)
11
- if file_stat.file?
12
- size = file_stat.size
13
- $DEBUG and warn "Encountered '#{filename}' (#{size} bytes)."
14
- files[size][filename] = true
15
- end
16
- end
17
-
18
- files = files.inject({}) do |h, (_,fs)|
19
- keys = fs.keys
20
- if keys.size >= 2
21
- keys.each { |k| h[k] = true }
22
- end
23
- h
24
- end.keys
25
-
26
- md5s = Hash.new { |h,k| h[k] = [] }
27
- for filename in files
28
- md5sum = md5 filename
29
- md5s[md5sum] << filename
30
- end
31
- files = md5s.values
32
- files.reject! { |fs| fs.size < 2 }
33
- files
34
- end
35
-
36
- puts find_same(*ARGV).map { |fs| [ fs.size, fs ] }.sort.map { |c, fs|
37
- "#{c}\t#{fs.sort.map { |f| "'#{f}'" } * "\t"}"
38
- }
data/bin/tmproc DELETED
@@ -1,21 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'yaml'
4
- require 'tins'
5
-
6
- filename = ARGV.shift || 'Procfile'
7
- procfile = YAML.load_file(filename)
8
-
9
- unless ENV['TMUX']
10
- name = File.basename(Dir.pwd)
11
- exec 'tmux', 'new-session', '-s', name, '-n', ?s, '-A', $0, filename
12
- end
13
-
14
- tmux_pane = ENV.fetch('TMUX_PANE')
15
- lines = Tins::Terminal.lines
16
-
17
- procfile.each_value do |process|
18
- system "(tmux select-pane -t #{tmux_pane} \\; split-window -l #{lines / procfile.size} #{process}) &"
19
- end
20
-
21
- exec 'tmux', 'new-window', '-n', 'e', 'edit', ?;, 'split-window', '-h', 'bundle', 'exec', 'probe', '-l'
@@ -1,13 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'fileutils'
4
- include FileUtils::Verbose
5
-
6
- prefix = ARGV.shift || ''
7
- directory = File.join(prefix, 'Applications')
8
- if File.directory?(directory)
9
- cd directory do
10
- STDERR.puts 'xattr -rd com.apple.quarantine'
11
- system 'xattr -rd com.apple.quarantine'
12
- end
13
- end
@@ -1,23 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'fileutils'
4
- include FileUtils
5
-
6
- case `uname -s`.chomp
7
- when 'Darwin'
8
- profiles="#{ENV['HOME']}/Library/Application Support/Firefox/Profiles"
9
- else
10
- profiles="#{ENV['HOME']}/.mozilla/firefox"
11
- end
12
-
13
- cd profiles do
14
- for p in Dir['*.default']
15
- cd p do
16
- for db in Dir['*.sqlite']
17
- print "Vacuuming #{db}..."
18
- system "sqlite3 #{db} VACUUM"
19
- puts "done."
20
- end
21
- end
22
- end
23
- end
data/bin/xmp DELETED
@@ -1,74 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require 'open3'
3
-
4
- class String
5
- unless method_defined?(:lines)
6
- def lines
7
- self
8
- end
9
- end
10
- end
11
-
12
- MARKER = "!XMP#{Time.new.to_i}_#{rand(1000000)}!"
13
- XMPRE = Regexp.new("^" + Regexp.escape(MARKER) + '\[([0-9]+)\] => (.*)')
14
- VAR = "_xmp_#{Time.new.to_i}_#{rand(1000000)}"
15
- WARNING_RE = /-:([0-9]+): warning: (.*)/
16
- interpreter = ARGV
17
- interpreter << 'ruby' << '-w' if interpreter.empty?
18
-
19
- IO.popen(interpreter.first, 'w') do |script|
20
- script.write <<-TEST
21
- begin
22
- require 'rubygems'
23
- rescue LoadError
24
- exit 1
25
- end
26
- exit 0
27
- TEST
28
- end
29
- if $?.exitstatus == 1
30
- ENV['RUBYOPT'] = ENV['RUBYOPT'].gsub(/-rr?ubygems/i, '')
31
- end
32
- code = STDIN.read
33
-
34
- idx = 0
35
- newcode = code.gsub(/^(.*) # =>.*/) do |l|
36
- expr = $1
37
- (/^\s*#/ =~ l) ? l :
38
- %!((#{VAR} = (#{expr}); $stderr.puts("#{MARKER}[#{idx+=1}] => " + #{VAR}.inspect) || #{VAR}))!
39
- end
40
- stdin, stdout, stderr = Open3::popen3(*interpreter)
41
- stdin.puts newcode
42
- stdin.close
43
- output = stderr.readlines
44
-
45
- results = Hash.new{|h,k| h[k] = []}
46
- output.grep(XMPRE).each do |line|
47
- result_id, result = XMPRE.match(line).captures
48
- results[result_id.to_i] << result
49
- end
50
-
51
- idx = 0
52
- annotated = code.gsub(/^(.*) # =>.*/) do |l|
53
- expr = $1
54
- (/^\s*#/ =~ l) ? l : "#{expr} # => " + (results[idx+=1] || []).join(", ")
55
- end.gsub(/ # !>.*/, '').gsub(/# (>>|~>)[^\n]*\n/m, "");
56
-
57
- warnings = {}
58
- output.join.lines.grep(WARNING_RE).map do |x|
59
- md = WARNING_RE.match(x)
60
- warnings[md[1].to_i] = md[2]
61
- end
62
- idx = 0
63
- annotated = annotated.lines.map do |line|
64
- w = warnings[idx+=1]
65
- w ? (line.chomp + " # !> #{w}") : line
66
- end
67
- puts annotated
68
- output.reject!{|x| /^-:[0-9]+: warning/.match(x)}
69
- if exception = /^-:[0-9]+:.*/m.match(output.join)
70
- puts exception[0].map{|line| "# ~> " + line }
71
- end
72
- if (s = stdout.read) != ""
73
- puts "# >> #{s.inspect}"
74
- end