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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 931a539b8bc837e347f9e8daaaa3bbf457f48e4c320512be024bc591852f6ddd
4
- data.tar.gz: 94ae6c7269ce07c2578499e51da76641b2b4df11caa5f76bc4dbd691ae61d43e
3
+ metadata.gz: e93930af24f01a0da060c8b7d39817f2a12dcde5d9b2057cf34f1c1851d624c3
4
+ data.tar.gz: 1c553f62f349fc8e97c5508efb00250f5b99333f36f5cfbc8f9a031029c637b7
5
5
  SHA512:
6
- metadata.gz: 25a3c87aa1e640ecc6f9b05c48717434d184a0987b35b78e38c19c5c57b399e2f63be87be3239e56f01800bd17dadefe79dfaabf0cad9b3e4274513f473fe2fa
7
- data.tar.gz: 56b6973f4de6917808a36e134575fe30c125f3ac6a9e03f3b507f4b2cae7c8b42ae40d032500d8c8e7f01d106c94811945e2dbd775ca70a2951eba9e141ae239
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
- # include Ravn::DataUtilities
12
- # newhash = deep_copy( oldhash )
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
 
@@ -6,19 +6,35 @@ require 'rubygems'
6
6
  require 'mixins' unless defined?( Mixins )
7
7
 
8
8
 
9
- # When extended in a class, automatically set the path to a DATA_DIR
10
- # constant, derived from the class name. Prefers environmental
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
- # DATA_DIR is a Pathname object.
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 DATA_DIR constant in the extending
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 extended class DATA_DIR. This
34
- ### allows for the DATA_DIR constant to be used transparently between
35
- ### development (local checkout) and production (gem installation)
36
- ### environments.
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
@@ -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
- ### class MyClass
14
- ### extend Strelka::Delegation
13
+ ### class MyClass
14
+ ### extend Mixins::Delegation
15
15
  ###
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
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
- ### def connection
22
- ### @connection ||= self.connect
23
- ### end
24
- ### end
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
- ### class MyClass
39
- ### extend Strelka::Delegation
38
+ ### class MyClass
39
+ ### extend Mixins::Delegation
40
40
  ###
41
- ### # Delegate the #each method to the @collection ivar
42
- ### def_ivar_delegators :@collection, :each
41
+ ### # Delegate the #each method to the @collection ivar
42
+ ### def_ivar_delegators :@collection, :each
43
43
  ###
44
- ### end
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
- # class MyClass
9
- # extend Mixins::Hooks
8
+ # class MyClass
9
+ # extend Mixins::Hooks
10
10
  #
11
- # define_hook :before_fork
12
- # define_hook :after_fork
13
- # end
11
+ # define_hook :before_fork
12
+ # define_hook :after_fork
13
+ # end
14
14
  #
15
- # MyClass.before_fork do
16
- # @socket.close
17
- # end
18
- # MyClass.after_fork do
19
- # @socket = Socket.new
20
- # end
15
+ # MyClass.before_fork do
16
+ # @socket.close
17
+ # end
18
+ # MyClass.after_fork do
19
+ # @socket = Socket.new
20
+ # end
21
21
  #
22
- # MyClass.run_before_fork_hook
23
- # fork do
24
- # MyClass.run_after_fork_hook
25
- # end
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
@@ -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.20250527171116
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-27 00:00:00.000000000 Z
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