pry-developer_tools 0.1.0.pre2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -0
- data/LICENSE.txt +25 -0
- data/README.md +54 -0
- data/Rakefile +1 -0
- data/lib/pry-developer_tools/commands.rb +129 -0
- data/lib/pry-developer_tools/version.rb +3 -0
- data/lib/pry-developer_tools.rb +4 -0
- data/pry-developer_tools.gemspec +23 -0
- metadata +77 -0
data/Gemfile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
gemspec
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
License
|
2
|
+
-------
|
3
|
+
|
4
|
+
(The MIT License)
|
5
|
+
|
6
|
+
Copyright (c) 2011 The Pry Team
|
7
|
+
|
8
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
9
|
+
a copy of this software and associated documentation files (the
|
10
|
+
'Software'), to deal in the Software without restriction, including
|
11
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
12
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
13
|
+
permit persons to whom the Software is furnished to do so, subject to
|
14
|
+
the following conditions:
|
15
|
+
|
16
|
+
The above copyright notice and this permission notice shall be
|
17
|
+
included in all copies or substantial portions of the Software.
|
18
|
+
|
19
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
20
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
21
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
22
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
23
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
24
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
25
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
__OVERVIEW__
|
2
|
+
|
3
|
+
|
4
|
+
| Project | pry-developer\_tools
|
5
|
+
|:----------------|:--------------------------------------------------
|
6
|
+
| Homepage | https://github.com/pry/pry-developer_tools
|
7
|
+
| Documentation | http://github.com/pry/pry-developer_tools/
|
8
|
+
| Author | Pry Team
|
9
|
+
|
10
|
+
|
11
|
+
__DESCRIPTION__
|
12
|
+
|
13
|
+
pry-developer\_tools is a collection of Pry commands that are useful for Pry
|
14
|
+
developers and Pry plugin developers. It provides commands that you can use
|
15
|
+
to edit, reload, or define commands while in a Pry session.
|
16
|
+
|
17
|
+
__EXAMPLES__
|
18
|
+
|
19
|
+
* define-command
|
20
|
+
|
21
|
+
# Define a command in-memory (for length of Pry session)
|
22
|
+
(pry) > define-command "name", "desc" do
|
23
|
+
p "Do something!"
|
24
|
+
end
|
25
|
+
|
26
|
+
* edit-command
|
27
|
+
|
28
|
+
# Perform a edit of show-method that will persist.
|
29
|
+
(pry) > edit-command show-method
|
30
|
+
|
31
|
+
# Perform a in-memory edit of show-method.
|
32
|
+
(pry) > edit-command -p show-method
|
33
|
+
|
34
|
+
* reload-command
|
35
|
+
|
36
|
+
# Reload a Pry command from disk.
|
37
|
+
(pry) > reload-command edit-method
|
38
|
+
|
39
|
+
__PRY SUPPORT__
|
40
|
+
|
41
|
+
Versions >= 0.9.8
|
42
|
+
|
43
|
+
__INSTALL__
|
44
|
+
|
45
|
+
gem install pry-developer\_tools
|
46
|
+
|
47
|
+
__LICENSE__
|
48
|
+
|
49
|
+
|
50
|
+
Same license as Pry (MIT).
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
@@ -0,0 +1,129 @@
|
|
1
|
+
module PryDeveloperTools
|
2
|
+
|
3
|
+
Commands = Pry::CommandSet.new do
|
4
|
+
command_class "define-command", "Define a Pry command for this session." do
|
5
|
+
banner <<-BANNER
|
6
|
+
Usage: define-command "name", "my description" do
|
7
|
+
p "I do something"
|
8
|
+
end
|
9
|
+
|
10
|
+
Define a Pry command.
|
11
|
+
BANNER
|
12
|
+
|
13
|
+
def process
|
14
|
+
if args.empty?
|
15
|
+
raise Pry::CommandError, "Provide an arg!"
|
16
|
+
end
|
17
|
+
|
18
|
+
prime_string = "command #{arg_string}\n"
|
19
|
+
command_string = _pry_.r(target, prime_string)
|
20
|
+
|
21
|
+
eval_string.replace <<-HERE
|
22
|
+
_pry_.commands.instance_eval do
|
23
|
+
#{command_string}
|
24
|
+
end
|
25
|
+
HERE
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
command_class "reload-command", "Reload a Pry command." do
|
30
|
+
banner <<-BANNER
|
31
|
+
Usage: reload-command command
|
32
|
+
Reload a Pry command.
|
33
|
+
BANNER
|
34
|
+
|
35
|
+
def process
|
36
|
+
command = _pry_.commands.find_command(args.first)
|
37
|
+
|
38
|
+
if command.nil?
|
39
|
+
raise Pry::CommandError, 'No command found.'
|
40
|
+
end
|
41
|
+
|
42
|
+
source_code = command.block.source
|
43
|
+
file, lineno = command.block.source_location
|
44
|
+
|
45
|
+
set = Pry::CommandSet.new do
|
46
|
+
eval(source_code, binding, file, lineno)
|
47
|
+
end
|
48
|
+
|
49
|
+
_pry_.commands.delete(command.name)
|
50
|
+
_pry_.commands.import(set)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
command_class "edit-command", "Edit a Pry command." do
|
55
|
+
banner <<-BANNER
|
56
|
+
Usage: edit-command [options] command
|
57
|
+
Edit a Pry command.
|
58
|
+
BANNER
|
59
|
+
|
60
|
+
def initialize env
|
61
|
+
@pry = env[:pry_instance]
|
62
|
+
@command = nil
|
63
|
+
super(env)
|
64
|
+
end
|
65
|
+
|
66
|
+
def options(opt)
|
67
|
+
opt.on :p, :patch, 'Perform a in-memory edit of a command'
|
68
|
+
end
|
69
|
+
|
70
|
+
def process
|
71
|
+
@command = @pry.commands.find_command(args.first)
|
72
|
+
|
73
|
+
if @command.nil?
|
74
|
+
raise Pry::CommandError, 'Command not found.'
|
75
|
+
end
|
76
|
+
|
77
|
+
case
|
78
|
+
when opts.present?(:patch)
|
79
|
+
edit_temporarily
|
80
|
+
else
|
81
|
+
edit_permanently
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def edit_permanently
|
86
|
+
file, lineno = @command.block.source_location
|
87
|
+
invoke_editor(file, lineno)
|
88
|
+
|
89
|
+
command_set = silence_warnings do
|
90
|
+
eval File.read(file), TOPLEVEL_BINDING, file, 1
|
91
|
+
end
|
92
|
+
|
93
|
+
unless command_set.is_a?(Pry::CommandSet)
|
94
|
+
raise Pry::CommandError,
|
95
|
+
"Expected file '#{file}' to return a CommandSet"
|
96
|
+
end
|
97
|
+
|
98
|
+
@pry.commands.delete(@command.name)
|
99
|
+
@pry.commands.import(command_set)
|
100
|
+
set_file_and_dir_locals(file)
|
101
|
+
end
|
102
|
+
|
103
|
+
def edit_temporarily
|
104
|
+
source_code = Pry::Method(@command.block).source
|
105
|
+
modified_code = nil
|
106
|
+
|
107
|
+
temp_file do |f|
|
108
|
+
f.write(source_code)
|
109
|
+
f.flush
|
110
|
+
|
111
|
+
invoke_editor(f.path, 1)
|
112
|
+
modified_code = File.read(f.path)
|
113
|
+
end
|
114
|
+
|
115
|
+
command_set = CommandSet.new do
|
116
|
+
silence_warnings do
|
117
|
+
pry = Pry.new :input => StringIO.new(modified_code)
|
118
|
+
pry.rep(binding)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
@pry.commands.delete(@command.name)
|
123
|
+
@pry.commands.import(command_set)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
end
|
129
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
$LOAD_PATH.unshift './lib'
|
2
|
+
require 'pry-developer_tools/version'
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = 'pry-developer_tools'
|
6
|
+
s.version = PryDeveloperTools::VERSION
|
7
|
+
s.authors = ["The Pry Team"]
|
8
|
+
s.email = 'rob@flowof.info'
|
9
|
+
s.homepage = 'https://github.com/pry/pry-developer_tools'
|
10
|
+
s.summary = 'A collection of developer tools for Pry users'
|
11
|
+
s.description = s.summary
|
12
|
+
|
13
|
+
s.files = `git ls-files`.each_line.map(&:chomp)
|
14
|
+
s.test_files = Dir.glob "test/**/*.rb"
|
15
|
+
|
16
|
+
s.platform = Gem::Platform::RUBY
|
17
|
+
s.require_path = 'lib'
|
18
|
+
s.rubyforge_project = '[none]'
|
19
|
+
s.required_rubygems_version = '>= 1.3.6'
|
20
|
+
|
21
|
+
s.add_runtime_dependency 'pry', '~> 0.9.8.pre'
|
22
|
+
s.add_development_dependency 'rake' , '~> 0.9.2'
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pry-developer_tools
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0.pre2
|
5
|
+
prerelease: 6
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- The Pry Team
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-01-20 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: pry
|
16
|
+
requirement: &70338629277220 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.9.8.pre
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70338629277220
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rake
|
27
|
+
requirement: &70338629276640 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 0.9.2
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70338629276640
|
36
|
+
description: A collection of developer tools for Pry users
|
37
|
+
email: rob@flowof.info
|
38
|
+
executables: []
|
39
|
+
extensions: []
|
40
|
+
extra_rdoc_files: []
|
41
|
+
files:
|
42
|
+
- Gemfile
|
43
|
+
- LICENSE.txt
|
44
|
+
- README.md
|
45
|
+
- Rakefile
|
46
|
+
- lib/pry-developer_tools.rb
|
47
|
+
- lib/pry-developer_tools/commands.rb
|
48
|
+
- lib/pry-developer_tools/version.rb
|
49
|
+
- pry-developer_tools.gemspec
|
50
|
+
homepage: https://github.com/pry/pry-developer_tools
|
51
|
+
licenses: []
|
52
|
+
post_install_message:
|
53
|
+
rdoc_options: []
|
54
|
+
require_paths:
|
55
|
+
- lib
|
56
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
segments:
|
63
|
+
- 0
|
64
|
+
hash: 94940989689613245
|
65
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ! '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: 1.3.6
|
71
|
+
requirements: []
|
72
|
+
rubyforge_project: ! '[none]'
|
73
|
+
rubygems_version: 1.8.15
|
74
|
+
signing_key:
|
75
|
+
specification_version: 3
|
76
|
+
summary: A collection of developer tools for Pry users
|
77
|
+
test_files: []
|