w-stdlib 0.0.10 → 0.0.11
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 +8 -0
- 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: aa29cae0da989123d7bd48801ead7b06f6a8c5f20a85e5feb471ac566c43fdb0
|
4
|
+
data.tar.gz: 6bb41ba957c8c800e98c081ac8208101ae40fa96942a2460cf81b8294ef3ef3a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa39a709023a1423f00f009d01026972f7a71a8ecd718082df99b4b6c07c2718c13c0dcc2aaa3ee045fadbcde476b768ac34d0bf4f8fdcde90a7732cdbd910ac
|
7
|
+
data.tar.gz: 6f9b027bf848f621fc4d98620d516611bb51f42a3675d99eebc2fd03aa163f72a4c6085aa8329b234df4a0e67fa3f08375486021a50423df2efb53fd76ad9ffa
|
data/lib/w-stdlib/prelude.rb
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
require 'http'
|
2
|
+
require 'json'
|
3
|
+
require 'w-stdlib/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.11'
|
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.11
|
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
|