extensible 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 11e889c3f8a16282c1c649689923862a79b5a049
4
- data.tar.gz: fbb2b8205fe0c9ea40bb6bab6cfd1f9ec5946a92
3
+ metadata.gz: 96a4477877370a5a81563a183e4c3d6a6df6d8e0
4
+ data.tar.gz: 1d0ace25f7d5512d2705704fb9d0c53e3a8e2ddf
5
5
  SHA512:
6
- metadata.gz: c8f44fd379d9f808fbbdecda8f0c19ba878cdc0a5a71bd68a6c2d2cc02effec54dd4ea5d045e38462a783e7e0fc39eff040a560867652680112708499c189bde
7
- data.tar.gz: d2029bff28b773b95165d66365fce188704f570ced823f2a943220840a92ae94df509222314ae6f357329ed566d7bd3064b6c4fc8aa6893f88e05333c8582cb8
6
+ metadata.gz: 6ca9f26f4d9ff1c0e64591b7beb3fdec8878208b3e1058a6605965824fc54ce40631de19751462171e44e543f06cbd573efaddd3bb2869c42017663fdca91943
7
+ data.tar.gz: 254aa5b4070544f54a7e6da9d627e898bec1702248f2405f2ae8839f7ea0cdf39b2bf21abfa7be80a3a0e870dc98961214479e0e57148ea4359cdd12238005df
data/LICENSE.txt CHANGED
@@ -1,22 +1,21 @@
1
- Copyright (c) 2015 Gabriel de Oliveira
1
+ The MIT License (MIT)
2
2
 
3
- MIT License
3
+ Copyright (c) 2015 Gabriel de Oliveira
4
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:
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:
12
11
 
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
15
14
 
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.
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 CHANGED
@@ -13,11 +13,14 @@
13
13
  [gemnasium]: https://gemnasium.com/gdeoliveira/extensible#development-dependencies
14
14
  [inch-ci]: http://inch-ci.org/github/gdeoliveira/extensible
15
15
 
16
- Use Extensible on your custom extensions in order to get the following set of advantages over traditional extensions that override the `Module#extended` method directly:
16
+ Use Extensible on your custom extensions in order to get the following set of advantages over traditional extensions
17
+ that override the `Module#extended` method directly:
17
18
 
18
19
  - Calls to `super` are handled internally to ensure all your _extensible_ extensions are properly initialized.
19
- - Your _extensible_ extensions will be automatically able to become the base of other, more specific extensions while proper initialization is maintained by simply including them.
20
- - Bundle several _extensible_ extensions in a single module by including them and they will all be correctly initialized when extending the bundler module.
20
+ - Your _extensible_ extensions will be automatically able to become the base of other, more specific extensions while
21
+ proper initialization is maintained by simply including them.
22
+ - Bundle several _extensible_ extensions in a single module by including them and they will all be correctly initialized
23
+ when extending the bundler module.
21
24
 
