sleeping_king_studios-tools 0.8.0 → 1.0.0.rc.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: ec480f3a22706bc58097d0d85632d800ea2ec49994a6f1f0694e2f33ff0b3809
4
- data.tar.gz: b4422c9ec69b876a987e78f84d13c89701704ab0ed7a61737812287595a72759
3
+ metadata.gz: '08f7da019bd99db3f4ca55c4fc1011c7673418e770fc71c6703b3bfc180d68ad'
4
+ data.tar.gz: fdbac29f13f7ac6f31cb3c2bc5b6ab6cd067f89a9d781dadac0c93162cb4fc7e
5
5
  SHA512:
6
- metadata.gz: 054a259336cde5f020e7fa67e2370c3ecef621f1ca2ebdd4c0e28703887e23dbcc8178844b2b415e0fdde0ad2e60ed72040a436f009eadb4d059a5f27fafac35
7
- data.tar.gz: 4b093d9a4c59900422d0b3851b04bccefc2aa5ee2b6dbed68a083aa8b511b47e84957c6d4dc71c997b24ede623584d07293161cfa5588fbe20e27ee6897aebd7
6
+ metadata.gz: 58b8f9dd88f40cf021c5d894203a785d4397a63837bdd64a4cc635e24f551b9504f7794117a06d0f5bb62d9d43b538bd02bffb4bb4bdbd3295b6b66ca6af236b
7
+ data.tar.gz: bdd4ed20447de1a9b3d8d1db3d73f9dd230abd3cc447d23b62935267e4fe79c254b792898bbcaa38ce02044770ae1fac0d14450f817ebce16bf75ac9f61131a0
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ### 1.0.0
4
+
5
+ - Removed all deprecated code from pre-1.0 releases.
6
+
3
7
  ### 0.8.0
4
8
 
5
9
  Last minor release before 1.0.0.
