exclusive_methods 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 340dd74d549d2607e0e33f60078c303aa0daaeda
4
+ data.tar.gz: 2b5789a26ad9ce75f5b0fe3a9188383a3575aff2
5
+ SHA512:
6
+ metadata.gz: d30e43b98598454022f389616a8b12e44858b2d5d47faa55582101f9840d1eec3b4c20715cd178985106e416dec0e717b797f3b3333029c256e0383fd9195fff
7
+ data.tar.gz: 484720d038bdbddef348f130e78f6b68649b6e400e10a8b66d55d72168c9b57a867856a2f0cc09d2b3fc3d5a5d11c8ea14c95088e8954c8ac8845042124402cd
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in exclusive_methods.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Kerri Miller
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,42 @@
1
+ # ExclusiveMethods
2
+
3
+ Adds methods to a Ruby class that return methods that are exclusive to that class, and do not belong to its ancestors.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'exclusive_methods'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install exclusive_methods
20
+
21
+ ## Usage
22
+
23
+ ```ruby
24
+ [1] pry(main)> require 'exclusive_methods'
25
+ => true
26
+ [2] pry(main)> String.exclusive_instance_methods.inspect
27
+ => "[:casecmp, :+, :*, :%, :[], :[]=, :insert, :length, :size, :bytesize, :empty?, :match, :succ, :succ!, :next, :next!, :upto, :index, :rindex, :replace, :clear, :chr, :getbyte, :setbyte, :byteslice, :scrub, :scrub!, :to_i, :to_f, :to_str, :dump, :upcase, :downcase, :capitalize, :swapcase, :upcase!, :downcase!, :capitalize!, :swapcase!, :hex, :oct, :split, :lines, :bytes, :chars, :codepoints, :reverse, :reverse!, :concat, :<<, :prepend, :crypt, :intern, :to_sym, :ord, :include?, :start_with?, :end_with?, :scan, :ljust, :rjust, :center, :sub, :gsub, :chop, :chomp, :strip, :lstrip, :rstrip, :sub!, :gsub!, :chop!, :chomp!, :strip!, :lstrip!, :rstrip!, :tr, :tr_s, :delete, :squeeze, :count, :tr!, :tr_s!, :delete!, :squeeze!, :each_line, :each_byte, :each_char, :each_codepoint, :sum, :slice, :slice!, :partition, :rpartition, :encoding, :force_encoding, :b, :valid_encoding?, :ascii_only?, :unpack, :encode, :encode!, :to_r, :to_c, :shellsplit, :shellescape, :shell_split]"
28
+ [3] pry(main)> String.exclusive_class_methods.inspect
29
+ => "[:try_convert]"
30
+ [4] pry(main)> class String; def self.fizz;end;end
31
+ => :fizz
32
+ [5] pry(main)> String.exclusive_class_methods.inspect
33
+ => "[:try_convert, :fizz]"
34
+ ```
35
+
36
+ ## Contributing
37
+
38
+ 1. Fork it ( https://github.com/[my-github-username]/exclusive_methods/fork )
39
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
40
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
41
+ 4. Push to the branch (`git push origin my-new-feature`)
42
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'exclusive_methods/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "exclusive_methods"
8
+ spec.version = ExclusiveMethods::VERSION
9
+ spec.authors = ["Kerri Miller"]
10
+ spec.email = ["kerrizor@kerrizor.com"]
11
+ spec.summary = %q{Adds methods to expose methods exclusive to a class.}
12
+ spec.description = %q{Adds methods to a Ruby class that return methods that are exclusive to that class, and do not belong to its ancestors.}
13
+ spec.homepage = "https://github.com/kerrizor/exclusive_methods"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ end
@@ -0,0 +1,25 @@
1
+ require_relative 'exclusive_methods/version'
2
+
3
+ module ExclusiveMethods
4
+ def exclusive_instance_methods
5
+ instance_methods - superclass.instance_methods - instance_methods_from_modules
6
+ end
7
+
8
+ def exclusive_class_methods
9
+ methods - superclass.methods - class_methods_from_modules
10
+ end
11
+
12
+
13
+ def instance_methods_from_modules
14
+ included_modules.map { |mod| mod.instance_methods }.flatten.uniq
15
+ end
16
+
17
+ def class_methods_from_modules
18
+ included_modules.map { |mod| mod.methods }.flatten.uniq
19
+ end
20
+ end
21
+
22
+
23
+ class Object
24
+ extend ExclusiveMethods
25
+ end
@@ -0,0 +1,3 @@
1
+ module ExclusiveMethods
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,21 @@
1
+ require_relative 'test_helper'
2
+
3
+ class ExclusiveMethodsTest < MiniTest::Test
4
+ describe 'A Foo' do
5
+ it "should return an array of its exclusive instance methods" do
6
+ assert_equal Foo.exclusive_instance_methods, [:bar]
7
+ end
8
+
9
+ it "should return an array of its exclusive class methods" do
10
+ assert_equal Foo.exclusive_class_methods, [:baz]
11
+ end
12
+
13
+ it "should return an array of its instance methods from modules" do
14
+ assert_includes Foo.instance_methods_from_modules, :fizz
15
+ end
16
+
17
+ it "should return an array of its class methods from modules" do
18
+ assert_includes Foo.class_methods_from_modules, :buzz
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,39 @@
1
+
2
+ require 'minitest/autorun'
3
+ require 'minitest/unit'
4
+ require 'minitest/pride'
5
+
6
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
7
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
8
+ require 'exclusive_methods'
9
+
10
+
11
+ module Bar
12
+ def fizz; end
13
+ def self.buzz; end
14
+ end
15
+
16
+ class Foo
17
+ include Bar
18
+
19
+ def bar; end
20
+ def self.baz; end
21
+ end
22
+
23
+ class MiniTest::Unit::TestCase
24
+ def assert_change(block)
25
+ before = block.call
26
+
27
+ yield
28
+
29
+ refute_equal before, block.call
30
+ end
31
+
32
+ def refute_change(block)
33
+ before = block.call
34
+
35
+ yield
36
+
37
+ assert_equal before, block.call
38
+ end
39
+ end
metadata ADDED
@@ -0,0 +1,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: exclusive_methods
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Kerri Miller
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-31 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: Adds methods to a Ruby class that return methods that are exclusive to
42
+ that class, and do not belong to its ancestors.
43
+ email:
44
+ - kerrizor@kerrizor.com
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".gitignore"
50
+ - Gemfile
51
+ - LICENSE.txt
52
+ - README.md
53
+ - Rakefile
54
+ - exclusive_methods.gemspec
55
+ - lib/exclusive_methods.rb
56
+ - lib/exclusive_methods/version.rb
57
+ - test/exclusive_methods_test.rb
58
+ - test/test_helper.rb
59
+ homepage: https://github.com/kerrizor/exclusive_methods
60
+ licenses:
61
+ - MIT
62
+ metadata: {}
63
+ post_install_message:
64
+ rdoc_options: []
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ requirements: []
78
+ rubyforge_project:
79
+ rubygems_version: 2.2.2
80
+ signing_key:
81
+ specification_version: 4
82
+ summary: Adds methods to expose methods exclusive to a class.
83
+ test_files:
84
+ - test/exclusive_methods_test.rb
85
+ - test/test_helper.rb