ileitch-hijack 0.1.6 → 0.1.7
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/COPYING +18 -0
 - data/Rakefile +3 -8
 - data/TODO +0 -1
 - data/lib/hijack/payload.rb +37 -6
 - data/lib/hijack/workspace.rb +4 -1
 - data/tasks/gem.rake +41 -0
 - metadata +11 -9
 
    
        data/COPYING
    ADDED
    
    | 
         @@ -0,0 +1,18 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            Copyright (c) 2009 Ian Leitch
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            Permission is hereby granted, free of charge, to any person obtaining a copy
         
     | 
| 
      
 4 
     | 
    
         
            +
            of this software and associated documentation files (the "Software"), to
         
     | 
| 
      
 5 
     | 
    
         
            +
            deal in the Software without restriction, including without limitation the
         
     | 
| 
      
 6 
     | 
    
         
            +
            rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
         
     | 
| 
      
 7 
     | 
    
         
            +
            sell copies of the Software, and to permit persons to whom the Software is
         
     | 
| 
      
 8 
     | 
    
         
            +
            furnished to do so, subject to the following conditions:
         
     | 
| 
      
 9 
     | 
    
         
            +
              
         
     | 
| 
      
 10 
     | 
    
         
            +
            The above copyright notice and this permission notice shall be included in
         
     | 
| 
      
 11 
     | 
    
         
            +
            all copies or substantial portions of the Software.
         
     | 
| 
      
 12 
     | 
    
         
            +
               
         
     | 
| 
      
 13 
     | 
    
         
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
         
     | 
| 
      
 14 
     | 
    
         
            +
            IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
         
     | 
| 
      
 15 
     | 
    
         
            +
            FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
         
     | 
| 
      
 16 
     | 
    
         
            +
            THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 
         
     | 
| 
      
 17 
     | 
    
         
            +
            IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
         
     | 
| 
      
 18 
     | 
    
         
            +
            CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         
     | 
    
        data/Rakefile
    CHANGED
    
    | 
         @@ -1,9 +1,4 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require ' 
     | 
| 
       2 
     | 
    
         
            -
            require 'rake/ 
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
            spec = eval(File.read('hijack.gemspec'))
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
            Rake::GemPackageTask.new(spec) do |pkg|
         
     | 
| 
       7 
     | 
    
         
            -
              pkg.gem_spec = spec
         
     | 
| 
       8 
     | 
    
         
            -
            end
         
     | 
| 
      
 1 
     | 
    
         
            +
            require 'rake'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'rake/clean'
         
     | 
| 
       9 
3 
     | 
    
         | 
| 
      
 4 
     | 
    
         
            +
            Dir['tasks/**/*.rake'].each { |rake| load rake }
         
     | 
    
        data/TODO
    CHANGED
    
    
    
        data/lib/hijack/payload.rb
    CHANGED
    
    | 
         @@ -11,7 +11,7 @@ module Hijack 
     | 
|
| 
       11 
11 
     | 
    
         
             
                end
         
     | 
| 
       12 
12 
     | 
    
         | 
| 
       13 
13 
     | 
    
         
             
                def self.payload(pid)
         
     | 
| 
       14 
     | 
    
         
            -
                  <<- 
     | 
| 
      
 14 
     | 
    
         
            +
                  <<-RUBY
         
     | 
| 
       15 
15 
     | 
    
         
             
                    require 'stringio'
         
     | 
| 
       16 
16 
     | 
    
         
             
                    require 'drb'
         
     | 
| 
       17 
17 
     | 
    
         | 
| 
         @@ -19,16 +19,32 @@ module Hijack 
     | 
|
| 
       19 
19 
     | 
    
         
             
                      module Hijack
         
     | 
| 
       20 
20 
     | 
    
         
             
                        class OutputCopier
         
     | 
| 
       21 
21 
     | 
    
         
             
                          def self.remote
         
     | 
| 
       22 
     | 
    
         
            -
                             
     | 
| 
      
 22 
     | 
    
         
            +
                            @remote
         
     | 
| 
      
 23 
     | 
    
         
            +
                          end
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                          def self.stop
         
     | 
| 
      
 26 
     | 
    
         
            +
                            @remote = nil
         
     | 
| 
      
 27 
     | 
    
         
            +
                            [$stdout, $stderr].each do |io|
         
     | 
| 
      
 28 
     | 
    
         
            +
                              if io.respond_to?(:write_with_copying)
         
     | 
| 
      
 29 
     | 
    
         
            +
                                class << io
         
     | 
| 
      
 30 
     | 
    
         
            +
                                  alias_method :write, :write_without_copying
         
     | 
| 
      
 31 
     | 
    
         
            +
                                  remove_method :write_with_copying
         
     | 
