added 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +4 -1
- data/Gemfile +1 -0
- data/README.md +5 -5
- data/Rakefile +41 -0
- data/added.gemspec +2 -2
- data/lib/added/version.rb +3 -1
- metadata +6 -8
- data/.travis.yml +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ab381ed07d25dd1d54514a8d04f7e4aa73d758c2384f86495d1c45608e1f09b9
|
4
|
+
data.tar.gz: 5b0d988cf19a1bd7c675c377d7af18a156fe41b5349bd2e9fe6af8a4c092485c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2dd727228aae1c26d93b1f4a1bc18146381b8797f483915df537ecce747d68e34d09c912b09b0451f0f174f2f2459baeb0ca7279f427506ad3dab9fc7756a57
|
7
|
+
data.tar.gz: '04923996696b01ff112cf654b10638eef4820188877a162f3c932eeb7f03a547770fbdcfc897e31c00c79d495809b0e5a7024888966e84d037e00aae34a35814'
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
# Added Hook for Ruby [![[version]](https://badge.fury.io/rb/added.svg)](
|
1
|
+
# Added Hook for Ruby [![[version]](https://badge.fury.io/rb/added.svg)](https://badge.fury.io/rb/added) [![[ci]](https://github.com/janlelis/added/workflows/Test/badge.svg)](https://github.com/janlelis/added/actions?query=workflow%3ATest)
|
2
2
|
|
3
3
|
Module#added: A unified module hook to run code on all instances when adding the module.
|
4
4
|
|
5
5
|
|
6
6
|
## Warning
|
7
7
|
|
8
|
-
This is experimental
|
8
|
+
This is experimental: You should exactly know what you do, if you want to use it in production.
|
9
9
|
|
10
10
|
Besides this, I am really curious if you like the approach this gem is taking!
|
11
11
|
|
@@ -18,7 +18,7 @@ Ruby allows you to run hooks, when an module is inserted into another object:
|
|
18
18
|
* Module#included
|
19
19
|
* Module#prepended
|
20
20
|
|
21
|
-
This gem unifies all these hooks into a single `Module#added` one, which will be fired for *all* instances that the module has been added to. An example use case might be that you want to set some instance variable for all instances that include the module. There are three different
|
21
|
+
This gem unifies all these hooks into a single `Module#added` one, which will be fired for *all* instances that the module has been added to. An example use case might be that you want to set some instance variable for all instances that include the module. There are three different occasions a hook is fired:
|
22
22
|
|
23
23
|
* An object extends itself with the module -> The added hook will run for this object
|
24
24
|
* A class has included/prepended the module -> The added hook will run on newly initialized objects of this class
|
@@ -77,7 +77,7 @@ object.instance_variable_get(:@my) # => "state"
|
|
77
77
|
|
78
78
|
## JRuby Notes
|
79
79
|
|
80
|
-
This gem requires a Module#prepend implementation and must have the ObjectSpace available. As JRuby user this means you will need to run JRuby
|
80
|
+
This gem requires a Module#prepend implementation and must have the ObjectSpace available. As JRuby user this means you will need to run JRuby with the -X+O option to use this gem.
|
81
81
|
|
82
82
|
|
83
83
|
# Also See
|
@@ -87,4 +87,4 @@ This gem requires a Module#prepend implementation and must have the ObjectSpace
|
|
87
87
|
|
88
88
|
## MIT License
|
89
89
|
|
90
|
-
Copyright (C) 2015 by [Jan Lelis](
|
90
|
+
Copyright (C) 2015 by [Jan Lelis](https://janlelis.com).
|
data/Rakefile
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# # #
|
2
|
+
# Get gemspec info
|
3
|
+
|
4
|
+
gemspec_file = Dir["*.gemspec"].first
|
5
|
+
gemspec = eval File.read(gemspec_file), binding, gemspec_file
|
6
|
+
info = "#{gemspec.name} | #{gemspec.version} | " \
|
7
|
+
"#{gemspec.runtime_dependencies.size} dependencies | " \
|
8
|
+
"#{gemspec.files.size} files"
|
9
|
+
|
10
|
+
# # #
|
11
|
+
# Gem build and install task
|
12
|
+
|
13
|
+
desc info
|
14
|
+
task :gem do
|
15
|
+
puts info + "\n\n"
|
16
|
+
print " "; sh "gem build #{gemspec_file}"
|
17
|
+
FileUtils.mkdir_p "pkg"
|
18
|
+
FileUtils.mv "#{gemspec.name}-#{gemspec.version}.gem", "pkg"
|
19
|
+
puts; sh %{gem install --no-document pkg/#{gemspec.name}-#{gemspec.version}.gem}
|
20
|
+
end
|
21
|
+
|
22
|
+
# # #
|
23
|
+
# Start an IRB session with the gem loaded
|
24
|
+
|
25
|
+
desc "#{gemspec.name} | IRB"
|
26
|
+
task :irb do
|
27
|
+
sh "irb -I ./lib -r #{gemspec.name.gsub '-','/'}"
|
28
|
+
end
|
29
|
+
|
30
|
+
# # #
|
31
|
+
# Run specs
|
32
|
+
|
33
|
+
desc "#{gemspec.name} | Spec"
|
34
|
+
task :spec do
|
35
|
+
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw/
|
36
|
+
sh "for %f in (spec/\*.rb) do ruby spec/%f"
|
37
|
+
else
|
38
|
+
sh "for file in spec/*.rb; do ruby $file; done"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
task default: :spec
|
data/added.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |gem|
|
|
9
9
|
gem.description = 'Module#added: A unified module hook to run code on all instances when adding the module.'
|
10
10
|
gem.license = "MIT"
|
11
11
|
gem.authors = ["Jan Lelis"]
|
12
|
-
gem.email = "
|
12
|
+
gem.email = "hi@ruby.consulting"
|
13
13
|
gem.homepage = "https://github.com/janlelis/added"
|
14
14
|
|
15
15
|
gem.files = Dir['{**/}{.*,*}'].select { |path| File.file?(path) }
|
@@ -17,5 +17,5 @@ Gem::Specification.new do |gem|
|
|
17
17
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
18
|
gem.require_paths = ['lib']
|
19
19
|
|
20
|
-
gem.required_ruby_version = '
|
20
|
+
gem.required_ruby_version = '>= 2.0'
|
21
21
|
end
|
data/lib/added/version.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: added
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Lelis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-05 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: 'Module#added: A unified module hook to run code on all instances when
|
14
14
|
adding the module.'
|
15
|
-
email:
|
15
|
+
email: hi@ruby.consulting
|
16
16
|
executables: []
|
17
17
|
extensions: []
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
20
|
- ".gitignore"
|
21
|
-
- ".travis.yml"
|
22
21
|
- CHANGELOG.md
|
23
22
|
- Gemfile
|
24
23
|
- Gemfile.lock
|
25
24
|
- MIT-LICENSE.txt
|
26
25
|
- README.md
|
26
|
+
- Rakefile
|
27
27
|
- added.gemspec
|
28
28
|
- lib/added.rb
|
29
29
|
- lib/added/core_ext.rb
|
@@ -40,7 +40,7 @@ require_paths:
|
|
40
40
|
- lib
|
41
41
|
required_ruby_version: !ruby/object:Gem::Requirement
|
42
42
|
requirements:
|
43
|
-
- - "
|
43
|
+
- - ">="
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '2.0'
|
46
46
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
@@ -49,11 +49,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
49
49
|
- !ruby/object:Gem::Version
|
50
50
|
version: '0'
|
51
51
|
requirements: []
|
52
|
-
|
53
|
-
rubygems_version: 2.4.5
|
52
|
+
rubygems_version: 3.2.3
|
54
53
|
signing_key:
|
55
54
|
specification_version: 4
|
56
55
|
summary: Added hook.
|
57
56
|
test_files:
|
58
57
|
- spec/added_spec.rb
|
59
|
-
has_rdoc:
|
data/.travis.yml
DELETED