utils 0.0.65 → 0.0.66
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/bin/irb_connect +38 -0
- data/bin/probe +5 -4
- data/lib/utils/irb.rb +60 -1
- data/lib/utils/version.rb +1 -1
- data/utils.gemspec +4 -4
- metadata +5 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.66
|
data/bin/irb_connect
ADDED
@@ -0,0 +1,38 @@
|
|
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
|
+
-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})
|
19
|
+
-h display this help
|
20
|
+
|
21
|
+
Version is #{File.basename($0)} #{Utils::VERSION}.
|
22
|
+
EOT
|
23
|
+
exit 1
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
$opt = go 'e:r:p:l:h'
|
28
|
+
$opt['h'] and usage
|
29
|
+
|
30
|
+
proxy = Utils::IRB::Service.connect($opt['r'], $opt['p'])
|
31
|
+
case
|
32
|
+
when load_path = $opt['l']
|
33
|
+
proxy.load(load_path)
|
34
|
+
when code = $opt['e']
|
35
|
+
p proxy.eval(code)
|
36
|
+
else
|
37
|
+
puts proxy.eval(STDIN.read)
|
38
|
+
end
|
data/bin/probe
CHANGED
@@ -6,7 +6,7 @@ require 'tins/lines_file'
|
|
6
6
|
include Tins::GO
|
7
7
|
require 'utils'
|
8
8
|
include Utils
|
9
|
-
require 'drb
|
9
|
+
require 'drb'
|
10
10
|
|
11
11
|
def usage
|
12
12
|
puts <<-EOT
|
@@ -57,7 +57,7 @@ if $opt['l']
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def enqueue(job)
|
60
|
-
output_message "Job #{
|
60
|
+
output_message "Job #{job.inspect} enqueued."
|
61
61
|
@jobs.push job
|
62
62
|
end
|
63
63
|
alias run enqueue
|
@@ -70,11 +70,12 @@ if $opt['l']
|
|
70
70
|
end
|
71
71
|
|
72
72
|
def run_job(job)
|
73
|
-
output_message "Job #{
|
73
|
+
output_message "Job #{job.inspect} about to run now."
|
74
74
|
fork do
|
75
|
-
exec
|
75
|
+
exec(*cmd(job))
|
76
76
|
end
|
77
77
|
Process.wait
|
78
|
+
output_message "Job #{job.inspect} was just run."
|
78
79
|
end
|
79
80
|
|
80
81
|
def work_loop
|
data/lib/utils/irb.rb
CHANGED
@@ -7,6 +7,8 @@ if Readline.respond_to?(:point) && Readline.respond_to?(:line_buffer)
|
|
7
7
|
require 'pry-editline'
|
8
8
|
end
|
9
9
|
require 'utils'
|
10
|
+
require 'drb'
|
11
|
+
|
10
12
|
$editor = Utils::Editor.new
|
11
13
|
$pager = ENV['PAGER'] || 'less -r'
|
12
14
|
|
@@ -41,6 +43,16 @@ module Utils
|
|
41
43
|
exec $0
|
42
44
|
end
|
43
45
|
|
46
|
+
# Start an irb server.
|
47
|
+
def irb_server(hostname = nil, port = nil)
|
48
|
+
Utils::IRB::Service.start(hostname, port) {}
|
49
|
+
end
|
50
|
+
|
51
|
+
# Conenct to an irb server.
|
52
|
+
def irb_connect(hostname = nil, port = nil)
|
53
|
+
Utils::IRB::Service.connect(hostname, port)
|
54
|
+
end
|
55
|
+
|
44
56
|
# Return all instance methods of obj's class.
|
45
57
|
def irb_all_class_instance_methods(obj)
|
46
58
|
methods = obj.class.instance_methods
|
@@ -425,6 +437,53 @@ module Utils
|
|
425
437
|
connection.select_all("EXPLAIN #{to_sql}")
|
426
438
|
end
|
427
439
|
end
|
440
|
+
|
441
|
+
module Service
|
442
|
+
class << self
|
443
|
+
attr_accessor :hostname
|
444
|
+
|
445
|
+
attr_accessor :port
|
446
|
+
|
447
|
+
def start(hostname = nil, port = nil, &block)
|
448
|
+
hostname ||= self.hostname
|
449
|
+
port ||= self.port
|
450
|
+
block ||= proc {}
|
451
|
+
uri = "druby://#{hostname}:#{port}"
|
452
|
+
puts "Starting IRB server listening to #{uri.inspect}."
|
453
|
+
DRb.start_service(uri, eval('irb_current_working_binding', block.binding))
|
454
|
+
end
|
455
|
+
|
456
|
+
def connect(hostname = nil, port = nil)
|
457
|
+
hostname ||= self.hostname
|
458
|
+
port ||= self.port
|
459
|
+
uri = "druby://#{hostname}:#{port}"
|
460
|
+
irb = DRbObject.new_with_uri(uri)
|
461
|
+
Proxy.new(irb)
|
462
|
+
end
|
463
|
+
end
|
464
|
+
|
465
|
+
self.hostname = 'localhost'
|
466
|
+
|
467
|
+
self.port = 6642
|
468
|
+
|
469
|
+
class Proxy
|
470
|
+
def initialize(irb)
|
471
|
+
@irb = irb
|
472
|
+
end
|
473
|
+
|
474
|
+
def eval(code)
|
475
|
+
@irb.conf.workspace.evaluate nil, code
|
476
|
+
end
|
477
|
+
|
478
|
+
def load(filename)
|
479
|
+
unless filename.start_with?('/')
|
480
|
+
filename = File.expand_path filename
|
481
|
+
end
|
482
|
+
@irb.irb_load filename
|
483
|
+
end
|
484
|
+
end
|
485
|
+
|
486
|
+
end
|
428
487
|
end
|
429
488
|
end
|
430
489
|
|
@@ -495,7 +554,7 @@ module IRB
|
|
495
554
|
end
|
496
555
|
IRB.conf[:SAVE_HISTORY] = 1000
|
497
556
|
|
498
|
-
if defined?(ActiveRecord::Relation)
|
557
|
+
if defined?(ActiveRecord::Relation) && !ActiveRecord::Relation.method_defined?(:examine)
|
499
558
|
class ActiveRecord::Relation
|
500
559
|
include Utils::IRB::Relation
|
501
560
|
end
|
data/lib/utils/version.rb
CHANGED
data/utils.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = "utils"
|
5
|
-
s.version = "0.0.
|
5
|
+
s.version = "0.0.66"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Florian Frank"]
|
9
|
-
s.date = "2012-
|
9
|
+
s.date = "2012-12-05"
|
10
10
|
s.description = "This ruby gem provides some useful command line utilities"
|
11
11
|
s.email = "flori@ping.de"
|
12
|
-
s.executables = ["chroot-exec", "chroot-libs", "classify", "create_tags", "discover", "edit", "edit_wait", "enum", "errf", "git-empty", "myex", "number_files", "on_change", "path", "probe", "same_files", "search", "sedit", "sshscreen", "strip_spaces", "unquarantine_apps", "untest", "utils-install-config", "utils-utilsrc", "vacuum_firefox_sqlite", "xmp"]
|
12
|
+
s.executables = ["chroot-exec", "chroot-libs", "classify", "create_tags", "discover", "edit", "edit_wait", "enum", "errf", "git-empty", "irb_connect", "myex", "number_files", "on_change", "path", "probe", "same_files", "search", "sedit", "sshscreen", "strip_spaces", "unquarantine_apps", "untest", "utils-install-config", "utils-utilsrc", "vacuum_firefox_sqlite", "xmp"]
|
13
13
|
s.extra_rdoc_files = ["README.rdoc", "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/md5.rb", "lib/utils/patterns.rb", "lib/utils/version.rb"]
|
14
|
-
s.files = [".gitignore", "COPYING", "Gemfile", "README.rdoc", "Rakefile", "TODO", "VERSION", "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/myex", "bin/number_files", "bin/on_change", "bin/path", "bin/probe", "bin/same_files", "bin/search", "bin/sedit", "bin/sshscreen", "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/config/vim/after/syntax/haml.vim", "lib/utils/config/vim/after/syntax/html.vim", "lib/utils/config/vim/autoload/Align.vim", "lib/utils/config/vim/autoload/AlignMaps.vim", "lib/utils/config/vim/autoload/ctrlp.vim", "lib/utils/config/vim/autoload/ctrlp/bookmarkdir.vim", "lib/utils/config/vim/autoload/ctrlp/buffertag.vim", "lib/utils/config/vim/autoload/ctrlp/changes.vim", "lib/utils/config/vim/autoload/ctrlp/dir.vim", "lib/utils/config/vim/autoload/ctrlp/line.vim", "lib/utils/config/vim/autoload/ctrlp/mixed.vim", "lib/utils/config/vim/autoload/ctrlp/mrufiles.vim", "lib/utils/config/vim/autoload/ctrlp/quickfix.vim", "lib/utils/config/vim/autoload/ctrlp/rtscript.vim", "lib/utils/config/vim/autoload/ctrlp/tag.vim", "lib/utils/config/vim/autoload/ctrlp/undo.vim", "lib/utils/config/vim/autoload/ctrlp/utils.vim", "lib/utils/config/vim/autoload/rails.vim", "lib/utils/config/vim/autoload/rubycomplete.vim", "lib/utils/config/vim/autoload/sqlcomplete.vim", "lib/utils/config/vim/autoload/vimball.vim", "lib/utils/config/vim/colors/flori.vim", "lib/utils/config/vim/compiler/coffee.vim", "lib/utils/config/vim/compiler/eruby.vim", "lib/utils/config/vim/compiler/ruby.vim", "lib/utils/config/vim/compiler/rubyunit.vim", "lib/utils/config/vim/doc/Decho.txt", "lib/utils/config/vim/doc/coffee-script.txt", "lib/utils/config/vim/doc/ctrlp.txt", "lib/utils/config/vim/doc/fugitive.txt", "lib/utils/config/vim/doc/rails.txt", "lib/utils/config/vim/doc/xml-plugin.txt", "lib/utils/config/vim/ftdetect/coffee.vim", "lib/utils/config/vim/ftdetect/eco.vim", "lib/utils/config/vim/ftdetect/ragel.vim", "lib/utils/config/vim/ftdetect/ruby.vim", "lib/utils/config/vim/ftdetect/slim.vim", "lib/utils/config/vim/ftplugin/coffee.vim", "lib/utils/config/vim/ftplugin/eruby.vim", "lib/utils/config/vim/ftplugin/ruby.vim", "lib/utils/config/vim/ftplugin/xml.vim", "lib/utils/config/vim/indent/IndentAnything_html.vim", "lib/utils/config/vim/indent/coffee.vim", "lib/utils/config/vim/indent/eruby.vim", "lib/utils/config/vim/indent/javascript.vim", "lib/utils/config/vim/indent/ruby.vim", "lib/utils/config/vim/indent/slim.vim", "lib/utils/config/vim/plugin/AlignMapsPlugin.vim", "lib/utils/config/vim/plugin/AlignPlugin.vim", "lib/utils/config/vim/plugin/Decho.vim", "lib/utils/config/vim/plugin/IndentAnything.vim", "lib/utils/config/vim/plugin/bufexplorer.vim", "lib/utils/config/vim/plugin/cecutil.vim", "lib/utils/config/vim/plugin/ctrlp.vim", "lib/utils/config/vim/plugin/fugitive.vim", "lib/utils/config/vim/plugin/lusty-explorer.vim", "lib/utils/config/vim/plugin/rails.vim", "lib/utils/config/vim/plugin/rubyextra.vim", "lib/utils/config/vim/plugin/surround.vim", "lib/utils/config/vim/plugin/taglist.vim", "lib/utils/config/vim/plugin/test/IndentAnything/test.js", "lib/utils/config/vim/plugin/vimballPlugin.vim", "lib/utils/config/vim/syntax/Decho.vim", "lib/utils/config/vim/syntax/coffee.vim", "lib/utils/config/vim/syntax/eco.vim", "lib/utils/config/vim/syntax/eruby.vim", "lib/utils/config/vim/syntax/javascript.vim", "lib/utils/config/vim/syntax/ragel.vim", "lib/utils/config/vim/syntax/ruby.vim", "lib/utils/config/vim/syntax/slim.vim", "lib/utils/config/vimrc", "lib/utils/editor.rb", "lib/utils/file_xt.rb", "lib/utils/finder.rb", "lib/utils/grepper.rb", "lib/utils/irb.rb", "lib/utils/md5.rb", "lib/utils/patterns.rb", "lib/utils/version.rb", "utils.gemspec"]
|
14
|
+
s.files = [".gitignore", "COPYING", "Gemfile", "README.rdoc", "Rakefile", "TODO", "VERSION", "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/myex", "bin/number_files", "bin/on_change", "bin/path", "bin/probe", "bin/same_files", "bin/search", "bin/sedit", "bin/sshscreen", "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/config/vim/after/syntax/haml.vim", "lib/utils/config/vim/after/syntax/html.vim", "lib/utils/config/vim/autoload/Align.vim", "lib/utils/config/vim/autoload/AlignMaps.vim", "lib/utils/config/vim/autoload/ctrlp.vim", "lib/utils/config/vim/autoload/ctrlp/bookmarkdir.vim", "lib/utils/config/vim/autoload/ctrlp/buffertag.vim", "lib/utils/config/vim/autoload/ctrlp/changes.vim", "lib/utils/config/vim/autoload/ctrlp/dir.vim", "lib/utils/config/vim/autoload/ctrlp/line.vim", "lib/utils/config/vim/autoload/ctrlp/mixed.vim", "lib/utils/config/vim/autoload/ctrlp/mrufiles.vim", "lib/utils/config/vim/autoload/ctrlp/quickfix.vim", "lib/utils/config/vim/autoload/ctrlp/rtscript.vim", "lib/utils/config/vim/autoload/ctrlp/tag.vim", "lib/utils/config/vim/autoload/ctrlp/undo.vim", "lib/utils/config/vim/autoload/ctrlp/utils.vim", "lib/utils/config/vim/autoload/rails.vim", "lib/utils/config/vim/autoload/rubycomplete.vim", "lib/utils/config/vim/autoload/sqlcomplete.vim", "lib/utils/config/vim/autoload/vimball.vim", "lib/utils/config/vim/colors/flori.vim", "lib/utils/config/vim/compiler/coffee.vim", "lib/utils/config/vim/compiler/eruby.vim", "lib/utils/config/vim/compiler/ruby.vim", "lib/utils/config/vim/compiler/rubyunit.vim", "lib/utils/config/vim/doc/Decho.txt", "lib/utils/config/vim/doc/coffee-script.txt", "lib/utils/config/vim/doc/ctrlp.txt", "lib/utils/config/vim/doc/fugitive.txt", "lib/utils/config/vim/doc/rails.txt", "lib/utils/config/vim/doc/xml-plugin.txt", "lib/utils/config/vim/ftdetect/coffee.vim", "lib/utils/config/vim/ftdetect/eco.vim", "lib/utils/config/vim/ftdetect/ragel.vim", "lib/utils/config/vim/ftdetect/ruby.vim", "lib/utils/config/vim/ftdetect/slim.vim", "lib/utils/config/vim/ftplugin/coffee.vim", "lib/utils/config/vim/ftplugin/eruby.vim", "lib/utils/config/vim/ftplugin/ruby.vim", "lib/utils/config/vim/ftplugin/xml.vim", "lib/utils/config/vim/indent/IndentAnything_html.vim", "lib/utils/config/vim/indent/coffee.vim", "lib/utils/config/vim/indent/eruby.vim", "lib/utils/config/vim/indent/javascript.vim", "lib/utils/config/vim/indent/ruby.vim", "lib/utils/config/vim/indent/slim.vim", "lib/utils/config/vim/plugin/AlignMapsPlugin.vim", "lib/utils/config/vim/plugin/AlignPlugin.vim", "lib/utils/config/vim/plugin/Decho.vim", "lib/utils/config/vim/plugin/IndentAnything.vim", "lib/utils/config/vim/plugin/bufexplorer.vim", "lib/utils/config/vim/plugin/cecutil.vim", "lib/utils/config/vim/plugin/ctrlp.vim", "lib/utils/config/vim/plugin/fugitive.vim", "lib/utils/config/vim/plugin/lusty-explorer.vim", "lib/utils/config/vim/plugin/rails.vim", "lib/utils/config/vim/plugin/rubyextra.vim", "lib/utils/config/vim/plugin/surround.vim", "lib/utils/config/vim/plugin/taglist.vim", "lib/utils/config/vim/plugin/test/IndentAnything/test.js", "lib/utils/config/vim/plugin/vimballPlugin.vim", "lib/utils/config/vim/syntax/Decho.vim", "lib/utils/config/vim/syntax/coffee.vim", "lib/utils/config/vim/syntax/eco.vim", "lib/utils/config/vim/syntax/eruby.vim", "lib/utils/config/vim/syntax/javascript.vim", "lib/utils/config/vim/syntax/ragel.vim", "lib/utils/config/vim/syntax/ruby.vim", "lib/utils/config/vim/syntax/slim.vim", "lib/utils/config/vimrc", "lib/utils/editor.rb", "lib/utils/file_xt.rb", "lib/utils/finder.rb", "lib/utils/grepper.rb", "lib/utils/irb.rb", "lib/utils/md5.rb", "lib/utils/patterns.rb", "lib/utils/version.rb", "utils.gemspec"]
|
15
15
|
s.homepage = "http://github.com/flori/utils"
|
16
16
|
s.rdoc_options = ["--title", "Utils - Some useful command line utilities", "--main", "README.rdoc"]
|
17
17
|
s.require_paths = ["lib"]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.66
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-12-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: gem_hadar
|
@@ -104,6 +104,7 @@ executables:
|
|
104
104
|
- enum
|
105
105
|
- errf
|
106
106
|
- git-empty
|
107
|
+
- irb_connect
|
107
108
|
- myex
|
108
109
|
- number_files
|
109
110
|
- on_change
|
@@ -152,6 +153,7 @@ files:
|
|
152
153
|
- bin/enum
|
153
154
|
- bin/errf
|
154
155
|
- bin/git-empty
|
156
|
+
- bin/irb_connect
|
155
157
|
- bin/myex
|
156
158
|
- bin/number_files
|
157
159
|
- bin/on_change
|
@@ -277,7 +279,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
277
279
|
version: '0'
|
278
280
|
segments:
|
279
281
|
- 0
|
280
|
-
hash: -
|
282
|
+
hash: -263809753649331147
|
281
283
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
282
284
|
none: false
|
283
285
|
requirements:
|