@@ -0,0 +1,132 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, religion, or sexual identity
10
+ and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open, welcoming,
13
+ diverse, inclusive, and healthy community.
14
+
15
+ ## Our Standards
16
+
17
+ Examples of behavior that contributes to a positive environment for our
18
+ community include:
19
+
20
+ * Demonstrating empathy and kindness toward other people
21
+ * Being respectful of differing opinions, viewpoints, and experiences
22
+ * Giving and gracefully accepting constructive feedback
23
+ * Accepting responsibility and apologizing to those affected by our mistakes,
24
+ and learning from the experience
25
+ * Focusing on what is best not just for us as individuals, but for the
26
+ overall community
27
+
28
+ Examples of unacceptable behavior include:
29
+
30
+ * The use of sexualized language or imagery, and sexual attention or
31
+ advances of any kind
32
+ * Trolling, insulting or derogatory comments, and personal or political attacks
33
+ * Public or private harassment
34
+ * Publishing others' private information, such as a physical or email
35
+ address, without their explicit permission
36
+ * Other conduct which could reasonably be considered inappropriate in a
37
+ professional setting
38
+
39
+ ## Enforcement Responsibilities
40
+
41
+ Community leaders are responsible for clarifying and enforcing our standards of
42
+ acceptable behavior and will take appropriate and fair corrective action in
43
+ response to any behavior that they deem inappropriate, threatening, offensive,
44
+ or harmful.
45
+
46
+ Community leaders have the right and responsibility to remove, edit, or reject
47
+ comments, commits, code, wiki edits, issues, and other contributions that are
48
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
49
+ decisions when appropriate.
50
+
51
+ ## Scope
52
+
53
+ This Code of Conduct applies within all community spaces, and also applies when
54
+ an individual is officially representing the community in public spaces.
55
+ Examples of representing our community include using an official e-mail address,
56
+ posting via an official social media account, or acting as an appointed
57
+ representative at an online or offline event.
58
+
59
+ ## Enforcement
60
+
61
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
+ reported to the community leaders responsible for enforcement at
63
+ merlin@sleepingkingstudios.com.
64
+ All complaints will be reviewed and investigated promptly and fairly.
65
+
66
+ All community leaders are obligated to respect the privacy and security of the
67
+ reporter of any incident.
68
+
69
+ ## Enforcement Guidelines
70
+
71
+ Community leaders will follow these Community Impact Guidelines in determining
72
+ the consequences for any action they deem in violation of this Code of Conduct:
73
+
74
+ ### 1. Correction
75
+
76
+ **Community Impact**: Use of inappropriate language or other behavior deemed
77
+ unprofessional or unwelcome in the community.
78
+
79
+ **Consequence**: A private, written warning from community leaders, providing
80
+ clarity around the nature of the violation and an explanation of why the
81
+ behavior was inappropriate. A public apology may be requested.
82
+
83
+ ### 2. Warning
84
+
85
+ **Community Impact**: A violation through a single incident or series
86
+ of actions.
87
+
88
+ **Consequence**: A warning with consequences for continued behavior. No
89
+ interaction with the people involved, including unsolicited interaction with
90
+ those enforcing the Code of Conduct, for a specified period of time. This
91
+ includes avoiding interactions in community spaces as well as external channels
92
+ like social media. Violating these terms may lead to a temporary or
93
+ permanent ban.
94
+
95
+ ### 3. Temporary Ban
96
+
97
+ **Community Impact**: A serious violation of community standards, including
98
+ sustained inappropriate behavior.
99
+
100
+ **Consequence**: A temporary ban from any sort of interaction or public
101
+ communication with the community for a specified period of time. No public or
102
+ private interaction with the people involved, including unsolicited interaction
103
+ with those enforcing the Code of Conduct, is allowed during this period.
104
+ Violating these terms may lead to a permanent ban.
105
+
106
+ ### 4. Permanent Ban
107
+
108
+ **Community Impact**: Demonstrating a pattern of violation of community
109
+ standards, including sustained inappropriate behavior, harassment of an
110
+ individual, or aggression toward or disparagement of classes of individuals.
111
+
112
+ **Consequence**: A permanent ban from any sort of public interaction within
113
+ the community.
114
+
115
+ ## Attribution
116
+
117
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
+ version 2.0, available at
119
+ [https://www.contributor-covenant.org/version/2/0/code_of_conduct.html][v2.0].
120
+
121
+ Community Impact Guidelines were inspired by
122
+ [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
123
+
124
+ For answers to common questions about this code of conduct, see the FAQ at
125
+ [https://www.contributor-covenant.org/faq][FAQ]. Translations are available
126
+ at [https://www.contributor-covenant.org/translations][translations].
127
+
128
+ [homepage]: https://www.contributor-covenant.org
129
+ [v2.0]: https://www.contributor-covenant.org/version/2/0/code_of_conduct.html
130
+ [Mozilla CoC]: https://github.com/mozilla/diversity
131
+ [FAQ]: https://www.contributor-covenant.org/faq
132
+ [translations]: https://www.contributor-covenant.org/translations
@@ -1,24 +1,17 @@
1
1
  # Development Notes
2
2
 
3
- ## 1.0.0
4
-
5
- - Remove sleeping_king_studios/tools/all
6
- - Remove all deprecated methods and references.
7
- - Documentation pass.
8
-
9
3
  ## Future Tasks
10
4
 
11
- ### Features
12
-
13
- - HashTools::slice, ::bisect_keys
14
- - ObjectTools::apply_with_arity
15
- - ObjectTools::method_arity
16
- - Delegator#delegate, :prefix => prefix_name
17
-
18
- #### Tools
5
+ ### Tools
19
6
 
7
+ - HashTools#bisect_keys
8
+ - HashTools#slice
9
+ - ObjectTools#apply_with_arity
10
+ - ObjectTools#method_arity
20
11
  - ObjectTools#pretty - returns user-friendly string representation. :multiline option? Delegates to specific toolset implementations.
21
12
  - RegexpTools#matching_string - generates a string that matches the regular expression. Does not support advanced Regexp features.
22
13
  - RegexpTools#nonmatching_strings - generates a set of strings that do not match the regular expression.
23
- - Identity Methods
24
- - RegexpTools#regexp? - true if object is regular expression, otherwise false.
14
+
15
+ #### Identity Methods
16
+
17
+ - RegexpTools#regexp? - true if object is regular expression, otherwise false.
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  (The MIT License)
2
2
 
3
- Copyright (c) 2013-2016 Rob Smith
3
+ Copyright (c) 2013 Rob Smith
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -2,13 +2,27 @@
2
2
 
3
3
  A library of utility services and concerns to expand the functionality of core classes without polluting the global namespace.
4
4
 
5
- ## Contribute
5
+ ## About
6
6
 
7
- - https://github.com/sleepingkingstudios/sleeping_king_studios-tools
7
+ SleepingKingStudios::Tools is tested against MRI Ruby 2.5 through 3.0.
8
8
 
9
- ### A Note From The Developer
9
+ ### Documentation
10
10
 
11
- Hi, I'm Rob Smith, a Ruby Engineer and the developer of this library. I use these tools every day, but they're not just written for me. If you find this project helpful in your own work, or if you have any questions, suggestions or critiques, please feel free to get in touch! I can be reached on GitHub (see above, and feel encouraged to submit bug reports or merge requests there) or via email at `merlin@sleepingkingstudios.com`. I look forward to hearing from you!
11
+ Method and class documentation is available courtesy of RubyDoc.
12
+
13
+ Documentation is generated using [YARD](https://yardoc.org/), and can be generated locally using the `yard` gem.
14
+
15
+ ### License
16
+
17
+ SleepingKingStudios::Tools is released under the [MIT License](https://opensource.org/licenses/MIT).
18
+
19
+ ### Contribute
20
+
21
+ The canonical repository for this gem is on [GitHub](https://github.com/sleepingkingstudios/sleeping_king_studios-tasks). Community contributions are welcome - please feel free to fork or submit issues, bug reports or pull requests.
22
+
23
+ ### Code of Conduct
24
+
25
+ Please note that the `SleepingKingStudios::Tools` project is released with a [Contributor Code of Conduct](https://github.com/sleepingkingstudios/sleeping_king_studios-tools/blob/master/CODE_OF_CONDUCT.md). By contributing to this project, you agree to abide by its terms.
12
26
 
13
27
  ## Tools
14
28
 
@@ -418,19 +432,19 @@ Creates a deep copy of the object. If the object is an Array, returns a new Arra
418
432
  :name => 'Welcome to the Jungle',
419
433
  :artist => "Guns N' Roses",
420
434
  :album => 'Appetite for Destruction'
421
- }, # end hash
435
+ },
422
436
  {
423
437
  :name => 'Hells Bells',
424
438
  :artist => 'AC/DC',
425
439
  :album => 'Back in Black'
426
- }, # end hash
440
+ },
427
441
  {
428
442
  :name => "Knockin' on Heaven's Door",
429
443
  :artist => 'Bob Dylan',
430
444
  :album => 'Pat Garrett & Billy The Kid'
431
- } # end hash
432
- ] # end array
433
- } # end hash
445
+ }
446
+ ]
447
+ }
434
448
 
