print_wrap 1.0.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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/print_wrap.rb +28 -0
  3. metadata +43 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f1941964bd4c4590f4bc85cc011065cd6f79279b94ec98ae211b7d1c79ba9bdf
4
+ data.tar.gz: 98a36f5df001c5777cf5bd8ddf652434def1eb11867cb1ca661a5850a68207b7
5
+ SHA512:
6
+ metadata.gz: 43ef4b8bef4f5772d10e76a6693503912df57b6ec4301c1ee3f61acc27778331f950806567019de4c6ada3820dc6064040ec51d2d7535164d9a6ea4715d6012b
7
+ data.tar.gz: 3dbec66609cb9c73aa16bce840cc1f2f1832fc2690b420b270b9505d158a9f6e69f19c99114ac37c7ab11810b4554869d5bfdd28b893f6064aa496cecf7dbd6a
data/lib/print_wrap.rb ADDED
@@ -0,0 +1,28 @@
1
+ # this module provides a simple way to print text before and after running a
2
+ # block of code in between. the purpose of this is to build CLI tools where you
3
+ # want to print something before starting a long-running step, and then print
4
+ # something when the long-running step is complete.
5
+ #
6
+ # usage:
7
+ # > PrintWrap.print('Loading large file ...', ' DONE') do
8
+ # > IO.read('/tmp/some_very_large_file.txt')
9
+ # > end
10
+ # => Loading large file ... # right before the block starts running
11
+ # => Loading large file ... DONE # when the block is complete
12
+ #
13
+ # > PrintWrap.print('Waiting ...', ' OK') do
14
+ # > sleep 5
15
+ # > end
16
+ # => Waiting ... # before the sleep call
17
+ # => Waiting ... OK # when the sleep is over
18
+ module PrintWrap
19
+ # before: String you want printed before the block runs
20
+ # after: String you want printed after the block runs
21
+ def self.print(before, after)
22
+ Kernel.print before # necessary, otherwise the method will call itself
23
+ block_result = yield if block_given?
24
+ Kernel.puts after
25
+
26
+ block_result
27
+ end
28
+ end
metadata ADDED
@@ -0,0 +1,43 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: print_wrap
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Jeff Lunt
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-01-17 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: wrap a block of code in a before/after message
14
+ email: jefflunt@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/print_wrap.rb
20
+ homepage: https://github.com/jefflunt/print_wrap
21
+ licenses:
22
+ - MIT
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubygems_version: 3.4.1
40
+ signing_key:
41
+ specification_version: 4
42
+ summary: wrap a block of code in a before/after message
43
+ test_files: []