mixins 0.1.0.pre.20250527171116 → 0.1.0.pre.20250529105050
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
- checksums.yaml.gz.sig +0 -0
- data/README.md +2 -1
- data/lib/mixins/data_utilities.rb +5 -2
- data/lib/mixins/datadir.rb +26 -9
- data/lib/mixins/delegation.rb +15 -15
- data/lib/mixins/hooks.rb +15 -15
- data/lib/mixins/inspection.rb +6 -0
- data.tar.gz.sig +0 -0
- metadata +4 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e93930af24f01a0da060c8b7d39817f2a12dcde5d9b2057cf34f1c1851d624c3
|
4
|
+
data.tar.gz: 1c553f62f349fc8e97c5508efb00250f5b99333f36f5cfbc8f9a031029c637b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a6dd68c2d5fc51d37816506520c6af967a822b5ac114975277080f78b9b5b76f48c64b489c19060b8c33f11690685e5b1c55f6a4872e8dfc1993cde05d7c773
|
7
|
+
data.tar.gz: 9a47fe11cf6223ddb354da6cee0bbb9a9f594b1c1acd9dc4ba6680e0af6302c88b792d6c1a92cb5203c908c801f415df698e272e2ab05e9c299e4e71b8d51182
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/README.md
CHANGED
@@ -54,11 +54,12 @@ This will install dependencies, and do any other necessary setup for development
|
|
54
54
|
## Authors
|
55
55
|
|
56
56
|
- Michael Granger <ged@faeriemud.org>
|
57
|
+
- Mahlon E. Smith <mahlon@martini.nu>
|
57
58
|
|
58
59
|
|
59
60
|
## License
|
60
61
|
|
61
|
-
Copyright (c) 2025, Michael Granger
|
62
|
+
Copyright (c) 2025, Michael Granger and Mahlon E. Smith
|
62
63
|
All rights reserved.
|
63
64
|
|
64
65
|
Redistribution and use in source and binary forms, with or without
|
@@ -8,8 +8,11 @@ require 'mixins' unless defined?( Mixins )
|
|
8
8
|
# A collection of miscellaneous functions that are useful for manipulating
|
9
9
|
# complex data structures.
|
10
10
|
#
|
11
|
-
#
|
12
|
-
#
|
11
|
+
# include Mixins::DataUtilities
|
12
|
+
# newhash = deep_copy( oldhash )
|
13
|
+
#
|
14
|
+
# # or called as a module function
|
15
|
+
# newhash = Mixins::DataUtilities.deep_copy( oldhash )
|
13
16
|
#
|
14
17
|
module Mixins::DataUtilities
|
15
18
|
|
data/lib/mixins/datadir.rb
CHANGED
@@ -6,19 +6,35 @@ require 'rubygems'
|
|
6
6
|
require 'mixins' unless defined?( Mixins )
|
7
7
|
|
8
8
|
|
9
|
-
#
|
10
|
-
#
|
9
|
+
# Adds a #data_dir method and a DATA_DIR constant to extended objects. These
|
10
|
+
# will be set to the `Pathname` to the data directory distributed with a gem of the
|
11
|
+
# name derived from the `#name` of the extended object. Prefers environmental
|
11
12
|
# override, Gem path, then local filesystem pathing.
|
12
13
|
#
|
13
14
|
# This can also be called manually if the including class name doesn't
|
14
15
|
# match the gem, or something else esoteric.
|
15
16
|
#
|
16
|
-
#
|
17
|
+
# require 'mixins'
|
18
|
+
#
|
19
|
+
# class Acme
|
20
|
+
# extend Mixins::Datadir
|
21
|
+
# end
|
22
|
+
#
|
23
|
+
# # When loading from checked-out source
|
24
|
+
# Rhizos.data_dir
|
25
|
+
# # => #<Pathname:../data/acme>
|
26
|
+
#
|
27
|
+
# # With ACME_DATADIR=/path/to/data set in the environment before Ruby starts:
|
28
|
+
# Rhizos.data_dir
|
29
|
+
# # => #<Pathname:/path/to/data>
|
30
|
+
#
|
31
|
+
# # When installed via gem
|
32
|
+
# Rhizos.data_dir
|
33
|
+
# # => #<Pathname:/path/to/lib/ruby/gems/3.4.0/gems/acme-1.0.0/data/acme>
|
17
34
|
#
|
18
35
|
module Mixins::Datadir
|
19
36
|
|
20
|
-
### Extend hook: Set the
|
21
|
-
### class.
|
37
|
+
### Extend hook: Set up the `data_dir` accessor and the `DATA_DIR` constant
|
22
38
|
###
|
23
39
|
def self::extended( obj )
|
24
40
|
name = obj.name.downcase.gsub( '::', '-' )
|
@@ -30,10 +46,11 @@ module Mixins::Datadir
|
|
30
46
|
end
|
31
47
|
|
32
48
|
|
33
|
-
### Return a pathname object for the
|
34
|
-
###
|
35
|
-
###
|
36
|
-
###
|
49
|
+
### Return a pathname object for the gem data directory. Use the `<gemname>_DATADIR`
|
50
|
+
### environment variable if it's set, or the data directory of the loaded gem if
|
51
|
+
### there is one. If neither of those are set, fall back to a relative path of
|
52
|
+
### `../../data/<gemname>`. You can override which environment variable is used for
|
53
|
+
### the override by setting +env+.
|
37
54
|
###
|
38
55
|
def self::find_datadir( gemname, env: nil )
|
39
56
|
unless env
|
data/lib/mixins/delegation.rb
CHANGED
@@ -10,18 +10,18 @@ module Mixins::Delegation
|
|
10
10
|
### Define the given +delegated_methods+ as delegators to the like-named method
|
11
11
|
### of the return value of the +delegate_method+.
|
12
12
|
###
|
13
|
-
###
|
14
|
-
###
|
13
|
+
### class MyClass
|
14
|
+
### extend Mixins::Delegation
|
15
15
|
###
|
16
|
-
###
|
17
|
-
###
|
18
|
-
###
|
19
|
-
###
|
16
|
+
### # Delegate the #bound?, #err, and #result2error methods to the connection
|
17
|
+
### # object returned by the #connection method. This allows the connection
|
18
|
+
### # to still be loaded on demand/overridden/etc.
|
19
|
+
### def_method_delegators :connection, :bound?, :err, :result2error
|
20
20
|
###
|
21
|
-
###
|
22
|
-
###
|
23
|
-
###
|
24
|
-
###
|
21
|
+
### def connection
|
22
|
+
### @connection ||= self.connect
|
23
|
+
### end
|
24
|
+
### end
|
25
25
|
###
|
26
26
|
def def_method_delegators( delegate_method, *delegated_methods )
|
27
27
|
delegated_methods.each do |name|
|
@@ -35,13 +35,13 @@ module Mixins::Delegation
|
|
35
35
|
### of the specified +ivar+. This is pretty much identical with how 'Forwardable'
|
36
36
|
### from the stdlib does delegation, but it's reimplemented here for consistency.
|
37
37
|
###
|
38
|
-
###
|
39
|
-
###
|
38
|
+
### class MyClass
|
39
|
+
### extend Mixins::Delegation
|
40
40
|
###
|
41
|
-
###
|
42
|
-
###
|
41
|
+
### # Delegate the #each method to the @collection ivar
|
42
|
+
### def_ivar_delegators :@collection, :each
|
43
43
|
###
|
44
|
-
###
|
44
|
+
### end
|
45
45
|
###
|
46
46
|
def def_ivar_delegators( ivar, *delegated_methods )
|
47
47
|
delegated_methods.each do |name|
|
data/lib/mixins/hooks.rb
CHANGED
@@ -5,24 +5,24 @@ require 'mixins' unless defined?( Mixins )
|
|
5
5
|
|
6
6
|
# Methods for declaring hook methods.
|
7
7
|
#
|
8
|
-
#
|
9
|
-
#
|
8
|
+
# class MyClass
|
9
|
+
# extend Mixins::Hooks
|
10
10
|
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
11
|
+
# define_hook :before_fork
|
12
|
+
# define_hook :after_fork
|
13
|
+
# end
|
14
14
|
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
15
|
+
# MyClass.before_fork do
|
16
|
+
# @socket.close
|
17
|
+
# end
|
18
|
+
# MyClass.after_fork do
|
19
|
+
# @socket = Socket.new
|
20
|
+
# end
|
21
21
|
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
22
|
+
# MyClass.run_before_fork_hook
|
23
|
+
# fork do
|
24
|
+
# MyClass.run_after_fork_hook
|
25
|
+
# end
|
26
26
|
#
|
27
27
|
#
|
28
28
|
module Mixins::Hooks
|
data/lib/mixins/inspection.rb
CHANGED
@@ -4,6 +4,12 @@ require 'mixins' unless defined?( Mixins )
|
|
4
4
|
|
5
5
|
|
6
6
|
# An extensible #inspect.
|
7
|
+
#
|
8
|
+
# This adds an overloaded #inspect method to including classes that provides
|
9
|
+
# a way to easily extend the default #inspect output. To add your own output to
|
10
|
+
# the body of the inspected object, implement the #inspect_details method and
|
11
|
+
# return your desired output from it. By default it returns the empty string, which
|
12
|
+
# will cause #inspect to use the default output.
|
7
13
|
module Mixins::Inspection
|
8
14
|
|
9
15
|
### Return a human-readable representation of the object suitable for debugging.
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mixins
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.pre.
|
4
|
+
version: 0.1.0.pre.20250529105050
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Granger
|
8
|
+
- Mahlon E. Smith
|
8
9
|
bindir: bin
|
9
10
|
cert_chain:
|
10
11
|
- |
|
@@ -34,7 +35,7 @@ cert_chain:
|
|
34
35
|
8qAqdfV+4u6Huu1KzAuDQCheyEyISsLST37sU/irV3czV6BiFipWag1XiJciRT3A
|
35
36
|
wZqCfTNVHTdtsCbfdA1DsA3RdG2iEH3TOHzv1Rqzqh4=
|
36
37
|
-----END CERTIFICATE-----
|
37
|
-
date: 2025-05-
|
38
|
+
date: 2025-05-29 00:00:00.000000000 Z
|
38
39
|
dependencies:
|
39
40
|
- !ruby/object:Gem::Dependency
|
40
41
|
name: rake-deveiate
|
@@ -55,6 +56,7 @@ description: This is a collection of zero-dependency mixins. They’re intended
|
|
55
56
|
dependencies.
|
56
57
|
email:
|
57
58
|
- ged@faeriemud.org
|
59
|
+
- mahlon@martini.nu
|
58
60
|
executables: []
|
59
61
|
extensions: []
|
60
62
|
extra_rdoc_files: []
|
metadata.gz.sig
CHANGED
Binary file
|