pry-larry 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +13 -8
- data/lib/pry-larry.rb +11 -8
- data/lib/pry-larry/version.rb +1 -1
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3164f6fcd6c14fce821cba144ebfbf77a0365f0f
|
4
|
+
data.tar.gz: edbb046147cd52338ce729a392e5ce26b16cccae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b3808bcb488a52ddff89bbde95849d753e30c26a84f6c7cd45b0217f87abe46e25a634aef5fc8f6ad355d26d3c457d429cdbaecc61ef196b3de8d94fe0b03f6
|
7
|
+
data.tar.gz: c3811be02eabf0c82f9e1597da178563e02bff07e9e1885b80acc206e80ce1349c6a5f13bd9c80fe637530e796f887a97cc56fa820fba6b40ec5bb678a4e5790
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
__v0.6.0__
|
2
|
+
|
3
|
+
* Add "pry.config.larry.benchmark_commands". Default is to not print benchmark information for Pry commands.
|
4
|
+
* Change "Larry says:" to "Benchmark:".
|
5
|
+
* Truncate elapsed time to 2 decimal places before passing it to "pry.config.larry.speak_if" and "pry.config.larry.speaker" Proc's.
|
6
|
+
* Fix the "-h" and "--help" option switches to print help when using the "larry" command.
|
7
|
+
|
1
8
|
__v0.5.0__
|
2
9
|
|
3
10
|
* Pass instance of "Pry" to speak_if lambda.
|
data/README.md
CHANGED
@@ -15,11 +15,12 @@ might not be released yet(`Pry.configure`) but the old way is [still supported](
|
|
15
15
|
|
16
16
|
```ruby
|
17
17
|
Pry.configure do |config|
|
18
|
-
config.larry.auto_start = false
|
19
|
-
config.larry.
|
18
|
+
config.larry.auto_start = false # default is true
|
19
|
+
config.larry.benchmark_commands = true # default is false
|
20
|
+
config.larry.speak_if = ->(pry, walltime) { # default is to speak if walltime is > 0.0
|
20
21
|
walltime > 0.5
|
21
22
|
}
|
22
|
-
config.larry.speaker = ->(pry, walltime) {
|
23
|
+
config.larry.speaker = ->(pry, walltime) { # default is to print "Benchmark: X.XXs"
|
23
24
|
pry.pager.page sprintf("Elapsed time: %.2fs", walltime)
|
24
25
|
}
|
25
26
|
end
|
@@ -29,20 +30,24 @@ __Examples__
|
|
29
30
|
|
30
31
|
__1.__
|
31
32
|
|
32
|
-
![
|
33
|
+
![Help screenshot](./screenshots/help.png)
|
34
|
+
|
35
|
+
__2.__
|
36
|
+
|
37
|
+
![Benchmark screenshot](./screenshots/benchmark.png)
|
33
38
|
|
34
39
|
__Install__
|
35
40
|
|
36
|
-
|
41
|
+
Rubygems
|
37
42
|
|
38
43
|
```
|
39
44
|
gem install pry-larry
|
40
45
|
```
|
41
46
|
|
42
|
-
|
47
|
+
Gemfile
|
43
48
|
|
44
49
|
```ruby
|
45
|
-
gem "pry-larry", "~> 0.
|
50
|
+
gem "pry-larry", "~> 0.6"
|
46
51
|
```
|
47
52
|
|
48
53
|
__License__
|
@@ -66,4 +71,4 @@ IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
66
71
|
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
67
72
|
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
68
73
|
OTHER DEALINGS IN THE SOFTWARE.
|
69
|
-
```
|
74
|
+
```
|
data/lib/pry-larry.rb
CHANGED
@@ -4,9 +4,13 @@ module Pry::Larry
|
|
4
4
|
BEFORE_EVAL = ->(_, pry) do
|
5
5
|
MEMORY[pry.hash].push Time.now.to_f
|
6
6
|
end
|
7
|
-
AFTER_EVAL = ->(
|
8
|
-
walltime = Time.now.to_f - MEMORY[pry.hash][-1]
|
9
|
-
|
7
|
+
AFTER_EVAL = ->(input, pry) do
|
8
|
+
walltime = (sprintf "%.2f", Time.now.to_f - MEMORY[pry.hash][-1]).to_f
|
9
|
+
if input.nil? # Pry command
|
10
|
+
pry.config.larry.speak_if.call(pry, walltime) and pry.config.larry.benchmark_commands and pry.config.larry.speaker.call(pry, walltime)
|
11
|
+
else
|
12
|
+
pry.config.larry.speak_if.call(pry, walltime) and pry.config.larry.speaker.call(pry, walltime)
|
13
|
+
end
|
10
14
|
end
|
11
15
|
BEFORE_SESSION = ->(_,_, pry) do
|
12
16
|
Pry::Larry.start(pry) if pry.config.larry.auto_start
|
@@ -36,7 +40,7 @@ module Pry::Larry
|
|
36
40
|
end
|
37
41
|
|
38
42
|
class LarryCommand < Pry::ClassCommand
|
39
|
-
match /larry (start|wakeup|stop|chill)
|
43
|
+
match /larry (start|wakeup|stop|chill|-h|--help)/
|
40
44
|
group 'pry-larry'
|
41
45
|
description 'Ask larry to start or stop counting wall-clock time.'
|
42
46
|
banner <<-CMDBANNER
|
@@ -70,12 +74,11 @@ module Pry::Larry
|
|
70
74
|
Pry.config.hooks.add_hook :before_session, BEFORE_SESSION.hash, BEFORE_SESSION
|
71
75
|
Pry.config.larry = Pry::Config.from_hash({
|
72
76
|
auto_start: true,
|
73
|
-
|
74
|
-
|
75
|
-
},
|
77
|
+
benchmark_commands: false,
|
78
|
+
speak_if: ->(pry, walltime) { walltime > 0 },
|
76
79
|
speaker: ->(pry, walltime) {
|
77
80
|
pry.pager.page "%{LarrySays} %{WallTime}s" % {
|
78
|
-
:LarrySays => Pry::Helpers::Text.green("
|
81
|
+
:LarrySays => Pry::Helpers::Text.green("Benchmark:"),
|
79
82
|
:WallTime => sprintf("%.2f", walltime)
|
80
83
|
}
|
81
84
|
}
|
data/lib/pry-larry/version.rb
CHANGED
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pry-larry
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jazzonmymind
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0.10'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0.10'
|
27
27
|
description: Larry keeps track of elapsed wall-clock time and tells you how long code
|
@@ -31,8 +31,8 @@ executables: []
|
|
31
31
|
extensions: []
|
32
32
|
extra_rdoc_files: []
|
33
33
|
files:
|
34
|
-
-
|
35
|
-
-
|
34
|
+
- .gitignore
|
35
|
+
- .pryrc
|
36
36
|
- CHANGELOG.md
|
37
37
|
- Gemfile
|
38
38
|
- README.md
|
@@ -50,17 +50,17 @@ require_paths:
|
|
50
50
|
- lib
|
51
51
|
required_ruby_version: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- -
|
53
|
+
- - '>='
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '0'
|
56
56
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
|
-
- -
|
58
|
+
- - '>='
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: '0'
|
61
61
|
requirements: []
|
62
62
|
rubyforge_project:
|
63
|
-
rubygems_version: 2.
|
63
|
+
rubygems_version: 2.0.14.1
|
64
64
|
signing_key:
|
65
65
|
specification_version: 4
|
66
66
|
summary: Larry is a plugin for Pry that tracks wall clock time.
|