| 
      
 32 
     | 
    
         
            +
                                end
         
     | 
| 
      
 33 
     | 
    
         
            +
                              end
         
     | 
| 
      
 34 
     | 
    
         
            +
                            end
         
     | 
| 
       23 
35 
     | 
    
         
             
                          end
         
     | 
| 
       24 
36 
     | 
    
         | 
| 
       25 
37 
     | 
    
         
             
                          def self.start(pid)
         
     | 
| 
       26 
     | 
    
         
            -
                             
     | 
| 
      
 38 
     | 
    
         
            +
                            @remote = DRbObject.new(nil, 'drbunix://tmp/hijack.' + pid + '.sock')
         
     | 
| 
       27 
39 
     | 
    
         | 
| 
       28 
40 
     | 
    
         
             
                            class << $stdout
         
     | 
| 
       29 
41 
     | 
    
         
             
                              def write_with_copying(str)
         
     | 
| 
       30 
42 
     | 
    
         
             
                                write_without_copying(str)
         
     | 
| 
       31 
     | 
    
         
            -
                                 
     | 
| 
      
 43 
     | 
    
         
            +
                                begin
         
     | 
| 
      
 44 
     | 
    
         
            +
                                  Hijack::OutputCopier.remote.write('stdout', str)
         
     | 
| 
      
 45 
     | 
    
         
            +
                                rescue Exception
         
     | 
| 
      
 46 
     | 
    
         
            +
                                  Hijack.stop
         
     | 
| 
      
 47 
     | 
    
         
            +
                                end
         
     | 
| 
       32 
48 
     | 
    
         
             
                              end
         
     | 
| 
       33 
49 
     | 
    
         
             
                              alias_method :write_without_copying, :write
         
     | 
| 
       34 
50 
     | 
    
         
             
                              alias_method :write, :write_with_copying
         
     | 
| 
         @@ -37,7 +53,11 @@ module Hijack 
     | 
|
| 
       37 
53 
     | 
    
         
             
                            class << $stderr
         
     | 
| 
       38 
54 
     | 
    
         
             
                              def write_with_copying(str)
         
     | 
| 
       39 
55 
     | 
    
         
             
                                write_without_copying(str)
         
     | 
| 
       40 
     | 
    
         
            -
                                 
     | 
| 
      
 56 
     | 
    
         
            +
                                begin
         
     | 
| 
      
 57 
     | 
    
         
            +
                                  Hijack::OutputCopier.remote.write('stderr', str)
         
     | 
| 
      
 58 
     | 
    
         
            +
                                rescue Exception
         
     | 
| 
      
 59 
     | 
    
         
            +
                                  Hijack.stop
         
     | 
| 
      
 60 
     | 
    
         
            +
                                end
         
     | 
| 
       41 
61 
     | 
    
         
             
                              end
         
     | 
| 
       42 
62 
     | 
    
         
             
                              alias_method :write_without_copying, :write
         
     | 
| 
       43 
63 
     | 
    
         
             
                              alias_method :write, :write_with_copying
         
     | 
| 
         @@ -56,6 +76,8 @@ module Hijack 
     | 
|
| 
       56 
76 
     | 
    
         
             
                              OutputCopier.start($1)
         
     | 
| 
       57 
77 
     | 
    
         
             
                            elsif rb =~ /__hijack_get_remote_file_name/
         
     | 
| 
       58 
78 
     | 
    
         
             
                              @file
         
     | 
| 
      
 79 
     | 
    
         
            +
                            elsif rb =~ /__hijack_exit/
         
     | 
| 
      
 80 
     | 
    
         
            +
                              Hijack.stop
         
     | 
| 
       59 
81 
     | 
    
         
             
                            else
         
     | 
| 
       60 
82 
     | 
    
         
             
                              @context.instance_eval(rb)
         
     | 
| 
       61 
83 
     | 
    
         
             
                            end
         
     | 
| 
         @@ -68,11 +90,20 @@ module Hijack 
     | 
|
| 
       68 
90 
     | 
    
         
             
                          @service = DRb.start_service('#{Hijack.socket_for(pid)}', evaluator)
         
     | 
| 
       69 
91 
     | 
    
         
             
                          File.chmod(0600, '#{Hijack.socket_path_for(pid)}')
         
     | 
| 
       70 
92 
     | 
    
         
             
                        end
         
     | 
| 
      
 93 
     | 
    
         
            +
             
     | 
| 
      
 94 
     | 
    
         
            +
                        def self.stop
         
     | 
| 
      
 95 
     | 
    
         
            +
                          begin
         
     | 
| 
      
 96 
     | 
    
         
            +
                            OutputCopier.stop
         
     | 
| 
      
 97 
     | 
    
         
            +
                            @service.stop_service
         
     | 
