trick_bag 0.67.0 → 0.68.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
  SHA1:
3
- metadata.gz: 7f8d5b7a9f77fdc75d8672b5947fd8075cca1ab5
4
- data.tar.gz: e61fd4ec8b3d7dc55023e2323e7cf75f853d9389
3
+ metadata.gz: 59ec06de448c4ccb3f3cd3966fcdc855cb602ac5
4
+ data.tar.gz: 67da903f678ed62aae6d7e0ba4d84441fe6a837a
5
5
  SHA512:
6
- metadata.gz: 50b8e5a3407f1b725598a1f22de963682b5e68f154f575989af03e6a84f4e18c39e17c4975978eb8ea2e32c0f705f05fecd41701619524e7e20c40571342d7b6
7
- data.tar.gz: edf428cd0e32c8f282ae0f80c84ba5a274d481e6973ba065ba4f1adeb3ebb5e2a43c70f40ccdde6ac5cfc98741faeab7b8b109519ea0b7bc0725c36129699561
6
+ metadata.gz: b8919fe6998b064c515dd6440474327691558c72c0755e93337d1e6c066fce99a6436610fe15651a71e6964ceb94b1daf785f225eaf3c2f38cb7dcb45f4c6906
7
+ data.tar.gz: a488a53c4369a98e6adf563e07b8f60d758726f7299aed2e6da47b6366caed364e4fbc57d7c059d9db499a09c36b4338aa71e8247852ac04fcc742116e364dcb
data/README.md CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  # TrickBag
4
4
 
5
- This gem is a collection of useful classes and modules for Ruby development.
6
-
5
+ Assorted Ruby classes, modules, and methods to simplify and enhance your code.
6
+
7
7
 
8
8
  ## Installation
9
9
 
data/RELEASE_NOTES.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## v0.68.0
2
+
3
+ * Add Filesystem.running_as_script?
4
+
5
+
1
6
  ## v0.67.0
2
7
 
3
8
  * Move Functional methods into Functional module.
@@ -0,0 +1,43 @@
1
+ module TrickBag
2
+ module Filesystem
3
+
4
+ module_function
5
+
6
+ # @return true if the passed file is being run as a script, else false
7
+ # @param __file__ - !!! __FILE__ must be passed as the __file__ argument for this to work correctly !!!
8
+ #
9
+ # Sometimes we want to see if a given file is being run as a script, as opposed to loaded
10
+ # by other Ruby code. For example, the script at https://github.com/keithrbennett/macwifi/blob/master/bin/mac-wifi
11
+ # is normally run as a script (either by running the file directly, or by running the executable's
12
+ # 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.
19
+ def running_as_script?(__file__)
20
+
21
+ # Here is some sample state, when running a file as a gem executable:
22
+ # __FILE__ = /Users/kbennett/.rvm/gems/ruby-2.4.0/gems/mac-wifi-1.0.0/bin/mac-wifi
23
+ # $0 = /Users/kbennett/.rvm/gems/ruby-2.4.0/bin/mac-wifi
24
+ # GEM_PATH = /Users/kbennett/.rvm/gems/ruby-2.4.0:/Users/kbennett/.rvm/gems/ruby-2.4.0@global
25
+
26
+ # Please enable this code and report its output if you report any issues with this method:
27
+ # puts "__file__ = #{__file__}"
28
+ # puts "$0 = #{$0}"
29
+ # puts "GEM_PATH = #{ENV['GEM_PATH']}"
30
+
31
+ return true if __file__ == $0
32
+ return false if File.basename(__file__) != File.basename($0)
33
+
34
+ # If here, then filespecs are different but have the same basename.
35
+ gem_paths = ENV['GEM_PATH'].split(File::PATH_SEPARATOR)
36
+ basename = File.basename($0)
37
+ gem_paths.any? do |path|
38
+ ($0 == File.join(path, 'bin', basename)) \
39
+ && (path == File.expand_path(File.join(__file__, '..', '..', '..', '..')))
40
+ end
41
+ end
42
+ end
43
+ end
@@ -1,3 +1,3 @@
1
1
  module TrickBag
2
- VERSION = '0.67.0'
2
+ VERSION = '0.68.0'
3
3
  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.67.0
4
+ version: 0.68.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-09-25 00:00:00.000000000 Z
11
+ date: 2017-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: os
@@ -146,6 +146,7 @@ files:
146
146
  - lib/trick_bag/enumerables/endless_last_enumerable.rb
147
147
  - lib/trick_bag/enumerables/file_line_reader.rb
148
148
  - lib/trick_bag/enumerables/filtered_enumerable.rb
149
+ - lib/trick_bag/filesystem/filesystem.rb
149
150
  - lib/trick_bag/formatters/binary_to_hex_and_ascii.rb
150
151
  - lib/trick_bag/formatters/erb_renderer.rb
151
152
  - lib/trick_bag/formatters/formatters.rb