trick_bag 0.68.0 → 0.70.0

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
- SHA1:
3
- metadata.gz: 59ec06de448c4ccb3f3cd3966fcdc855cb602ac5
4
- data.tar.gz: 67da903f678ed62aae6d7e0ba4d84441fe6a837a
2
+ SHA256:
3
+ metadata.gz: 251ade42cdcce7b7e2dca8d4294a2b0438b08a7f4e178be3963c6943d5a44c63
4
+ data.tar.gz: '0794dfdbb741473db1c183e252efd3cbe353aa2440869d829768b96c256be2c9'
5
5
  SHA512:
6
- metadata.gz: b8919fe6998b064c515dd6440474327691558c72c0755e93337d1e6c066fce99a6436610fe15651a71e6964ceb94b1daf785f225eaf3c2f38cb7dcb45f4c6906
7
- data.tar.gz: a488a53c4369a98e6adf563e07b8f60d758726f7299aed2e6da47b6366caed364e4fbc57d7c059d9db499a09c36b4338aa71e8247852ac04fcc742116e364dcb
6
+ metadata.gz: 48a7a3cf28009050d3299515d921a35ba8449a223b09ef9fa144763981947f427abece315dcbbc5489e594d81cbcd6309a46a151545bc77ea9c2e3089e4a83db
7
+ data.tar.gz: 5757543d00078251e4172d5282d8ddd8a88143f6447cc5bc50ec57a72d5e8e0c88246c93ff47ff825b8736303966a535994df404aaf34b205ca99d81f1a5bc5d
@@ -0,0 +1,39 @@
1
+ name: Push Gem
2
+
3
+ on:
4
+ workflow_dispatch:
5
+
6
+ permissions:
7
+ contents: read
8
+
9
+ jobs:
10
+ push:
11
+ if: github.repository == 'keithrbennett/trick_bag'
12
+ runs-on: ubuntu-latest
13
+
14
+ permissions:
15
+ contents: write
16
+ id-token: write
17
+
18
+ steps:
19
+ # Set up
20
+ - name: Harden Runner
21
+ uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
22
+ with:
23
+ disable-sudo: true
24
+ egress-policy: block
25
+ allowed-endpoints: >
26
+ github.com:443
27
+ index.rubygems.org:443
28
+ objects.githubusercontent.com:443
29
+ rubygems.org:443
30
+
31
+ - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
32
+ - name: Set up Ruby
33
+ uses: ruby/setup-ruby@a2bbe5b1b236842c1cb7dd11e8e3b51e0a616acc # v1.202.0
34
+ with:
35
+ bundler-cache: true
36
+ ruby-version: ruby
37
+
38
+ # Release
39
+ - uses: rubygems/release-gem@612653d273a73bdae1df8453e090060bb4db5f31 # v1
data/.travis.yml CHANGED
@@ -7,9 +7,8 @@ before_install:
7
7
 
8
8
 
9
9
  rvm:
10
- - 2.4.2
11
- - 2.0.0
12
- - jruby-1.7.26
13
- - jruby-9.1.9.0
10
+ - 2.6.2
11
+ - 2.4.5
12
+ - jruby-head
14
13
 
15
14
  script: "bundle exec rspec spec"