| 
      
 98 
     | 
    
         
            +
                            @service = nil
         
     | 
| 
      
 99 
     | 
    
         
            +
                          rescue Exception
         
     | 
| 
      
 100 
     | 
    
         
            +
                          end
         
     | 
| 
      
 101 
     | 
    
         
            +
                        end
         
     | 
| 
       71 
102 
     | 
    
         
             
                      end
         
     | 
| 
       72 
103 
     | 
    
         
             
                    end
         
     | 
| 
       73 
104 
     | 
    
         
             
                    __hijack_context = self
         
     | 
| 
       74 
105 
     | 
    
         
             
                    Signal.trap('USR2') { Hijack.start(__hijack_context) }
         
     | 
| 
       75 
     | 
    
         
            -
                   
     | 
| 
      
 106 
     | 
    
         
            +
                  RUBY
         
     | 
| 
       76 
107 
     | 
    
         
             
                end
         
     | 
| 
       77 
108 
     | 
    
         
             
              end
         
     | 
| 
       78 
109 
     | 
    
         
             
            end
         
     | 
    
        data/lib/hijack/workspace.rb
    CHANGED
    
    | 
         @@ -12,7 +12,10 @@ module Hijack 
     | 
|
| 
       12 
12 
     | 
    
         
             
              class Workspace < IRB::WorkSpace
         
     | 
| 
       13 
13 
     | 
    
         
             
                attr_accessor :remote, :pid
         
     | 
| 
       14 
14 
     | 
    
         
             
                def evaluate(context, statements, file = __FILE__, line = __LINE__)
         
     | 
| 
       15 
     | 
    
         
            -
                  if statements =~ / 
     | 
| 
      
 15 
     | 
    
         
            +
                  if statements =~ /IRB\./
         
     | 
| 
      
 16 
     | 
    
         
            +
                    super
         
     | 
| 
      
 17 
     | 
    
         
            +
                  elsif statements.strip =~ /^exit/
         
     | 
| 
      
 18 
     | 
    
         
            +
                    remote.evaluate('__hijack_exit') rescue nil
         
     | 
| 
       16 
19 
     | 
    
         
             
                    super
         
     | 
| 
       17 
20 
     | 
    
         
             
                  elsif helper = Hijack::Helper.find_helper(statements)
         
     | 
| 
       18 
21 
     | 
    
         
             
                    Hijack::Helper.send(helper, remote)
         
     | 
    
        data/tasks/gem.rake
    ADDED
    
    | 
         @@ -0,0 +1,41 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'rake/gempackagetask'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'yaml'
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            HIJACK_VERSION = '0.1.7'
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            task :clean => :clobber_package
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            spec = Gem::Specification.new do |s|  
         
     | 
| 
      
 9 
     | 
    
         
            +
              s.name                  = 'hijack'
         
     | 
| 
      
 10 
     | 
    
         
            +
              s.version               = HIJACK_VERSION
         
     | 
| 
      
 11 
     | 
    
         
            +
              s.platform              = Gem::Platform::RUBY
         
     | 
| 
      
 12 
     | 
    
         
            +
              s.summary               = 
         
     | 
| 
      
 13 
     | 
    
         
            +
              s.description           = 'Provides an irb session to an existing ruby process.'
         
     | 
| 
      
 14 
     | 
    
         
            +
              s.author                = "Ian Leitch"
         
     | 
| 
      
 15 
     | 
    
         
            +
              s.email                 = 'ian.leitch@systino.net'
         
     | 
| 
      
 16 
     | 
    
         
            +
              s.homepage              = 'http://github.com/ileitch/hijack'
         
     | 
| 
      
 17 
     | 
    
         
            +
              s.has_rdoc              = false
         
     | 
| 
      
 18 
     | 
    
         
            +
              s.files                 = %w(COPYING TODO README.rdoc Rakefile) + Dir.glob("{lib,test,tasks,bin,examples}/**/*")
         
     | 
| 
      
 19 
     | 
    
         
            +
              s.bindir                = "bin"
         
     | 
| 
      
 20 
     | 
    
         
            +
              s.executables           = %w( hijack )
         
     | 
| 
      
 21 
     | 
    
         
            +
              s.require_path          = "lib"
         
     | 
| 
      
 22 
     | 
    
         
            +
            end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
            Rake::GemPackageTask.new(spec) do |p|
         
     | 
| 
      
 25 
     | 
    
         
            +
              p.gem_spec = spec
         
     | 
| 
      
 26 
     | 
    
         
            +
            end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
            namespace :gem do
         
     | 
| 
      
 29 
     | 
    
         
            +
              desc "Update the gemspec for GitHub's gem server"
         
     | 
| 
      
 30 
     | 
    
         
            +
              task :github do
         
     | 