435
449
  copy = ObjectTools.deep_dup data
436
450
 
@@ -452,19 +466,19 @@ Performs a deep freeze of the object. If the object is an Array, freezes the arr
452
466
  :name => 'Welcome to the Jungle',
453
467
  :artist => "Guns N' Roses",
454
468
  :album => 'Appetite for Destruction'
455
- }, # end hash
469
+ },
456
470
  {
457
471
  :name => 'Hells Bells',
458
472
  :artist => 'AC/DC',
459
473
  :album => 'Back in Black'
460
- }, # end hash
474
+ },
461
475
  {
462
476
  :name => "Knockin' on Heaven's Door",
463
477
  :artist => 'Bob Dylan',
464
478
  :album => 'Pat Garrett & Billy The Kid'
465
- } # end hash
466
- ] # end array
467
- } # end hash
479
+ }
480
+ ]
481
+ }
468
482
  ObjectTools.deep_freeze(data)
469
483
 
470
484
  data.frozen?
@@ -577,7 +591,7 @@ Adds the specified number of spaces to the start of each line of the string. Def
577
591
  "The Fellowship of the Ring",
578
592
  "The Two Towers",
579
593
  "The Return of the King"
580
- ] # end titles
594
+ ]
581
595
  string = titles.join "\n"
582
596
  StringTools.indent(string, 4)
583
597
  #=> " The Fellowship of the Ring\n"\
@@ -596,7 +610,7 @@ Yields each line of the string to the provided block and combines the results in
596
610
  "The Fellowship of the Ring",
597
611
  "The Two Towers",
598
612
  "The Return of the King"
599
- ] # end titles
613
+ ]
600
614
  string = titles.join "\n"
601
615
  StringTools.map_lines(string) { |line, index| "#{index}. #{line}" }
602
616
  #=> "0. The Fellowship of the Ring\n"\
@@ -691,75 +705,6 @@ Converts a mixed-case string expression to a lowercase, underscore separated str
691
705
 
692
706
  Common objects or patterns that are useful across projects but are larger than or do not fit the functional paradigm of the tools.* pattern.
693
707
 
