l42_my_ruby 0.1.2 → 0.1.5

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: 878bf96a608ecbdb0a5fa11dfd1dfd1623843fa12ecede6104a58eb039324758
4
- data.tar.gz: a73393d4a5268da7ce0b03f2cd8e4acdf1e82d3526c20c371b7585eac0ce464e
3
+ metadata.gz: 4938cb9057c2b175d94365f78099bd19aeed2635d429db074fb60524e5c8a271
4
+ data.tar.gz: bdc033b44f684c1ed42abdc89261beea32704184332f97e23148a04e61e7606d
5
5
  SHA512:
6
- metadata.gz: f85bb9344263e6d1ab22b106631600e828c7f21cc6b0cf8e267fb58933b9a78c75f9828c1f6f02185bed1bb9438e50ab3bd91393d41bfe11242c05b2d3b3308d
7
- data.tar.gz: edba69dac39e3c02b23219ced7052faf59411c4121472852fefb83ec9bc61e75f1a0859586fb0eb05afe145467a202b7e38e4b994cf53080a2feb7d111ba2ba7
6
+ metadata.gz: d59faa935852bde2cfad6bb494ba4840f492d0a20c226e220cc02ae52004e4aa06fc1921c269f5e82a9638c54223a6d5f78718be68754050f9ad774b4d0dd9dd
7
+ data.tar.gz: 46e4cad75820294c553c48b588784dc45f7147b592ebbdc33772178bdad2863435d53abec9ad1666180176a3679be85555da0e2ab616f873bb039827c4b72426
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
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)
2
+ [![Coverage Status](https://coveralls.io/repos/github/RobertDober/l42_my_ruby/badge.svg?branch=master)](https://coveralls.io/github/RobertDober/l42_my_ruby?branch=master)
3
+ [![Gem Version](https://badge.fury.io/rb/l42_my_ruby.svg)](http://badge.fury.io/rb/l42_my_ruby)
4
+ [![Gem Downloads](https://img.shields.io/gem/dt/l42_my_ruby.svg)](https://rubygems.org/gems/l42_my_ruby)
5
5
 
6
6
  # L42MyRuby
7
7
 
data/bin/mv_pfx_by_now ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require_relative '../lib/l42'
5
+
6
+ L42::Monad.interact(L42::Interfaces::PfxByNow)
7
+ # SPDX-License-Identifier: Apache-2.0
data/bin/mv_to_random CHANGED
@@ -1,4 +1,7 @@
1
- #!/usr/bin/env bash
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- ASDF_RUBY_VERSION=3.1.2 ruby $(realpath $0).rb $@
4
+ require_relative '../lib/l42'
4
5
 
6
+ L42::Monad.interact(L42::Interfaces::ToRandom)
7
+ # SPDX-License-Identifier: Apache-2.0
data/bin/mv_with_ts CHANGED
@@ -1,4 +1,6 @@
1
- #!/usr/bin/env bash
2
-
3
- ASDF_RUBY_VERSION=3.1.2 ruby $(realpath $0).rb $@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ require_relative '../lib/l42'
4
4
 
5
+ L42::Monad.functional_output(L42::Interfaces::WithTs, *ARGV)
6
+ # SPDX-License-Identifier: Apache-2.0
data/bin/tx_send CHANGED
@@ -1,4 +1,12 @@
1
- #!/usr/bin/env bash
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- ASDF_RUBY_VERSION=3.1.2 ruby $(realpath $0).rb $@ | bash
4
+ require_relative '../lib/l42'
4
5
 
6
+ output =
7
+ L42::Monad
8
+ .functional_input(L42::Interfaces::TxSend, ARGV.first, use_params: ARGV.drop(1))
9
+ output&.each do |line|
10
+ system(line)
11
+ end
12
+ # SPDX-License-Identifier: Apache-2.0
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'lab42/rgxargs'
4
+ require 'securerandom'
5
+ module L42
6
+ module Interfaces
7
+ module PfxByNow
8
+ extend self
9
+
10
+ def call(files)
11
+ now = Time.now.to_i.to_s(16)
12
+ [
13
+ :stdout,
14
+ files.map(&_pfx_by_now(now))
15
+ ]
16
+ end
17
+
18
+ private
19
+
20
+ def _pfx_by_now(now)
21
+ ->file do
22
+ ["mv", file.inspect, [now, file].join("_").inspect ].join(" ")
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ # SPDX-License-Identifier: Apache-2.0
@@ -6,8 +6,7 @@ module L42
6
6
  module TxSend
7
7
  extend self
8
8
 
9
- def call(lines)
10
- Lab42::Rgxargs.new.parse(ARGV) => [OpenStruct, [dest], *]
9
+ def call(lines, dest)
11
10
  [
12
11
  :stdout,
13
12
  [*lines.map(&_send_to(dest)), "tmux select-window -t #{dest}"]
data/lib/l42/monad.rb CHANGED
@@ -6,8 +6,8 @@ module L42
6
6
 
7
7
  class ContractViolation < RuntimeError; end
8
8
 
9
- def interact(interactor)
10
- case interactor.($stdin.readlines(chomp: true))
9
+ def interact(interactor, *args, **kwds)
10
+ case interactor.($stdin.readlines(chomp: true), *args, **kwds)
11
11
  in [:stdout, output]
12
12
  $stdout.puts(output)
13
13
  in [:stderr, output]
@@ -29,6 +29,21 @@ module L42
29
29
  "a transformer needs to return a result of type `[:stderr|:stdout, anything]`, not #{x.inspect}"
30
30
  end
31
31
  end
32
+
33
+ def functional_input(transformer, *args, use_params: nil)
34
+ input =
35
+ use_params || $stdin.readlines(chomp: true)
36
+ case transformer.(input, *args)
37
+ in [:stdout, output]
38
+ output
39
+ in [:stderr, output]
40
+ $stderr.puts(output)
41
+ exit(-1)
42
+ in x
43
+ raise ContractViolation,
44
+ "a transformer needs to return a result of type `[:stderr|:stdout, anything]`, not #{x.inspect}"
45
+ end
46
+ end
32
47
  end
33
48
  end
34
49
  # SPDX-License-Identifier: Apache-2.0
data/lib/l42/version.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  module L42
4
4
  module Version
5
- VERSION = '0.1.2'
5
+ VERSION = '0.1.5'
6
6
  end
7
7
  end
8
8
  # SPDX-License-Identifier: Apache-2.0
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: l42_my_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.5
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-25 00:00:00.000000000 Z
11
+ date: 2022-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lab42_rgxargs
@@ -30,6 +30,7 @@ description: |
30
30
  Binaries and libs which make Ruby awesome (for me)
31
31
  email: robert.dober@gmail.com
32
32
  executables:
33
+ - mv_pfx_by_now
33
34
  - mv_to_random
34
35
  - mv_with_ts
35
36
  - tx_send
@@ -38,14 +39,13 @@ extra_rdoc_files: []
38
39
  files:
39
40
  - LICENSE
40
41
  - README.md
42
+ - bin/mv_pfx_by_now
41
43
  - bin/mv_to_random
42
- - bin/mv_to_random.rb
43
44
  - bin/mv_with_ts
44
- - bin/mv_with_ts.rb
45
45
  - bin/tx_send
46
- - bin/tx_send.rb
47
46
  - lib/l42.rb
48
47
  - lib/l42/data_class.rb
48
+ - lib/l42/interfaces/pfx_by_now.rb
49
49
  - lib/l42/interfaces/to_random.rb
50
50
  - lib/l42/interfaces/tx_send.rb
51
51
  - lib/l42/interfaces/with_ts.rb
data/bin/mv_to_random.rb DELETED
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- raise RuntimeError, "Do not require me" unless __FILE__ == $PROGRAM_NAME
4
-
5
- require_relative '../lib/l42'
6
-
7
- L42::Monad.interact(L42::Interfaces::ToRandom)
8
- # SPDX-License-Identifier: Apache-2.0
data/bin/mv_with_ts.rb DELETED
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- raise RuntimeError, "Do not require me" unless __FILE__ == $PROGRAM_NAME
4
-
5
- require_relative '../lib/l42'
6
-
7
- L42::Monad.functional_output(L42::Interfaces::WithTs, *ARGV)
8
- # SPDX-License-Identifier: Apache-2.0
data/bin/tx_send.rb DELETED
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- raise RuntimeError, "Do not require me" unless __FILE__ == $PROGRAM_NAME
4
-
5
- require_relative '../lib/l42'
6
-
7
- L42::Monad.interact(L42::Interfaces::TxSend)
8
- # SPDX-License-Identifier: Apache-2.0