helpema 3.1.210909 → 3.2.210924

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: 06db87416d69a4ed736c20927d8f9d3c379d7654cbd3e85f57e6e44a5571098e
4
- data.tar.gz: e0f8202e576a5ba7d7fb30ec1b045bc8da3bf1c696bf98874b30c032820e45a8
3
+ metadata.gz: 958027b0a2546243bae724c0a543197d7632385c0f9049d8e59ed53349b18f4d
4
+ data.tar.gz: d57d402890e736b580fc052c66308df90a6e29202d467cd4e26714ad11b64331
5
5
  SHA512:
6
- metadata.gz: 0e59e80e64f0c88ac0a0948ff773b9238f7334939231d70c70aec105217962cc4e3e68276b29013cb4e22eec57e392031b2f927c690d29d35999ca236860b1ee
7
- data.tar.gz: aaddb40d73e6d372d50ff61244232dbc998076806dcc3903fefd1c46647e3f739bfd9b0b0d6d29ab4b56c8bfb0411d2314bee2505ceae11c90ffeb717b2cf781
6
+ metadata.gz: dd576603c81835d9610eac6d15487d25d82491eec8de717fcfbe6a16c51c865968d8ac259dddc45e02f2148f7653c6fa5b9ed5be55eb05c878b184df3bc5cdec
7
+ data.tar.gz: 65f36c77c56ded75225ecd35fe6f6f4bb3581aeff1c3ce1de855f423e65de78e3e69d1131a63e7b18760b1224f27eda14a33c0a41e40e55bef67d8c0cb89b488
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Helpema
2
2
 
