l42_my_ruby 0.1.5 → 0.1.6

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: 4938cb9057c2b175d94365f78099bd19aeed2635d429db074fb60524e5c8a271
4
- data.tar.gz: bdc033b44f684c1ed42abdc89261beea32704184332f97e23148a04e61e7606d
3
+ metadata.gz: 8a762c688eb1bbaa6420cfb79a6268bb4443d972ac1b68c6083fe617e4e0c4a8
4
+ data.tar.gz: 0e722cc52df7fa8c8c99f2be71403701d6f7c04b954306fca3ccae062377cf64
5
5
  SHA512:
6
- metadata.gz: d59faa935852bde2cfad6bb494ba4840f492d0a20c226e220cc02ae52004e4aa06fc1921c269f5e82a9638c54223a6d5f78718be68754050f9ad774b4d0dd9dd
7
- data.tar.gz: 46e4cad75820294c553c48b588784dc45f7147b592ebbdc33772178bdad2863435d53abec9ad1666180176a3679be85555da0e2ab616f873bb039827c4b72426
6
+ metadata.gz: 790d92485477fd06231991265cfe43f6a72278aaa348d0a51e5e2d5c69da982315dd9e52cd61d28052b16d95682cd43c047dd86be8026ff97f28e597eaff6bcb
7
+ data.tar.gz: 41b618d3238f06f5d301f10cfbb1a3c80672d54fd7b3c9c3d138699e6f265036ff9ad8fb3a7e4595a3d3d3104db204eb511536bbe9d7a7fa96126d30693b4abc
data/bin/map_inp 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::MapInp, *ARGV)
7
+ # SPDX-License-Identifier: Apache-2.0
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'securerandom'
4
+ module L42
5
+ module Interfaces
6
+ module MapInp
7
+ extend self
8
+
9
+ def call(input, pattern)
10
+ pattern = pattern.gsub(Now, Time.now.to_i.to_s(16))
11
+ [
12
+ :stdout,
13
+ input.each_with_index.map(&_map(pattern))
14
+ ]
15
+ end
16
+
17
+ private
18
+
19
+ Count = %r{(?<!%)%c}
20
+ FormattedCount = %r{(?<!%)%f(\d+)}
21
+ Now = %r{(?<!%)%x}
22
+ Replacer = %r{(?<!%)%(?!%)}
23
+
24
+ def _map(pattern)
25
+ ->(record, idx) do
26
+ _transform_inp(pattern, record, idx)
27
+ end
28
+ end
29
+
30
+ def _replace_formatted(idx)
31
+ ->match_str do
32
+ "%0#{match_str[2..]}d" % idx
33
+ end
34
+ end
35
+
36
+ def _transform_inp(pattern, record, idx)
37
+ pattern
38
+ .gsub(Count, idx.to_s)
39
+ .gsub(FormattedCount, &_replace_formatted(idx))
40
+ .gsub(Replacer, record)
41
+ .gsub("%%", "%")
42
+ end
43
+ end
44
+ end
45
+ end
46
+ # SPDX-License-Identifier: Apache-2.0
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'lab42/rgxargs'
4
3
  require 'securerandom'
5
4
  module L42
6
5
  module Interfaces
data/lib/l42/version.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  module L42
4
4
  module Version
5
- VERSION = '0.1.5'
5
+ VERSION = '0.1.6'
6
6
  end
7
7
  end
8
8
  # SPDX-License-Identifier: Apache-2.0
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: l42_my_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Dober
@@ -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
+ - map_inp
33
34
  - mv_pfx_by_now
34
35
  - mv_to_random
35
36
  - mv_with_ts
@@ -39,12 +40,14 @@ extra_rdoc_files: []
39
40
  files:
40
41
  - LICENSE
41
42
  - README.md
43
+ - bin/map_inp
42
44
  - bin/mv_pfx_by_now
43
45
  - bin/mv_to_random
44
46
  - bin/mv_with_ts
45
47
  - bin/tx_send
46
48
  - lib/l42.rb
47
49
  - lib/l42/data_class.rb
50
+ - lib/l42/interfaces/map_inp.rb
48
51
  - lib/l42/interfaces/pfx_by_now.rb
49
52
  - lib/l42/interfaces/to_random.rb
50
53
  - lib/l42/interfaces/tx_send.rb