method-not-implemented 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b7647ef1084811d03b48d16e1f1a558239f49386
4
+ data.tar.gz: ecea00e134a10c15fbef56c0b7a75f43f29107ce
5
+ SHA512:
6
+ metadata.gz: f23d384116186fd58b801b203014764cf7259809311fc0fb23143180da94d7e2212cc105b49434cb0adc60e75870fecee418657a45d640548f324c526fb04ff3
7
+ data.tar.gz: 862f0bef5684f98f17aabd266c19ae742f4bbc62e483621a46fb6b984a8192b2cd610f26aceb95dbf5854468ce4b6aaf24e8968537ee54c8e9610b335d8cc769
@@ -0,0 +1,6 @@
1
+ *.gem
2
+ .bundle
3
+ .ruby-version
4
+ pkg/
5
+ tmp/
6
+ /.idea/
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - 2.4.0
5
+
6
+ cache: bundler
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ # encoding: UTF-8
2
+ # frozen_string_literal: true
3
+
4
+ source 'https://rubygems.org'
5
+ gemspec
@@ -0,0 +1,23 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ method-not-implemented (1.0.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ power_assert (1.0.1)
10
+ rake (12.0.0)
11
+ test-unit (3.2.3)
12
+ power_assert
13
+
14
+ PLATFORMS
15
+ ruby
16
+
17
+ DEPENDENCIES
18
+ method-not-implemented!
19
+ rake (~> 12.0)
20
+ test-unit (~> 3.2)
21
+
22
+ BUNDLED WITH
23
+ 1.14.3
@@ -0,0 +1,42 @@
1
+ ## Adds `method_not_implemented` to every class and module in Ruby.
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/method-not-implemented.svg)](https://badge.fury.io/rb/method-not-implemented)
4
+ [![Build Status](https://travis-ci.org/yivo/method-not-implemented.svg?branch=master)](https://travis-ci.org/yivo/method-not-implemented)
5
+
6
+ ## About
7
+ This gem adds `method_not_implemented` to every class and module in Ruby.
8
+ ```ruby
9
+ class SomeBaseClass
10
+ def some_method
11
+ method_not_implemented
12
+ end
13
+ end
14
+
15
+ class SomeDerivedClass < SomeBaseClass
16
+
17
+ end
18
+ ```
19
+
20
+ If `some_method` will be invoked on instance of `SomeDerivedClass` `MethodNotImplemented: SomeDerivedClass.some_method (instance method)` will be raised.
21
+
22
+ ## Installing gem
23
+ Add to your Gemfile:
24
+ ```ruby
25
+ gem 'method-not-implemented', '~> 1.0'
26
+ ```
27
+
28
+ ## Running Tests
29
+ Install bundler:
30
+ ```bash
31
+ gem install bundler
32
+ ```
33
+
34
+ Install dependencies:
35
+ ```bash
36
+ cd method-not-implemented && bundle
37
+ ```
38
+
39
+ Run tests:
40
+ ```bash
41
+ cd method-not-implemented && bundle exec rake test
42
+ ```
@@ -0,0 +1,8 @@
1
+ # encoding: UTF-8
2
+ # frozen_string_literal: true
3
+
4
+ require 'rake/testtask'
5
+
6
+ Rake::TestTask.new { |t| t.libs << 'test' }
7
+
8
+ task default: :test
@@ -0,0 +1,22 @@
1
+ # encoding: UTF-8
2
+ # frozen_string_literal: true
3
+
4
+ class MethodNotImplemented < StandardError
5
+ VERSION = '1.0.0'
6
+
7
+ module Extension
8
+ def method_not_implemented
9
+ method = caller_locations(1,1)[0].label
10
+ message = case self
11
+ when Class, Module
12
+ "#{self.inspect}.#{method} (class or module method)"
13
+ else
14
+ "#{self.class.inspect}.#{method} (instance method)"
15
+ end
16
+
17
+ raise MethodNotImplemented, message
18
+ end
19
+ end
20
+ end
21
+
22
+ Object.include MethodNotImplemented::Extension
@@ -0,0 +1,22 @@
1
+ # encoding: UTF-8
2
+ # frozen_string_literal: true
3
+
4
+ require File.expand_path('../lib/method-not-implemented', __FILE__)
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = 'method-not-implemented'
8
+ s.version = MethodNotImplemented::VERSION
9
+ s.author = 'Yaroslav Konoplov'
10
+ s.email = 'eahome00@gmail.com'
11
+ s.summary = 'Adds method_not_implemented to every class and module in Ruby.'
12
+ s.description = 'Adds method_not_implemented to every class and module in Ruby.'
13
+ s.homepage = 'https://github.com/yivo/method-not-implemented'
14
+ s.license = 'MIT'
15
+
16
+ s.files = `git ls-files -z`.split("\x0")
17
+ s.test_files = `git ls-files -z -- {test,spec,features}/*`.split("\x0")
18
+ s.require_paths = ['lib']
19
+
20
+ s.add_development_dependency 'rake', '~> 12.0'
21
+ s.add_development_dependency 'test-unit', '~> 3.2'
22
+ end
@@ -0,0 +1,27 @@
1
+ # encoding: UTF-8
2
+ # frozen_string_literal: true
3
+
4
+ require 'test-unit'
5
+ require 'method-not-implemented'
6
+
7
+ class MethodNotImplementedTest < Test::Unit::TestCase
8
+ class Foo
9
+ def bar
10
+ method_not_implemented
11
+ end
12
+
13
+ class << self
14
+ def baz
15
+ method_not_implemented
16
+ end
17
+ end
18
+ end
19
+
20
+ def test_method_not_implemented_works_with_classes
21
+ assert_raise(MethodNotImplemented) { Foo.new.bar }
22
+ end
23
+
24
+ def test_method_not_implemented_works_with_modules
25
+ assert_raise(MethodNotImplemented) { Foo.baz }
26
+ end
27
+ end
metadata ADDED
@@ -0,0 +1,81 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: method-not-implemented
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Yaroslav Konoplov
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-03-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '12.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '12.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: test-unit
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.2'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.2'
41
+ description: Adds method_not_implemented to every class and module in Ruby.
42
+ email: eahome00@gmail.com
43
+ executables: []
44
+ extensions: []
45
+ extra_rdoc_files: []
46
+ files:
47
+ - ".gitignore"
48
+ - ".travis.yml"
49
+ - Gemfile
50
+ - Gemfile.lock
51
+ - README.md
52
+ - Rakefile
53
+ - lib/method-not-implemented.rb
54
+ - method-not-implemented.gemspec
55
+ - test/test_method_not_implemented.rb
56
+ homepage: https://github.com/yivo/method-not-implemented
57
+ licenses:
58
+ - MIT
59
+ metadata: {}
60
+ post_install_message:
61
+ rdoc_options: []
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ requirements: []
75
+ rubyforge_project:
76
+ rubygems_version: 2.6.8
77
+ signing_key:
78
+ specification_version: 4
79
+ summary: Adds method_not_implemented to every class and module in Ruby.
80
+ test_files:
81
+ - test/test_method_not_implemented.rb