3
- * [VERSION 3.1.210909](https://github.com/carlosjhr64/helpema/releases)
3
+ * [VERSION 3.2.210924](https://github.com/carlosjhr64/helpema/releases)
4
4
  * [github](https://github.com/carlosjhr64/helpema)
5
5
  * [rubygems](https://rubygems.org/gems/helpema)
6
6
 
@@ -18,6 +18,7 @@ $ gem install helpema
18
18
 
19
19
  ## SYNOPSIS:
20
20
 
21
+ ### requires
21
22
  ```ruby
22
23
  require 'helpema'
23
24
  include Helpema
@@ -34,23 +35,31 @@ helpema ~>3.1
34
35
  base_convert ~>4.0
35
36
  entropia ~>0.1'
36
37
  #=> ["base_convert", "entropia"]
37
-
38
+ ```
39
+ ### String#satisfies?
40
+ ```ruby
38
41
  ### String#satisfies? ###
39
42
  # Uses Gem::Requirement and Gem::Version to check version strings.
40
43
  '1.2.3'.satisfies? '~>1.1' #=> true
41
44
  '1.2.3'.satisfies? '~>1.3' #=> false
42
-
45
+ ```
46
+ ### run_command
47
+ ```ruby
43
48
  ### run_command ###
44
49
  # Automates pipe creation to a system command.
45
50
  # See the code for all available features.
46
51
  run_command('date',{d: 'Dec 31, 2020'}) #=> "Thu Dec 31 12:00:00 AM PST 2020\n"
47
-
52
+ ```
53
+ ### define_command
54
+ ```ruby
48
55
  ### define_command ###
49
56
  # Creates a method out of a system command.
50
57
  # See the code for all available features.
51
58
  define_command(:date, cmd: 'date', usage: {d: nil}, synonyms: {string: :d})
52
59
  date(string: 'Dec 31, 2020') #=> "Thu Dec 31 12:00:00 AM PST 2020\n"
53
-
60
+ ```
61
+ ### to_arg
62
+ ```ruby
54
63
  ### to_arg ###
55
64
  # A helper function to do system command calls.
56
65
  to_arg :q, true #=> "-q"
@@ -59,7 +68,9 @@ to_arg :verbose, false #=> nil
59
68
  to_arg :f, '/path-to/file' #=> ["-f", "/path-to/file"]
60
69
  to_arg :geo=, '10x20' #=> "--geo=10x20"
61
70
  to_arg :arg0, 'Hello World' #=> "Hello World"
62
-
71
+ ```
72
+ ### Hash#to_args
73
+ ```ruby
63
74
  ### Hash#to_args ###
64
75
  { q: true,
65
76
  quiet: true,
@@ -68,23 +79,31 @@ to_arg :arg0, 'Hello World' #=> "Hello World"
68
79
  :geo= => '10x20',
69
80
  arg0: 'Hello World' }.to_args
70
81
  #=> ["-q", "--quiet", "-f", "/path-to/file", "--geo=10x20", "Hello World"]
71
-
82
+ ```
83
+ ### Array#classify
84
+ ```ruby
72
85
  ### Array#classify ###
73
86
  # Groups items in Array by class.
74
87
  [1, 2.0, :Three, 'Four', /Five/, :Six, 'Seven'].classify
75
88
  #=> {Integer=>[1], Float=>[2.0], Symbol=>[:Three, :Six], String=>["Four", "Seven"], Regexp=>[/Five/]}
76
-
89
+ ```
90
+ ### SSSS.split
91
+ ```ruby
77
92
  ### SSSS.split ####
78
93
  SSSS.split(secret: "Top Secret!", threshold: 2, shares: 3)
79
94
  #~> ^\["1-\h+", "2-\h+", "3-\h+"\]$
80
95
  # Note that the split has random outputs on the same inputs.
81
-
96
+ ```
97
+ ### SSS.combine
98
+ ```ruby
82
99
  #### SSSS.combine ###
83
100
  # Pregenerated splits combine to reproduce the secret.
84
101
  SSSS.combine(secrets: ["3-055562917c41e68c6ab2c8", "1-27bf3cbfe8d2c25c7e8928"],
85
102
  threshold: 2)
86
103
  #=> "Top Secret!"
87
-
104
+ ```
105
+ ### YouTubeDL.json
106
+ ```ruby
88
107
  ### YouTubeDL.json ###
89
108
  list = []
90
109
  url = 'https://www.youtube.com/watch?v=u4oK3ZSccZI'
@@ -93,16 +112,24 @@ YouTubeDL.json(url){|json| list.push json}
93
112
  list.length #=> 1
94
113
  json = list[0]
95
114
  json['title'] #=> "Fortnite Easy Last Ten"
96
-
115
+ ```
116
+ ### YouTubeDL.mp3(url, output: '%(id)s.%(ext)s')
117
+ ### FFMPEG.hash(filename, digest: 'sha160')
118
+ ### ZBar.screen
119
+ ```ruby
97
120
  ### ZBar.screen ###
98
121
  # Reads qrcodes on screen.
99
122
  string_or_nil = ZBar.screen
100
-
123
+ ```
124
+ ### ZBar.cam
125
+ ```ruby
101
126
  ### ZBar.cam ###
102
127
  # Reads qrcodes from camera.
103
128
  # You may want to wrap this one in a Timeout block.
104
129
  # string = ZBar.cam
105
-
130
+ ```
131
+ ### GPG.encrypt and GPG.decrypt
132
+ ```ruby
106
133
  ### GPG Symmetric ###
107
134
  ## String to String
108
135
  encrypted = GPG.encrypt(passphrase: '<Secret>', string: '<Plain Text>')
@@ -0,0 +1,23 @@
1
+ module Helpema
2
+ module FFMPEG
3
+ extend Helpema
4
+
5
+ FFMPEG.define_command(:_hash,
6
+ cmd: 'ffmpeg',
7
+ usage: {arg0: '-i',
8
+ arg1: nil,
9
+ arg2: '-f',
10
+ arg3: 'hash',
11
+ arg4: '-hash',
12
+ arg5: nil,
13
+ arg6: '-'},
14
+ synonyms: {filename: :arg1, digest: :arg5},
15
+ exception: 'ffmpeg failed',
16
+ err: '/dev/null')
17
+ def hash(filename, digest:'sha160')
18
+ FFMPEG._hash(filename:filename, digest:digest).strip.split('=').last
19
+ end
20
+
21
+ extend self
22
+ end
23
+ end
@@ -21,6 +21,17 @@ module Helpema
21
21
  end
22
22
  def json(url, &blk) = YouTubeDL._json(url:url, &blk)
23
23
 
24
+ YouTubeDL.define_command(:_mp3,
25
+ cmd: 'youtube-dl', version: YouTubeDL.version,
26
+ usage: { output: nil,
27
+ 'extract-audio': true,
28
+ 'audio-format': true,
29
+ arg0: 'mp3',
30
+ arg1: nil },
31
+ synonyms: {url: :arg1},
32
+ err: '/dev/null')
33
+ def mp3(url, output:'%(id)s.%(ext)s') = YouTubeDL._mp3(url:url, output:output)
34
+
24
35
  extend self
25
36
  end
26
37
  end
data/lib/helpema.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Helpema
2
- VERSION = '3.1.210909'
2
+ VERSION = '3.2.210924'
3
3
 
4
4
  require_relative 'helpema/helpema'
5
5
 
@@ -7,6 +7,7 @@ module Helpema
7
7
  autoload :YouTubeDL, 'helpema/youtubedl.rb'
8
8
  autoload :ZBar, 'helpema/zbar.rb'
9
9
  autoload :GPG, 'helpema/gpg.rb'
10
+ autoload :FFMPEG, 'helpema/ffmpeg.rb'
10
11
  end
11
12
 
12
13
  # Requires:
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: helpema
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.210909
4
+ version: 3.2.210924
5
5
  platform: ruby
6
6
  authors:
7
7
  - CarlosJHR64
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-09 00:00:00.000000000 Z
11
+ date: 2021-09-24 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |
14
14
  Meant to be an eclectic collection of useful single functions and wrappers.
@@ -21,6 +21,7 @@ extra_rdoc_files: []
21
21
  files:
22
22
  - README.md
23
23
  - lib/helpema.rb
24
+ - lib/helpema/ffmpeg.rb
24
25
  - lib/helpema/gpg.rb
25
26
  - lib/helpema/helpema.rb
26
27
  - lib/helpema/ssss.rb