interesting_methods 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +8 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +60 -0
- data/Guardfile +3 -0
- data/LICENSE.txt +21 -0
- data/README.md +93 -0
- data/Rakefile +10 -0
- data/bin/console +13 -0
- data/bin/setup +6 -0
- data/interesting_methods.gemspec +23 -0
- data/lib/interesting_methods.rb +19 -0
- data/lib/interesting_methods/version.rb +3 -0
- metadata +14 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ea34469eb43623c36642744a20b4f9798074336ac7c527da441cad58ad52d3a
|
4
|
+
data.tar.gz: cf66703970fd23799cf0415e21acfbb57a65502f4ef8df9498017e39a1115f22
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f66807577417a46290ebd23c5352be8c90831260e1eebf19372b1689306a56f03991c752df5f964df3b6748e808b7d7e94a1e3a8701d19a5ce0e7ebb960a6911
|
7
|
+
data.tar.gz: 95bd4f05924c9b4ed1f8e5d8a55b0a21bfecfe73c82129c57f9f670387d2d0a37335074ff29c0d2f4fe4386f04fb9212674700c1712c23ed15a17666938c4ff9
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
interesting_methods (0.1.1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
coderay (1.1.2)
|
10
|
+
ffi (1.9.23)
|
11
|
+
formatador (0.2.5)
|
12
|
+
guard (2.14.2)
|
13
|
+
formatador (>= 0.2.4)
|
14
|
+
listen (>= 2.7, < 4.0)
|
15
|
+
lumberjack (>= 1.0.12, < 2.0)
|
16
|
+
nenv (~> 0.1)
|
17
|
+
notiffany (~> 0.0)
|
18
|
+
pry (>= 0.9.12)
|
19
|
+
shellany (~> 0.0)
|
20
|
+
thor (>= 0.18.1)
|
21
|
+
guard-compat (1.2.1)
|
22
|
+
guard-minitest (2.4.6)
|
23
|
+
guard-compat (~> 1.2)
|
24
|
+
minitest (>= 3.0)
|
25
|
+
listen (3.1.5)
|
26
|
+
rb-fsevent (~> 0.9, >= 0.9.4)
|
27
|
+
rb-inotify (~> 0.9, >= 0.9.7)
|
28
|
+
ruby_dep (~> 1.2)
|
29
|
+
lumberjack (1.0.12)
|
30
|
+
method_source (0.9.0)
|
31
|
+
minitest (5.11.3)
|
32
|
+
nenv (0.3.0)
|
33
|
+
notiffany (0.1.1)
|
34
|
+
nenv (~> 0.1)
|
35
|
+
shellany (~> 0.0)
|
36
|
+
pry (0.11.3)
|
37
|
+
coderay (~> 1.1.0)
|
38
|
+
method_source (~> 0.9.0)
|
39
|
+
rake (10.5.0)
|
40
|
+
rb-fsevent (0.10.3)
|
41
|
+
rb-inotify (0.9.10)
|
42
|
+
ffi (>= 0.5.0, < 2)
|
43
|
+
ruby_dep (1.5.0)
|
44
|
+
shellany (0.0.1)
|
45
|
+
thor (0.20.0)
|
46
|
+
|
47
|
+
PLATFORMS
|
48
|
+
ruby
|
49
|
+
|
50
|
+
DEPENDENCIES
|
51
|
+
bundler (~> 1.16)
|
52
|
+
guard (~> 2.14)
|
53
|
+
guard-minitest (~> 2.4)
|
54
|
+
interesting_methods!
|
55
|
+
minitest (~> 5.0)
|
56
|
+
pry (~> 0.11)
|
57
|
+
rake (~> 10.0)
|
58
|
+
|
59
|
+
BUNDLED WITH
|
60
|
+
1.16.1
|
data/Guardfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Sean Lerner
|
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,93 @@
|
|
1
|
+
# Interesting Methods
|
2
|
+
|
3
|
+
This gem lets you add `.im` to any object in ruby to see the interesting methods.
|
4
|
+
|
5
|
+
`.im` stands for 'Interesting Methods'.
|
6
|
+
|
7
|
+
Without this Gem, to find out an Object's methods, you might try this:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
MyClass.methods
|
11
|
+
my_instance.methods
|
12
|
+
```
|
13
|
+
|
14
|
+
Each of those would show you all of the objects method's, including all those it's inherited, which may be too much to wade through to find what you're after.
|
15
|
+
|
16
|
+
---
|
17
|
+
|
18
|
+
In order to see just the interesting methods, you might try one of these instead:
|
19
|
+
|
20
|
+
```ruby
|
21
|
+
MyClass.methods - Object.methods
|
22
|
+
my_instance.methods - Object.methods
|
23
|
+
MyClass.singleton_methods(false)
|
24
|
+
my_instance.instance_methods(false)
|
25
|
+
MyModule.singleton_methods
|
26
|
+
MyModule.instance_methods
|
27
|
+
```
|
28
|
+
|
29
|
+
These will show you the more useful methods on that object.
|
30
|
+
|
31
|
+
---
|
32
|
+
|
33
|
+
This Gem wraps the above techniques into a simple `.im` that you can call on any object (class, instance, module) and it will show the appropriate interesting methods:
|
34
|
+
|
35
|
+
```
|
36
|
+
MyClass.im
|
37
|
+
my_instance.im
|
38
|
+
MyModule.im
|
39
|
+
```
|
40
|
+
|
41
|
+
## Installation
|
42
|
+
|
43
|
+
Create irb and pry rc files if they don't already exist:
|
44
|
+
|
45
|
+
```shell
|
46
|
+
touch ~/.irbrc
|
47
|
+
touch ~/.pryrc
|
48
|
+
```
|
49
|
+
|
50
|
+
Edit those files and add the following code:
|
51
|
+
|
52
|
+
```ruby
|
53
|
+
# This will install interesting_methods if it's not yet installed
|
54
|
+
unless Gem::Specification.find_all_by_name('interesting_methods').any?
|
55
|
+
system('gem install interesting_methods')
|
56
|
+
end
|
57
|
+
|
58
|
+
require 'interesting_methods'
|
59
|
+
```
|
60
|
+
|
61
|
+
The first time you go into `irb` or `pry`, the gem will be installed.
|
62
|
+
|
63
|
+
## Usage
|
64
|
+
|
65
|
+
Load up either `irb` or `pry` from your command line.
|
66
|
+
Add `.im` to any object to see its interesting methods.
|
67
|
+
|
68
|
+
## Caveat
|
69
|
+
|
70
|
+
This gem is not meant to be used in production as it monkey patches Ruby's core `Object` class.
|
71
|
+
|
72
|
+
## Development
|
73
|
+
|
74
|
+
After checking out this repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests.
|
75
|
+
|
76
|
+
You can run `guard` for a continuous test runner.
|
77
|
+
|
78
|
+
You can run `bin/console` for an interactive prompt that will allow you to experiment.
|
79
|
+
|
80
|
+
## Contributing
|
81
|
+
|
82
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/seanlerner/interesting_methods.
|
83
|
+
|
84
|
+
## License
|
85
|
+
|
86
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
87
|
+
|
88
|
+
## Credit
|
89
|
+
|
90
|
+
Having `interesting_methods` available in your repl is something ruby programmers have been doing for a while. I think I first came across it years ago in a stackoverflow post. Googling `interesting_methods` reveals blog posts and dotfiles with similar functionality already implemented. AFAIK this is the first time its been packaged up in a gem.
|
91
|
+
|
92
|
+
Sean Lerner<br>
|
93
|
+
https://smallcity.ca
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'interesting_methods'
|
5
|
+
require 'pry'
|
6
|
+
|
7
|
+
require_relative '../test/test_objects/animal'
|
8
|
+
require_relative '../test/test_objects/colours'
|
9
|
+
require_relative '../test/test_objects/pig'
|
10
|
+
require_relative '../test/test_objects/pig_with_colours_extended'
|
11
|
+
require_relative '../test/test_objects/pig_with_colours_included'
|
12
|
+
|
13
|
+
Pry.start
|
data/bin/setup
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
|
4
|
+
require 'interesting_methods/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'interesting_methods'
|
8
|
+
spec.version = InterestingMethods::VERSION
|
9
|
+
spec.authors = ['Sean Lerner']
|
10
|
+
spec.email = ['sean@@smallcity.ca']
|
11
|
+
spec.summary = 'See relevant methods in your repl by adding .im to any object'
|
12
|
+
spec.homepage = 'https://github.com/seanlerner/interesting_methods'
|
13
|
+
spec.license = 'MIT'
|
14
|
+
spec.files = `git ls-files`.split.reject { |f| f.match('test') }
|
15
|
+
spec.require_paths = ['lib']
|
16
|
+
|
17
|
+
spec.add_development_dependency 'bundler', '~> 1.16'
|
18
|
+
spec.add_development_dependency 'guard', '~> 2.14'
|
19
|
+
spec.add_development_dependency 'guard-minitest', '~> 2.4'
|
20
|
+
spec.add_development_dependency 'minitest', '~> 5.0'
|
21
|
+
spec.add_development_dependency 'pry', '~> 0.11'
|
22
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
23
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class Object
|
2
|
+
|
3
|
+
def im
|
4
|
+
interesting_methods
|
5
|
+
end
|
6
|
+
|
7
|
+
def interesting_methods
|
8
|
+
if self.class == Module
|
9
|
+
(singleton_methods + instance_methods).sort
|
10
|
+
else
|
11
|
+
(public_methods - Object.methods).sort
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.interesting_methods
|
16
|
+
(public_methods - Object.methods).sort
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: interesting_methods
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Lerner
|
@@ -100,7 +100,19 @@ email:
|
|
100
100
|
executables: []
|
101
101
|
extensions: []
|
102
102
|
extra_rdoc_files: []
|
103
|
-
files:
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- Gemfile
|
106
|
+
- Gemfile.lock
|
107
|
+
- Guardfile
|
108
|
+
- LICENSE.txt
|
109
|
+
- README.md
|
110
|
+
- Rakefile
|
111
|
+
- bin/console
|
112
|
+
- bin/setup
|
113
|
+
- interesting_methods.gemspec
|
114
|
+
- lib/interesting_methods.rb
|
115
|
+
- lib/interesting_methods/version.rb
|
104
116
|
homepage: https://github.com/seanlerner/interesting_methods
|
105
117
|
licenses:
|
106
118
|
- MIT
|