mabbre 0.0.3 → 1.0.0
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/.rubocop.yml +1 -1
- data/.travis.yml +0 -2
- data/Gemfile +5 -5
- data/Guardfile +7 -7
- data/Rakefile +1 -1
- data/lib/mabbre/interpreter.rb +2 -2
- data/lib/mabbre/version.rb +1 -1
- data/lib/mabbre.rb +0 -1
- data/mabbre.gemspec +16 -18
- data/spec/lib/mabbre/mixin_spec.rb +3 -3
- data/tasks/console.rb +4 -12
- data/tasks/coverage.rb +1 -5
- metadata +11 -14
- data/lib/mabbre/compatibility.rb +0 -49
- data/lib/mabbre/patch/object_mixin/respond_to_missing.rb +0 -36
- data/spec/lib/mabbre/patch/object_mixin/respond_to_missing_spec.rb +0 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae00b5dd2871079afc8e1a0eb53e6d7a1cef2aad
|
4
|
+
data.tar.gz: b8958e850430143ea3f149ecf3e3cb8c5f531be7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8d56b416f0efb13dc17f23a24fd445ea8d1ec4e1246c7bcc45e1843759d31c142f3014003557e6ab30d048e89deac75b22cd96bb683b3f803aa7813090b393a
|
7
|
+
data.tar.gz: 687a332f3a2373173901649cb3730f010dc544fea0f51db69c2efb973f0387bc14d24791992b49d27e5a902eec82d1549d9522da1da5aaab75a1c1ba949eeae5
|
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
@@ -3,16 +3,16 @@ gemspec
|
|
3
3
|
|
4
4
|
group :development do
|
5
5
|
gem "byebug", "~> 3.5.1"
|
6
|
-
gem "guard-rspec", "~> 4.
|
6
|
+
gem "guard-rspec", "~> 4.5.0"
|
7
7
|
gem "guard-rubocop", "~> 1.2.0"
|
8
|
-
gem "libnotify", "~> 0.
|
8
|
+
gem "libnotify", "~> 0.9.0"
|
9
9
|
gem "pry", "~> 0.10.1"
|
10
|
-
gem "rubocop", "~> 0.
|
10
|
+
gem "rubocop", "~> 0.28.0"
|
11
11
|
end
|
12
12
|
|
13
13
|
group :development, :test do
|
14
|
-
gem "codeclimate-test-reporter", "~> 0.4.
|
15
|
-
gem "rake", "~> 10.4.
|
14
|
+
gem "codeclimate-test-reporter", "~> 0.4.3"
|
15
|
+
gem "rake", "~> 10.4.2"
|
16
16
|
gem "rspec", "~> 3.1.0"
|
17
17
|
gem "simplecov", "~> 0.9.1"
|
18
18
|
end
|
data/Guardfile
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
guard :
|
2
|
-
watch(/^spec\/.+_spec\.rb$/)
|
3
|
-
watch(/^lib\/(.+)\.rb$/) {|m| "spec/lib/#{m[1]}_spec.rb" }
|
4
|
-
watch("spec/spec_helper.rb") { "spec" }
|
5
|
-
end
|
6
|
-
|
7
|
-
guard :rubocop do
|
1
|
+
guard :rubocop, all_on_start: false do
|
8
2
|
watch(/^.+\.rb$/)
|
9
3
|
watch(/^(?:.+\/)?\.rubocop\.yml$/) {|m| File.dirname(m[0]) }
|
10
4
|
watch(/^(?:.+\/)?.+\.gemspec$/)
|
11
5
|
watch(/^(?:.+\/)?(?:Gem|Rake)file$/)
|
12
6
|
end
|
7
|
+
|
8
|
+
guard :rspec, cmd: "bundle exec rspec -fd" do
|
9
|
+
watch(/^spec\/.+_spec\.rb$/)
|
10
|
+
watch(/^lib\/(.+)\.rb$/) {|m| "spec/lib/#{m[1]}_spec.rb" }
|
11
|
+
watch("spec/spec_helper.rb") { "spec" }
|
12
|
+
end
|
data/Rakefile
CHANGED
data/lib/mabbre/interpreter.rb
CHANGED
@@ -13,7 +13,7 @@ module MAbbre
|
|
13
13
|
def method_missing(name, *args)
|
14
14
|
matched = nil
|
15
15
|
|
16
|
-
if self.class.tracked_methods(MAbbre).one? {|m| matched = m if m
|
16
|
+
if self.class.tracked_methods(MAbbre).one? {|m| matched = m if m =~ /\A#{name}/ }
|
17
17
|
send(matched, *args)
|
18
18
|
else
|
19
19
|
super
|
@@ -29,7 +29,7 @@ module MAbbre
|
|
29
29
|
#
|
30
30
|
# Returns +true+ if this object responds to +name+, or whatever +super+ returns otherwise.
|
31
31
|
def respond_to_missing?(name, include_all)
|
32
|
-
self.class.tracked_methods(MAbbre).one? {|m| m
|
32
|
+
self.class.tracked_methods(MAbbre).one? {|m| m =~ /\A#{name}/ } or super
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
data/lib/mabbre/version.rb
CHANGED
data/lib/mabbre.rb
CHANGED
data/mabbre.gemspec
CHANGED
@@ -4,23 +4,21 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require "mabbre/version"
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.
|
8
|
-
spec.
|
9
|
-
spec.
|
10
|
-
spec.
|
11
|
-
spec.
|
12
|
-
spec.
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
spec.
|
19
|
-
spec.
|
20
|
-
|
21
|
-
spec.files = `git ls-files -z`.split("\x0")
|
22
|
-
spec.test_files = spec.files.grep(/^(test|spec|features)\//)
|
7
|
+
spec.required_ruby_version = ">= 1.9"
|
8
|
+
spec.name = "mabbre"
|
9
|
+
spec.version = MAbbre::VERSION
|
10
|
+
spec.authors = ["Gabriel de Oliveira"]
|
11
|
+
spec.email = ["deoliveira.gab@gmail.com"]
|
12
|
+
spec.summary = "Enable shortened method names on classes and modules."
|
13
|
+
spec.description = <<-EOS
|
14
|
+
MAbbre allows a group of methods in a Class or a Module to be accessed using an abbreviated form. These methods can be
|
15
|
+
defined anywhere within a hierarchy of inclusion and/or inheritance.
|
16
|
+
EOS
|
17
|
+
spec.homepage = "https://github.com/gdeoliveira/mabbre"
|
18
|
+
spec.license = "MIT"
|
19
|
+
spec.files = `git ls-files -z`.split("\x0")
|
20
|
+
spec.test_files = spec.files.grep(/^(test|spec|features)\//)
|
23
21
|
spec.require_paths = ["lib"]
|
24
|
-
|
25
|
-
spec.add_dependency "mtrack", "~>
|
22
|
+
spec.rdoc_options << "--title=MAbbre"
|
23
|
+
spec.add_dependency "mtrack", "~> 2.0"
|
26
24
|
end
|
@@ -6,9 +6,9 @@ describe MAbbre::Mixin do
|
|
6
6
|
describe "#allow_abbreviated" do
|
7
7
|
it "is added after extending #{described_class}" do
|
8
8
|
mod = ::Module.new
|
9
|
-
expect(mod.private_methods
|
9
|
+
expect(mod.private_methods).not_to include(:allow_abbreviated)
|
10
10
|
mod.module_eval { extend MAbbre::Mixin }
|
11
|
-
expect(mod.private_methods
|
11
|
+
expect(mod.private_methods).to include(:allow_abbreviated)
|
12
12
|
end
|
13
13
|
|
14
14
|
context "block given" do
|
@@ -125,7 +125,7 @@ describe MAbbre::Mixin do
|
|
125
125
|
subject { base_module }
|
126
126
|
|
127
127
|
it "has custom extensions as ancestors" do
|
128
|
-
expect(subject.singleton_methods
|
128
|
+
expect(subject.singleton_methods).to include(:base_extension_meth, :sub_extension_meth)
|
129
129
|
end
|
130
130
|
|
131
131
|
it "tracks methods that can be abbreviated" do
|
data/tasks/console.rb
CHANGED
@@ -14,19 +14,11 @@ task :console do
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
require "pry"
|
20
|
-
rescue LoadError
|
21
|
-
require "irb"
|
22
|
-
end
|
23
|
-
else
|
24
|
-
require "irb"
|
25
|
-
end
|
26
|
-
|
27
|
-
if defined? Pry
|
17
|
+
begin
|
18
|
+
require "pry"
|
28
19
|
Pry.start
|
29
|
-
|
20
|
+
rescue LoadError
|
21
|
+
require "irb"
|
30
22
|
ARGV.clear
|
31
23
|
IRB.start
|
32
24
|
end
|
data/tasks/coverage.rb
CHANGED
@@ -1,9 +1,5 @@
|
|
1
1
|
desc "Run tests and generate coverage report"
|
2
2
|
task :coverage do
|
3
|
-
|
4
|
-
ENV["COVERAGE"] = "true"
|
5
|
-
else
|
6
|
-
warn "Ruby version 1.9+ is needed in order to generate coverage report."
|
7
|
-
end
|
3
|
+
ENV["COVERAGE"] = "true"
|
8
4
|
Rake::Task[:spec].invoke
|
9
5
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mabbre
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gabriel de Oliveira
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mtrack
|
@@ -16,17 +16,17 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2.0'
|
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
|
-
version: '
|
27
|
-
description:
|
28
|
-
using an abbreviated form. These methods can be
|
29
|
-
of inclusion and/or inheritance.
|
26
|
+
version: '2.0'
|
27
|
+
description: |
|
28
|
+
MAbbre allows a group of methods in a Class or a Module to be accessed using an abbreviated form. These methods can be
|
29
|
+
defined anywhere within a hierarchy of inclusion and/or inheritance.
|
30
30
|
email:
|
31
31
|
- deoliveira.gab@gmail.com
|
32
32
|
executables: []
|
@@ -43,16 +43,13 @@ files:
|
|
43
43
|
- README.md
|
44
44
|
- Rakefile
|
45
45
|
- lib/mabbre.rb
|
46
|
-
- lib/mabbre/compatibility.rb
|
47
46
|
- lib/mabbre/extension.rb
|
48
47
|
- lib/mabbre/interpreter.rb
|
49
48
|
- lib/mabbre/mixin.rb
|
50
|
-
- lib/mabbre/patch/object_mixin/respond_to_missing.rb
|
51
49
|
- lib/mabbre/version.rb
|
52
50
|
- mabbre.gemspec
|
53
51
|
- spec/.rubocop.yml
|
54
52
|
- spec/lib/mabbre/mixin_spec.rb
|
55
|
-
- spec/lib/mabbre/patch/object_mixin/respond_to_missing_spec.rb
|
56
53
|
- spec/lib/mabbre/version_spec.rb
|
57
54
|
- spec/spec_helper.rb
|
58
55
|
- tasks/console.rb
|
@@ -62,14 +59,15 @@ licenses:
|
|
62
59
|
- MIT
|
63
60
|
metadata: {}
|
64
61
|
post_install_message:
|
65
|
-
rdoc_options:
|
62
|
+
rdoc_options:
|
63
|
+
- "--title=MAbbre"
|
66
64
|
require_paths:
|
67
65
|
- lib
|
68
66
|
required_ruby_version: !ruby/object:Gem::Requirement
|
69
67
|
requirements:
|
70
68
|
- - ">="
|
71
69
|
- !ruby/object:Gem::Version
|
72
|
-
version: '
|
70
|
+
version: '1.9'
|
73
71
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
72
|
requirements:
|
75
73
|
- - ">="
|
@@ -77,13 +75,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
75
|
version: '0'
|
78
76
|
requirements: []
|
79
77
|
rubyforge_project:
|
80
|
-
rubygems_version: 2.4.
|
78
|
+
rubygems_version: 2.4.5
|
81
79
|
signing_key:
|
82
80
|
specification_version: 4
|
83
81
|
summary: Enable shortened method names on classes and modules.
|
84
82
|
test_files:
|
85
83
|
- spec/.rubocop.yml
|
86
84
|
- spec/lib/mabbre/mixin_spec.rb
|
87
|
-
- spec/lib/mabbre/patch/object_mixin/respond_to_missing_spec.rb
|
88
85
|
- spec/lib/mabbre/version_spec.rb
|
89
86
|
- spec/spec_helper.rb
|
data/lib/mabbre/compatibility.rb
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
module MAbbre # rubocop:disable Style/Documentation
|
2
|
-
##
|
3
|
-
# This is a temporary module that is run when loading MAbbre in order to add patches on some Ruby
|
4
|
-
# versions/implementations. After the environment is patched it will be automatically removed.
|
5
|
-
module Compatibility
|
6
|
-
class << self
|
7
|
-
private
|
8
|
-
|
9
|
-
##
|
10
|
-
# call-seq:
|
11
|
-
# init_self() => nil
|
12
|
-
#
|
13
|
-
# This method is automatically called by this module in order to apply all patches.
|
14
|
-
#
|
15
|
-
# Returns a +nil+ value.
|
16
|
-
def init_self
|
17
|
-
check_object
|
18
|
-
nil
|
19
|
-
end
|
20
|
-
|
21
|
-
##
|
22
|
-
# call-seq:
|
23
|
-
# check_object() => Object or nil
|
24
|
-
#
|
25
|
-
# Checks all available patches for the Object class and applies the ones that are needed.
|
26
|
-
#
|
27
|
-
# Returns Object if patches were applied or +nil+ otherwise.
|
28
|
-
def check_object
|
29
|
-
OBJECT_PATCHES.each {|patch, needed| require "#{PATH_TO_OBJECT_PATCHES}/#{patch}" if needed }
|
30
|
-
Object.instance_eval { include Patch::ObjectMixin } if OBJECT_PATCHES.values.any?
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
##
|
35
|
-
# Relative path to the directory where patch files for the Object class live.
|
36
|
-
PATH_TO_OBJECT_PATCHES = "mabbre/patch/object_mixin".freeze
|
37
|
-
|
38
|
-
##
|
39
|
-
# A hash of patch names for the Object class. Each patch name has a +true+ or +false+ value assigned that represents
|
40
|
-
# if they need to be applied or not.
|
41
|
-
OBJECT_PATCHES = {
|
42
|
-
:respond_to_missing => !Object.private_instance_methods.map(&:to_sym).include?(:respond_to_missing?)
|
43
|
-
}.freeze
|
44
|
-
|
45
|
-
init_self
|
46
|
-
end
|
47
|
-
|
48
|
-
remove_const :Compatibility
|
49
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
module MAbbre
|
2
|
-
##
|
3
|
-
# Contains all compatibility patches that may be added to the environment depending on the current Ruby
|
4
|
-
# version/implementation. This module won't be defined in an environment were no patches were applied.
|
5
|
-
module Patch
|
6
|
-
##
|
7
|
-
# Contains all patches related to the Object class. The methods contained within will only be defined if they are
|
8
|
-
# needed.
|
9
|
-
module ObjectMixin
|
10
|
-
##
|
11
|
-
# call-seq:
|
12
|
-
# respond_to?(name, include_all = false) => true or false
|
13
|
-
#
|
14
|
-
# Passes +name+ and +include_all+ to +super+, and if +false+ is returned then #respond_to_missing? will be
|
15
|
-
# called.
|
16
|
-
#
|
17
|
-
# Returns +true+ if this object responds to +name+, and +false+ otherwise.
|
18
|
-
def respond_to?(name, include_all = false)
|
19
|
-
super or respond_to_missing?(name, include_all)
|
20
|
-
end
|
21
|
-
|
22
|
-
private
|
23
|
-
|
24
|
-
##
|
25
|
-
# call-seq:
|
26
|
-
# respond_to_missing?(name, include_all) => false
|
27
|
-
#
|
28
|
-
# This is used as the base implementation of #respond_to_missing?.
|
29
|
-
#
|
30
|
-
# Returns +false+ irregardless of the value of +name+ and +include_all+.
|
31
|
-
def respond_to_missing?(_name, _include_all)
|
32
|
-
false
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require "mabbre/patch/object_mixin/respond_to_missing"
|
3
|
-
|
4
|
-
describe MAbbre::Patch::ObjectMixin do
|
5
|
-
subject do
|
6
|
-
dc = described_class
|
7
|
-
Class.new.instance_eval { include dc }.new
|
8
|
-
end
|
9
|
-
|
10
|
-
describe "#respond_to?" do
|
11
|
-
it "calls #respond_to_missing? at least once" do
|
12
|
-
expect(subject).to receive(:respond_to_missing?).with(:test_method, false).at_least(:once)
|
13
|
-
subject.respond_to? :test_method
|
14
|
-
end
|
15
|
-
|
16
|
-
it "calls #respond_to_missing? at most twice" do
|
17
|
-
expect(subject).to receive(:respond_to_missing?).with(:test_method, false).at_most(:twice)
|
18
|
-
subject.respond_to? :test_method
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
describe "#respond_to_missing?" do
|
23
|
-
it "returns false" do
|
24
|
-
expect(subject.send(:respond_to_missing?, :test_method, true)).to be(false)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|