w-stdlib 0.0.9 → 0.0.12
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 +4 -4
- data/lib/w-stdlib/core_ext/string.rb +9 -1
- data/lib/w-stdlib/prelude.rb +27 -0
- data/w-stdlib.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 91974a1619f3422256a2242641122ae6d6772987f951a14f5ee9b0a14d181898
|
4
|
+
data.tar.gz: 382a6972fd190d20e01ff8db0462b161ef23b92d983f5d373e30cc07e2f5061d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f49a7beee0df46384f7907e68c5aad231873d2cd521d4c27449d06040317b3e54b8f3a2569fac444b6e03c42016ad75a220ec4e47c0151dc91d664096f5cd7c
|
7
|
+
data.tar.gz: 951c96aeefb755d40c872913fd0ba2946ae6c4a3294ea49275e75176e49f41a87e553857df91e70f8f957037f9a8e62f2687d76dc000339e764169005a986d7b
|
@@ -105,6 +105,14 @@ module StringExt
|
|
105
105
|
downcase.include? s.downcase
|
106
106
|
end
|
107
107
|
|
108
|
+
def contains?(s)
|
109
|
+
include?(s)
|
110
|
+
end
|
111
|
+
|
112
|
+
def icontains?(s)
|
113
|
+
include_ignore_case?(s)
|
114
|
+
end
|
115
|
+
|
108
116
|
def is_numeric?
|
109
117
|
Float(self)
|
110
118
|
true
|
@@ -113,7 +121,7 @@ module StringExt
|
|
113
121
|
end
|
114
122
|
|
115
123
|
def indent_count
|
116
|
-
scan(/^\s+/).first
|
124
|
+
scan(/^\s+/).first&.length || 0
|
117
125
|
end
|
118
126
|
end
|
119
127
|
end
|
data/lib/w-stdlib/prelude.rb
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
require 'http'
|
2
|
+
require 'json'
|
3
|
+
require_relative 'core_ext/string'
|
4
|
+
|
5
|
+
using StringExt
|
6
|
+
|
1
7
|
def fatal(msg, code=1, pref='[!] ')
|
2
8
|
STDERR.puts pref + msg
|
3
9
|
exit code
|
@@ -15,6 +21,27 @@ def json_file(name)
|
|
15
21
|
JSON.parse File.read(name)
|
16
22
|
end
|
17
23
|
|
24
|
+
def read_json(path)
|
25
|
+
json_file(path)
|
26
|
+
end
|
27
|
+
|
28
|
+
def write_json(path, o, pretty=false)
|
29
|
+
json = pretty ? JSON.pretty_generate(o) : o.to_json
|
30
|
+
File.write(path, json)
|
31
|
+
end
|
32
|
+
|
33
|
+
def get_json(url)
|
34
|
+
HTTP.get(url).to_s.from_json
|
35
|
+
end
|
36
|
+
|
37
|
+
def read_lines(path)
|
38
|
+
File.readlines(path).map(&:strip).reject(&:empty?)
|
39
|
+
end
|
40
|
+
|
41
|
+
def write_lines(path, lines)
|
42
|
+
File.write(path, lines.join("\n"))
|
43
|
+
end
|
44
|
+
|
18
45
|
def home_join(*paths)
|
19
46
|
home = ENV['HOME']
|
20
47
|
if paths.empty?
|
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.
|
3
|
+
g.version = '0.0.12'
|
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.
|
4
|
+
version: 0.0.12
|
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-
|
11
|
+
date: 2022-07-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parallel
|