pry-timetravel 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +6 -0
- data/.travis.yml +7 -0
- data/Gemfile +2 -0
- data/LICENSE.MIT +19 -0
- data/README.md +21 -0
- data/Rakefile +14 -0
- data/lib/pry-timetravel.rb +87 -0
- data/lib/pry-timetravel/commands.rb +49 -0
- data/lib/pry/timetravel.rb +2 -0
- data/pry-timetravel.gemspec +19 -0
- data/spec/commands_spec.rb +11 -0
- data/spec/spec_helper.rb +6 -0
- metadata +84 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: de1866b7ed3e671da6c46593c64cf8a6d67f79b1
|
4
|
+
data.tar.gz: 3250ab254a725690e9918c419eb99e9bea65a213
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 72cd2382bb52e80f742995b9055c0e4680a0468413b431c26f097e3ffb3c022d45d43930f54c6eea2712ba8b8bca1e4c70ed2933f30eb8ac2c1b4f32b5c1484b
|
7
|
+
data.tar.gz: ddeda18934b6405411a1971a1cfd4a0b5dc68d49cb234bc2f0ca5044ac623668312e06c909c4f63737a3b3801c26b34dba3c45f2ccf90fca5d025ec65516d611
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.MIT
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2012 Conrad Irwin <conrad.irwin@gmail.com>
|
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 deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
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 THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# pry-timetravel
|
2
|
+
|
3
|
+
DOES NOT WORK. DO NOT USE.
|
4
|
+
|
5
|
+
Time travel! For your REPL!
|
6
|
+
|
7
|
+
> x = 5
|
8
|
+
5
|
9
|
+
> checkpoint
|
10
|
+
> x = 10
|
11
|
+
10
|
12
|
+
> timetravel
|
13
|
+
> x
|
14
|
+
5
|
15
|
+
|
16
|
+
This is an attempt to package the proof of concept. API WILL CHANGE!
|
17
|
+
|
18
|
+
## Meta
|
19
|
+
|
20
|
+
Released under the MIT license, see LICENSE.MIT for details. Contributions and bug-reports
|
21
|
+
are welcome.
|
data/Rakefile
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'pry'
|
3
|
+
|
4
|
+
require File.expand_path('../pry-timetravel/commands', __FILE__)
|
5
|
+
|
6
|
+
class PryTimetravel
|
7
|
+
class << self
|
8
|
+
|
9
|
+
def dlog(msg)
|
10
|
+
# File.open("meta.log", 'a') do |file|
|
11
|
+
# file.puts(msg)
|
12
|
+
# end
|
13
|
+
end
|
14
|
+
|
15
|
+
def checkpoint
|
16
|
+
parent_pid = $$
|
17
|
+
child_pid = fork
|
18
|
+
if child_pid
|
19
|
+
dlog("PARENT #{parent_pid}: I have a child pid #{child_pid}")
|
20
|
+
|
21
|
+
# Method 1: Child suspends themselves, parent adds them to list
|
22
|
+
# @previous_pid ||= []
|
23
|
+
# @previous_pid.push child_pid
|
24
|
+
|
25
|
+
# Method 2: Parent does a global-blocking waitall
|
26
|
+
# when the child exits, we can continue
|
27
|
+
# Problem: What if the child exits in a bad way? Check out '$?'
|
28
|
+
Process.waitpid(child_pid)
|
29
|
+
dlog("ME #{$$}: Previous exit: #{$?.inspect}")
|
30
|
+
if $?.exitstatus != 42
|
31
|
+
# Since this wasn't a timetravel return, we must unravel this world
|
32
|
+
Kernel.exit! $?.exitstatus
|
33
|
+
end
|
34
|
+
|
35
|
+
# The parent universe freezes
|
36
|
+
# dlog("PARENT #{$$}: I am suspending. My child is #{parent_pid}")
|
37
|
+
# dlog("PARENT #{$$}: suspending")
|
38
|
+
# Process.setpgrp
|
39
|
+
# Process.setsid
|
40
|
+
# dlog("PARENT #{$$}: resumed!")
|
41
|
+
else
|
42
|
+
child_pid = $$
|
43
|
+
dlog("CHILD: #{child_pid}: I have a parent pid #{parent_pid}")
|
44
|
+
|
45
|
+
# Method 1: Child suspends themselves, parent adds them to list
|
46
|
+
# The child is eventually resumed
|
47
|
+
# Process.kill 'SIGSTOP', child_pid
|
48
|
+
# dlog("CHILD #{child_pid}: resumed!")
|
49
|
+
|
50
|
+
# Method 2: Parent does a global-blocking waitall
|
51
|
+
# Child doesn't need to keep track of parent at all?
|
52
|
+
# Child will just exit! when it is done
|
53
|
+
@previous_pid ||= []
|
54
|
+
@previous_pid.push parent_pid
|
55
|
+
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def go_back
|
60
|
+
dlog("ME #{$$}: Thinking about time travel...");
|
61
|
+
dlog("ME #{$$}: previous_pid = #{ @previous_pid }");
|
62
|
+
if @previous_pid && ! @previous_pid.empty?
|
63
|
+
previous_pid = @previous_pid.pop
|
64
|
+
dlog("ME #{$$}: I found a previous pid #{previous_pid}! TIME TRAVEL TIME")
|
65
|
+
|
66
|
+
# Method 1: Awaken the child and let them take over
|
67
|
+
# Main parent can't exit or shell will get upset, so wait for all children
|
68
|
+
# Once all children are done, kill ourself
|
69
|
+
# Process.kill 'SIGCONT', previous_pid
|
70
|
+
# dlog("ME #{$$}: I resumed pid #{previous_pid}... now time to wait")
|
71
|
+
# # Process.waitpid(previous_pid)
|
72
|
+
# Process.waitall
|
73
|
+
# dlog("ME #{$$}: If you meet your previous self, kill yourself.")
|
74
|
+
# # Process.kill 'SIGKILL', $$
|
75
|
+
# Kernel.exit!
|
76
|
+
|
77
|
+
# Method 2: Kill ourself and let the parent take over
|
78
|
+
# The parent was just doing a waitpid, so it is ready
|
79
|
+
# Process.kill 'SIGKILL', $$
|
80
|
+
Process.exit! 42
|
81
|
+
|
82
|
+
end
|
83
|
+
dlog("ME #{$$}: I was unable to time travel. Maybe it is a myth.");
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
@@ -0,0 +1,49 @@
|
|
1
|
+
|
2
|
+
Pry::Commands.create_command "checkpoint", "Set a marker in the timeline" do
|
3
|
+
match 'checkpoint'
|
4
|
+
group 'Timetravel'
|
5
|
+
# description 'Snapshot the world so we can timetravel back here later'
|
6
|
+
banner <<-'BANNER'
|
7
|
+
Usage: checkpoint
|
8
|
+
checkpoint --list
|
9
|
+
checkpoint --delete [INDEX]
|
10
|
+
|
11
|
+
This will add a checkpoint which you can return to later.
|
12
|
+
BANNER
|
13
|
+
|
14
|
+
# def options(opt)
|
15
|
+
# opt.on :d, :delete,
|
16
|
+
# "Delete the checkpoint with the given index. If no index is given delete them all",
|
17
|
+
# :optional_argument => true, :as => Integer
|
18
|
+
# opt.on :l, :list,
|
19
|
+
# "Show all checkpoints"
|
20
|
+
# end
|
21
|
+
def process
|
22
|
+
PryTimetravel.checkpoint
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
Pry::Commands.create_command "timetravel", "Set a marker in the timeline" do
|
27
|
+
match 'timetravel'
|
28
|
+
group 'Timetravel'
|
29
|
+
# description 'Snapshot the world so we can timetravel back here later'
|
30
|
+
banner <<-'BANNER'
|
31
|
+
Usage: checkpoint
|
32
|
+
checkpoint --list
|
33
|
+
checkpoint --delete [INDEX]
|
34
|
+
|
35
|
+
This will add a checkpoint which you can return to later.
|
36
|
+
BANNER
|
37
|
+
|
38
|
+
# def options(opt)
|
39
|
+
# opt.on :d, :delete,
|
40
|
+
# "Delete the checkpoint with the given index. If no index is given delete them all",
|
41
|
+
# :optional_argument => true, :as => Integer
|
42
|
+
# opt.on :l, :list,
|
43
|
+
# "Show all checkpoints"
|
44
|
+
# end
|
45
|
+
def process
|
46
|
+
PryTimetravel.go_back
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'pry-timetravel'
|
3
|
+
s.version = '0.0.1'
|
4
|
+
s.summary = 'Timetravel'
|
5
|
+
s.description = 'Allows you to timetravel!'
|
6
|
+
s.homepage = 'https://github.com/awwaiid/pry-timetravel'
|
7
|
+
s.email = ['awwaiid@thelackthereof.org']
|
8
|
+
s.authors = ['Brock Wilcox']
|
9
|
+
s.files = `git ls-files`.split("\n")
|
10
|
+
s.require_paths = ['lib']
|
11
|
+
|
12
|
+
s.add_dependency 'pry'
|
13
|
+
|
14
|
+
s.add_development_dependency 'rake'
|
15
|
+
# s.add_development_dependency 'rspec'
|
16
|
+
# s.add_development_dependency 'yard'
|
17
|
+
# s.add_development_dependency 'redcarpet'
|
18
|
+
# s.add_development_dependency 'capybara'
|
19
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pry-timetravel
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Brock Wilcox
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-08-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: pry
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Allows you to timetravel!
|
42
|
+
email:
|
43
|
+
- awwaiid@thelackthereof.org
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- ".travis.yml"
|
50
|
+
- Gemfile
|
51
|
+
- LICENSE.MIT
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- lib/pry-timetravel.rb
|
55
|
+
- lib/pry-timetravel/commands.rb
|
56
|
+
- lib/pry/timetravel.rb
|
57
|
+
- pry-timetravel.gemspec
|
58
|
+
- spec/commands_spec.rb
|
59
|
+
- spec/spec_helper.rb
|
60
|
+
homepage: https://github.com/awwaiid/pry-timetravel
|
61
|
+
licenses: []
|
62
|
+
metadata: {}
|
63
|
+
post_install_message:
|
64
|
+
rdoc_options: []
|
65
|
+
require_paths:
|
66
|
+
- lib
|
67
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
72
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
requirements: []
|
78
|
+
rubyforge_project:
|
79
|
+
rubygems_version: 2.2.2
|
80
|
+
signing_key:
|
81
|
+
specification_version: 4
|
82
|
+
summary: Timetravel
|
83
|
+
test_files: []
|
84
|
+
has_rdoc:
|