| 
      
 31 
     | 
    
         
            +
                File.open("hijack.gemspec", 'w') { |f| f << YAML.dump(spec) }
         
     | 
| 
      
 32 
     | 
    
         
            +
              end  
         
     | 
| 
      
 33 
     | 
    
         
            +
            end
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
            task :install => [:clean, :clobber, :package] do
         
     | 
| 
      
 36 
     | 
    
         
            +
              sh "sudo gem install pkg/#{spec.full_name}.gem"
         
     | 
| 
      
 37 
     | 
    
         
            +
            end
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
            task :uninstall => :clean do
         
     | 
| 
      
 40 
     | 
    
         
            +
              sh "sudo gem uninstall -v #{HIJACK_VERSION} -x hijack"
         
     | 
| 
      
 41 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification 
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: ileitch-hijack
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version 
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.1. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.1.7
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors: 
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Ian Leitch
         
     | 
| 
         @@ -9,7 +9,7 @@ autorequire: 
     | 
|
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
       12 
     | 
    
         
            -
            date: 2009- 
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2009-09-13 21:00:00 -07:00
         
     | 
| 
       13 
13 
     | 
    
         
             
            default_executable: 
         
     | 
| 
       14 
14 
     | 
    
         
             
            dependencies: []
         
     | 
| 
       15 
15 
     | 
    
         | 
| 
         @@ -19,24 +19,26 @@ executables: 
     | 
|
| 
       19 
19 
     | 
    
         
             
            - hijack
         
     | 
| 
       20 
20 
     | 
    
         
             
            extensions: []
         
     | 
| 
       21 
21 
     | 
    
         | 
| 
       22 
     | 
    
         
            -
            extra_rdoc_files: 
         
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
      
 22 
     | 
    
         
            +
            extra_rdoc_files: []
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
       24 
24 
     | 
    
         
             
            files: 
         
     | 
| 
      
 25 
     | 
    
         
            +
            - COPYING
         
     | 
| 
      
 26 
     | 
    
         
            +
            - TODO
         
     | 
| 
       25 
27 
     | 
    
         
             
            - README.rdoc
         
     | 
| 
       26 
28 
     | 
    
         
             
            - Rakefile
         
     | 
| 
       27 
     | 
    
         
            -
            - TODO
         
     | 
| 
       28 
29 
     | 
    
         
             
            - lib/hijack
         
     | 
| 
       29 
     | 
    
         
            -
            - lib/hijack.rb
         
     | 
| 
       30 
30 
     | 
    
         
             
            - lib/hijack/console.rb
         
     | 
| 
       31 
31 
     | 
    
         
             
            - lib/hijack/gdb.rb
         
     | 
| 
       32 
32 
     | 
    
         
             
            - lib/hijack/helper.rb
         
     | 
| 
       33 
33 
     | 
    
         
             
            - lib/hijack/payload.rb
         
     | 
| 
       34 
34 
     | 
    
         
             
            - lib/hijack/workspace.rb
         
     | 
| 
       35 
     | 
    
         
            -
            -  
     | 
| 
       36 
     | 
    
         
            -
            - bin/hijack
         
     | 
| 
      
 35 
     | 
    
         
            +
            - lib/hijack.rb
         
     | 
| 
       37 
36 
     | 
    
         
             
            - test/app.rb
         
     | 
| 
       38 
37 
     | 
    
         
             
            - test/gc.rb
         
     | 
| 
       39 
38 
     | 
    
         
             
            - test/test.rb
         
     | 
| 
      
 39 
     | 
    
         
            +
            - tasks/gem.rake
         
     | 
| 
      
 40 
     | 
    
         
            +
            - bin/hijack
         
     | 
| 
      
 41 
     | 
    
         
            +
            - examples/rails_dispatcher.rb
         
     | 
| 
       40 
42 
     | 
    
         
             
            has_rdoc: true
         
     | 
| 
       41 
43 
     | 
    
         
             
            homepage: http://github.com/ileitch/hijack
         
     | 
| 
       42 
44 
     | 
    
         
             
            post_install_message: 
         
     | 
| 
         @@ -61,7 +63,7 @@ requirements: [] 
     | 
|
| 
       61 
63 
     | 
    
         
             
            rubyforge_project: 
         
     | 
| 
       62 
64 
     | 
    
         
             
            rubygems_version: 1.2.0
         
     | 
| 
       63 
65 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       64 
     | 
    
         
            -
            specification_version:  
     | 
| 
      
 66 
     | 
    
         
            +
            specification_version: 3
         
     | 
| 
       65 
67 
     | 
    
         
             
            summary: Provides an irb session to an existing ruby process.
         
     | 
| 
       66 
68 
     | 
    
         
             
            test_files: []
         
     | 
| 
       67 
69 
     | 
    
         |