helpema 1.0.1 → 2.0.200124

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
- SHA1:
3
- metadata.gz: 58cbb6726a88d792e7e22a6a7795829531cf0137
4
- data.tar.gz: '00592e63eb485bac3a87ba7e8d2fd3facdc0aa68'
2
+ SHA256:
3
+ metadata.gz: 99e52f3d2144ddf05fe8d83ef1a3929a62c43bd68fb8c7db11d360dd2288fe5a
4
+ data.tar.gz: 636874ab3c6c109751825ec67fd08ae8aff7a18e7adf37b134f4c9ede3c6cc5f
5
5
  SHA512:
6
- metadata.gz: 6da8d0dd4ac4b78c533b88c2bb21b2ea058a222a4698721abbff4e8f17ce1f2a61c73a4c2f90b80a42d50453ae0e7208b9a7136a384d824eeedc50feefdbad5c
7
- data.tar.gz: 10758511542e2cf75e828160b14df8a1ebb9d3a5e63edd14f20835ec36610eee0daad663b10eca7d1f581d1f629974145d6a4d0b5da33c9fe2c59fd18d770c1a
6
+ metadata.gz: 2a22a1de5d55755b4b8481f73d9710cf8472c1e8ad5bcd73418147014432641b8d632085efeaf52d9758e536dce79b2d3b295f686ac172c525ea1fca59c3c9c1
7
+ data.tar.gz: a5e908afbed85d4812f2b9284d3535334c07ccdaf4c78799a0d32c103bac33ec99edb4b36e2f72321aa9c9bd7f37725b4b88a23b051051b88419c54304c49d83
data/README.md ADDED
@@ -0,0 +1,80 @@
1
+ # helpema
2
+
3
+ * [VERSION 2.0.200124](https://github.com/carlosjhr64/helpema/releases)
4
+ * [github](https://github/carlosjhr64/helpema)
5
+ * [rubygems](https://rubygems/gems/helpema)
6
+
7
+ ## DESCRIPTION:
8
+
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
+
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.
48
+
49
+ ## INSTALL:
50
+
51
+ $ sudo gem install helpema
52
+
53
+ ## FEATURES:
54
+
55
+ * Autoloaded: no need to pick and choose which library component to require.
56
+
57
+ ## LICENSE:
58
+
59
+ (The MIT License)
60
+
61
+ Copyright (c) 2020 carlosjhr64
62
+
63
+ Permission is hereby granted, free of charge, to any person obtaining
64
+ a copy of this software and associated documentation files (the
65
+ 'Software'), to deal in the Software without restriction, including
66
+ without limitation the rights to use, copy, modify, merge, publish,
67
+ distribute, sublicense, and/or sell copies of the Software, and to
68
+ permit persons to whom the Software is furnished to do so, subject to
69
+ the following conditions:
70
+
71
+ The above copyright notice and this permission notice shall be
72
+ included in all copies or substantial portions of the Software.
73
+
74
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
75
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
76
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
77
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
78
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
79
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
80
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,16 @@
1
+ module HELPEMA
2
+ module Helpema
3
+ def requires(*list)
4
+ loaded = []
5
+ list.each do |gems|
6
+ gems.lines.each do |gemname_version|
7
+ gemname, *version = gemname_version.split
8
+ gem gemname, *version unless version.empty?
9
+ require gemname and loaded.push gemname
10
+ end
11
+ end
12
+ loaded
13
+ end
14
+ extend self
15
+ end
16
+ end
data/lib/helpema/ssss.rb CHANGED
@@ -1,27 +1,34 @@
1
1
  require 'open3'
2
2
 
3
- module Helpema
3
+ module HELPEMA
4
4
  module SSSS
5
-
6
- def self.split(pwd, t, n)
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)
7
11
  pwds = nil
8
- Open3.popen3("ssss-split -Q -t #{t} -n #{n}") do |stdin, stdout, stderr|
9
- stdin.puts pwd
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
10
18
  stdin.close
11
- pwds = stdout.read.strip.split
19
+ pwds = stdout.read.split("\n")
12
20
  end
13
21
  return pwds
14
22
  end
15
23
 
16
24
  def self.combine(*pwds)
17
25
  pwd = ''
18
- Open3.popen3("ssss-combine -Q -t #{pwds.length}") do |stdin, stdout, stderr|
26
+ Open3.popen3("ssss-combine -q -t #{pwds.length}") do |stdin, stdout, stderr|
19
27
  pwds.each{|p| stdin.puts p}
20
28
  stdin.close
21
- pwd = stderr.read.strip.split.last
29
+ pwd = stderr.read.split("\n").last
22
30
  end
23
31
  return pwd
24
32
  end
25
-
26
33
  end
27
34
  end
@@ -1,9 +1,8 @@
1
1
  require 'json'
2
2
  require 'open3'
3
3
 
4
- module Helpema
4
+ module HELPEMA
5
5
  module YouTubeDL
6
-
7
6
  def self.json(url, pwd=nil)
8
7
  Open3.popen2e("youtube-dl -j '#{url}'") do |i, o|
9
8
  i.puts pwd if pwd
@@ -17,6 +16,5 @@ module YouTubeDL
17
16
  end
18
17
  end
19
18
  end
20
-
21
19
  end
22
20
  end
data/lib/helpema/zbar.rb CHANGED
@@ -1,9 +1,8 @@
1
1
  require 'timeout'
2
2
  require 'tmpdir'
3
3
 
4
- module Helpema
4
+ module HELPEMA
5
5
  module ZBar
6
-
7
6
  def self.cam(timeout=3)
8
7
  raw = ''
9
8
  IO.popen('zbarcam --nodisplay --raw --prescale=800x800', 'r') do |io|
@@ -35,6 +34,5 @@ module ZBar
35
34
  end
36
35
  raw
37
36
  end
38
-
39
37
  end
40
38
  end
data/lib/helpema.rb CHANGED
@@ -1,12 +1,11 @@
1
- module Helpema
2
- VERSION = '1.0.1'
3
- end
4
-
5
- # This Gem
6
- require 'helpema/ssss.rb'
7
- require 'helpema/zbar.rb'
8
- require 'helpema/youtubedl.rb'
1
+ module HELPEMA
2
+ VERSION = '2.0.200124'
9
3
 
4
+ autoload :Helpema, 'helpema/helpema.rb'
5
+ autoload :SSSS, 'helpema/ssss.rb'
6
+ autoload :YouTubeDL, 'helpema/youtubedl.rb'
7
+ autoload :ZBar, 'helpema/zbar.rb'
8
+ end
10
9
  # Requires:
11
10
  #`ruby`
12
11
  #`ssss-split`
metadata CHANGED
@@ -1,27 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: helpema
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 2.0.200124
5
5
  platform: ruby
6
6
  authors:
7
7
  - carlosjhr64
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-22 00:00:00.000000000 Z
11
+ date: 2020-01-24 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |
14
- Some wrappers on the following linux commands: ssss-split, ssss-combine, zbarcam, youtube-dl -j.
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",...).
15
17
 
16
18
  More later.
17
19
  email: carlosjhr64@gmail.com
18
20
  executables: []
19
21
  extensions: []
20
- extra_rdoc_files:
21
- - README.rdoc
22
+ extra_rdoc_files: []
22
23
  files:
23
- - README.rdoc
24
+ - README.md
24
25
  - lib/helpema.rb
26
+ - lib/helpema/helpema.rb
25
27
  - lib/helpema/ssss.rb
26
28
  - lib/helpema/youtubedl.rb
27
29
  - lib/helpema/zbar.rb
@@ -30,9 +32,7 @@ licenses:
30
32
  - MIT
31
33
  metadata: {}
32
34
  post_install_message:
33
- rdoc_options:
34
- - "--main"
35
- - README.rdoc
35
+ rdoc_options: []
36
36
  require_paths:
37
37
  - lib
38
38
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -46,15 +46,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  requirements:
49
- - 'ruby: ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-linux]'
49
+ - 'ruby: ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux]'
50
50
  - 'ssss-split: 0.5'
51
51
  - 'ssss-combine: 0.5'
52
- - 'zbarcam: 0.20'
53
- - 'gnome-screenshot: gnome-screenshot 3.22.0'
54
- rubyforge_project:
55
- rubygems_version: 2.6.13
52
+ - 'zbarcam: 0.23'
53
+ - 'gnome-screenshot: gnome-screenshot 3.34.0'
54
+ rubygems_version: 3.1.2
56
55
  signing_key:
57
56
  specification_version: 4
58
- summary: 'Some wrappers on the following linux commands: ssss-split, ssss-combine,
59
- zbarcam, youtube-dl -j.'
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",...).'
60
60
  test_files: []
data/README.rdoc DELETED
@@ -1,54 +0,0 @@
1
- = helpema
2
-
3
- {<img src="https://badge.fury.io/rb/helpema.svg" alt="Gem Version" />}[http://badge.fury.io/rb/helpema]
4
-
5
- == DESCRIPTION:
6
-
7
- Some wrappers on the following linux commands: ssss-split, ssss-combine, zbarcam, youtube-dl -j.
8
-
9
- More later.
10
-
11
- == SYNOPSIS:
12
-
13
- === Helpema::SSSS.split( secret, threshold, shares)
14
-
15
- === Helpema::SSSS.combine( *shared_secrets )
16
-
17
- === Helpema::ZBar.cam( timeout=3 )
18
-
19
- Reads qrcodes on camera.
20
-
21
- === Helpema::ZBar.screen
22
-
23
- Reads qrcodes on screen.
24
-
25
- === Helpema::YouTubeDL.json( url ){|obj| ... }
26
-
27
- == INSTALL:
28
-
29
- $ sudo gem install helpema
30
-
31
- == LICENSE:
32
-
33
- (The MIT License)
34
-
35
- Copyright (c) 2017 carlosjhr64
36
-
37
- Permission is hereby granted, free of charge, to any person obtaining
38
- a copy of this software and associated documentation files (the
39
- 'Software'), to deal in the Software without restriction, including
40
- without limitation the rights to use, copy, modify, merge, publish,
41
- distribute, sublicense, and/or sell copies of the Software, and to
42
- permit persons to whom the Software is furnished to do so, subject to
43
- the following conditions:
44
-
45
- The above copyright notice and this permission notice shall be
46
- included in all copies or substantial portions of the Software.
47
-
48
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
49
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
50
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
51
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
52
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
53
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
54
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.