694
- ### Configuration
695
-
696
- require 'sleeping_king_studios/tools/toolbox/configuration'
697
-
698
- This module is now deprecated. Use a struct instead.
699
-
700
- Provides a simple DSL for defining configuration objects, which can be populated via hashes or data objects (such as a Rails configuration object).
701
-
702
- class MyGemConfig < SleepingKingStudios::Tools::Toolbox::Configuration
703
- option :template_dir
704
-
705
- namespace :serialization do
706
- option :format, :default => :json, :enum => [:json, :xml, :yaml]
707
- end # namespace
708
- end # class
709
-
710
- # Initialize with a hash.
711
- hsh = YAML.load(File.read 'path/to/config.yml')
712
- config = MyGemConfig.new(hsh)
713
-
714
- # Initialize with a data object.
715
- klass = Struct.new(:template_dir)
716
- data = klass.new('path/to/templates')
717
- config = MyGemConfig.new(data)
718
-
719
- # Retrieve data by calling methods or using hash syntax. All of the
720
- # following will return the configured value:
721
- config.serialization.format
722
- config[:serialization][:format]
723
- config['serialization']['format']
724
- config.dig(:serialization, :format)
725
- config.fetch(:serialization', {}).fetch(:format, :json)
726
-
727
- #### `::namespace`
728
-
729
- Defines an inner namespace for the configuration, which will itself be an instance of Configuration. Can be nested to any depth:
730
-
731
- class MyGemConfig < SleepingKingStudios::Tools::Toolbox::Configuration
732
- namespace :weapons do
733
- namespace :swords do
734
- namespace :upgrades do
735
- option :hilts
736
-
737
- option :tangs
738
- end # namespace
739
- end # namespace
740
- end # namespace
741
- end # class
742
-
743
- config.weapons.swords.upgrades
744
- #=> a Configuration instance, with options #hilts and #tangs.
745
-
746
- #### `::option`
747
-
748
- Defines an option, which creates an accessor and mutator method for the property. Can configure a :default (can be a value, a Proc, or the name of a
749
- method) and/or allowable values via the :enum option.
750
-
751
- class MyGemConfig < SleepingKingStudios::Tools::Toolbox::Configuration
752
- option :max_level, :default => 20
753
-
754
- option :class, :enum => %(warrior ranger elementalist monk)
755
- end # class
756
-
757
- config.max_level
758
- # Returns 20 if no configured value is set.
759
-
760
- config.class = 'necromancer'
761
- # Raises an error.
762
-
763
708
  ### ConstantMap
764
709
 
765
710
  require 'sleeping_king_studios/tools/toolbox/constant_map'
@@ -767,10 +712,12 @@ method) and/or allowable values via the :enum option.
767
712
  Provides an enumerable interface for defining a group of constants.
768
713
 
769
714
  UserRoles = ConstantMap.new(
770
- :GUEST => 'guest',
771
- :USER => 'user',
772
- :ADMIN => 'admin'
773
- ) # end constants
715
+ {
716
+ GUEST: 'guest',
717
+ USER: 'user',
718
+ ADMIN: 'admin'
719
+ }'
720
+ )
774
721
 
775
722
  UserRoles::GUEST
776
723
  #=> 'guest'
@@ -781,11 +728,27 @@ Provides an enumerable interface for defining a group of constants.
781
728
  UserRoles.all
782
729
  #=> { :GUEST => 'guest', :USER => 'user', :ADMIN => 'admin' }
783
730
 
784
- ### Delegator
731
+ ConstantMap includes `Enumerable`, with `#each` yielding the name and value of each defined constant. It also defines the following additional methods:
732
+
733
+ #### `#each_key`
734
+
735
+ Yields each defined constant name, similar to `Hash#each_key`.
736
+
737
+ #### `#each_value`
738
+
739
+ Yields each defined constant value, similar to `Hash#each_value`.
740
+
741
+ #### `#keys`
742
+
743
+ Returns an array containing the names of the defined constants, similar to `Hash#keys`.
744
+
745
+ #### `#to_h`
746
+
747
+ Also `#all`. Returns a Hash representation of the constants.
785
748
 
786
- require 'sleeping_king_studios/tools/toolbox/delegator'
749
+ #### `#values`
787
750
 
788
- This module is now deprecated. Use the stdlib `Forwardable` module instead.
751
+ Returns an array containing the values of the defined constants, similar to `Hash#values`.
789
752
 
790
753
  ### Mixin
791
754
 
@@ -5,7 +5,10 @@ require 'sleeping_king_studios/tools'
5
5
  module SleepingKingStudios::Tools
6
6
  # Tools for working with array-like enumerable objects.
7
7
  class ArrayTools < SleepingKingStudios::Tools::Base
8
+ # Expected methods that an Array-like object should implement.
8
9
  ARRAY_METHODS = %i[[] count each].freeze
10
+
11
+ # Methods that an Array-like object should *not* implement.
9
12
  OTHER_METHODS = %i[each_key each_pair].freeze
10
13
 
11
14
  class << self
@@ -182,7 +185,7 @@ module SleepingKingStudios::Tools
182
185
  # @raise ArgumentError If the first argument is not an Array-like object.
183
186
  #
184
187
  # @return [String] The formatted string.
185
- def humanize_list(ary, **options, &block) # rubocop:disable Metrics/AbcSize
188
+ def humanize_list(ary, **options, &block)
186
189
  require_array! ary
187
190
 
188
191
  return '' if ary.empty?
@@ -280,9 +283,9 @@ module SleepingKingStudios::Tools
280
283
  private
281
284
 
282
285
  def options_for_humanize_list(
286
+ size:,
283
287
  last_separator: ' and ',
284
- separator: ', ',
285
- size:
288
+ separator: ', '
286
289
  )
287
290
  return [separator, last_separator] if size < 3
288
291