helpema 2.0.200124 → 3.1.210909

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: 99e52f3d2144ddf05fe8d83ef1a3929a62c43bd68fb8c7db11d360dd2288fe5a
4
- data.tar.gz: 636874ab3c6c109751825ec67fd08ae8aff7a18e7adf37b134f4c9ede3c6cc5f
3
+ metadata.gz: 06db87416d69a4ed736c20927d8f9d3c379d7654cbd3e85f57e6e44a5571098e
4
+ data.tar.gz: e0f8202e576a5ba7d7fb30ec1b045bc8da3bf1c696bf98874b30c032820e45a8
5
5
  SHA512:
6
- metadata.gz: 2a22a1de5d55755b4b8481f73d9710cf8472c1e8ad5bcd73418147014432641b8d632085efeaf52d9758e536dce79b2d3b295f686ac172c525ea1fca59c3c9c1
7
- data.tar.gz: a5e908afbed85d4812f2b9284d3535334c07ccdaf4c78799a0d32c103bac33ec99edb4b36e2f72321aa9c9bd7f37725b4b88a23b051051b88419c54304c49d83
6
+ metadata.gz: 0e59e80e64f0c88ac0a0948ff773b9238f7334939231d70c70aec105217962cc4e3e68276b29013cb4e22eec57e392031b2f927c690d29d35999ca236860b1ee
7
+ data.tar.gz: aaddb40d73e6d372d50ff61244232dbc998076806dcc3903fefd1c46647e3f739bfd9b0b0d6d29ab4b56c8bfb0411d2314bee2505ceae11c90ffeb717b2cf781
data/README.md CHANGED
@@ -1,64 +1,149 @@
1
- # helpema
1
+ # Helpema
2
2
 