22
25
  Specific examples for each of these scenarios can be found in the [usage](#usage) section.
23
26
 
@@ -39,15 +42,19 @@ Or install it yourself as:
39
42
 
40
43
  ## When should I use Extensible?
41
44
 
42
- You should use Extensible every time you're implementing a module that is intended to be used as an extension for a module or a class **and** that extension needs to have some initialization code.
45
+ You should use Extensible every time you're implementing a module that is intended to be used as an extension for a
46
+ module or a class **and** that extension needs to have some initialization code.
43
47
 
44
48
  In short: if you are going to override `Module#extended`, use Extensible instead.
45
49
 
46
- ## <a name="usage"></a>Usage
50
+ <a name="usage"></a>
51
+ ## Usage
47
52
 
48
53
  #### Basic
49
54
 
50
- Creating an _extensible_ extension module is, arguably, simpler than creating a traditional extension that overrides `Module#extended`. Note that we do not need to call `super` within the code block since it will be called "under the hood" _before_ the code is executed:
55
+ Creating an _extensible_ extension module is, arguably, simpler than creating a traditional extension that overrides
56
+ `Module#extended`. Note that we do not need to call `super` within the code block since it will be called "under the
57
+ hood" _before_ the code is executed:
51
58
 
52
59
  ```ruby
53
60
  module MyExtension
@@ -66,9 +73,12 @@ end #=> MyExtension has extended MyClass.
66
73
 
67
74
  #### Extending extensions
68
75
 
69
- The extensions you create using Extensible are "extensible" in the sense that you (or someone else) can use them as the base for other, more specific extensions. The best bit is you get this at no additional cost. Simply include them and extend away!
76
+ The extensions you create using Extensible are "extensible" in the sense that you (or someone else) can use them as the
77
+ base for other, more specific extensions. The best bit is you get this at no additional cost. Simply include them and
78
+ extend away!
70
79
 
71
- Suppose we have a base extension that sets an instance variable that holds the reversed name of the module or class extending it:
80
+ Suppose we have a base extension that sets an instance variable that holds the reversed name of the module or class
81
+ extending it:
72
82
 
73
83
  ```ruby
74
84
  module MyBaseExtension
@@ -79,7 +89,8 @@ module MyBaseExtension
79
89
  end
80
90
  ```
81
91
 
82
- Now we can use `MyBaseExtension` on its own, but we can also _extend_ it to, for example, create a reader method for the `@reversed_name` variable by including it on our more specific `MySubExtension`:
92
+ Now we can use `MyBaseExtension` on its own, but we can also _extend_ it to, for example, create a reader method for the
93
+ `@reversed_name` variable by including it on our more specific `MySubExtension`:
83
94
 
84
95
  ```ruby
85
96
  module MySubExtension
@@ -88,7 +99,8 @@ module MySubExtension
88
99
  end
89
100
  ```
90
101
 
91
- We can now extend `MySubExtension` ensuring that the initialization routine of `MyBaseExtension` is executed as expected:
102
+ We can now extend `MySubExtension` ensuring that the initialization routine of `MyBaseExtension` is executed as
103
+ expected:
92
104
 
93
105
  ```ruby
94
106
  class MyClass
@@ -98,13 +110,18 @@ end
98
110
  MyClass.reversed_name #=> "ssalCyM"
99
111
  ```
100
112
 
101
- Note: `MySubExtension` could have (if needed) extended Extensible to provide its own initialization routine. In this case both initialization routines (the one for `MyBaseExtension` and the one for `MySubExtension`) would have been executed when `MyClass` extended it.
113
+ Note: `MySubExtension` could have (if needed) extended Extensible to provide its own initialization routine. In this
114
+ case both initialization routines (the one for `MyBaseExtension` and the one for `MySubExtension`) would have been
115
+ executed when `MyClass` extended it.
102
116
 
103
117
  #### Bundling extensions
104
118
 
105
- Traditional extensions that override the `Module#extended` method work correctly as long as they are explicitly extended in the module or class that will ultimately use them. This can become really cumbersome really fast when you want to apply several extensions to a set of different modules or classes.
119
+ Traditional extensions that override the `Module#extended` method work correctly as long as they are explicitly extended
120
+ in the module or class that will ultimately use them. This can become really cumbersome really fast when you want to
121
+ apply several extensions to a set of different modules or classes.
106
122
 
107
- Using _extensible_ extensions you can bundle many of them within a single module, and then extend all of them at the same time by extending the bundler module.
123
+ Using _extensible_ extensions you can bundle many of them within a single module, and then extend all of them at the
124
+ same time by extending the bundler module.
108
125
 
109
126
  Suppose you have two extensions (`A` and `B`) that you want to bundle together:
110
127
 
data/extensible.gemspec CHANGED
@@ -1,23 +1,46 @@
1
1
  # coding: utf-8
2
- lib = File.expand_path("../lib", __FILE__)
2
+ lib = File.expand_path("../lib".freeze, __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "extensible/version"
4
+
5
+ require "extensible/version".freeze
5
6
 
6
7
  Gem::Specification.new do |spec|
7
- spec.required_ruby_version = ">= 1.9"
8
- spec.name = "extensible"
8
+ spec.author = "Gabriel de Oliveira".freeze
9
+ spec.files = Dir[
10
+ "*.gemspec".freeze,
11
+ "LICENSE.*".freeze,
12
+ "README.*".freeze,
13
+ "lib/**/*.rb".freeze
14
+ ]
15
+ spec.name = "extensible".freeze
16
+ spec.summary = "Ruby extensions made easy.".freeze
9
17
  spec.version = Extensible::VERSION
10
- spec.authors = ["Gabriel de Oliveira"]
11
- spec.email = ["deoliveira.gab@gmail.com"]
12
- spec.summary = "Ruby extensions made easy."
13
- spec.description = <<-EOS
18
+
19
+ spec.email = "deoliveira.gab@gmail.com".freeze
20
+ spec.homepage = "https://github.com/gdeoliveira/extensible".freeze
21
+ spec.license = "MIT".freeze
22
+
23
+ spec.description = <<-EOS.freeze
14
24
  Use Extensible on your custom extensions in order to get a set of advantages over traditional extensions that override
15
25
  the Module#extended method directly.
16
26
  EOS
17
- spec.homepage = "https://github.com/gdeoliveira/extensible"
18
- spec.license = "MIT"
19
- spec.files = `git ls-files -z`.split("\x0")
20
- spec.test_files = spec.files.grep(/^spec\//)
21
- spec.require_paths = ["lib"]
22
- spec.rdoc_options << "--title=Extensible"
27
+ spec.rdoc_options = [
28
+ "--main=README.md".freeze,
29
+ "--title=Extensible".freeze,
30
+ "LICENSE.txt".freeze,
31
+ "README.md".freeze,
32
+ "lib/".freeze
33
+ ].freeze
34
+ spec.required_ruby_version = ">= 1.9".freeze
35
+
36
+ spec.add_development_dependency "bundler".freeze, "~> 1.13.0".freeze
37
+ spec.add_development_dependency "codeclimate-test-reporter".freeze, "~> 0.6.0".freeze
38
+ spec.add_development_dependency "guard-rspec".freeze, "~> 4.7.3".freeze
39
+ spec.add_development_dependency "guard-rubocop".freeze, "~> 1.2.0".freeze
40
+ spec.add_development_dependency "io-console".freeze, "~> 0.4.6".freeze
41
+ spec.add_development_dependency "pry-byebug".freeze, "~> 3.4.0".freeze
42
+ spec.add_development_dependency "rake".freeze, "~> 11.2.2".freeze
43
+ spec.add_development_dependency "rdoc".freeze, "~> 4.2.2".freeze
44
+ spec.add_development_dependency "ruby_gntp".freeze, "~> 0.3.4".freeze
45
+ spec.add_development_dependency "simplecov".freeze, "~> 0.12.0".freeze
23
46
  end
@@ -1,10 +1,10 @@
1
- require "extensible/extension_kernel_template"
1
+ require "extensible/extension_kernel_template".freeze
2
2
 
3
- module Extensible # rubocop:disable Style/Documentation
3
+ module Extensible
4
4
  ##
5
5
  # A custom ExtensionKernelTemplate clone that is extended by Extensible to make it, well, extensible.
6
6
  ExtensionKernel = ExtensionKernelTemplate.clone.module_eval do
7
- private # rubocop:disable Style/EmptyLinesAroundAccessModifier
7
+ private
8
8
 
9
9
  def extended(submodule)
10
10
  super
@@ -1,39 +1,5 @@
1
- ##
2
- # Use Extensible on your custom extensions in order to get a set of advantages over traditional extensions that override
3
- # the <tt>Module#extended</tt> method directly. When _extending_ Extensible you will be able to define your
4
- # initialization code (similar to using <tt>Module#extended</tt>) via the when_extended method.
5
- #
6
- # module MyExtension
7
- # extend Extensible
8
- # when_extended {|m| puts "#{self} has extended #{m}." }
9
- # end
10
- #
11
- # class MyClass
12
- # extend MyExtension
13
- # end #=> MyExtension has extended MyClass.
14
- #
15
- # Extensible is, itself, extensible. This means that you will be able to extend it further or bundle it together with
16
- # other extensible modules by _including_ it in your module.
17
- #
18
- # module MyExtensibleExtension
19
- # include Extensible
20
- #
21
- # def custom_when_extended(&block)
22
- # puts "Defining initialization code..."
23
- # when_extended &block
24
- # end
25
- # end
26
- #
27
- # module MyExtension
28
- # extend MyExtensibleExtension
29
- # custom_when_extended {|m| puts "#{self} has extended #{m}." }
30
- # end #=> Defining initialization code...
31
- #
32
- # class MyClass
33
- # extend MyExtension
34
- # end #=> MyExtension has extended MyClass.
35
1
  module Extensible
36
2
  ##
37
3
  # Current version of Extensible.
38
- VERSION = "0.0.2".freeze
4
+ VERSION = "0.0.3".freeze
39
5
  end
data/lib/extensible.rb CHANGED
@@ -1,8 +1,41 @@
1
- require "extensible/constants"
2
- require "extensible/extension_kernel"
3
- require "extensible/version"
1
+ require "extensible/extension_kernel".freeze
2
+ require "extensible/version".freeze
4
3
 
5
- module Extensible # rubocop:disable Style/Documentation
4
+ ##
5
+ # Use Extensible on your custom extensions in order to get a set of advantages over traditional extensions that override
6
+ # the <tt>Module#extended</tt> method directly. When _extending_ Extensible you will be able to define your
7
+ # initialization code (similar to using <tt>Module#extended</tt>) via the when_extended method.
8
+ #
9
+ # module MyExtension
10
+ # extend Extensible
11
+ # when_extended {|m| puts "#{self} has extended #{m}." }
12
+ # end
13
+ #
14
+ # class MyClass
15
+ # extend MyExtension
16
+ # end #=> MyExtension has extended MyClass.
17
+ #
18
+ # Extensible is, itself, extensible. This means that you will be able to extend it further or bundle it together with
19
+ # other extensible modules by _including_ it in your module.
20
+ #
21
+ # module MyExtensibleExtension
22
+ # include Extensible
23
+ #
24
+ # def custom_when_extended(&block)
25
+ # puts "Defining initialization code..."
26
+ # when_extended &block
27
+ # end
28
+ # end
29
+ #
30
+ # module MyExtension
31
+ # extend MyExtensibleExtension
32
+ # custom_when_extended {|m| puts "#{self} has extended #{m}." }
33
+ # end #=> Defining initialization code...
34
+ #
35
+ # class MyClass
36
+ # extend MyExtension
37
+ # end #=> MyExtension has extended MyClass.
38
+ module Extensible
6
39
  extend ExtensionKernel
7
40
 
8
41
  private
@@ -17,13 +50,13 @@ module Extensible # rubocop:disable Style/Documentation
17
50
  # internally by Extensible.
18
51
  #
19
52
  # Returns self (this module).
20
- def when_extended(&block)
21
- fail(ArgumentError, Error::BLOCK_NOT_GIVEN) unless block_given?
53
+ def when_extended
54
+ raise LocalJumpError, "no block given".freeze unless block_given?
22
55
 
23
56
  self::ExtensionKernel.module_eval do
24
57
  define_method :extended do |submodule|
25
58
  super submodule
26
- block.call submodule
59
+ yield submodule
27
60
  self
28
61
  end
29
62
 
metadata CHANGED
@@ -1,53 +1,181 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: extensible
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
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: 2015-02-11 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2016-09-10 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.13.0
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.13.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: codeclimate-test-reporter
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.6.0
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.6.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: guard-rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 4.7.3
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 4.7.3
55
+ - !ruby/object:Gem::Dependency
56
+ name: guard-rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 1.2.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 1.2.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: io-console
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.4.6
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.4.6
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry-byebug
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 3.4.0
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 3.4.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: rake
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 11.2.2
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 11.2.2
111
+ - !ruby/object:Gem::Dependency
112
+ name: rdoc
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 4.2.2
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 4.2.2
125
+ - !ruby/object:Gem::Dependency
126
+ name: ruby_gntp
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: 0.3.4
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: 0.3.4
139
+ - !ruby/object:Gem::Dependency
140
+ name: simplecov
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: 0.12.0
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: 0.12.0
13
153
  description: |
14
154
  Use Extensible on your custom extensions in order to get a set of advantages over traditional extensions that override
15
155
  the Module#extended method directly.
16
- email:
17
- - deoliveira.gab@gmail.com
156
+ email: deoliveira.gab@gmail.com
18
157
  executables: []
19
158
  extensions: []
20
159
  extra_rdoc_files: []
21
160
  files:
22
- - ".gitignore"
23
- - ".rubocop.yml"
24
- - ".ruby-version"
25
- - ".travis.yml"
26
- - Gemfile
27
- - Guardfile
28
161
  - LICENSE.txt
29
162
  - README.md
30
- - Rakefile
31
163
  - extensible.gemspec
32
164
  - lib/extensible.rb
33
- - lib/extensible/constants.rb
34
165
  - lib/extensible/extension_kernel.rb
35
166
  - lib/extensible/extension_kernel_template.rb
36
167
  - lib/extensible/version.rb
37
- - spec/.rubocop.yml
38
- - spec/lib/extensible/constants_spec.rb
39
- - spec/lib/extensible/version_spec.rb
40
- - spec/lib/extensible_spec.rb
41
- - spec/spec_helper.rb
42
- - tasks/console.rb
43
- - tasks/coverage.rb
44
168
  homepage: https://github.com/gdeoliveira/extensible
45
169
  licenses:
46
170
  - MIT
47
171
  metadata: {}
48
172
  post_install_message:
49
173
  rdoc_options:
174
+ - "--main=README.md"
50
175
  - "--title=Extensible"
176
+ - LICENSE.txt
177
+ - README.md
178
+ - lib/
51
179
  require_paths:
52
180
  - lib
53
181
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -62,13 +190,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
62
190
  version: '0'
63
191
  requirements: []
64
192
  rubyforge_project:
65
- rubygems_version: 2.4.5
193
+ rubygems_version: 2.6.6
66
194
  signing_key:
67
195
  specification_version: 4
68
196
  summary: Ruby extensions made easy.
69
- test_files:
70
- - spec/.rubocop.yml
71
- - spec/lib/extensible/constants_spec.rb
72
- - spec/lib/extensible/version_spec.rb
73
- - spec/lib/extensible_spec.rb
74
- - spec/spec_helper.rb
197
+ test_files: []
data/.gitignore DELETED
@@ -1,16 +0,0 @@
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
15
- .buildpath
16
- .project
data/.rubocop.yml DELETED
@@ -1,10 +0,0 @@
1
- Metrics/LineLength:
2
- Max: 120
3
- Style/AndOr:
4
- EnforcedStyle: conditionals
5
- Style/HashSyntax:
6
- EnforcedStyle: ruby19
7
- Style/SpaceInsideBlockBraces:
8
- SpaceBeforeBlockParameters: false
9
- Style/StringLiterals:
10
- EnforcedStyle: double_quotes
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- 2.2.0
data/.travis.yml DELETED
@@ -1,16 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - ruby-head
4
- - 2.2
5
- - 2.1
6
- - 2.0
7
- - 1.9.3
8
- - 1.9.2
9
- - jruby-head
10
- - jruby-1.7
11
- - rbx
12
- bundler_args: "--without development"
13
- addons:
14
- code_climate:
15
- repo_token:
16
- secure: E3bOUINqN9inAqw0EsziZGyTzwThdrVrPuiRN6LQYIc7tHWkJBY0UO+tNvpj0tQcF3ViBy8Lbi26W2Fy+y0FWR163AXxQ8wu6Tu21es+sIPUxxnr/WFbVc7CEsE68ExsfNUciHHa82xnHECYaSqpR7gLHeMW7wFksdQvcnNMr38=
data/Gemfile DELETED
@@ -1,18 +0,0 @@
1
- source "https://rubygems.org"
2
- gemspec
3
-
4
- group :development do
5
- gem "byebug", "~> 3.5.1"
6
- gem "guard-rspec", "~> 4.5.0"
7
- gem "guard-rubocop", "~> 1.2.0"
8
- gem "libnotify", "~> 0.9.1"
9
- gem "pry", "~> 0.10.1"
10
- gem "rubocop", "~> 0.29.0"
11
- end
12
-
13
- group :development, :test do
14
- gem "codeclimate-test-reporter", "~> 0.4.6"
15
- gem "rake", "~> 10.4.2"
16
- gem "rspec", "~> 3.2.0"
17
- gem "simplecov", "~> 0.9.1"
18
- end
data/Guardfile DELETED
@@ -1,12 +0,0 @@
1
- guard :rubocop, all_on_start: false do
2
- watch(/^.+\.rb$/)
3
- watch(/^(?:.+\/)?\.rubocop\.yml$/) {|m| File.dirname(m[0]) }
4
- watch(/^(?:.+\/)?.+\.gemspec$/)
5
- watch(/^(?:.+\/)?(?:Gem|Rake)file$/)
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 DELETED
@@ -1,10 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
-
4
- Dir[File.join(File.dirname(__FILE__), "tasks", "**", "*.rb")].each do |file|
5
- require file
6
- end
7
-
8
- RSpec::Core::RakeTask.new(:spec)
9
-
10
- task default: :coverage
@@ -1,9 +0,0 @@
1
- module Extensible
2
- ##
3
- # Contains error message constants.
4
- module Error
5
- ##
6
- # Describes calling a method that expects a code block but isn't provided one.
7
- BLOCK_NOT_GIVEN = "code block was expected".freeze
8
- end
9
- end
data/spec/.rubocop.yml DELETED
@@ -1,4 +0,0 @@
1
- inherit_from:
2
- - ../.rubocop.yml
3
- Metrics/LineLength:
4
- Max: 140
@@ -1,7 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Extensible::Error do
4
- subject { described_class.constants.map {|c| described_class.const_get c } }
5
-
6
- it { is_expected.to all(be_frozen) }
7
- end
@@ -1,5 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Extensible::VERSION do
4
- it { is_expected.not_to be_nil }
5
- end
@@ -1,195 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Extensible do
4
- context "#when_extended" do
5
- it "raises an error if code block is not provided" do
6
- m = Module.new
7
-
8
- expect do
9
- m.module_eval do
10
- extend Extensible
11
- when_extended
12
- end
13
- end.to raise_error(ArgumentError)
14
- end
15
- end
16
-
17
- context "hierarchy" do
18
- let(:extensible_base_extension_1) do
19
- Module.new.tap do |m|
20
- m.module_eval do
21
- include Extensible
22
- end
23
- end
24
- end
25
-
26
- let(:extensible_base_extension_2) do
27
- Module.new.tap do |m|
28
- m.module_eval do
29
- include Extensible
30
- extend Extensible
31
- when_extended do |sm|
32
- sm.const_set(:EBE_2_CALLED, true)
33
- end
34
- end
35
- end
36
- end
37
-
38
- let(:extensible_sub_extension) do
39
- ebe_1 = extensible_base_extension_1
40
- ebe_2 = extensible_base_extension_2
41
- Module.new.tap do |m|
42
- m.module_eval do
43
- include ebe_1
44
- include ebe_2
45
- end
46
- end
47
- end
48
-
49
- let(:base_extension_1) do
50
- ese = extensible_sub_extension
51
- Module.new.tap do |m|
52
- m.module_eval do
53
- extend ese
54
- when_extended do |sm|
55
- sm.const_set(:BE_1_CALLED, true)
56
- end
57
- end
58
- end
59
- end
60
-
61
- let(:base_extension_2) do
62
- ebe_1 = extensible_base_extension_1
63
- Module.new.tap do |m|
64
- m.module_eval do
65
- extend ebe_1
66
- when_extended do |sm|
67
- sm.const_set(:BE_2_CALLED, true)
68
- end
69
- end
70
- end
71
- end
72
-
73
- let(:sub_extension) do
74
- be_1 = base_extension_1
75
- be_2 = base_extension_2
76
- Module.new.tap do |m|
77
- m.module_eval do
78
- include be_1
79
- include be_2
80
- end
81
- end
82
- end
83
-
84
- subject do
85
- se = sub_extension
86
- Class.new.tap do |c|
87
- c.class_eval do
88
- extend se
89
- end
90
- end
91
- end
92
-
93
- def extension_ids(mod)
94
- mod.singleton_class.ancestors.map(&:object_id)
95
- end
96
-
97
- it "adds the extensible extension kernel to all extensible extensions" do
98
- expect(extension_ids(Extensible)).to include(Extensible::ExtensionKernel.object_id)
99
- expect(extension_ids(extensible_base_extension_1)).to include(Extensible::ExtensionKernel.object_id)
100
- expect(extension_ids(extensible_base_extension_2)).to include(Extensible::ExtensionKernel.object_id)
101
- expect(extension_ids(extensible_sub_extension)).to include(Extensible::ExtensionKernel.object_id)
102
- end
103
-
104
- it "does not add the extensible extension kernel to non-extensible extensions" do
105
- expect(extension_ids(base_extension_1)).not_to include(Extensible::ExtensionKernel.object_id)
106
- expect(extension_ids(base_extension_2)).not_to include(Extensible::ExtensionKernel.object_id)
107
- expect(extension_ids(sub_extension)).not_to include(Extensible::ExtensionKernel.object_id)
108
- expect(extension_ids(subject)).not_to include(Extensible::ExtensionKernel.object_id)
109
- end
110
-
111
- it "adds the `extensible_base_extension_2` extension kernel to modules that include it" do
112
- expect(extension_ids(extensible_base_extension_2)).to include(extensible_base_extension_2::ExtensionKernel.object_id)
113
- expect(extension_ids(extensible_sub_extension)).to include(extensible_base_extension_2::ExtensionKernel.object_id)
114
- end
115
-
116
- it "does not add the `extensible_base_extension_2` extension kernel to modules that do not include it" do
117
- expect(extension_ids(Extensible)).not_to include(extensible_base_extension_2::ExtensionKernel.object_id)
118
- expect(extension_ids(extensible_base_extension_1)).not_to include(extensible_base_extension_2::ExtensionKernel.object_id)
119
- expect(extension_ids(base_extension_1)).not_to include(extensible_base_extension_2::ExtensionKernel.object_id)
120
- expect(extension_ids(base_extension_2)).not_to include(extensible_base_extension_2::ExtensionKernel.object_id)
121
- expect(extension_ids(sub_extension)).not_to include(extensible_base_extension_2::ExtensionKernel.object_id)
122
- expect(extension_ids(subject)).not_to include(extensible_base_extension_2::ExtensionKernel.object_id)
123
- end
124
-
125
- it "adds the `base_extension_1` extension kernel to modules that include it" do
126
- expect(extension_ids(base_extension_1)).to include(base_extension_1::ExtensionKernel.object_id)
127
- expect(extension_ids(sub_extension)).to include(base_extension_1::ExtensionKernel.object_id)
128
- end
129
-
130
- it "does not add the `base_extension_1` extension kernel to modules that do not include it" do
131
- expect(extension_ids(Extensible)).not_to include(base_extension_1::ExtensionKernel.object_id)
132
- expect(extension_ids(extensible_base_extension_1)).not_to include(base_extension_1::ExtensionKernel.object_id)
133
- expect(extension_ids(extensible_base_extension_2)).not_to include(base_extension_1::ExtensionKernel.object_id)
134
- expect(extension_ids(extensible_sub_extension)).not_to include(base_extension_1::ExtensionKernel.object_id)
135
- expect(extension_ids(base_extension_2)).not_to include(base_extension_1::ExtensionKernel.object_id)
136
- expect(extension_ids(subject)).not_to include(base_extension_1::ExtensionKernel.object_id)
137
- end
138
-
139
- it "adds the `base_extension_2` extension kernel to modules that include it" do
140
- expect(extension_ids(base_extension_2)).to include(base_extension_2::ExtensionKernel.object_id)
141
- expect(extension_ids(sub_extension)).to include(base_extension_2::ExtensionKernel.object_id)
142
- end
143
-
144
- it "does not add the `base_extension_2` extension kernel to modules that do not include it" do
145
- expect(extension_ids(Extensible)).not_to include(base_extension_2::ExtensionKernel.object_id)
146
- expect(extension_ids(extensible_base_extension_1)).not_to include(base_extension_2::ExtensionKernel.object_id)
147
- expect(extension_ids(extensible_base_extension_2)).not_to include(base_extension_2::ExtensionKernel.object_id)
148
- expect(extension_ids(extensible_sub_extension)).not_to include(base_extension_2::ExtensionKernel.object_id)
149
- expect(extension_ids(base_extension_1)).not_to include(base_extension_2::ExtensionKernel.object_id)
150
- expect(extension_ids(subject)).not_to include(base_extension_2::ExtensionKernel.object_id)
151
- end
152
-
153
- it "executes the `extensible_base_extension_2` extension code on modules that extend it" do
154
- expect(base_extension_1.const_defined?(:EBE_2_CALLED, false)).to be(true)
155
- end
156
-
157
- it "does not execute `extensible_base_extension_2` extension code on modules that do not extend it" do
158
- expect(Extensible.const_defined?(:EBE_2_CALLED, false)).to be(false)
159
- expect(extensible_base_extension_1.const_defined?(:EBE_2_CALLED, false)).to be(false)
160
- expect(extensible_base_extension_2.const_defined?(:EBE_2_CALLED, false)).to be(false)
161
- expect(extensible_sub_extension.const_defined?(:EBE_2_CALLED, false)).to be(false)
162
- expect(base_extension_2.const_defined?(:EBE_2_CALLED, false)).to be(false)
163
- expect(sub_extension.const_defined?(:EBE_2_CALLED, false)).to be(false)
164
- expect(subject.const_defined?(:EBE_2_CALLED, false)).to be(false)
165
- end
166
-
167
- it "executes the `base_extension_1` extension code on modules that extend it" do
168
- expect(subject.const_defined?(:BE_1_CALLED, false)).to be(true)
169
- end
170
-
171
- it "does not execute `base_extension_1` extension code on modules that do not extend it" do
172
- expect(Extensible.const_defined?(:BE_1_CALLED, false)).to be(false)
173
- expect(extensible_base_extension_1.const_defined?(:BE_1_CALLED, false)).to be(false)
174
- expect(extensible_base_extension_2.const_defined?(:BE_1_CALLED, false)).to be(false)
175
- expect(extensible_sub_extension.const_defined?(:BE_1_CALLED, false)).to be(false)
176
- expect(base_extension_1.const_defined?(:BE_1_CALLED, false)).to be(false)
177
- expect(base_extension_2.const_defined?(:BE_1_CALLED, false)).to be(false)
178
- expect(sub_extension.const_defined?(:BE_1_CALLED, false)).to be(false)
179
- end
180
-
181
- it "executes the `base_extension_2` extension code on modules that extend it" do
182
- expect(subject.const_defined?(:BE_2_CALLED, false)).to be(true)
183
- end
184
-
185
- it "does not execute `base_extension_2` extension code on modules that do not extend it" do
186
- expect(Extensible.const_defined?(:BE_2_CALLED, false)).to be(false)
187
- expect(extensible_base_extension_1.const_defined?(:BE_2_CALLED, false)).to be(false)
188
- expect(extensible_base_extension_2.const_defined?(:BE_2_CALLED, false)).to be(false)
189
- expect(extensible_sub_extension.const_defined?(:BE_2_CALLED, false)).to be(false)
190
- expect(base_extension_1.const_defined?(:BE_2_CALLED, false)).to be(false)
191
- expect(base_extension_2.const_defined?(:BE_2_CALLED, false)).to be(false)
192
- expect(sub_extension.const_defined?(:BE_2_CALLED, false)).to be(false)
193
- end
194
- end
195
- end
data/spec/spec_helper.rb DELETED
@@ -1,21 +0,0 @@
1
- unless ENV["COVERAGE"].nil?
2
- require "codeclimate-test-reporter"
3
- SimpleCov.start do
4
- formatter SimpleCov::Formatter::MultiFormatter[
5
- SimpleCov::Formatter::HTMLFormatter,
6
- CodeClimate::TestReporter::Formatter
7
- ]
8
- add_filter "/spec/"
9
- end
10
- end
11
-
12
- $LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
13
- require "extensible"
14
-
15
- RSpec.configure do |config|
16
- config.color = true
17
- config.order = :rand
18
- config.expect_with :rspec do |c|
19
- c.syntax = :expect
20
- end
21
- end
data/tasks/console.rb DELETED
@@ -1,25 +0,0 @@
1
- desc "Open a console with the #{Bundler::GemHelper.gemspec.name} gem loaded"
2
- task :console do
3
- require Bundler::GemHelper.gemspec.name
4
-
5
- if RUBY_VERSION >= "2"
6
- begin
7
- require "byebug"
8
- rescue LoadError # rubocop:disable Lint/HandleExceptions
9
- end
10
- else
11
- begin
12
- require "debugger"
13
- rescue LoadError # rubocop:disable Lint/HandleExceptions
14
- end
15
- end
16
-
17
- begin
18
- require "pry"
19
- Pry.start
20
- rescue LoadError
21
- require "irb"
22
- ARGV.clear
23
- IRB.start
24
- end
25
- end
data/tasks/coverage.rb DELETED
@@ -1,5 +0,0 @@
1
- desc "Run tests and generate coverage report"
2
- task :coverage do
3
- ENV["COVERAGE"] = "true"
4
- Rake::Task[:spec].invoke
5
- end