irb-power_assert 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/LICENSE +21 -0
- data/README.md +72 -0
- data/lib/irb-power_assert.rb +5 -0
- data/lib/irb/cmd/pa.rb +25 -0
- data/lib/irb/power_assert.rb +13 -0
- data/lib/irb/power_assert/version.rb +8 -0
- metadata +152 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: '050580ce927d4f88311fa118e714cdf7954b6e13664b828b36ee4b3a6eaca0db'
|
4
|
+
data.tar.gz: '068ee87cfe06a9a56fe62ea9efc8083df10d719e3889fba4a727aacd9c92b218'
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 48ab08cc0c1c8b5c21e0116a9633b1aeb92791151b07693b206278660c885954c85c2ece9f68b4a0d9c7850d9bc3e40580578191e69c69b395ccae7504002ae9
|
7
|
+
data.tar.gz: 2970b67540d3676a686b205389309ecbd8d192298d32e28ff74a57d7f56e17336b0791bb3b36c1556c7100a5655936e8ff14c73a85428bd301d2059ed9a630d5
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2021 Kenichi Kamiya
|
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 all
|
13
|
+
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 THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
# irb-power_assert
|
2
|
+
|
3
|
+
![Build Status](https://github.com/kachick/irb-power_assert/actions/workflows/test.yml/badge.svg?branch=main)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/irb-power_assert.png)](http://badge.fury.io/rb/irb-power_assert)
|
5
|
+
|
6
|
+
## Overview
|
7
|
+
|
8
|
+
![screenshot](https://user-images.githubusercontent.com/1180335/118393194-c3120180-b678-11eb-8c23-1b4854c90840.png)
|
9
|
+
|
10
|
+
[ruby/power_assert](https://github.com/ruby/power_assert) is a recent My favorites.
|
11
|
+
|
12
|
+
It is super helpful in annoy testing.
|
13
|
+
|
14
|
+
Don't say [ruby/irb](https://github.com/ruby/irb) is old-fashioned.
|
15
|
+
|
16
|
+
I just would get irb version of [yui-knk/pry-power_assert](https://github.com/yui-knk/pry-power_assert)
|
17
|
+
|
18
|
+
Honor should be bestowed upon them.
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
Require Ruby 2.5 or later
|
23
|
+
|
24
|
+
This command will install the latest version into your environment
|
25
|
+
|
26
|
+
```console
|
27
|
+
$ gem install irb-power_assert
|
28
|
+
Should be installed!
|
29
|
+
```
|
30
|
+
|
31
|
+
```console
|
32
|
+
$ irb -r irb-power_assert
|
33
|
+
# Then enabled this gem!
|
34
|
+
```
|
35
|
+
|
36
|
+
Or specify in your `~/.irbrc` as below
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
require 'irb/power_assert'
|
40
|
+
```
|
41
|
+
|
42
|
+
Or
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
require 'irb-power_assert'
|
46
|
+
```
|
47
|
+
|
48
|
+
```console
|
49
|
+
$ irb
|
50
|
+
# Then enabled this gem!
|
51
|
+
```
|
52
|
+
|
53
|
+
The you can use `pa` as an IRB command.
|
54
|
+
|
55
|
+
```ruby
|
56
|
+
irb(main):001:0> pa '"0".class == "3".to_i.times.map {|i| i + 1 }.class'
|
57
|
+
result: false
|
58
|
+
|
59
|
+
"0".class == "3".to_i.times.map {|i| i + 1 }.class
|
60
|
+
| | | | | |
|
61
|
+
| | | | | Array
|
62
|
+
| | | | [1, 2, 3]
|
63
|
+
| | | #<Enumerator: ...>
|
64
|
+
| | 3
|
65
|
+
| false
|
66
|
+
String
|
67
|
+
=> nil
|
68
|
+
```
|
69
|
+
|
70
|
+
## References
|
71
|
+
|
72
|
+
* [ja - IRB is new than Pry](https://k0kubun.hatenablog.com/entry/2021/04/02/211455)
|
data/lib/irb/cmd/pa.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: us-ascii
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'irb/cmd/nop'
|
5
|
+
require 'power_assert'
|
6
|
+
require 'power_assert/colorize'
|
7
|
+
|
8
|
+
module IRB
|
9
|
+
module ExtendCommand
|
10
|
+
class Pa < Nop
|
11
|
+
def execute(expression)
|
12
|
+
# The implementation basically taken from https://github.com/yui-knk/pry-power_assert/blob/2d10ee3df8efaf9c448f31d51bff8033a1792739/lib/pry-power_assert.rb#L26-L35, thank you!
|
13
|
+
|
14
|
+
result = +"result: "
|
15
|
+
|
16
|
+
::PowerAssert.start(expression, source_binding: irb_context.workspace.binding) do |pa|
|
17
|
+
result << pa.yield.inspect << "\n\n"
|
18
|
+
result << pa.message_proc.call
|
19
|
+
end
|
20
|
+
|
21
|
+
puts result
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# coding: us-ascii
|
2
|
+
# frozen_string_literal: true
|
3
|
+
# Copyright (C) 2021 Kenichi Kamiya
|
4
|
+
|
5
|
+
require 'irb'
|
6
|
+
|
7
|
+
require_relative 'cmd/pa'
|
8
|
+
|
9
|
+
module IRB
|
10
|
+
module ExtendCommandBundle
|
11
|
+
def_extend_command(:irb_pa, :Pa, "#{__dir__}/cmd/pa.rb", [:pa, NO_OVERRIDE])
|
12
|
+
end
|
13
|
+
end
|
metadata
ADDED
@@ -0,0 +1,152 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: irb-power_assert
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kenichi Kamiya
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-05-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: irb
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.3.5
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '2.0'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.3.5
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '2.0'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: power_assert
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: 2.0.0
|
40
|
+
- - "<"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '3.0'
|
43
|
+
type: :runtime
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 2.0.0
|
50
|
+
- - "<"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '3.0'
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: test-unit
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: 3.4.1
|
60
|
+
- - "<"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '4.0'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 3.4.1
|
70
|
+
- - "<"
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '4.0'
|
73
|
+
- !ruby/object:Gem::Dependency
|
74
|
+
name: warning
|
75
|
+
requirement: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: 1.2.0
|
80
|
+
- - "<"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '2.0'
|
83
|
+
type: :development
|
84
|
+
prerelease: false
|
85
|
+
version_requirements: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 1.2.0
|
90
|
+
- - "<"
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '2.0'
|
93
|
+
- !ruby/object:Gem::Dependency
|
94
|
+
name: rake
|
95
|
+
requirement: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: 13.0.3
|
100
|
+
- - "<"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '20.0'
|
103
|
+
type: :development
|
104
|
+
prerelease: false
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 13.0.3
|
110
|
+
- - "<"
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '20.0'
|
113
|
+
description: " `power_assert` is super helpful in complex test! This gem provide
|
114
|
+
`pa(power_assert)` command in `irb`.\n"
|
115
|
+
email:
|
116
|
+
- kachick1+ruby@gmail.com
|
117
|
+
executables: []
|
118
|
+
extensions: []
|
119
|
+
extra_rdoc_files: []
|
120
|
+
files:
|
121
|
+
- LICENSE
|
122
|
+
- README.md
|
123
|
+
- lib/irb-power_assert.rb
|
124
|
+
- lib/irb/cmd/pa.rb
|
125
|
+
- lib/irb/power_assert.rb
|
126
|
+
- lib/irb/power_assert/version.rb
|
127
|
+
homepage: https://github.com/kachick/irb-power_assert
|
128
|
+
licenses:
|
129
|
+
- MIT
|
130
|
+
metadata:
|
131
|
+
homepage_uri: https://github.com/kachick/irb-power_assert
|
132
|
+
source_code_uri: https://github.com/kachick/irb-power_assert
|
133
|
+
post_install_message:
|
134
|
+
rdoc_options: []
|
135
|
+
require_paths:
|
136
|
+
- lib
|
137
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
138
|
+
requirements:
|
139
|
+
- - ">="
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: 2.5.0
|
142
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - ">="
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0'
|
147
|
+
requirements: []
|
148
|
+
rubygems_version: 3.2.15
|
149
|
+
signing_key:
|
150
|
+
specification_version: 4
|
151
|
+
summary: power_assert in irb
|
152
|
+
test_files: []
|