core-global 0.1.2 → 0.3.0

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: 9ba04c98482953bcff1570c1b5e7ae7c837cdc2ef6d03a9b8821d5845423e5c0
4
- data.tar.gz: f254547dad6d3627e8a17ad7c3edef898f33c4743e9b669b13448727bc61f267
3
+ metadata.gz: 1a033c333e9c9734f967ebd99b29b191211634a229571023cfdf17866b9fcb3d
4
+ data.tar.gz: d8ed81721a927c652e696f6eeae63a3f9306516151204b22407cbe236734ddcf
5
5
  SHA512:
6
- metadata.gz: dae07b7348a022b5a3e57ca99154fff78ad9544ba372ba1346a4c434fa691b11a717aeac00f64f72dde37e5546eb1df189f170c4ded0244a8b08001620c186db
7
- data.tar.gz: 1215a0b83d07b88cf73e63128e1ee967859c27fd8468a21d4fdbc15c69d511c03079073659a52289e7ca4356cecf167e330518ce01e04add2fb4766c3bc3aa15
6
+ metadata.gz: e35a7a4248f7cdc331cb34e16552f19084992a22e67ce40b5481f1f4e0824ce28b2ceceb07214aa49dd35ce639a6d795a1b3a571a9855b77c95797657f0faa40
7
+ data.tar.gz: 05bce4649eaae219f7b5031e503b4a819cca778f1a471c7fd41901fd057847664b81019027faa0a1ebfc5588e62a52eece21c4dd4ec0d89475f0fd6ca032e771
data/CHANGELOG.md CHANGED
@@ -1,31 +1,45 @@
1
- ## [v0.1.2](https://github.com/metabahn/corerb/releases/tag/2021-11-02)
1
+ ## [v0.3.0](https://github.com/bryanp/corerb/releases/tag/2023-12-24)
2
+
3
+ *released on 2023-12-24*
4
+
5
+ * `dep` [#143](https://github.com/bryanp/corerb/pull/143) Deprecate `Is::*` and `Refine::*` namespaces ([bryanp](https://github.com/bryanp))
6
+ * `dep` [#135](https://github.com/bryanp/corerb/pull/135) Remove Ruby 2 support ([bryanp](https://github.com/bryanp))
7
+
8
+ ## [v0.2.0](https://github.com/bryanp/corerb/releases/tag/2022-06-02)
9
+
10
+ *released on 2022-06-02*
11
+
12
+ * `fix` [#129](https://github.com/bryanp/corerb/pull/129) Accept all arguments in prepended finalize ([bryanp](https://github.com/bryanp))
13
+ * `chg` [#118](https://github.com/bryanp/corerb/pull/118) Allow global instance builders to be overridden ([bryanp](https://github.com/bryanp))
14
+
15
+ ## [v0.1.2](https://github.com/bryanp/corerb/releases/tag/2021-11-02)
2
16
 
3
17
  *released on 2021-11-02*
4
18
 
5
- * `chg` [#97](https://github.com/metabahn/corerb/pull/97) Designate internal state with leading and trailing double underscores ([bryanp](https://github.com/bryanp))
19
+ * `chg` [#97](https://github.com/bryanp/corerb/pull/97) Designate internal state with leading and trailing double underscores ([bryanp](https://github.com/bryanp))
6
20
 
7
- ## [v0.1.0](https://github.com/metabahn/corerb/releases/tag/2021-07-07)
21
+ ## [v0.1.0](https://github.com/bryanp/corerb/releases/tag/2021-07-07)
8
22
 
9
23
  *released on 2021-07-07*
10
24
 
11
- * `chg` [#41](https://github.com/metabahn/corerb/pull/41) Drop Ruby 2.6 support from core-global ([bryanp](https://github.com/bryanp))
25
+ * `chg` [#41](https://github.com/bryanp/corerb/pull/41) Drop Ruby 2.6 support from core-global ([bryanp](https://github.com/bryanp))
12
26
 
13
- ## [v0.0.2](https://github.com/metabahn/corerb/releases/tag/2021-06-01.1)
27
+ ## [v0.0.2](https://github.com/bryanp/corerb/releases/tag/2021-06-01.1)
14
28
 
15
29
  *released on 2021-06-01*
16
30
 
17
- * `fix` [#36](https://github.com/metabahn/corerb/pull/36) Allow globalization of basic objects ([bryanp](https://github.com/bryanp))
31
+ * `fix` [#36](https://github.com/bryanp/corerb/pull/36) Allow globalization of basic objects ([bryanp](https://github.com/bryanp))
18
32
 
19
- ## [v0.0.1](https://github.com/metabahn/corerb/releases/tag/2021-06-01)
33
+ ## [v0.0.1](https://github.com/bryanp/corerb/releases/tag/2021-06-01)
20
34
 
21
35
  *released on 2021-06-01*
22
36
 
23
- * `fix` [#35](https://github.com/metabahn/corerb/pull/35) Correctly delegate method_missing in global instances ([bryanp](https://github.com/bryanp))
37
+ * `fix` [#35](https://github.com/bryanp/corerb/pull/35) Correctly delegate method_missing in global instances ([bryanp](https://github.com/bryanp))
24
38
 
25
- ## [v0.0.0](https://github.com/metabahn/corerb/releases/tag/2021-02-10)
39
+ ## [v0.0.0](https://github.com/bryanp/corerb/releases/tag/2021-02-10)
26
40
 
27
41
  *released on 2021-02-10*
28
42
 
29
- * `add` [#4](https://github.com/metabahn/corerb/pull/4) Initial core-global behavior ([bryanp](https://github.com/bryanp))
43
+ * `add` [#4](https://github.com/bryanp/corerb/pull/4) Initial core-global behavior ([bryanp](https://github.com/bryanp))
30
44
 
31
45
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Core
4
4
  module Global
5
- VERSION = "0.1.2"
5
+ VERSION = "0.3.0"
6
6
 
7
7
  def self.version
8
8
  VERSION
data/lib/core/global.rb CHANGED
@@ -1,9 +1,72 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "forwardable"
4
+ require "core/extension"
5
+
3
6
  module Core
7
+ # [public] Add a global instance to any object.
8
+ #
4
9
  module Global
5
10
  require_relative "global/version"
11
+
12
+ extend Core::Extension
13
+
14
+ extends :definition do
15
+ # [public] Build a global instance. This method can safely overrided on a global object and still be memoized.
16
+ #
17
+ def global
18
+ new
19
+ end
20
+
21
+ # [public] Reset the global instance.
22
+ #
23
+ def reset
24
+ remove_instance_variable(:@__global__) if defined?(@__global__)
25
+ end
26
+
27
+ def finalize(...)
28
+ singleton_class.def_delegators(:global, *public_instance_methods(false) - singleton_class.public_instance_methods(false))
29
+ end
30
+ end
31
+
32
+ extends :definition, prepend: true do
33
+ # [public] Return the current global instance.
34
+ #
35
+ def global
36
+ @__global__ ||= super
37
+ end
38
+
39
+ def method_added(name)
40
+ if instance_variable_defined?(:@__finalized__)
41
+ remove_instance_variable(:@__finalized__)
42
+ end
43
+
44
+ super
45
+ end
46
+
47
+ def method_missing(name, *args, &block)
48
+ unless defined?(@__finalized__)
49
+ finalize
50
+ end
51
+
52
+ if public_method_defined?(name)
53
+ global.__send__(name, *args, &block)
54
+ else
55
+ super
56
+ end
57
+ end
58
+
59
+ if Module.private_method_defined?(:ruby2_keywords)
60
+ ruby2_keywords(:method_missing)
61
+ end
62
+
63
+ def respond_to_missing?(name, *)
64
+ public_method_defined?(name) || super
65
+ end
66
+ end
67
+
68
+ applies do
69
+ singleton_class.extend(Forwardable)
70
+ end
6
71
  end
7
72
  end
8
-
9
- require_relative "../is/global"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: core-global
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bryan Powell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-02 00:00:00.000000000 Z
11
+ date: 2023-12-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: core-extension
@@ -16,16 +16,16 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.3'
19
+ version: '0.5'
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: '0.3'
26
+ version: '0.5'
27
27
  description: Patterns for responsible global state.
28
- email: bryan@metabahn.com
28
+ email: bryan@bryanp.org
29
29
  executables: []
30
30
  extensions: []
31
31
  extra_rdoc_files: []
@@ -34,8 +34,7 @@ files:
34
34
  - LICENSE
35
35
  - lib/core/global.rb
36
36
  - lib/core/global/version.rb
37
- - lib/is/global.rb
38
- homepage: https://github.com/metabahn/corerb/
37
+ homepage: https://github.com/bryanp/corerb/
39
38
  licenses:
40
39
  - MPL-2.0
41
40
  metadata: {}
@@ -47,14 +46,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
47
46
  requirements:
48
47
  - - ">="
49
48
  - !ruby/object:Gem::Version
50
- version: '2.7'
49
+ version: '3.0'
51
50
  required_rubygems_version: !ruby/object:Gem::Requirement
52
51
  requirements:
53
52
  - - ">="
54
53
  - !ruby/object:Gem::Version
55
54
  version: '0'
56
55
  requirements: []
57
- rubygems_version: 3.2.22
56
+ rubygems_version: 3.5.1
58
57
  signing_key:
59
58
  specification_version: 4
60
59
  summary: Patterns for responsible global state.
data/lib/is/global.rb DELETED
@@ -1,65 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "forwardable"
4
-
5
- require "core/extension"
6
-
7
- module Is
8
- # [public] Adds a global instance to any object.
9
- #
10
- module Global
11
- extend Is::Extension
12
-
13
- extends :definition do
14
- # [public] Return the current global instance.
15
- #
16
- def global
17
- @__global__ ||= new
18
- end
19
-
20
- # [public] Reset the global instance.
21
- #
22
- def reset
23
- remove_instance_variable(:@__global__) if defined?(@__global__)
24
- end
25
-
26
- def finalize
27
- singleton_class.def_delegators(:global, *public_instance_methods(false) - singleton_class.public_instance_methods(false))
28
- end
29
- end
30
-
31
- extends :definition, prepend: true do
32
- def method_added(name)
33
- if instance_variable_defined?(:@__finalized__)
34
- remove_instance_variable(:@__finalized__)
35
- end
36
-
37
- super
38
- end
39
-
40
- def method_missing(name, *args, &block)
41
- unless defined?(@__finalized__)
42
- finalize
43
- end
44
-
45
- if public_method_defined?(name)
46
- global.__send__(name, *args, &block)
47
- else
48
- super
49
- end
50
- end
51
-
52
- if Module.private_method_defined?(:ruby2_keywords)
53
- ruby2_keywords(:method_missing)
54
- end
55
-
56
- def respond_to_missing?(name, *)
57
- public_method_defined?(name) || super
58
- end
59
- end
60
-
61
- applies do
62
- singleton_class.extend(Forwardable)
63
- end
64
- end
65
- end