w-stdlib 0.0.11 → 0.0.14

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: aa29cae0da989123d7bd48801ead7b06f6a8c5f20a85e5feb471ac566c43fdb0
4
- data.tar.gz: 6bb41ba957c8c800e98c081ac8208101ae40fa96942a2460cf81b8294ef3ef3a
3
+ metadata.gz: 3355c40d71a6abcf9d8d1f74872c23fa251444c5105f3798f6cbbe90497635ed
4
+ data.tar.gz: 17f0b9a70c22a681bfc6576e9f7b5789d9dd592bdc300803308c620595bb9740
5
5
  SHA512:
6
- metadata.gz: fa39a709023a1423f00f009d01026972f7a71a8ecd718082df99b4b6c07c2718c13c0dcc2aaa3ee045fadbcde476b768ac34d0bf4f8fdcde90a7732cdbd910ac
7
- data.tar.gz: 6f9b027bf848f621fc4d98620d516611bb51f42a3675d99eebc2fd03aa163f72a4c6085aa8329b234df4a0e67fa3f08375486021a50423df2efb53fd76ad9ffa
6
+ metadata.gz: 27a8fb9264d9cf7ff56d471107b2a45e9a3968fe5fe4188606ff6a2184fc5c9c32f62e5f52a323b5fe5c7433c23cccb69c23ffa146eedcf8d7d1a09a145d91ae
7
+ data.tar.gz: 13aa45d3fd2fc54f0a7a74a93ae191fb49f725efad56877c934143f81ca1a1d64e654318d2260169d8d8dff05a8f8d2bc0cd28da550f738ee82914eb234a1986
@@ -5,10 +5,36 @@ require 'yaml'
5
5
 
6
6
  module StringExt
7
7
  refine String do
8
+ def include_any?(ss)
9
+ ss.any? { include? _1 }
10
+ end
11
+
12
+ def include_all?(ss)
13
+ ss.all? { include? _1 }
14
+ end
15
+
16
+ def match_any?(pats)
17
+ pats.any? { match? _1 }
18
+ end
19
+
20
+ def match_all?(pats)
21
+ pats.all? { match? _1 }
22
+ end
23
+
24
+ def
25
+
8
26
  def from_yaml
9
27
  YAML.safe_load(self)
10
28
  end
11
29
 
30
+ def yaml_encode
31
+ to_yaml
32
+ end
33
+
34
+ def yaml_decode
35
+ from_yaml
36
+ end
37
+
12
38
  def from_json
13
39
  JSON.parse self
14
40
  end
@@ -25,6 +51,22 @@ module StringExt
25
51
  Base64.decode64 self
26
52
  end
27
53
 
54
+ def b64_encode
55
+ to_b64
56
+ end
57
+
58
+ def b64_decode
59
+ from_b64
60
+ end
61
+
62
+ def json_encode
63
+ to_json
64
+ end
65
+
66
+ def json_decode
67
+ from_json
68
+ end
69
+
28
70
  def url_encode
29
71
  CGI.escape self
30
72
  end
@@ -1,6 +1,6 @@
1
1
  require 'http'
2
2
  require 'json'
3
- require 'w-stdlib/core_ext/string'
3
+ require_relative 'core_ext/string'
4
4
 
5
5
  using StringExt
6
6
 
@@ -38,6 +38,14 @@ def read_lines(path)
38
38
  File.readlines(path).map(&:strip).reject(&:empty?)
39
39
  end
40
40
 
41
+ def stdin_lines
42
+ $stdin.lines.map(&:strip).reject(&:empty?)
43
+ end
44
+
45
+ def stdin_json
46
+ $stdin.read.from_json
47
+ end
48
+
41
49
  def write_lines(path, lines)
42
50
  File.write(path, lines.join("\n"))
43
51
  end
data/w-stdlib.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |g|
2
2
  g.name = 'w-stdlib'
3
- g.version = '0.0.11'
3
+ g.version = '0.0.14'
4
4
  g.summary = 'Pre-alpha package that contains abstractions that I find useful when scripting. Not suitable for production use. Breaking changes highly likely even with minor version bumps. Use at your own risk'
5
5
  g.description = g.summary
6
6
  g.authors = ['will@btlr.dev']
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: w-stdlib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - will@btlr.dev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-06 00:00:00.000000000 Z
11
+ date: 2022-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parallel