super_module 1.4.1 → 1.4.2

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
  SHA256:
3
- metadata.gz: 192ef511f9395d9d90d7110a154602a4c62a47c5287cfaf9662456be09c84712
4
- data.tar.gz: c4233e47af1355abff03878070f2916175aa1c399deb3a2e696b5fb18351dbef
3
+ metadata.gz: dff7a317bbcdd55b3df13bf0a29b263708a97c52044a07df8009256cc98f5b55
4
+ data.tar.gz: 961629e60023945619be8b5ed0221cb6313529670dd563bc0afd8d947edc3618
5
5
  SHA512:
6
- metadata.gz: f1cd9c156c81762b287a4eb67b1b0b1bff5a27cd0325e3baef9b0fe2da7b77a3ecfb948c21ed99c295e6c020858c0c2c0a507dd8c9c232f80b6abc07b539cf17
7
- data.tar.gz: 11973559c530a77b64f1d04bdd15964f73549f1b3a3f7fc93d694b503f35cfcacbdacbbf74602b2ea371b02d70137ab26b663756e7ab4d753bb19f0910df752f
6
+ metadata.gz: 8df9bbb3bede461f3b069d37b7305c06509cfc17eb2b31117c45cccc478a0d6db8116ff7ef3abcf5312f3dfcf51570c693bb6bdfecf818c0b36061b9d2a84923
7
+ data.tar.gz: 882725ee1e32a31fba2801c5811051259be139028d612e45b254a1ea05fc33cbbee162c7c297826fd185a66eae364485edc43399589fae0770454168eb9b2e20
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Change Log
2
2
 
3
+ ## 1.4.2
4
+
5
+ - Relax method_source gem dependency to `">= 0.8.2", "< 2.0.0"`
6
+
3
7
  ## 1.4.1
4
8
 
