ripl-hijack 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gemspec ADDED
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require 'rubygems' unless Object.const_defined?(:Gem)
3
+ require File.dirname(__FILE__) + "/lib/ripl/hijack"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "ripl-hijack"
7
+ s.version = Ripl::Hijack::VERSION
8
+ s.authors = ["Gabriel Horner"]
9
+ s.email = "gabriel.horner@gmail.com"
10
+ s.homepage = "http://github.com/cldwalker/ripl-hijack"
11
+ s.summary = "A ripl plugin that hijacks a process"
12
+ s.description = "This ripl plugin gives you a ripl console to any ruby process using hijack."
13
+ s.required_rubygems_version = ">= 1.3.6"
14
+ s.rubyforge_project = 'tagaholic'
15
+ s.executables = ['ripl-hijack']
16
+ s.add_dependency 'ripl', '>= 0.2.8'
17
+ s.add_dependency 'hijack', '>= 0.1.9'
18
+ s.files = Dir.glob(%w[{lib,test}/**/*.rb bin/* [A-Z]*.{txt,rdoc} ext/**/*.{rb,c} **/deps.rip]) + %w{Rakefile .gemspec}
19
+ s.extra_rdoc_files = ["README.rdoc", "LICENSE.txt"]
20
+ s.license = 'MIT'
21
+ end
data/CHANGELOG.rdoc ADDED
@@ -0,0 +1,2 @@
1
+ == 0.1.0
2
+ * Initial release
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ The MIT LICENSE
2
+
3
+ Copyright (c) 2010 Gabriel Horner
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,31 @@
1
+ == Description
2
+ This ripl plugin gives you a ripl console to any ruby process using
3
+ {hijack}[https://github.com/ileitch/hijack].
4
+
5
+ == Install
6
+ Install the gem with:
7
+
8
+ sudo gem install ripl-hijack
9
+
10
+ == Usage
11
+
12
+ Say on a server far away you have an evil process 666.
13
+
14
+ Use just like hijack:
15
+
16
+ $ ripl hijack 666
17
+ => Hijacked 666
18
+ >>
19
+
20
+ Supports same options as hijack:
21
+
22
+ $ ripl hijack 666 --mute
23
+
24
+ Can also take ripl options:
25
+
26
+ # Don't load irbrc and riplrc
27
+ $ ripl hijack 666 --mute -f -F
28
+
29
+ == Limitations
30
+ * Completion is partially working
31
+ * _ isn't working
data/Rakefile ADDED
@@ -0,0 +1,35 @@
1
+ require 'rake'
2
+ require 'fileutils'
3
+
4
+ def gemspec
5
+ @gemspec ||= eval(File.read('.gemspec'), binding, '.gemspec')
6
+ end
7
+
8
+ desc "Build the gem"
9
+ task :gem=>:gemspec do
10
+ sh "gem build .gemspec"
11
+ FileUtils.mkdir_p 'pkg'
12
+ FileUtils.mv "#{gemspec.name}-#{gemspec.version}.gem", 'pkg'
13
+ end
14
+
15
+ desc "Install the gem locally"
16
+ task :install => :gem do
17
+ sh %{gem install pkg/#{gemspec.name}-#{gemspec.version}}
18
+ end
19
+
20
+ desc "Generate the gemspec"
21
+ task :generate do
22
+ puts gemspec.to_ruby
23
+ end
24
+
25
+ desc "Validate the gemspec"
26
+ task :gemspec do
27
+ gemspec.validate
28
+ end
29
+
30
+ desc 'Run tests'
31
+ task :test do |t|
32
+ sh 'bacon -q -Ilib -I. test/*_test.rb'
33
+ end
34
+
35
+ task :default => :test
data/bin/ripl-hijack ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'ripl'
4
+ require 'ripl/hijack'
5
+
6
+ if ARGV[0].nil? || ARGV.delete('-h') || ARGV.delete('--help')
7
+ abort "ripl hijack [--gdb-debug] [--mute] [--execute=FILE] PID"
8
+ end
9
+
10
+ options = {}
11
+ options[:gdb_debug] = true if ARGV.delete('--gdb-debug')
12
+ options[:mute] = true if ARGV.delete('--mute')
13
+ if (opt = ARGV.find {|e| e[/^--execute/] }) && opt[/-execute=?(.*)/]
14
+ options[:execute] = $1.empty? ? argv.shift.to_s : $1
15
+ end
16
+
17
+ Ripl.start :hijack_pid => ARGV.shift, :hijack_options => options
data/deps.rip ADDED
@@ -0,0 +1,2 @@
1
+ ripl >=0.2.8
2
+ hijack >=0.1.9
@@ -0,0 +1,33 @@
1
+ require 'ripl'
2
+ require 'hijack'
3
+
4
+ class Hijack::Console
5
+ class <<self; attr_accessor :remote; end
6
+
7
+ # Disable irb and make @remote accessible
8
+ def start_irb
9
+ self.class.remote = @remote
10
+ end
11
+ end
12
+
13
+ module Ripl::Hijack
14
+ VERSION = '0.1.0'
15
+
16
+ def before_loop
17
+ Hijack.start(config[:hijack_pid], config[:hijack_options])
18
+ @binding = loop_eval("self").instance_eval { binding }
19
+ super
20
+ end
21
+
22
+ def after_loop
23
+ Hijack::Console.remote.evaluate('__hijack_exit') rescue nil
24
+ end
25
+
26
+ def loop_eval(str)
27
+ (helper = Hijack::Helper.find_helper(str)) ?
28
+ Hijack::Helper.send(helper, Hijack::Console.remote) :
29
+ Hijack::Console.remote.evaluate(str)
30
+ end
31
+ end
32
+
33
+ Ripl::Shell.send :include, Ripl::Hijack
metadata ADDED
@@ -0,0 +1,108 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ripl-hijack
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Gabriel Horner
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-12-15 00:00:00 -05:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: ripl
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 7
30
+ segments:
31
+ - 0
32
+ - 2
33
+ - 8
34
+ version: 0.2.8
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: hijack
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 9
46
+ segments:
47
+ - 0
48
+ - 1
49
+ - 9
50
+ version: 0.1.9
51
+ type: :runtime
52
+ version_requirements: *id002
53
+ description: This ripl plugin gives you a ripl console to any ruby process using hijack.
54
+ email: gabriel.horner@gmail.com
55
+ executables:
56
+ - ripl-hijack
57
+ extensions: []
58
+
59
+ extra_rdoc_files:
60
+ - README.rdoc
61
+ - LICENSE.txt
62
+ files:
63
+ - lib/ripl/hijack.rb
64
+ - bin/ripl-hijack
65
+ - LICENSE.txt
66
+ - CHANGELOG.rdoc
67
+ - README.rdoc
68
+ - deps.rip
69
+ - Rakefile
70
+ - .gemspec
71
+ has_rdoc: true
72
+ homepage: http://github.com/cldwalker/ripl-hijack
73
+ licenses:
74
+ - MIT
75
+ post_install_message:
76
+ rdoc_options: []
77
+
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ hash: 3
86
+ segments:
87
+ - 0
88
+ version: "0"
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ hash: 23
95
+ segments:
96
+ - 1
97
+ - 3
98
+ - 6
99
+ version: 1.3.6
100
+ requirements: []
101
+
102
+ rubyforge_project: tagaholic
103
+ rubygems_version: 1.3.7
104
+ signing_key:
105
+ specification_version: 3
106
+ summary: A ripl plugin that hijacks a process
107
+ test_files: []
108
+