pry-inline 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.rspec +2 -0
- data/.rubocop.yml +21 -0
- data/.travis.yml +4 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +8 -0
- data/LICENSE.txt +21 -0
- data/README.md +50 -0
- data/Rakefile +15 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/pry-inline.rb +13 -0
- data/lib/pry-inline/before_session_hook.rb +12 -0
- data/lib/pry-inline/inline_debuggable_code.rb +46 -0
- data/lib/pry-inline/inline_debuggable_loc.rb +45 -0
- data/lib/pry-inline/version.rb +3 -0
- data/lib/pry-inline/when_started_hook.rb +12 -0
- data/pry-inline.gemspec +25 -0
- data/screenshot.png +0 -0
- metadata +119 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c870a5bd3848d3ef04db13ca0ff68f747e1009e5
|
4
|
+
data.tar.gz: a4d161cc5bf205da19dc287db45803fdad8f05bc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 64da43309081163b75ef508da4a683af4e5a914a244af749de63581475b8ed13d2d0df8428a0aa665abb4008e9611ceb9d0075867ebe08dc02f56992a0074008
|
7
|
+
data.tar.gz: 0a8e00a2b8f9c1ab09b779ab3408135a377866d4de1ecf56c1c6653aa8065c2f9c90e4ce84437f4665b1ddb588567b99a9d50b967de550caf50ac3eb340ab1ba
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
AllCops:
|
2
|
+
Exclude:
|
3
|
+
- examples/*.rb
|
4
|
+
|
5
|
+
Metrics/LineLength:
|
6
|
+
Max: 120
|
7
|
+
|
8
|
+
Style/ClassVars:
|
9
|
+
Enabled: false
|
10
|
+
|
11
|
+
Style/Documentation:
|
12
|
+
Enabled: false
|
13
|
+
|
14
|
+
Style/FileName:
|
15
|
+
Enabled: false
|
16
|
+
|
17
|
+
Style/ParallelAssignment:
|
18
|
+
Enabled: false
|
19
|
+
|
20
|
+
Lint/UselessAssignment:
|
21
|
+
Enabled: false
|
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Seiichi KONDO
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# Pry Inline
|
2
|
+
|
3
|
+
Pry Inline is a plugin for [pry](https://github.com/pry/pry/),
|
4
|
+
which enables the inline debugging functionality like [RubyMine](https://www.jetbrains.com/ruby/help/inline-debugging.html).
|
5
|
+
|
6
|
+
![screenshot](./screenshot.png)
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
gem 'pry-inline'
|
14
|
+
```
|
15
|
+
|
16
|
+
And then execute:
|
17
|
+
|
18
|
+
$ bundle
|
19
|
+
|
20
|
+
Or install it yourself as:
|
21
|
+
|
22
|
+
$ gem install pry-inline
|
23
|
+
|
24
|
+
## Usage
|
25
|
+
|
26
|
+
There is no need to edit any configuration.
|
27
|
+
After you have added the dependency in Gemfile,
|
28
|
+
pry-inline will enable the inline debugging functionality.
|
29
|
+
|
30
|
+
## Development
|
31
|
+
|
32
|
+
After checking out the repo, run `bin/setup` to install dependencies.
|
33
|
+
Then, run `rake spec` to run the tests.
|
34
|
+
You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
35
|
+
|
36
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
37
|
+
To release a new version, update the version number in `version.rb`,
|
38
|
+
and then run `bundle exec rake release`, which will create a git tag for the version,
|
39
|
+
push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
40
|
+
|
41
|
+
## Contributing
|
42
|
+
|
43
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/pry-inline.
|
44
|
+
This project is intended to be a safe, welcoming space for collaboration,
|
45
|
+
and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
46
|
+
|
47
|
+
|
48
|
+
## License
|
49
|
+
|
50
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# coding: UTF-8
|
2
|
+
|
3
|
+
require 'rake/testtask'
|
4
|
+
require 'bundler/gem_tasks'
|
5
|
+
require 'rubocop/rake_task'
|
6
|
+
|
7
|
+
task default: [:test]
|
8
|
+
|
9
|
+
Rake::TestTask.new do |t|
|
10
|
+
t.libs << 'test'
|
11
|
+
t.test_files = Dir['test/**/test_*.rb']
|
12
|
+
t.verbose = true
|
13
|
+
end
|
14
|
+
|
15
|
+
RuboCop::RakeTask.new
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'pry/inline'
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require 'irb'
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/lib/pry-inline.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'pry'
|
2
|
+
require 'ripper'
|
3
|
+
require 'set'
|
4
|
+
|
5
|
+
require 'pry-inline/when_started_hook'
|
6
|
+
require 'pry-inline/before_session_hook'
|
7
|
+
|
8
|
+
Pry.config.hooks
|
9
|
+
.add_hook(:when_started, :pry_inline, PryInline::WhenStartedHook.new)
|
10
|
+
.add_hook(:before_session, :pry_inline, PryInline::BeforeSessionHook.new)
|
11
|
+
|
12
|
+
module PryInline
|
13
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'pry-inline/inline_debuggable_loc'
|
2
|
+
|
3
|
+
module PryInline
|
4
|
+
class BeforeSessionHook
|
5
|
+
def call(_, target, pry)
|
6
|
+
return if target.eval('self') == Pry.main
|
7
|
+
PryInline::InlineDebuggableLOC.binding = target
|
8
|
+
pry.run_command('whereami')
|
9
|
+
PryInline::InlineDebuggableLOC.binding = nil
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module PryInline
|
2
|
+
# monkey patch for Pry::Code
|
3
|
+
module InlineDebuggableCode
|
4
|
+
def initialize(lines, start_line, code_type)
|
5
|
+
super(lines, start_line, code_type)
|
6
|
+
|
7
|
+
@lineno_to_variables = Hash.new { |h, k| h[k] = Set.new }
|
8
|
+
traverse_sexp(Ripper.sexp(lines.is_a?(String) ? lines : lines.join("\n")))
|
9
|
+
@lineno_to_variables.each do |lineno, variables|
|
10
|
+
next if lineno == 0 || @lines.length <= lineno
|
11
|
+
@lines[lineno - 1].variables = variables
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def with_marker(lineno = 1)
|
16
|
+
super.tap do
|
17
|
+
@lines.each do |line|
|
18
|
+
line.variables = nil if line.lineno >= lineno
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def traverse_sexp(sexp)
|
26
|
+
return unless sexp.is_a?(Array)
|
27
|
+
event = sexp[0]
|
28
|
+
|
29
|
+
return sexp.each { |s| traverse_sexp(s) } if event.is_a?(Array)
|
30
|
+
return traverse_sexp_in_assignment(sexp[1]) if %i(assign massign params).include?(event)
|
31
|
+
traverse_sexp(sexp[1..sexp.length]) unless event.to_s.start_with?('@')
|
32
|
+
end
|
33
|
+
|
34
|
+
def traverse_sexp_in_assignment(sexp)
|
35
|
+
return unless sexp.is_a?(Array)
|
36
|
+
event = sexp[0]
|
37
|
+
|
38
|
+
return sexp.each { |s| traverse_sexp_in_assignment(s) } if event.is_a?(Array)
|
39
|
+
if %i( @ident @cvar @ivar ).include?(event)
|
40
|
+
return @lineno_to_variables[sexp[2][0]] << sexp[1]
|
41
|
+
end
|
42
|
+
|
43
|
+
traverse_sexp_in_assignment(sexp[1..sexp.length])
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module PryInline
|
2
|
+
# monkey patch for Pry::Code::LOC
|
3
|
+
module InlineDebuggableLOC
|
4
|
+
MAX_DEBUG_INFO_LENGTH = 80
|
5
|
+
|
6
|
+
@@binding = nil
|
7
|
+
|
8
|
+
attr_accessor :variables
|
9
|
+
|
10
|
+
def dup
|
11
|
+
super.tap { |ret| ret.variables = variables }
|
12
|
+
end
|
13
|
+
|
14
|
+
def colorize(code_type)
|
15
|
+
if @variables && (@variables & defined_variables).size > 0
|
16
|
+
if debug_info.length <= MAX_DEBUG_INFO_LENGTH
|
17
|
+
tuple[0] += " # #{debug_info}"
|
18
|
+
else
|
19
|
+
tuple[0] += " # #{debug_info[0..MAX_DEBUG_INFO_LENGTH]} ...}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
ensure
|
23
|
+
super(code_type)
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.binding=(value)
|
27
|
+
@@binding = value
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def defined_variables
|
33
|
+
return [] unless @@binding
|
34
|
+
@@binding.eval('local_variables').map(&:to_s) |
|
35
|
+
@@binding.eval('self.instance_variables').map(&:to_s) |
|
36
|
+
@@binding.eval('self.class.class_variables').map(&:to_s)
|
37
|
+
end
|
38
|
+
|
39
|
+
def debug_info
|
40
|
+
@variables.select { |k| defined_variables.include?(k) }
|
41
|
+
.map { |k| "#{k}: #{@@binding.eval(k).inspect}" }
|
42
|
+
.join(', ')
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'pry-inline/inline_debuggable_code'
|
2
|
+
require 'pry-inline/inline_debuggable_loc'
|
3
|
+
|
4
|
+
module PryInline
|
5
|
+
class WhenStartedHook
|
6
|
+
def call(_, _, _)
|
7
|
+
Pry.config.quiet = true
|
8
|
+
Pry::Code.send(:prepend, PryInline::InlineDebuggableCode)
|
9
|
+
Pry::Code::LOC.send(:prepend, PryInline::InlineDebuggableLOC)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
data/pry-inline.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
lib = File.expand_path('../lib', __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'pry-inline/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'pry-inline'
|
9
|
+
spec.version = PryInline::VERSION
|
10
|
+
spec.authors = ['Seiichi KONDO']
|
11
|
+
spec.email = ['seikichi@kmc.gr.jp']
|
12
|
+
|
13
|
+
spec.summary = 'Inline debugging like RubyMine'
|
14
|
+
spec.description = 'This Pry plugin enables inline debugging like RubyMine!'
|
15
|
+
spec.homepage = 'https://github.com/seikichi/pry-inline'
|
16
|
+
spec.license = 'MIT'
|
17
|
+
|
18
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_dependency 'pry', '>= 0.10.1'
|
22
|
+
spec.add_development_dependency 'bundler', '~> 1.10'
|
23
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
24
|
+
spec.add_development_dependency 'test-unit', '>= 3.0.0'
|
25
|
+
end
|
data/screenshot.png
ADDED
Binary file
|
metadata
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pry-inline
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Seiichi KONDO
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-09-05 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.10.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.10.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.10'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.10'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: test-unit
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 3.0.0
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 3.0.0
|
69
|
+
description: This Pry plugin enables inline debugging like RubyMine!
|
70
|
+
email:
|
71
|
+
- seikichi@kmc.gr.jp
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rspec"
|
78
|
+
- ".rubocop.yml"
|
79
|
+
- ".travis.yml"
|
80
|
+
- CODE_OF_CONDUCT.md
|
81
|
+
- Gemfile
|
82
|
+
- LICENSE.txt
|
83
|
+
- README.md
|
84
|
+
- Rakefile
|
85
|
+
- bin/console
|
86
|
+
- bin/setup
|
87
|
+
- lib/pry-inline.rb
|
88
|
+
- lib/pry-inline/before_session_hook.rb
|
89
|
+
- lib/pry-inline/inline_debuggable_code.rb
|
90
|
+
- lib/pry-inline/inline_debuggable_loc.rb
|
91
|
+
- lib/pry-inline/version.rb
|
92
|
+
- lib/pry-inline/when_started_hook.rb
|
93
|
+
- pry-inline.gemspec
|
94
|
+
- screenshot.png
|
95
|
+
homepage: https://github.com/seikichi/pry-inline
|
96
|
+
licenses:
|
97
|
+
- MIT
|
98
|
+
metadata: {}
|
99
|
+
post_install_message:
|
100
|
+
rdoc_options: []
|
101
|
+
require_paths:
|
102
|
+
- lib
|
103
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '0'
|
113
|
+
requirements: []
|
114
|
+
rubyforge_project:
|
115
|
+
rubygems_version: 2.4.5
|
116
|
+
signing_key:
|
117
|
+
specification_version: 4
|
118
|
+
summary: Inline debugging like RubyMine
|
119
|
+
test_files: []
|