l42_my_ruby 0.1.0 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -0
- data/bin/mv_to_random +4 -0
- data/bin/mv_to_random.rb +8 -0
- data/bin/mv_with_ts +4 -0
- data/bin/mv_with_ts.rb +8 -0
- data/bin/tx_send +4 -0
- data/bin/tx_send.rb +8 -0
- data/lib/l42/interfaces/to_random.rb +30 -0
- data/lib/l42/interfaces/tx_send.rb +27 -0
- data/lib/l42/interfaces/with_ts.rb +21 -0
- data/lib/l42/monad.rb +34 -0
- data/lib/l42/version.rb +1 -1
- metadata +31 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 878bf96a608ecbdb0a5fa11dfd1dfd1623843fa12ecede6104a58eb039324758
|
4
|
+
data.tar.gz: a73393d4a5268da7ce0b03f2cd8e4acdf1e82d3526c20c371b7585eac0ce464e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f85bb9344263e6d1ab22b106631600e828c7f21cc6b0cf8e267fb58933b9a78c75f9828c1f6f02185bed1bb9438e50ab3bd91393d41bfe11242c05b2d3b3308d
|
7
|
+
data.tar.gz: edba69dac39e3c02b23219ced7052faf59411c4121472852fefb83ec9bc61e75f1a0859586fb0eb05afe145467a202b7e38e4b994cf53080a2feb7d111ba2ba7
|
data/README.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
[![CI](https://github.com/robertdober/l42_my_ruby/workflows/CI/badge.svg)](https://github.com/robertdober/l42_my_ruby/actions)
|
2
|
+
[![Coverage Status](https://coveralls.io/repos/github/RobertDober/l42_my_ruby/badge.svg?branch=main)](https://coveralls.io/github/RobertDober/l42_my_ruby?branch=main)
|
3
|
+
[![Gem Version](http://img.shields.io/gem/v/l42.svg)](https://rubygems.org/gems/l42_my_ruby)
|
4
|
+
[![Gem Downloads](https://img.shields.io/gem/dt/l42.svg)](https://rubygems.org/gems/l42_my_ruby)
|
5
|
+
|
1
6
|
# L42MyRuby
|
2
7
|
|
3
8
|
Occupying the `L42` namespace this gem provides tools and binaries useful to me (lab42) and
|
data/bin/mv_to_random
ADDED
data/bin/mv_to_random.rb
ADDED
data/bin/mv_with_ts
ADDED
data/bin/mv_with_ts.rb
ADDED
data/bin/tx_send
ADDED
data/bin/tx_send.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'lab42/rgxargs'
|
4
|
+
require 'securerandom'
|
5
|
+
module L42
|
6
|
+
module Interfaces
|
7
|
+
module ToRandom
|
8
|
+
extend self
|
9
|
+
|
10
|
+
def call(files)
|
11
|
+
Lab42::Rgxargs.new.parse(ARGV) => [kwds, args, *]
|
12
|
+
[
|
13
|
+
:stdout,
|
14
|
+
files.map(&_random_file(args, kwds))
|
15
|
+
]
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def _random_file(_args, kwds)
|
21
|
+
->file do
|
22
|
+
ext = File.extname(file)
|
23
|
+
name = SecureRandom.hex((kwds.hex || 10).to_i)
|
24
|
+
["mv #{file.inspect} ", name, ext].join
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
# SPDX-License-Identifier: Apache-2.0
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'lab42/rgxargs'
|
4
|
+
module L42
|
5
|
+
module Interfaces
|
6
|
+
module TxSend
|
7
|
+
extend self
|
8
|
+
|
9
|
+
def call(lines)
|
10
|
+
Lab42::Rgxargs.new.parse(ARGV) => [OpenStruct, [dest], *]
|
11
|
+
[
|
12
|
+
:stdout,
|
13
|
+
[*lines.map(&_send_to(dest)), "tmux select-window -t #{dest}"]
|
14
|
+
]
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def _send_to(dest)
|
20
|
+
->line do
|
21
|
+
%(tmux send-keys -t #{dest} '#{line}' C-m)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
# SPDX-License-Identifier: Apache-2.0
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module L42
|
4
|
+
module Interfaces
|
5
|
+
module WithTs
|
6
|
+
extend self
|
7
|
+
def call(file_name, dest_dir, *tags)
|
8
|
+
[
|
9
|
+
:stdout,
|
10
|
+
%(mv #{file_name.inspect} #{File.join(dest_dir, _make_tagged_name(file_name, tags)).inspect})
|
11
|
+
]
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
def _make_tagged_name(file_name, tags)
|
16
|
+
[*tags.sort, Time.now.to_i.to_s(16)].join("-") + File.extname(file_name)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
# SPDX-License-Identifier: Apache-2.0
|
data/lib/l42/monad.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module L42
|
4
|
+
module Monad
|
5
|
+
extend self
|
6
|
+
|
7
|
+
class ContractViolation < RuntimeError; end
|
8
|
+
|
9
|
+
def interact(interactor)
|
10
|
+
case interactor.($stdin.readlines(chomp: true))
|
11
|
+
in [:stdout, output]
|
12
|
+
$stdout.puts(output)
|
13
|
+
in [:stderr, output]
|
14
|
+
$stderr.puts(output)
|
15
|
+
in x
|
16
|
+
raise ContractViolation,
|
17
|
+
"an interactor needs to return a result of type `[:stderr|:stdout, anything]`, not #{x.inspect}"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def functional_output(transformer, *args)
|
22
|
+
case transformer.(*args)
|
23
|
+
in [:stdout, output]
|
24
|
+
$stdout.puts(output)
|
25
|
+
in [:stderr, output]
|
26
|
+
$stderr.puts(output)
|
27
|
+
in x
|
28
|
+
raise ContractViolation,
|
29
|
+
"a transformer needs to return a result of type `[:stderr|:stdout, anything]`, not #{x.inspect}"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
# SPDX-License-Identifier: Apache-2.0
|
data/lib/l42/version.rb
CHANGED
metadata
CHANGED
@@ -1,28 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: l42_my_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Dober
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-08-
|
12
|
-
dependencies:
|
11
|
+
date: 2022-08-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: lab42_rgxargs
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.2.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.2.1
|
13
27
|
description: |
|
14
28
|
All my Ruby Code
|
15
29
|
|
16
30
|
Binaries and libs which make Ruby awesome (for me)
|
17
31
|
email: robert.dober@gmail.com
|
18
|
-
executables:
|
32
|
+
executables:
|
33
|
+
- mv_to_random
|
34
|
+
- mv_with_ts
|
35
|
+
- tx_send
|
19
36
|
extensions: []
|
20
37
|
extra_rdoc_files: []
|
21
38
|
files:
|
22
39
|
- LICENSE
|
23
40
|
- README.md
|
41
|
+
- bin/mv_to_random
|
42
|
+
- bin/mv_to_random.rb
|
43
|
+
- bin/mv_with_ts
|
44
|
+
- bin/mv_with_ts.rb
|
45
|
+
- bin/tx_send
|
46
|
+
- bin/tx_send.rb
|
24
47
|
- lib/l42.rb
|
25
48
|
- lib/l42/data_class.rb
|
49
|
+
- lib/l42/interfaces/to_random.rb
|
50
|
+
- lib/l42/interfaces/tx_send.rb
|
51
|
+
- lib/l42/interfaces/with_ts.rb
|
52
|
+
- lib/l42/monad.rb
|
26
53
|
- lib/l42/version.rb
|
27
54
|
homepage: https://github.com/robertdober/l42_my_ruby
|
28
55
|
licenses:
|