data/LICENSE.txt CHANGED
@@ -1,22 +1,201 @@
1
- Copyright (c) 2014 Keith Bennett
2
-
3
- MIT License
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2019 Bennett Business Solutions, Inc.
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ ![logo](logo/trickbag-logo-horizontal-color.png)
2
+
1
3
  [![Build Status](https://travis-ci.org/keithrbennett/trick_bag.svg?branch=master)](https://travis-ci.org/keithrbennett/trick_bag)
2
4
 
3
5
  # TrickBag
@@ -175,6 +177,10 @@ This means that if you like you can easily copy single methods or files from the
175
177
  your code base to eliminate a dependency on this gem. If you do this, then I suggest you include an
176
178
  attribution to this gem so that future developers can consult it for fixes and enhancements.
177
179
 
180
+ ## Logo
181
+
182
+ Logo designed and generously contributed by Anhar Ismail (Github: [@anharismail](https://github.com/anharismail), Twitter: [@aizenanhar](https://twitter.com/aizenanhar)).
183
+
178
184
 
179
185
  ## Contributing
180
186
 
data/RELEASE_NOTES.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## v0.70.0
2
+
3
+ * Use gem exec configure_trusted_publisher rubygem to restrict gem pushing.
4
+
5
+ ## v0.69.0
6
+
7
+ In BufferedEnumerable, rename create_with_lambdas to create_with_callables. Create alias so old name still works.
8
+
9
+
1
10
  ## v0.68.0
2
11
 
3
12
  * Add Filesystem.running_as_script?
@@ -1,3 +1,9 @@
1
+ # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2
+ # IMPORTANT: MOST OF THE FUNCTIONALITY OF THIS MODULE HAS BEEN PROVIDED IN
3
+ # THE RUBY 2.3+ RUNTIME IN THE FORM OF THE dig METHOD ON HASHES AND ARRAYS.
4
+ # USING dig IS RECOMMENDED UNLESS YOU NEED A FEATURE OF THIS MODULE NOT SUPPORTED BY IT.
5
+ # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6
+ #
1
7
  # Supports access to nested hashes, arrays, etc., with a string instead of multiple []'s.
2
8
  # (e.g. 'myhostname.interfaces.0' instead of ['myhostname']['interfaces'][0])
3
9
  #
@@ -8,10 +8,10 @@ module Enumerables
8
8
  # fetches them in chunks.
9
9
  #
10
10
  # This class knows nothing about how to fetch anything; that behavior is provided
11
- # by either subclassing this class, or calling .create_with_lambdas and passing
12
- # a lambda that knows how to do that.
11
+ # by either subclassing this class, or calling .create_with_callables and passing
12
+ # a callable that knows how to do that.
13
13
  #
14
- # Also supported is an optional fetch notification, a method or lambda that will
14
+ # Also supported is an optional fetch notification, a method or callable that will
15
15
  # be called whenever a fetch is done. This can be useful to update counters,
16
16
  # provide user feedback (e.g. a progress bar), etc.
17
17
  #
@@ -19,11 +19,10 @@ module Enumerables
19
19
  # one immediately after another, and the responses can be collected as a group,
20
20
  # for improved performance.
21
21
  #
22
- # The fetch method and fetcher lambda modify the instance's data array directly,
23
- # to avoid the need to allow the lambda to modify the data array reference,
24
- # needlessly copying arrays,
25
- # and to eliminate the need for garbage collecting many array objects
26
- # (though the latter is rarely important).
22
+ # The fetch method and fetcher callable modify the instance's data array directly,
23
+ # to avoid the need to allow the callable to modify the data array reference,
24
+ # needlessly copying arrays, and to eliminate the need for garbage collecting
25
+ # many array objects (though the latter is rarely important).
27
26
  class BufferedEnumerable
28
27
 
29
28
  include Enumerable
@@ -36,24 +35,31 @@ class BufferedEnumerable
36
35
  attr_access :protected, :protected, :data
37
36
  attr_access :public, :private, :chunk_count, :fetch_count, :yield_count
38
37
 
38
+ class NoFetcherError < RuntimeError; end
39
39
 
40
- # Creates an instance with lambdas for fetch and fetch notify behaviors.
40
+
41
+ # Creates an instance with callables for fetch and fetch notify behaviors.
42
+ # Callables are usually lambdas but can be any object responding to the method name `call`.
41
43
  # @param chunk_size the maximum number of objects to be buffered
42
- # @param fetcher lambda to be called to fetch to fill the buffer
43
- # @param fetch_notifier lambda to be called to when a fetch is done
44
- def self.create_with_lambdas(chunk_size, fetcher, fetch_notifier = nil)
44
+ # @param fetcher callable to be called to fetch to fill the buffer
45
+ # @param fetch_notifier callable to be called to when a fetch is done
46
+ # in case the caller wants to receive notification, update counters, etc.
47
+ # It's passed the array of objects just fetched, whose size may be
48
+ # less than chunk size.
49
+ def self.create_with_callables(chunk_size, fetcher, fetch_notifier = nil)
45
50
  instance = self.new(chunk_size)
46
51
  instance.fetcher = fetcher
47
52
  instance.fetch_notifier = fetch_notifier
48
53
  instance
49
54
  end
50
55
 
51
- # @param fetcher lambda to be called to fetch to fill the buffer
56
+
57
+ class << self
58
+ alias_method :create_with_lambdas, :create_with_callables
59
+ end
60
+
61
+
52
62
  # @param chunk_size the maximum number of objects to be buffered
53
- # @param fetch_notifier lambda to be called to when a fetch is done
54
- # in case the caller wants to receive notification, update counters, etc.
55
- # It's passed the array of objects just fetched, whose size may be
56
- # less than chunk size.
57
63
  def initialize(chunk_size)
58
64
  @chunk_size = chunk_size
59
65
  @data = []
@@ -63,14 +69,18 @@ class BufferedEnumerable
63
69
  end
64
70
 
65
71
 
66
- # Unless you use self.create_with_lambdas to create your instance,
72
+ # Unless you use self.create_with_callables to create your instance,
67
73
  # you'll need to override this method in your subclass.
68
74
  def fetch
69
- fetcher.(data, chunk_size) if fetcher
75
+ if fetcher
76
+ fetcher.(data, chunk_size)
77
+ else
78
+ raise NoFetcherError.new
79
+ end
70
80
  end
71
81
 
72
82
 
73
- # Unless you use self.create_with_lambdas to create your instance,
83
+ # Unless you use self.create_with_callables to create your instance,
74
84
  # you'll need to override this method in your subclass.
75
85
  def fetch_notify
76
86
  fetch_notifier.(data) if fetch_notifier
@@ -101,7 +111,6 @@ class BufferedEnumerable
101
111
  yield(object_to_yield)
102
112
  end
103
113
  end
104
-
105
114
  end
106
115
  end
107
116
  end
@@ -51,7 +51,7 @@ class CompoundEnumerable
51
51
  # Permissible values are [:yields_arrays, :yields_hashes].
52
52
  def initialize(mode, keys, *enumerables)
53
53
 
54
- validate_inputs = ->do
54
+ validate_inputs = -> do
55
55
  raise ArgumentError.new("Mode must be either :yields_arrays or :yields_hashes") unless [:yields_arrays, :yields_hashes].include?(mode)
56
56
  raise ArgumentError.new("Keys not provided") if mode == :yields_hashes && (! keys.is_a?(Array))
57
57
  raise ArgumentError.new("No enumerables provided") if enumerables.empty?
@@ -6,16 +6,14 @@ module Filesystem
6
6
  # @return true if the passed file is being run as a script, else false
7
7
  # @param __file__ - !!! __FILE__ must be passed as the __file__ argument for this to work correctly !!!
8
8
  #
9
+ # When the file's behavior needs to differ when running as a script and _not_ running as a script,
10
+ # this method can be called to report which of the two states it is.
11
+ #
9
12
  # Sometimes we want to see if a given file is being run as a script, as opposed to loaded
10
13
  # by other Ruby code. For example, the script at https://github.com/keithrbennett/macwifi/blob/master/bin/mac-wifi
11
14
  # is normally run as a script (either by running the file directly, or by running the executable's
12
15
  # binstub installed by the gem), but it can also be loaded so that the model can be used by custom code.
13
- #
14
- # When the file's behavior needs to differ when running as a script and _not_ running as a script,
15
- # this method can be called to report which of the two states it is.
16
- #
17
- # An example of differing behavior is also in the case of `mac-wifi`. When run as a script,
18
- # it parses the command line and executes a task, sending text to stdout.
16
+ # When run as a script, it parses the command line and executes a task, sending text to stdout.
19
17
  def running_as_script?(__file__)
20
18
 
21
19
  # Here is some sample state, when running a file as a gem executable:
@@ -36,7 +34,8 @@ module Filesystem
36
34
  basename = File.basename($0)
37
35
  gem_paths.any? do |path|
38
36
  ($0 == File.join(path, 'bin', basename)) \
39
- && (path == File.expand_path(File.join(__file__, '..', '..', '..', '..')))
37
+ && \
38
+ (path == File.expand_path(File.join(__file__, '..', '..', '..', '..')))
40
39
  end
41
40
  end
42
41
  end
@@ -4,28 +4,28 @@ module TrickBag
4
4
  module Io
5
5
  module TempFiles
6
6
 
7
- module_function
7
+ module_function
8
8
 
9
- # For the easy creation and deletion of a temp file populated with text,
10
- # wrapped around the code block you provide.
11
- #
12
- # @param text the text to write to the temporary file
13
- # @param file_prefix optional prefix for the temporary file's name
14
- # @yield filespec of the temporary file
15
- def file_containing(text, file_prefix = '')
16
- raise "This method must be called with a code block." unless block_given?
9
+ # For the easy creation and deletion of a temp file populated with text,
10
+ # wrapped around the code block you provide.
11
+ #
12
+ # @param text the text to write to the temporary file
13
+ # @param file_prefix optional prefix for the temporary file's name
14
+ # @yield filespec of the temporary file
15
+ def file_containing(text, file_prefix = '')
16
+ raise "This method must be called with a code block." unless block_given?
17
17
 
18
- filespec = nil
19
- begin
20
- Tempfile.open(file_prefix) do |file|
21
- file << text
22
- filespec = file.path
23
- end
24
- yield(filespec)
25
- ensure
26
- File.delete filespec if filespec && File.exist?(filespec)
18
+ filespec = nil
19
+ begin
20
+ Tempfile.open(file_prefix) do |file|
21
+ file << text
22
+ filespec = file.path
27
23
  end
24
+ yield(filespec)
25
+ ensure
26
+ File.delete(filespec) if filespec && File.exist?(filespec)
28
27
  end
29
28
  end
30
29
  end
31
30
  end
31
+ end
@@ -1,8 +1,6 @@
1
1
  module TrickBag
2
2
  module Io
3
3
 
4
- # Provides an updatable and customizable status/information line in a terminal,
5
- # typically used to display progress.
6
4
  # Updates the terminal line with text, erasing the original content and displaying at the same place.
7
5
  # Uses ANSI escape sequences for cursor positioning and clearing
8
6
  # (see http://www.oldlinux.org/Linux.old/Ref-docs/ASCII/ANSI%20Escape%20Sequences.htm).
@@ -116,7 +116,9 @@ class SshOutputReader
116
116
  end
117
117
 
118
118
 
119
-
119
+ # This is an eample of use of the class that will be run if the file is run explicitly
120
+ # i.e.: ruby ssh_output_reader.rb
121
+ # This should be moved somewhere else.
120
122
  if $0 == __FILE__
121
123
 
122
124
  Thread.abort_on_exception = true
@@ -147,6 +149,8 @@ echo 3
147
149
  sleep 1
148
150
  echo 4'
149
151
 
152
+ # TODO: Clean this up!
153
+
150
154
  # reader = SshOutputReader.new('localhost', command)
151
155
  # reader.run
152
156
  # puts "All reader stdout:\n" + reader.all_stdout
@@ -62,8 +62,8 @@ module Timing
62
62
  text_generator = ->() do
63
63
  now = Time.now
64
64
  elapsed = now - start_time
65
- to_go = end_time - now
66
- '%9.3f %9.3f' % [elapsed, to_go]
65
+ remaining = end_time - now
66
+ '%9.3f %9.3f' % [elapsed, remaining]
67
67
  end
68
68
  status_updater = ::TrickBag::Io::TextModeStatusUpdater.new(text_generator, output_stream)
69
69
 
@@ -1,3 +1,3 @@
1
1
  module TrickBag
2
- VERSION = '0.68.0'
2
+ VERSION = '0.70.0'
3
3
  end
data/logo/logo.md ADDED
@@ -0,0 +1,41 @@
1
+ Many thanks to @anharismail for these logos!
2
+
3
+ ## Logo Image Files
4
+
5
+ #### trickbag-logo-horizontal-color.png
6
+ ![h-color](trickbag-logo-horizontal-color.png)
7
+
8
+ #### trickbag-logo-horizontal-black.png
9
+ ![h-black](trickbag-logo-horizontal-black.png)
10
+
11
+ #### trickbag-logo-horizontal-white.png
12
+
13
+ (White is invisible on this page.)
14
+
15
+ ![h-white](trickbag-logo-horizontal-white.png)
16
+
17
+
18
+ #### trickbag-logo-vertical-color.png
19
+ ![v-color](trickbag-logo-vertical-color.png)
20
+
21
+ #### trickbag-logo-vertical-black.png
22
+ ![v-black](trickbag-logo-vertical-black.png)
23
+
24
+ #### trickbag-logo-vertical-white.png
25
+
26
+ (White is invisible on this page.)
27
+
28
+ ![v-white](trickbag-logo-vertical-white.png)
29
+
30
+
31
+ #### trickbag-logomark-color.png
32
+ ![v-color](trickbag-logomark-color.png)
33
+
34
+ #### trickbag-logomark-black.png
35
+ ![v-black](trickbag-logomark-black.png)
36
+
37
+ #### trickbag-logomark-white.png
38
+
39
+ (White is invisible on this page.)
40
+
41
+ ![v-white](trickbag-logomark-white.png)
Binary file
Binary file
Binary file
@@ -6,7 +6,7 @@ module Enumerables
6
6
 
7
7
  describe BufferedEnumerable do
8
8
 
9
- context 'when created with lambdas' do
9
+ context 'when created with callables' do
10
10
  # Returns an object that returns chunks of incrementing integers.
11
11
  let(:fetcher) do
12
12
  object = 0
@@ -27,19 +27,32 @@ module Enumerables
27
27
  object_count += fetched_objects.size
28
28
  end
29
29
 
30
- e = BufferedEnumerable.create_with_lambdas(4, fetcher, fetch_notifier).to_enum
30
+ e = BufferedEnumerable.create_with_callables(4, fetcher, fetch_notifier).to_enum
31
31
  (1..10).each { |n| expect(e.next).to eq(n) }
32
32
  expect(chunk_fetch_calls).to eq(3)
33
33
  expect(object_count).to eq(12)
34
34
  end
35
35
 
36
- specify 'create_with_lambdas can be called without specifying a fetch_notifier' do
36
+ specify 'create_with_callables can be called without specifying a fetch_notifier' do
37
37
  be = nil
38
- f1 = -> { be = BufferedEnumerable.create_with_lambdas(4, fetcher).to_enum }
38
+ f1 = -> { be = BufferedEnumerable.create_with_callables(4, fetcher).to_enum }
39
39
  expect(f1).not_to raise_error
40
40
  f2 = -> { (1..10).each { be.next } }
41
- expect(f2).not_to raise_error
42
41
  end
42
+
43
+ specify 'create_with_callables *cannot* be called without specifying a fetcher' do
44
+ be = nil
45
+ f1 = -> { be = BufferedEnumerable.create_with_callables(4, nil).to_enum }
46
+ expect(f1).not_to raise_error
47
+ f2 = -> { be.next }
48
+ expect(f2).to raise_error(TrickBag::Enumerables::BufferedEnumerable::NoFetcherError)
49
+ end
50
+ end
51
+
52
+
53
+ specify 'create with old method name create_with_lambdas still works' do
54
+ buffered_enumerable = BufferedEnumerable.create_with_lambdas(4, ->() {}, ->() {})
55
+ expect(buffered_enumerable.class).to eq(BufferedEnumerable)
43
56
  end
44
57
 
45
58
 
@@ -46,7 +46,7 @@ end
46
46
 
47
47
  context 'private_attr_reader' do
48
48
 
49
- fn_create_class = ->do
49
+ fn_create_class = -> do
50
50
  class ClassPatchTestClass
51
51
  extend Classes
52
52
  private_attr_reader :foo
@@ -65,7 +65,7 @@ end
65
65
 
66
66
  context 'private_attr_writer' do
67
67
 
68
- fn_create_class = ->do
68
+ fn_create_class = -> do
69
69
  class ClassPatchTestClass
70
70
  extend Classes
71
71
  private_attr_writer :foo
@@ -82,7 +82,7 @@ end
82
82
 
83
83
  context 'private_attr_accessor' do
84
84
 
85
- fn_create_class = ->do
85
+ fn_create_class = -> do
86
86
  class ClassPatchTestClass
87
87
 
88
88
  extend Classes
@@ -109,7 +109,7 @@ end
109
109
 
110
110
  context 'attr_access(:public, :private, :foo)' do
111
111
 
112
- fn_create_class = ->do
112
+ fn_create_class = -> do
113
113
  class ClassPatchTestClass
114
114
 
115
115
  extend Classes
@@ -138,7 +138,7 @@ end
138
138
 
139
139
  context 'attr_access(:private, :none, :foo)' do
140
140
 
141
- fn_create_class = ->do
141
+ fn_create_class = -> do
142
142
  class ClassPatchTestClass
143
143
  extend Classes
144
144
  attr_access :private, :none, :foo
data/trick_bag.gemspec CHANGED
@@ -18,22 +18,18 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency "os", '~> 0'
21
+ spec.add_dependency "os", '~> 1.1'
22
22
  spec.add_dependency "diffy", '~> 3.0'
23
23
 
24
24
 
25
- if RUBY_VERSION.split('.').first.to_i >= 2
26
- spec.add_dependency 'net-ssh'
27
- else
28
- spec.add_dependency 'net-ssh', '= 2.9.2'
29
- end
25
+ spec.add_dependency 'net-ssh'
30
26
 
31
- spec.add_development_dependency "bundler", "~> 1.3"
32
- spec.add_development_dependency "rake", '~> 10.1'
33
- spec.add_development_dependency "rspec", '~> 3.0'
27
+ spec.add_development_dependency "bundler"
28
+ spec.add_development_dependency "rake", "~> 13.0"
29
+ spec.add_development_dependency "rspec", '~> 3.11'
34
30
 
35
31
  unless /java/ === RUBY_PLATFORM
36
- spec.add_development_dependency 'pry', '~> 0.10'
37
- spec.add_development_dependency 'pry-byebug', '~> 2.0' if RUBY_VERSION >= '2'
32
+ spec.add_development_dependency 'pry', '~> 0.13'
33
+ spec.add_development_dependency 'pry-byebug', '~> 3.9'
38
34
  end
39
35
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trick_bag
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.68.0
4
+ version: 0.70.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Keith Bennett
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-01 00:00:00.000000000 Z
11
+ date: 2024-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: os
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '1.1'
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'
26
+ version: '1.1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: diffy
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -56,72 +56,72 @@ dependencies:
56
56
  name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '1.3'
61
+ version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: '1.3'
68
+ version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rake
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '10.1'
75
+ version: '13.0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '10.1'
82
+ version: '13.0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rspec
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '3.0'
89
+ version: '3.11'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '3.0'
96
+ version: '3.11'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: pry
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '0.10'
103
+ version: '0.13'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '0.10'
110
+ version: '0.13'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: pry-byebug
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '2.0'
117
+ version: '3.9'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '2.0'
124
+ version: '3.9'
125
125
  description: Miscellaneous general useful tools for general purpose programming.
126
126
  email:
127
127
  - keithrbennett@gmail.com
@@ -129,6 +129,7 @@ executables: []
129
129
  extensions: []
130
130
  extra_rdoc_files: []
131
131
  files:
132
+ - ".github/workflows/push_gem.yml"
132
133
  - ".gitignore"
133
134
  - ".travis.yml"
134
135
  - Gemfile
@@ -172,6 +173,16 @@ files:
172
173
  - lib/trick_bag/validations/other_validations.rb
173
174
  - lib/trick_bag/validations/regex_validations.rb
174
175
  - lib/trick_bag/version.rb
176
+ - logo/logo.md
177
+ - logo/trickbag-logo-horizontal-black.png
178
+ - logo/trickbag-logo-horizontal-color.png
179
+ - logo/trickbag-logo-horizontal-white.png
180
+ - logo/trickbag-logo-vertical-black.png
181
+ - logo/trickbag-logo-vertical-color.png
182
+ - logo/trickbag-logo-vertical-white.png
183
+ - logo/trickbag-logomark-black.png
184
+ - logo/trickbag-logomark-color.png
185
+ - logo/trickbag-logomark-white.png
175
186
  - spec/spec_helper.rb
176
187
  - spec/trick_bag/collections/collection_access_spec.rb
177
188
  - spec/trick_bag/collections/linked_list_spec.rb
@@ -223,8 +234,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
223
234
  - !ruby/object:Gem::Version
224
235
  version: '0'
225
236
  requirements: []
226
- rubyforge_project:
227
- rubygems_version: 2.6.13
237
+ rubygems_version: 3.5.22
228
238
  signing_key:
229
239
  specification_version: 4
230
240
  summary: Miscellaneous general useful tools.