5
9
  - Pauses singleton method recording inside a super_module_included block to avoid replaying on submodules
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2014 Andy Maleh
1
+ Copyright (c) 2014-2024 Andy Maleh
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,9 +1,12 @@
1
- # <img src="https://raw.githubusercontent.com/AndyObtiva/super_module/master/SuperModule.jpg" alt="SuperModule" align="left" height="50" /> &nbsp; SuperModule 1.4.0
1
+ # <img src="https://raw.githubusercontent.com/AndyObtiva/super_module/master/SuperModule.jpg" alt="SuperModule" align="left" height="50" /> &nbsp; SuperModule 1.4.2
2
2
  [![Gem Version](https://badge.fury.io/rb/super_module.svg)](http://badge.fury.io/rb/super_module)
3
- [![Build Status](https://api.travis-ci.org/AndyObtiva/super_module.svg?branch=master)](https://travis-ci.org/AndyObtiva/super_module)
4
3
  [![Coverage Status](https://coveralls.io/repos/AndyObtiva/super_module/badge.svg?branch=master)](https://coveralls.io/r/AndyObtiva/super_module?branch=master)
5
4
  [![Code Climate](https://codeclimate.com/github/AndyObtiva/super_module.svg)](https://codeclimate.com/github/AndyObtiva/super_module)
6
5
 
6
+ (Note: despite the advanced version number, the idea of super_module is highly experimental and relies heavily on meta-programming, so unless you really need it, always prefer using pure Ruby modules when sufficient)
7
+
8
+ [SuperModule](https://rubygems.org/gems/super_module) enables developers to continue to use Ruby modules as first-class citizens with mixin inheritance even when wanting to inherit singleton-class methods and invocations.
9
+
7
10
  Calling [Ruby](https://www.ruby-lang.org/en/)'s [`Module#include`](http://ruby-doc.org/core-2.2.1/Module.html#method-i-include) to mix in a module does not bring in class methods by default. This can come as quite the surprise when attempting to include class methods via a module.
8
11
 
9
12
  Ruby offers one workaround in the form of implementing the hook method [`Module.included(base)`](http://ruby-doc.org/core-2.2.1/Module.html#method-i-included) [following a certain boilerplate code idiom](http://www.railstips.org/blog/archives/2009/05/15/include-vs-extend-in-ruby/). Unfortunately, it hinders code maintainability and productivity with extra unnecessary complexity, especially in production-environment projects employing many [mixins](http://en.wikipedia.org/wiki/Mixin) (e.g. modeling business domain models with composable object [traits](http://en.wikipedia.org/wiki/Trait_(computer_programming))).
@@ -12,12 +15,14 @@ Another workaround is [`ActiveSupport::Concern`](http://api.rubyonrails.org/clas
12
15
 
13
16
  But do not fear, [SuperModule](https://rubygems.org/gems/super_module) comes to the rescue! By declaring your module as a SuperModule, it will simply behave as one would expect and automatically include class methods along with instance methods, without any further work needed.
14
17
 
15
- Used in my other project: [Glimmer](https://github.com/AndyObtiva/Glimmer) (Ruby Desktop GUI Library)
18
+ Used in my other project: [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt) (JRuby Desktop Development GUI Framework)
19
+
20
+ Works in both [Ruby](https://www.ruby-lang.org) and [JRuby](https://www.jruby.org).
16
21
 
17
22
  ## Introductory Comparison
18
23
 
19
24
  To introduce [SuperModule](https://rubygems.org/gems/super_module), here is a comparison of three different approaches for writing a
20
- <code>UserIdentifiable</code> module, which includes ActiveModel::Model module as an in-memory alternative to ActiveRecord::Base superclass (Side-note: ActiveModel::Model is not needed when extending ActiveRecord::Base to connect to database.)
25
+ `UserIdentifiable` module, which includes ActiveModel::Model module as an in-memory alternative to `ActiveRecord::Base` superclass.
21
26
 
22
27
  #### 1) [self.included(base)](http://ruby-doc.org/core-2.2.1/Module.html#method-i-included)
23
28
 
@@ -71,7 +76,7 @@ module UserIdentifiable
71
76
  end
72
77
  ```
73
78
 
74
- A step forward that addresses the boiler-plate repetitive code concern, but is otherwise really just lipstick on a pig. To explain more, developer problem solving and creativity flow is still disrupted by having to think about the lower-level mechanism of running code on inclusion (using `included`) and structuring class methods in an extra sub-module (`ClassMethods`) instead of simply declaring class methods like they normally would in Ruby and staying focused on the task at hand.
79
+ A step forward that addresses the boiler-plate repetitive code concern, but is otherwise no more than putting a band-aid on the problem. To explain more, developer problem solving and creativity flow is still disrupted by having to think about the lower-level mechanism of running code on inclusion (using `included`) and structuring class methods in an extra sub-module (`ClassMethods`) instead of simply declaring class methods like they normally would in Ruby and staying focused on the task at hand.
75
80
 
76
81
  #### 3) [SuperModule](https://github.com/AndyObtiva/super_module)
77
82
 
@@ -98,13 +103,15 @@ As a result, [SuperModule](https://rubygems.org/gems/super_module) collapses the
98
103
 
99
104
  In other words, [SuperModule](https://rubygems.org/gems/super_module) furthers Ruby's goal of making programmers happy.
100
105
 
106
+ P.S. this library intentionally avoids bad techniques like "eval" of entire module body since they do not maintain Module mixin inheritance support. SuperModule supports full Ruby module mixin inheritance as it does not change it, yet only adds automation for singleton-class method inheritance on top of it (via surgical class_eval instead of full eval). SuperModule in fact encourages developers to continue to rely on basic Ruby code like `include SuperModule`.
107
+
101
108
  ## Instructions
102
109
 
103
110
  #### 1) Install and require gem
104
111
 
105
112
  <b>Using [Bundler](http://bundler.io/)</b>
106
113
 
107
- Add the following to Gemfile: <pre>gem 'super_module', '1.4.1'</pre>
114
+ Add the following to Gemfile: <pre>gem 'super_module', '1.4.2'</pre>
108
115
 
109
116
  And run the following command: <pre>bundle</pre>
110
117
 
@@ -371,7 +378,7 @@ puts V1::FakeExtraSummarizedActiveRecord.fake_extra
371
378
 
372
379
  ## Limitations
373
380
 
374
- 1) [SuperModule](https://rubygems.org/gems/super_module) by definition has been designed to be used only in the initial code declaration of a module, not later mixing or re-opening of a module.
381
+ [SuperModule](https://rubygems.org/gems/super_module) by definition has been designed to be used only in the initial code declaration of a module, not later mixing or re-opening of a module.
375
382
 
376
383
  ## Change Log
377
384
 
@@ -382,11 +389,10 @@ puts V1::FakeExtraSummarizedActiveRecord.fake_extra
382
389
  [SuperModule](https://rubygems.org/gems/super_module) is written in a very clean and maintainable test-first approach, so you are welcome to read through the code on GitHub for more in-depth details:
383
390
  https://github.com/AndyObtiva/super_module
384
391
 
385
- The library is quite new and can use all the feedback and help it can get. So, please do not hesitate to add comments if you have any, and please fork [the project on GitHub](https://github.com/AndyObtiva/super_module#fork-destination-box) in order to [make contributions via Pull Requests](https://github.com/AndyObtiva/super_module/pulls).
392
+ The library is quite novel and can use all the feedback and help it can get. So, please do not hesitate to add comments if you have any, and please fork [the project on GitHub](https://github.com/AndyObtiva/super_module#fork-destination-box) in order to [make contributions via Pull Requests](https://github.com/AndyObtiva/super_module/pulls).
386
393
 
387
394
  ## Articles, Publications, and Blog Posts
388
395
  * 2015-04-05 - [Ruby Weekly](http://rubyweekly.com): [Issue 240](http://rubyweekly.com/issues/240)
389
- * 2015-03-27 - [AirPair](http://www.airpair.com) Article: [Step aside ActiveSupport::Concern. SuperModule is the new sheriff in town!](https://www.airpair.com/ruby/posts/step-aside-activesupportconcern-supermodule-is-the-new-sheriff-in-town)
390
396
  * 2014-03-27 - [Code Painter](http://andymaleh.blogspot.com) Blog Post: [Ruby SuperModule Comes To The Rescue!!](http://andymaleh.blogspot.ca/2014/03/ruby-supermodule-comes-to-rescue.html)
391
397
 
392
398
  ## TODO
@@ -395,5 +401,4 @@ None
395
401
 
396
402
  ## Copyright
397
403
 
398
- Copyright (c) 2014-2020 Andy Maleh. See LICENSE.txt for
399
- further details.
404
+ Copyright (c) 2014-2024 Andy Maleh. See [LICENSE.txt](LICENSE.txt) for further details.
data/TODO.md ADDED
@@ -0,0 +1,32 @@
1
+ # TODO
2
+
3
+ - Make replay of class method invocations optional (allow for a basic use case of simply including a module with class methods)
4
+ - Replay class level attributes on classes
5
+ - Fix issue with class methods including a method matching name with instance methods
6
+ - Fix issue with class method alias as per details below
7
+
8
+ ```ruby
9
+ require 'glimmer/error'
10
+
11
+ module Glimmer
12
+ module UI
13
+ module CustomShell
14
+ include SuperModule
15
+ include Glimmer::UI::CustomWidget
16
+
17
+ class << self
18
+ attr_reader :launched_custom_shell
19
+ alias launched_custom_window launched_custom_shell
20
+ ```
21
+
22
+ ```
23
+ [DEVELOPMENT MODE] (detected /Users/andymaleh/code/glimmer-dsl-swt/lib/glimmer-dsl-swt.rb)
24
+ MethodSource::SourceNotFoundError: Could not locate source for launched_custom_window!
25
+ source_helper at /Users/andymaleh/.rvm/gems/jruby-9.2.14.0@glimmer-dsl-swt/gems/method_source-1.0.0/lib/method_source.rb:24
26
+ source at /Users/andymaleh/.rvm/gems/jruby-9.2.14.0@glimmer-dsl-swt/gems/method_source-1.0.0/lib/method_source.rb:110
27
+ __build_singleton_method_body_source at /Users/andymaleh/.rvm/gems/jruby-9.2.14.0@glimmer-dsl-swt/gems/super_module-1.4.1/lib/super_module/v1/singleton_method_definition_store.rb:74
28
+ __singleton_method_body at /Users/andymaleh/.rvm/gems/jruby-9.2.14.0@glimmer-dsl-swt/gems/super_module-1.4.1/lib/super_module/v1/singleton_method_definition_store.rb:85
29
+ singleton_method_added at /Users/andymaleh/.rvm/gems/jruby-9.2.14.0@glimmer-dsl-swt/gems/super_module-1.4.1/lib/super_module/v1/singleton_method_definition_store.rb:100
30
+ alias_method at org/jruby/RubyModule.java:3228
31
+ singleton class at /Users/andymaleh/code/glimmer-dsl-swt/lib/glimmer/ui/custom_shell.rb:32
32
+ ```
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.4.1
1
+ 1.4.2
data/lib/super_module.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # SuperModule allows defining class methods and method invocations the same way a super class does without using def included(base).
2
2
  #
3
3
  # Author:: Andy Maleh
4
- # Copyright:: Copyright (c) 2014-2015 Andy Maleh
4
+ # Copyright:: Copyright (c) 2014-2024 Andy Maleh
5
5
  # License:: MIT License
6
6
 
7
7
  # This module allows defining class methods and method invocations the same way a super class does without using def included(base).
data/super_module.gemspec CHANGED
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: super_module 1.4.1 ruby lib
5
+ # stub: super_module 1.4.2 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "super_module".freeze
9
- s.version = "1.4.1"
9
+ s.version = "1.4.2"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
13
13
  s.authors = ["Andy Maleh".freeze]
14
- s.date = "2020-04-23"
14
+ s.date = "2024-07-28"
15
15
  s.description = "SuperModule allows defining class methods and method invocations the same way a super class does without using def included(base). This also succeeds ActiveSupport::Concern by offering lighter syntax".freeze
16
16
  s.extra_rdoc_files = [
17
17
  "CHANGELOG.md",
@@ -24,6 +24,7 @@ Gem::Specification.new do |s|
24
24
  "LICENSE.txt",
25
25
  "README.md",
26
26
  "SuperModule.jpg",
27
+ "TODO.md",
27
28
  "VERSION",
28
29
  "lib/super_module.rb",
29
30
  "lib/super_module/v1.rb",
@@ -39,44 +40,31 @@ Gem::Specification.new do |s|
39
40
  ]
40
41
  s.homepage = "http://github.com/AndyObtiva/super_module".freeze
41
42
  s.licenses = ["MIT".freeze]
42
- s.rubygems_version = "3.0.8".freeze
43
+ s.rubygems_version = "3.3.5".freeze
43
44
  s.summary = "SuperModule allows defining class methods and method invocations the same way a super class does without using def included(base). This also succeeds ActiveSupport::Concern by offering lighter syntax".freeze
44
45
 
45
46
  if s.respond_to? :specification_version then
46
47
  s.specification_version = 4
48
+ end
47
49
 
48
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
49
- s.add_runtime_dependency(%q<method_source>.freeze, [">= 0.8.2", "< 1.1.0"])
50
- s.add_development_dependency(%q<jeweler>.freeze, ["~> 2.3.0"])
51
- s.add_development_dependency(%q<rdoc>.freeze, ["~> 4.2.0"])
52
- s.add_development_dependency(%q<rspec>.freeze, ["~> 3.2.0"])
53
- s.add_development_dependency(%q<puts_debuggerer>.freeze, ["~> 0.8.1"])
54
- s.add_development_dependency(%q<rake>.freeze, ["~> 10.4.2"])
55
- s.add_development_dependency(%q<rack>.freeze, ["~> 1.6.5"])
56
- s.add_development_dependency(%q<nokogiri>.freeze, ["~> 1.6.8.1"])
57
- s.add_development_dependency(%q<tins>.freeze, ["~> 1.6.0"])
58
- s.add_development_dependency(%q<term-ansicolor>.freeze, ["~> 1.3.2"])
59
- else
60
- s.add_dependency(%q<method_source>.freeze, [">= 0.8.2", "< 1.1.0"])
61
- s.add_dependency(%q<jeweler>.freeze, ["~> 2.3.0"])
62
- s.add_dependency(%q<rdoc>.freeze, ["~> 4.2.0"])
63
- s.add_dependency(%q<rspec>.freeze, ["~> 3.2.0"])
64
- s.add_dependency(%q<puts_debuggerer>.freeze, ["~> 0.8.1"])
65
- s.add_dependency(%q<rake>.freeze, ["~> 10.4.2"])
66
- s.add_dependency(%q<rack>.freeze, ["~> 1.6.5"])
67
- s.add_dependency(%q<nokogiri>.freeze, ["~> 1.6.8.1"])
68
- s.add_dependency(%q<tins>.freeze, ["~> 1.6.0"])
69
- s.add_dependency(%q<term-ansicolor>.freeze, ["~> 1.3.2"])
70
- end
50
+ if s.respond_to? :add_runtime_dependency then
51
+ s.add_runtime_dependency(%q<method_source>.freeze, [">= 0.8.2", "< 2.0.0"])
52
+ s.add_development_dependency(%q<jeweler>.freeze, ["~> 2.3.0"])
53
+ s.add_development_dependency(%q<rdoc>.freeze, ["~> 4.2.0"])
54
+ s.add_development_dependency(%q<rspec>.freeze, ["~> 3.2.0"])
55
+ s.add_development_dependency(%q<puts_debuggerer>.freeze, ["> 0.8.1"])
56
+ s.add_development_dependency(%q<rake>.freeze, ["~> 10.4.2"])
57
+ s.add_development_dependency(%q<rack>.freeze, ["~> 1.6.5"])
58
+ s.add_development_dependency(%q<tins>.freeze, ["~> 1.6.0"])
59
+ s.add_development_dependency(%q<term-ansicolor>.freeze, ["~> 1.3.2"])
71
60
  else
72
- s.add_dependency(%q<method_source>.freeze, [">= 0.8.2", "< 1.1.0"])
61
+ s.add_dependency(%q<method_source>.freeze, [">= 0.8.2", "< 2.0.0"])
73
62
  s.add_dependency(%q<jeweler>.freeze, ["~> 2.3.0"])
74
63
  s.add_dependency(%q<rdoc>.freeze, ["~> 4.2.0"])
75
64
  s.add_dependency(%q<rspec>.freeze, ["~> 3.2.0"])
76
- s.add_dependency(%q<puts_debuggerer>.freeze, ["~> 0.8.1"])
65
+ s.add_dependency(%q<puts_debuggerer>.freeze, ["> 0.8.1"])
77
66
  s.add_dependency(%q<rake>.freeze, ["~> 10.4.2"])
78
67
  s.add_dependency(%q<rack>.freeze, ["~> 1.6.5"])
79
- s.add_dependency(%q<nokogiri>.freeze, ["~> 1.6.8.1"])
80
68
  s.add_dependency(%q<tins>.freeze, ["~> 1.6.0"])
81
69
  s.add_dependency(%q<term-ansicolor>.freeze, ["~> 1.3.2"])
82
70
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: super_module
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Maleh
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-23 00:00:00.000000000 Z
11
+ date: 2024-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: method_source
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: 0.8.2
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: 1.1.0
22
+ version: 2.0.0
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: 0.8.2
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: 1.1.0
32
+ version: 2.0.0
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: jeweler
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -76,14 +76,14 @@ dependencies:
76
76
  name: puts_debuggerer
77
77
  requirement: !ruby/object:Gem::Requirement
78
78
  requirements:
79
- - - "~>"
79
+ - - ">"
80
80
  - !ruby/object:Gem::Version
81
81
  version: 0.8.1
82
82
  type: :development
83
83
  prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
85
85
  requirements:
86
- - - "~>"
86
+ - - ">"
87
87
  - !ruby/object:Gem::Version
88
88
  version: 0.8.1
89
89
  - !ruby/object:Gem::Dependency
@@ -114,20 +114,6 @@ dependencies:
114
114
  - - "~>"
115
115
  - !ruby/object:Gem::Version
116
116
  version: 1.6.5
117
- - !ruby/object:Gem::Dependency
118
- name: nokogiri
119
- requirement: !ruby/object:Gem::Requirement
120
- requirements:
121
- - - "~>"
122
- - !ruby/object:Gem::Version
123
- version: 1.6.8.1
124
- type: :development
125
- prerelease: false
126
- version_requirements: !ruby/object:Gem::Requirement
127
- requirements:
128
- - - "~>"
129
- - !ruby/object:Gem::Version
130
- version: 1.6.8.1
131
117
  - !ruby/object:Gem::Dependency
132
118
  name: tins
133
119
  requirement: !ruby/object:Gem::Requirement
@@ -159,7 +145,7 @@ dependencies:
159
145
  description: SuperModule allows defining class methods and method invocations the
160
146
  same way a super class does without using def included(base). This also succeeds
161
147
  ActiveSupport::Concern by offering lighter syntax
162
- email:
148
+ email:
163
149
  executables: []
164
150
  extensions: []
165
151
  extra_rdoc_files:
@@ -172,6 +158,7 @@ files:
172
158
  - LICENSE.txt
173
159
  - README.md
174
160
  - SuperModule.jpg
161
+ - TODO.md
175
162
  - VERSION
176
163
  - lib/super_module.rb
177
164
  - lib/super_module/v1.rb
@@ -188,7 +175,7 @@ homepage: http://github.com/AndyObtiva/super_module
188
175
  licenses:
189
176
  - MIT
190
177
  metadata: {}
191
- post_install_message:
178
+ post_install_message:
192
179
  rdoc_options: []
193
180
  require_paths:
194
181
  - lib
@@ -203,8 +190,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
203
190
  - !ruby/object:Gem::Version
204
191
  version: '0'
205
192
  requirements: []
206
- rubygems_version: 3.0.8
207
- signing_key:
193
+ rubygems_version: 3.3.5
194
+ signing_key:
208
195
  specification_version: 4
209
196
  summary: SuperModule allows defining class methods and method invocations the same
210
197
  way a super class does without using def included(base). This also succeeds ActiveSupport::Concern