lemme-pry 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.gitlab-ci.yml +20 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +123 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/lemme-pry +107 -0
- data/lemme-pry.gemspec +29 -0
- data/lib/lemme-pry.rb +5 -0
- data/lib/lemme-pry/version.rb +3 -0
- metadata +115 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: aa90cabd98e889bce395d8199da10c2cf60a7cd7
|
4
|
+
data.tar.gz: 299e5d863d1d5b568b90f61004c25294334bf3c5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f71b72ea61180c691a0c4378aefd36c53f28b45856d9c77fb1de7642f6eec6f4f3d2949a5e264e6c96bfad9b0cf2b20c446f23586a3c155974f0db3856bdf041
|
7
|
+
data.tar.gz: 93018cd9eb4dcd56b28eab0b2f3389bc6fba2d4c6d4a556ec136a0f13f5d1a081aa9db2b256075f69790d10f19e9349efd51f6c49c25a33b74fa11d92f067e89
|
data/.gitignore
ADDED
data/.gitlab-ci.yml
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
.spec: &spec
|
2
|
+
tags:
|
3
|
+
- docker
|
4
|
+
script:
|
5
|
+
- bundle install --path vendor --without production --jobs $(nproc) > /dev/null
|
6
|
+
- gem build lemme-pry.gemspec
|
7
|
+
- gem install *.gem
|
8
|
+
- echo 'puts "Hello AS " + ActiveSupport.version.to_s;exit' | lemme-pry activesupport '~> 4.0'
|
9
|
+
|
10
|
+
spec2.1:
|
11
|
+
image: ruby:2.1
|
12
|
+
<<: *spec
|
13
|
+
|
14
|
+
spec2.3:
|
15
|
+
image: ruby:2.3
|
16
|
+
<<: *spec
|
17
|
+
|
18
|
+
spec2.4:
|
19
|
+
image: ruby:2.4
|
20
|
+
<<: *spec
|
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Gert Goet
|
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,123 @@
|
|
1
|
+
# lemme-pry
|
2
|
+
|
3
|
+
Start a pry-session with specific gems or a (remote) script preloaded.
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
This gem allows you to get a pry-session with either...
|
8
|
+
|
9
|
+
1. gems preloaded
|
10
|
+
2. a script preloaded
|
11
|
+
|
12
|
+
### pry-session with gems pre-loaded
|
13
|
+
|
14
|
+
This requires lemme-pry to be [installed system-wide](#system-wide).
|
15
|
+
|
16
|
+
```bash
|
17
|
+
$ lemme-pry activesupport
|
18
|
+
Fetching gem metadata from https://rubygems.org/.........
|
19
|
+
Fetching version metadata from https://rubygems.org/.
|
20
|
+
Resolving dependencies...
|
21
|
+
Using concurrent-ruby 1.0.5
|
22
|
+
Using i18n 0.8.1
|
23
|
+
Using minitest 5.10.1
|
24
|
+
Using thread_safe 0.3.6
|
25
|
+
Using coderay 1.1.1
|
26
|
+
Using method_source 0.8.2
|
27
|
+
Using slop 3.6.0
|
28
|
+
Using bundler 1.14.5
|
29
|
+
Using tzinfo 1.2.2
|
30
|
+
Using pry 0.10.4
|
31
|
+
Using activesupport 5.0.2
|
32
|
+
[2] pry(main)> 1.second
|
33
|
+
=> 1 second
|
34
|
+
```
|
35
|
+
|
36
|
+
Use a specific version:
|
37
|
+
|
38
|
+
```bash
|
39
|
+
# any version notation that is accepted in a Gemfile will work
|
40
|
+
$ lemme-pry activesupport '~> 4.2'
|
41
|
+
...
|
42
|
+
[2] pry(main)>
|
43
|
+
```
|
44
|
+
|
45
|
+
Multiple gems:
|
46
|
+
|
47
|
+
```bash
|
48
|
+
$ lemme-pry activesupport '~> 4.2' redis
|
49
|
+
...
|
50
|
+
[2] pry(main)>
|
51
|
+
```
|
52
|
+
|
53
|
+
### pry-session with script preloaded
|
54
|
+
|
55
|
+
Anything piped to lemme-pry will be evaluated before the pry-session starts:
|
56
|
+
|
57
|
+
```bash
|
58
|
+
$ echo '@a = 1' | lemme-pry
|
59
|
+
[1] pry(main)> @a
|
60
|
+
=> 1
|
61
|
+
```
|
62
|
+
|
63
|
+
```bash
|
64
|
+
# handy when sharing code with others:
|
65
|
+
$ curl https://gist.githubusercontent.com/eval/76955c57512c1e4ac01cdd913b76c92d/raw/bf714a15789eca3e968c3544f85b9b786b8eae8f/hello.rb | lemme-pry
|
66
|
+
|
67
|
+
# or via the gist command:
|
68
|
+
$ gist -r 76955c57512c1e4ac01cdd913b76c92d | lemme-pry
|
69
|
+
```
|
70
|
+
|
71
|
+
**NOTE:** curl-pipe-runtime is [not without risk](https://www.idontplaydarts.com/2016/04/detecting-curl-pipe-bash-server-side/). A tool like [vipe](https://github.com/madx/moreutils/blob/master/vipe) ([npm variant](https://github.com/juliangruber/vipe#vipe)) allows you to inspect the fetched script before handing it over to lemme-pry.
|
72
|
+
|
73
|
+
#### within a (Rails-)project
|
74
|
+
|
75
|
+
When the script needs to be evaluated within a project (i.e. use the gems of your project), make sure lemme-pry is [part of your project](#within-project).
|
76
|
+
|
77
|
+
A script for a Rails project would typically look like this:
|
78
|
+
|
79
|
+
```ruby
|
80
|
+
# script.rb
|
81
|
+
require './config/environment' # load Rails-application
|
82
|
+
@user = User.first
|
83
|
+
```
|
84
|
+
|
85
|
+
Evaluate via:
|
86
|
+
```
|
87
|
+
cat script.rb | bundle exec lemme-pry
|
88
|
+
...
|
89
|
+
[1] pry(main)> @user
|
90
|
+
#<User id: 1, username: ...
|
91
|
+
```
|
92
|
+
|
93
|
+
## Installation
|
94
|
+
|
95
|
+
### System-wide
|
96
|
+
|
97
|
+
```bash
|
98
|
+
$ gem install lemme-pry
|
99
|
+
```
|
100
|
+
|
101
|
+
### Within project
|
102
|
+
|
103
|
+
Add the following to `Gemfile`:
|
104
|
+
|
105
|
+
```ruby
|
106
|
+
# Gemfile
|
107
|
+
gem 'lemme-pry', group: :development
|
108
|
+
```
|
109
|
+
|
110
|
+
|
111
|
+
## Development
|
112
|
+
|
113
|
+
After checking out the repo, run `bin/setup` to install dependencies.
|
114
|
+
Then run the tool via:
|
115
|
+
|
116
|
+
```
|
117
|
+
$ ruby -Ilib exe/lemme-pry activesupport
|
118
|
+
```
|
119
|
+
|
120
|
+
## License
|
121
|
+
|
122
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
123
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "prytry"
|
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(__FILE__)
|
data/bin/setup
ADDED
data/exe/lemme-pry
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
VERSION_LIKE_RE = [Gem::Requirement::PATTERN, /v?\d+\.\d+/, /^\h+$/].freeze
|
4
|
+
|
5
|
+
REQUIREMENTS = {
|
6
|
+
'rails' => %w(rails/all active_support/all),
|
7
|
+
'activerecord' => %w(active_record),
|
8
|
+
'activesupport' => %w(active_support/all),
|
9
|
+
}.freeze
|
10
|
+
|
11
|
+
def parse_gems(args)
|
12
|
+
args.each_with_object([]) do |arg, obj|
|
13
|
+
matches_arg = arg.method(:match).to_proc
|
14
|
+
if VERSION_LIKE_RE.detect(&matches_arg)
|
15
|
+
obj[-1] << arg
|
16
|
+
else
|
17
|
+
obj << [arg]
|
18
|
+
end
|
19
|
+
end.map do |gem|
|
20
|
+
if r = REQUIREMENTS[gem.first]
|
21
|
+
gem << {:require => r}
|
22
|
+
else
|
23
|
+
gem
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def template_for_gems(gems, options = {})
|
29
|
+
require 'erb'
|
30
|
+
@gems = gems
|
31
|
+
@inline = options[:inline]
|
32
|
+
ERB.new(<<-GEMFILE, 1, "-").result
|
33
|
+
<% if @inline -%>
|
34
|
+
#!/usr/bin/env ruby
|
35
|
+
|
36
|
+
begin
|
37
|
+
require "bundler/inline"
|
38
|
+
rescue LoadError => e
|
39
|
+
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
|
40
|
+
raise e
|
41
|
+
end
|
42
|
+
<% else -%>
|
43
|
+
require "bundler/inline"
|
44
|
+
<% end -%>
|
45
|
+
gemfile(true) do
|
46
|
+
source 'https://rubygems.org'
|
47
|
+
gem 'pry'
|
48
|
+
<% @gems.each do |(gem, *opts)|
|
49
|
+
options = opts.last.is_a?(Hash) ? opts.pop : {}
|
50
|
+
version = opts.pop -%>
|
51
|
+
gem <%= gem.inspect %><% if version %>, <%= version.inspect %> <% end %><% if options[:require] %>, :require => <%= options[:require] %><% end %>
|
52
|
+
<% end -%>
|
53
|
+
end
|
54
|
+
GEMFILE
|
55
|
+
end
|
56
|
+
|
57
|
+
if ($stdin.tty? && ARGV.empty?) || %w(-h --help).include?(ARGV.first)
|
58
|
+
puts(<<-EOH)
|
59
|
+
**NOTE** this gem is continued under the name `lemme-pry`. Please update your dependencies.
|
60
|
+
|
61
|
+
Usage:
|
62
|
+
lemme-pry activesupport
|
63
|
+
cat script.rb | lemme-pry
|
64
|
+
|
65
|
+
Options:
|
66
|
+
-h Show this help
|
67
|
+
-v Show version
|
68
|
+
--inline Print script to STDOUT with inline gemfile as specified
|
69
|
+
|
70
|
+
Example:
|
71
|
+
lemme-pry activesupport
|
72
|
+
|
73
|
+
Start Pry-repl with activesupport required.
|
74
|
+
|
75
|
+
lemme-pry activesupport '~> 4.2'
|
76
|
+
|
77
|
+
Start Pry-repl with activesupport version 4.x required.
|
78
|
+
|
79
|
+
lemme-pry activesupport redis
|
80
|
+
|
81
|
+
Start Pry-repl with both activesupport and redis required.
|
82
|
+
|
83
|
+
lemme-pry --inline activesupport '~> 4.2'
|
84
|
+
|
85
|
+
Print script with inline gemfile.
|
86
|
+
EOH
|
87
|
+
exit
|
88
|
+
elsif %w(-v --version).include?(ARGV.first)
|
89
|
+
require 'lemme-pry'
|
90
|
+
puts LemmePry::VERSION
|
91
|
+
exit
|
92
|
+
elsif %w(--inline).include?(ARGV.first)
|
93
|
+
ARGV.shift
|
94
|
+
puts template_for_gems(parse_gems(ARGV), :inline => true)
|
95
|
+
exit
|
96
|
+
end
|
97
|
+
|
98
|
+
@gems = parse_gems(ARGV)
|
99
|
+
|
100
|
+
if @gems.any?
|
101
|
+
require 'tempfile'
|
102
|
+
|
103
|
+
@script = Tempfile.new('lemme-pry').tap do |f|
|
104
|
+
File.write(f, template_for_gems(@gems).gsub(/\n+ *(?=\S)/, ';'))
|
105
|
+
end
|
106
|
+
end
|
107
|
+
exec %{unset BUNDLE_BIN;script=$(cat #{@script ? @script.path : ''} #{$stdin.tty? ? '' : '-'}; echo;echo '$stdin = $stdin.reopen "/dev/tty";'); printf "${script}" | pry}
|
data/lemme-pry.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'lemme-pry/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "lemme-pry"
|
8
|
+
spec.version = LemmePry::VERSION
|
9
|
+
spec.authors = ["Gert Goet"]
|
10
|
+
spec.email = ["gert@thinkcreate.nl"]
|
11
|
+
|
12
|
+
spec.summary = %q{Quickly try a gem or script on the repl}
|
13
|
+
spec.description = %q{Start a pry-session with specific gems or a (remote) script loaded.}
|
14
|
+
spec.homepage = "https://gitlab.com/eval/lemme-pry/tree/master#lemme-pry"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
spec.bindir = "exe"
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.required_ruby_version = '>= 2.1'
|
25
|
+
spec.add_dependency "pry", "~>0.10"
|
26
|
+
spec.add_dependency "bundler", "~> 1.10"
|
27
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
28
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
29
|
+
end
|
data/lib/lemme-pry.rb
ADDED
metadata
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lemme-pry
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Gert Goet
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-06-13 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'
|
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'
|
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: :runtime
|
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: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.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'
|
69
|
+
description: Start a pry-session with specific gems or a (remote) script loaded.
|
70
|
+
email:
|
71
|
+
- gert@thinkcreate.nl
|
72
|
+
executables:
|
73
|
+
- lemme-pry
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
78
|
+
- ".gitlab-ci.yml"
|
79
|
+
- ".rspec"
|
80
|
+
- ".travis.yml"
|
81
|
+
- Gemfile
|
82
|
+
- LICENSE.txt
|
83
|
+
- README.md
|
84
|
+
- Rakefile
|
85
|
+
- bin/console
|
86
|
+
- bin/setup
|
87
|
+
- exe/lemme-pry
|
88
|
+
- lemme-pry.gemspec
|
89
|
+
- lib/lemme-pry.rb
|
90
|
+
- lib/lemme-pry/version.rb
|
91
|
+
homepage: https://gitlab.com/eval/lemme-pry/tree/master#lemme-pry
|
92
|
+
licenses:
|
93
|
+
- MIT
|
94
|
+
metadata: {}
|
95
|
+
post_install_message:
|
96
|
+
rdoc_options: []
|
97
|
+
require_paths:
|
98
|
+
- lib
|
99
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '2.1'
|
104
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
requirements: []
|
110
|
+
rubyforge_project:
|
111
|
+
rubygems_version: 2.5.2
|
112
|
+
signing_key:
|
113
|
+
specification_version: 4
|
114
|
+
summary: Quickly try a gem or script on the repl
|
115
|
+
test_files: []
|