3
- * [VERSION 2.0.200124](https://github.com/carlosjhr64/helpema/releases)
4
- * [github](https://github/carlosjhr64/helpema)
5
- * [rubygems](https://rubygems/gems/helpema)
3
+ * [VERSION 3.1.210909](https://github.com/carlosjhr64/helpema/releases)
4
+ * [github](https://github.com/carlosjhr64/helpema)
5
+ * [rubygems](https://rubygems.org/gems/helpema)
6
6
 
7
7
  ## DESCRIPTION:
8
8
 
9
9
  Meant to be an eclectic collection of useful single functions and wrappers.
10
- Wrappers: ssss-split, ssss-combine, zbarcam, youtube-dl -j.
11
- Funtions: requires("gemname version",...).
12
10
 
13
- More later.
14
-
15
- ## SYNOPSIS:
16
-
17
- require 'helpema'
18
- include HELPEMA
19
-
20
- Helpema.requires <<-GEMS
21
- awesome_print ~>1.8
22
- base_convert ~>4.0
23
- entropia ~>0.1
24
- GEMS
25
- #=> ["awesome_print", "base_convert", "entropia"]
26
- # Returns the list of loaded gems.
27
- # For those quick little scripts one writes in one's bin
28
- # that annoyingly keep falling out of maintainance... right?
29
-
30
- SSSS.split("Top Secret!", threshold: 2, shares: 3)
31
- #~> ^\["1-\h+", "2-\h+", "3-\h+"\]$
32
- # Note that the split has random outputs on the same inputs.
33
-
34
- SSSS.combine("3-055562917c41e68c6ab2c8", "1-27bf3cbfe8d2c25c7e8928")
35
- #=> Top Secret!
36
- # Pregenerated splits combine to reproduce the secret.
37
-
38
- list = []
39
- url = 'https://www.youtube.com/watch?v=u4oK3ZSccZI'
40
- YouTubeDL.json(url){|json| list.push json}
41
- # The url was for just one video
42
- list.length #=> 1
43
- json = list[0]
44
- json['title'] #=> "Fortnite Easy Last Ten"
45
-
46
- ZBar.cam( timeout=3 ) # Reads qrcodes on camera.
47
- ZBar.screen # Reads qrcodes on screen.
11
+ Featured method: `requires "good ~>3.0", "bad ~>2.7", "ugly ~>1.8"`
48
12
 
49
13
  ## INSTALL:
50
14
 
51
- $ sudo gem install helpema
15
+ ```console
16
+ $ gem install helpema
17
+ ```
52
18
 
53
- ## FEATURES:
19
+ ## SYNOPSIS:
54
20
 
55
- * Autoloaded: no need to pick and choose which library component to require.
21
+ ```ruby
22
+ require 'helpema'
23
+ include Helpema
24
+ using Helpema
25
+
26
+ ### requires ###
27
+ # Ensure ruby's and helpema's version.
28
+ # Returns the list of loaded gems.
29
+ # For those quick little scripts one writes in one's bin
30
+ # that annoyingly keep falling out of maintainance... right?
31
+ requires'
32
+ ruby ~>3.0
33
+ helpema ~>3.1
34
+ base_convert ~>4.0
35
+ entropia ~>0.1'
36
+ #=> ["base_convert", "entropia"]
37
+
38
+ ### String#satisfies? ###
39
+ # Uses Gem::Requirement and Gem::Version to check version strings.
40
+ '1.2.3'.satisfies? '~>1.1' #=> true
41
+ '1.2.3'.satisfies? '~>1.3' #=> false
42
+
43
+ ### run_command ###
44
+ # Automates pipe creation to a system command.
45
+ # See the code for all available features.
46
+ run_command('date',{d: 'Dec 31, 2020'}) #=> "Thu Dec 31 12:00:00 AM PST 2020\n"
47
+
48
+ ### define_command ###
49
+ # Creates a method out of a system command.
50
+ # See the code for all available features.
51
+ define_command(:date, cmd: 'date', usage: {d: nil}, synonyms: {string: :d})
52
+ date(string: 'Dec 31, 2020') #=> "Thu Dec 31 12:00:00 AM PST 2020\n"
53
+
54
+ ### to_arg ###
55
+ # A helper function to do system command calls.
56
+ to_arg :q, true #=> "-q"
57
+ to_arg :quiet, true #=> "--quiet"
58
+ to_arg :verbose, false #=> nil
59
+ to_arg :f, '/path-to/file' #=> ["-f", "/path-to/file"]
60
+ to_arg :geo=, '10x20' #=> "--geo=10x20"
61
+ to_arg :arg0, 'Hello World' #=> "Hello World"
62
+
63
+ ### Hash#to_args ###
64
+ { q: true,
65
+ quiet: true,
66
+ verbose: false,
67
+ f: '/path-to/file',
68
+ :geo= => '10x20',
69
+ arg0: 'Hello World' }.to_args
70
+ #=> ["-q", "--quiet", "-f", "/path-to/file", "--geo=10x20", "Hello World"]
71
+
72
+ ### Array#classify ###
73
+ # Groups items in Array by class.
74
+ [1, 2.0, :Three, 'Four', /Five/, :Six, 'Seven'].classify
75
+ #=> {Integer=>[1], Float=>[2.0], Symbol=>[:Three, :Six], String=>["Four", "Seven"], Regexp=>[/Five/]}
76
+
77
+ ### SSSS.split ####
78
+ SSSS.split(secret: "Top Secret!", threshold: 2, shares: 3)
79
+ #~> ^\["1-\h+", "2-\h+", "3-\h+"\]$
80
+ # Note that the split has random outputs on the same inputs.
81
+
82
+ #### SSSS.combine ###
83
+ # Pregenerated splits combine to reproduce the secret.
84
+ SSSS.combine(secrets: ["3-055562917c41e68c6ab2c8", "1-27bf3cbfe8d2c25c7e8928"],
85
+ threshold: 2)
86
+ #=> "Top Secret!"
87
+
88
+ ### YouTubeDL.json ###
89
+ list = []
90
+ url = 'https://www.youtube.com/watch?v=u4oK3ZSccZI'
91
+ YouTubeDL.json(url){|json| list.push json}
92
+ # The url was for just one video
93
+ list.length #=> 1
94
+ json = list[0]
95
+ json['title'] #=> "Fortnite Easy Last Ten"
96
+
97
+ ### ZBar.screen ###
98
+ # Reads qrcodes on screen.
99
+ string_or_nil = ZBar.screen
100
+
101
+ ### ZBar.cam ###
102
+ # Reads qrcodes from camera.
103
+ # You may want to wrap this one in a Timeout block.
104
+ # string = ZBar.cam
105
+
106
+ ### GPG Symmetric ###
107
+ ## String to String
108
+ encrypted = GPG.encrypt(passphrase: '<Secret>', string: '<Plain Text>')
109
+ decrypted = GPG.decrypt(passphrase: '<Secret>', string: encrypted)
110
+ #=> "<Plain Text>"
111
+ ## File to File
112
+ # Got a text file...
113
+ `md5sum tmp/text.txt` #~> ^d27b3111fdeb72f2862909c216214bc1
114
+ # gpg wont overwrite, so need to remove existing...
115
+ File.exist?(_='tmp/text.enc') and File.unlink(_)
116
+ File.exist?(_='tmp/text.dec') and File.unlink(_)
117
+ # Encrypt text file...
118
+ GPG.encrypt(passphrase: '<Secret>', input: 'tmp/text.txt', output: 'tmp/text.enc') #=> ""
119
+ # Decrypt encrypted file...
120
+ GPG.decrypt(passphrase: '<Secret>', input: 'tmp/text.enc', output: 'tmp/text.dec') #=> ""
121
+ # Decrypted file should match...
122
+ `md5sum tmp/text.dec` #~> ^d27b3111fdeb72f2862909c216214bc1
123
+ ## IO to IO
124
+ require 'stringio'
125
+ pio = StringIO.new '<Plain>'
126
+ eio = StringIO.new ''
127
+ dio = StringIO.new ''
128
+ GPG.encrypt(passphrase: '<Secret>', ioin: pio, ioout: eio)
129
+ eio.rewind
130
+ GPG.decrypt(passphrase: '<Secret>', ioin: eio, ioout: dio)
131
+ dio.string #=> "<Plain>"
132
+ ```
133
+
134
+ ## TROUBLESHOOTING:
135
+
136
+ Command version mismatch
137
+ : set `Helpema::WRAPPER.version = "your.version"` or just nil it.
138
+
139
+ More documentation
140
+ : see [sig/helpema.rb](sig/helpema.rbs) for the expected method signatures.
56
141
 
57
142
  ## LICENSE:
58
143
 
59
144
  (The MIT License)
60
145
 
61
- Copyright (c) 2020 carlosjhr64
146
+ Copyright (c) 2021 CarlosJHR64
62
147
 
63
148
  Permission is hereby granted, free of charge, to any person obtaining
64
149
  a copy of this software and associated documentation files (the
@@ -0,0 +1,86 @@
1
+ module Helpema
2
+ module GPG
3
+ extend Helpema
4
+ class << self; attr_accessor :version; end
5
+ GPG.version = '^gpg \\(GnuPG\\) 2\.[234]\.' # version as of this writing is 2.2.27
6
+
7
+ GPG.define_command(:cryptor,
8
+ cmd: 'gpg', version: GPG.version,
9
+ usage: {
10
+ quiet: true,
11
+ batch: true,
12
+ 'passphrase-fd': 0,
13
+ output: nil,
14
+ symmetric: nil,
15
+ decrypt: nil,
16
+ arg0: nil,
17
+ },
18
+ synonyms: {
19
+ input: :arg0,
20
+ },
21
+ mode: 'w+',
22
+ exception: 'gpg failed'
23
+ ) do |pipe, options, blk|
24
+ passphrase, string, ioin, ioout =
25
+ options.fetch_values(:passphrase, :string, :ioin, :ioout)
26
+ pipe.puts passphrase
27
+ Thread.new do
28
+ if string
29
+ pipe.write string
30
+ elsif ioin
31
+ while c = ioin.getbyte
32
+ pipe.putc c
33
+ end
34
+ end
35
+ pipe.close_write
36
+ end
37
+ if ioout
38
+ while c = pipe.getbyte
39
+ ioout.putc c
40
+ end
41
+ else
42
+ pipe.read
43
+ end
44
+ end
45
+
46
+ def encrypt(passphrase:,
47
+ string:nil,
48
+ output:nil,
49
+ input:nil,
50
+ ioin:nil,
51
+ ioout:nil)
52
+ unless [string,input,ioin].count{_1} == 1
53
+ raise "Need only one of string, input, or ioin"
54
+ end
55
+ raise "Can't have both output and ioout" if output and ioout
56
+ GPG.cryptor(symmetric: true,
57
+ passphrase: passphrase,
58
+ string: string,
59
+ input: input,
60
+ output: output,
61
+ ioin: ioin,
62
+ ioout: ioout)
63
+ end
64
+
65
+ def decrypt(passphrase:,
66
+ string:nil,
67
+ output:nil,
68
+ input:nil,
69
+ ioin:nil,
70
+ ioout:nil)
71
+ unless [string,input,ioin].count{_1} == 1
72
+ raise "Need only one of string, input, or ioin"
73
+ end
74
+ raise "Can't have both output and ioout" if output and ioout
75
+ GPG.cryptor(decrypt: true,
76
+ passphrase: passphrase,
77
+ string: string,
78
+ input: input,
79
+ output: output,
80
+ ioin: ioin,
81
+ ioout: ioout)
82
+ end
83
+
84
+ extend self
85
+ end
86
+ end
@@ -1,16 +1,118 @@
1
- module HELPEMA
2
1
  module Helpema
2
+ refine ::String do
3
+ def satisfies?(*reqs)
4
+ Gem::Requirement.new(*reqs).satisfied_by? Gem::Version.new(self)
5
+ end
6
+ end
7
+ refine ::Hash do
8
+ def to_args(usage:nil, synonyms:nil)
9
+ # create separate args from self with the translated synonyms
10
+ args = self.transform_keys(synonyms.to_h)
11
+ # pad usage's defaults to args
12
+ usage&.each{|key,default| args[key]=default unless args.has_key? key}
13
+ # order might be important so enforce usage
14
+ args = usage&.map{|k,v|[k,args[k]]} || args.to_a
15
+ # convert key,value tuples to final list of args
16
+ args.map!(&:to_arg)
17
+ # get rid of nil
18
+ args.compact!
19
+ # ...and finally flatten!
20
+ args.flatten!
21
+ return args
22
+ end
23
+ end
24
+ refine ::Array do
25
+ def classify(hash: Hash.new{|h,k|h[k]=[]})
26
+ self.each{|v| hash[v.class] << v}
27
+ return hash
28
+ end
29
+ def to_arg
30
+ Helpema.to_arg(*self)
31
+ end
32
+ end
33
+ refine ::Symbol do
34
+ def to_flag
35
+ return nil if self[-1].match?(/\d/) # like :arg0
36
+ (self.length > 1)? "--#{self}": "-#{self}" # like --verbose or -V
37
+ end
38
+ end
39
+ using Helpema
40
+
41
+ def to_arg(key,value)
42
+ # keep only keys with value(no false or nil)
43
+ return nil unless value
44
+ # assume nil0/--long/-short
45
+ key = key.to_flag
46
+ if key
47
+ return key if value==true # a flag
48
+ return "#{key}#{value}" if key[-1]=='=' # joined key=value
49
+ return [key,value.to_s]
50
+ end
51
+ # It's a Nth arg, like arg0...
52
+ return value.to_s
53
+ end
54
+
55
+ def run_command(cmd, options={},
56
+ usage:nil, synonyms:nil, mode:'r',
57
+ exception:nil, forward_pass:nil, **popt, &blk)
58
+ args,ret = options.to_args(usage:usage,synonyms:synonyms),nil
59
+ $stderr.puts "#{cmd} #{args.join(' ')}" if $DEBUG
60
+ IO.popen([cmd, *args], mode, **popt) do |pipe|
61
+ ret = forward_pass ? forward_pass.call(pipe, options, blk) :
62
+ blk ? blk.call(pipe) :
63
+ pipe.read
64
+ end
65
+ (exception.nil? or $?.exitstatus==0)? ret : raise(exception)
66
+ end
67
+
68
+ def define_command(name,
69
+ cmd: name.to_s, version: nil, v: nil,
70
+ usage: nil, synonyms: nil,
71
+ mode: 'r',exception: nil,
72
+ **popt, &forward_pass)
73
+
74
+ # which version? --version or -v
75
+ if version and not `#{cmd} --version`.strip.match?(version)
76
+ raise "`#{cmd} --version` !~ #{version}"
77
+ end
78
+ if v and not `#{cmd} -v`.strip.match?(v)
79
+ raise "`#{cmd} -v` !~ #{v}"
80
+ end
81
+
82
+ define_method(name) do |**options, &blk|
83
+ run_command(cmd, options,
84
+ usage:usage, synonyms:synonyms, mode:mode,
85
+ exception:exception, forward_pass:forward_pass, **popt, &blk)
86
+ end
87
+ end
88
+
3
89
  def requires(*list)
4
90
  loaded = []
5
91
  list.each do |gems|
6
- gems.lines.each do |gemname_version|
7
- gemname, *version = gemname_version.split
8
- gem gemname, *version unless version.empty?
92
+ gems.lines.each do |gemname_reqs|
93
+ gemname, *reqs = gemname_reqs.split
94
+ next unless gemname
95
+ unless reqs.empty?
96
+ case gemname
97
+ when 'helpema'
98
+ unless VERSION.satisfies?(*reqs)
99
+ raise "helpema #{VERSION} not #{reqs.join(', ')}"
100
+ end
101
+ next
102
+ when 'ruby'
103
+ unless RUBY_VERSION.satisfies?(*reqs)
104
+ raise "ruby #{RUBY_VERSION} not #{reqs.join(', ')}"
105
+ end
106
+ next
107
+ else
108
+ gem gemname, *reqs
109
+ end
110
+ end
9
111
  require gemname and loaded.push gemname
10
112
  end
11
113
  end
12
- loaded
114
+ return loaded
13
115
  end
116
+
14
117
  extend self
15
118
  end
16
- end
data/lib/helpema/ssss.rb CHANGED
@@ -1,34 +1,46 @@
1
- require 'open3'
1
+ module Helpema
2
+ module SSSS
3
+ extend Helpema
4
+ class << self; attr_accessor :version; end
5
+ SSSS.version = 'Version: 0\.[567]\b' # version as of this writing is 0.5
2
6
 
3
- module HELPEMA
4
- module SSSS
5
- # Note how the function mirrors the command line options.
6
- def self.split(secret, t0=2, n0=3,
7
- t: t0, n: n0,
8
- threshold: t, shares: n,
9
- w: nil, s: nil, x: false,
10
- token: w, level: s, hexmode: x)
11
- pwds = nil
12
- command = "ssss-split -Q -t #{threshold} -n #{shares}"
13
- command << " -w #{token}" if token
14
- command << " -s #{level}" if level
15
- command << " -x" if hexmode
16
- Open3.popen3(command) do |stdin, stdout, stderr|
17
- stdin.puts secret
18
- stdin.close
19
- pwds = stdout.read.split("\n")
7
+ SSSS.define_command(:_split,
8
+ cmd: 'ssss-split', v: SSSS.version,
9
+ usage: {Q:true,t:2,n:3,w:nil,s:nil,x:false},
10
+ synonyms: {threshold: :t, shares: :n, token: :w, level: :s, hexmode: :x},
11
+ mode: 'w+', exception: 'ssss-split failed.',
12
+ err: [:child, :out]
13
+ ) do |pipe, options, blk|
14
+ pipe.puts options.fetch(:secret)
15
+ pipe.read.split.last(options[:shares])
20
16
  end
21
- return pwds
22
- end
23
-
24
- def self.combine(*pwds)
25
- pwd = ''
26
- Open3.popen3("ssss-combine -q -t #{pwds.length}") do |stdin, stdout, stderr|
27
- pwds.each{|p| stdin.puts p}
28
- stdin.close
29
- pwd = stderr.read.split("\n").last
17
+ def split(
18
+ secret:, threshold:,
19
+ shares:, token:nil,
20
+ level:nil,
21
+ hexmode:false
22
+ ) = SSSS._split(
23
+ secret:secret,
24
+ threshold:threshold,
25
+ shares:shares,
26
+ token:token,
27
+ level:level,
28
+ hexmode:hexmode)
29
+ SSSS.define_command(:_combine,
30
+ cmd: 'ssss-combine', v: SSSS.version,
31
+ usage: {Q:true,t:2,x:false}, synonyms: {threshold: :t, hexmode: :x},
32
+ mode: 'w+', exception: 'ssss-combine failed.',
33
+ err: [:child, :out]
34
+ ) do |pipe, options, blk|
35
+ secrets,n = options.fetch_values(:secrets,:threshold)
36
+ secrets.first(n).each{pipe.puts _1}
37
+ pipe.read.lines.last.chomp
38
+ end
39
+ def combine(secrets:, threshold:, hexmode:false)
40
+ raise 'Need threshold number of secrets.' unless secrets.size >= threshold
41
+ SSSS._combine(secrets:secrets, threshold:threshold, hexmode:hexmode)
30
42
  end
31
- return pwd
43
+
44
+ extend self
32
45
  end
33
46
  end
34
- end
@@ -1,20 +1,26 @@
1
1
  require 'json'
2
- require 'open3'
3
2
 
4
- module HELPEMA
5
- module YouTubeDL
6
- def self.json(url, pwd=nil)
7
- Open3.popen2e("youtube-dl -j '#{url}'") do |i, o|
8
- i.puts pwd if pwd
9
- i.close
10
- o.each do |line|
3
+ module Helpema
4
+ module YouTubeDL
5
+ extend Helpema
6
+ class << self; attr_accessor :version; end
7
+ YouTubeDL.version = '^202\d\.[01]\d\.[0123]\d$'
8
+
9
+ YouTubeDL.define_command(:_json,
10
+ cmd: 'youtube-dl', version: YouTubeDL.version,
11
+ usage: {j:true, arg0:nil}, synonyms: {url: :arg0},
12
+ err: '/dev/null'
13
+ ) do |pipe, options, blk|
14
+ pipe.each do |data|
11
15
  begin
12
- yield JSON.parse line
13
- rescue JSON::ParserError
14
- yield line
16
+ data = JSON.parse data
17
+ ensure
18
+ blk.call data
15
19
  end
16
20
  end
17
21
  end
22
+ def json(url, &blk) = YouTubeDL._json(url:url, &blk)
23
+
24
+ extend self
18
25
  end
19
26
  end
20
- end
data/lib/helpema/zbar.rb CHANGED
@@ -1,38 +1,46 @@
1
- require 'timeout'
2
1
  require 'tmpdir'
3
2
 
4
- module HELPEMA
5
- module ZBar
6
- def self.cam(timeout=3)
7
- raw = ''
8
- IO.popen('zbarcam --nodisplay --raw --prescale=800x800', 'r') do |io|
3
+ module Helpema
4
+ module ZBar
5
+ extend Helpema
6
+ class << self; attr_accessor :version, :screenshot; end
7
+ ZBar.version = '^0\.2[345]\b' # version as of this writing is 0.23
8
+ ZBar.screenshot = ['gnome-screenshot', '-f']
9
+
10
+ def snapshot(filename)
11
+ system(*ZBar.screenshot, filename)
12
+ end
13
+
14
+ ZBar.define_command(:_cam,
15
+ cmd: 'zbarcam',
16
+ version: ZBar.version,
17
+ usage: {raw:true,quiet:true,nodisplay:true, :prescale= => '800x800'},
18
+ synonyms: {prescale: :prescale=}
19
+ ) do |pipe, kw, blk|
9
20
  begin
10
- Timeout.timeout(timeout) do
11
- raw << io.gets
12
- while q = io.gets
13
- break if q=="\n"
14
- raw << q
15
- end
16
- raw.strip!
17
- end
18
- rescue Timeout::Error
19
- raw = nil
20
- $stderr.puts $!
21
+ pipe.gets.chomp # This is the return value!
21
22
  ensure
22
- Process.kill('INT', io.pid)
23
+ Process.kill('TERM', pipe.pid)
23
24
  end
24
25
  end
25
- raw
26
- end
26
+ def cam() = ZBar._cam()
27
27
 
28
- def self.screen
29
- raw = nil
30
- Dir.mktmpdir do |tmpdir|
31
- screenshot = File.join(tmpdir, "#{$$}.#{Time.now.to_f}.png")
32
- system "gnome-screenshot -f #{screenshot}"
33
- raw = `zbarimg -q --raw #{screenshot}`.strip
28
+ ZBar.define_command(:_img,
29
+ cmd: 'zbarimg',
30
+ version: ZBar.version,
31
+ usage: {q:true,raw:true,arg0:nil},
32
+ synonyms: {filename: :arg0})
33
+ def img(filename) = ZBar._img(filename:filename)
34
+
35
+ def screen
36
+ raw = nil
37
+ Dir.mktmpdir do |tmpdir|
38
+ _ = File.join(tmpdir, "#{$$}.#{Time.now.to_f}.png")
39
+ raw = _ if ZBar.snapshot(_) and not (_=ZBar.img(_).chomp).empty?
40
+ end
41
+ raw
34
42
  end
35
- raw
43
+
44
+ extend self
36
45
  end
37
46
  end
38
- end
data/lib/helpema.rb CHANGED
@@ -1,14 +1,20 @@
1
- module HELPEMA
2
- VERSION = '2.0.200124'
1
+ module Helpema
2
+ VERSION = '3.1.210909'
3
+
4
+ require_relative 'helpema/helpema'
3
5
 
4
- autoload :Helpema, 'helpema/helpema.rb'
5
6
  autoload :SSSS, 'helpema/ssss.rb'
6
7
  autoload :YouTubeDL, 'helpema/youtubedl.rb'
7
8
  autoload :ZBar, 'helpema/zbar.rb'
9
+ autoload :GPG, 'helpema/gpg.rb'
8
10
  end
11
+
9
12
  # Requires:
10
13
  #`ruby`
14
+ #`youtube-dl`
11
15
  #`ssss-split`
12
16
  #`ssss-combine`
13
17
  #`zbarcam`
18
+ #`zbarimg`
14
19
  #`gnome-screenshot`
20
+ #`gpg`
metadata CHANGED
@@ -1,21 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: helpema
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.200124
4
+ version: 3.1.210909
5
5
  platform: ruby
6
6
  authors:
7
- - carlosjhr64
8
- autorequire:
7
+ - CarlosJHR64
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-24 00:00:00.000000000 Z
11
+ date: 2021-09-09 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.
15
- Wrappers: ssss-split, ssss-combine, zbarcam, youtube-dl -j.
16
- Funtions: requires("gemname version",...).
17
15
 
18
- More later.
16
+ Featured method: `requires "good ~>3.0", "bad ~>2.7", "ugly ~>1.8"`
19
17
  email: carlosjhr64@gmail.com
20
18
  executables: []
21
19
  extensions: []
@@ -23,6 +21,7 @@ extra_rdoc_files: []
23
21
  files:
24
22
  - README.md
25
23
  - lib/helpema.rb
24
+ - lib/helpema/gpg.rb
26
25
  - lib/helpema/helpema.rb
27
26
  - lib/helpema/ssss.rb
28
27
  - lib/helpema/youtubedl.rb
@@ -31,7 +30,7 @@ homepage: https://github.com/carlosjhr64/helpema
31
30
  licenses:
32
31
  - MIT
33
32
  metadata: {}
34
- post_install_message:
33
+ post_install_message:
35
34
  rdoc_options: []
36
35
  require_paths:
37
36
  - lib
@@ -46,15 +45,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
46
45
  - !ruby/object:Gem::Version
47
46
  version: '0'
48
47
  requirements:
49
- - 'ruby: ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux]'
48
+ - 'ruby: ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-linux]'
49
+ - 'youtube-dl: 2021.06.06'
50
50
  - 'ssss-split: 0.5'
51
51
  - 'ssss-combine: 0.5'
52
52
  - 'zbarcam: 0.23'
53
- - 'gnome-screenshot: gnome-screenshot 3.34.0'
54
- rubygems_version: 3.1.2
55
- signing_key:
53
+ - 'zbarimg: 0.23'
54
+ - 'gnome-screenshot: gnome-screenshot 40.0'
55
+ - 'gpg: gpg (GnuPG) 2.2.27'
56
+ rubygems_version: 3.2.22
57
+ signing_key:
56
58
  specification_version: 4
57
- summary: 'Meant to be an eclectic collection of useful single functions and wrappers.
58
- Wrappers: ssss-split, ssss-combine, zbarcam, youtube-dl -j. Funtions: requires("gemname
59
- version",...).'
59
+ summary: Meant to be an eclectic collection of useful single functions and wrappers.
60
60
  test_files: []