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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1be9c5b12a7d325c4714974c0a227b09aa561666e0c3b0cd8d07e1babb683686
4
- data.tar.gz: 839f8736548006f150fe24181efac6e3e88e606c1e686a659045c08f492737dc
3
+ metadata.gz: aa29cae0da989123d7bd48801ead7b06f6a8c5f20a85e5feb471ac566c43fdb0
4
+ data.tar.gz: 6bb41ba957c8c800e98c081ac8208101ae40fa96942a2460cf81b8294ef3ef3a
5
5
  SHA512:
6
- metadata.gz: aae578dff551dba2619b53c753da67d8e56cf9987a08e474d9eca3155f61debf8a54843227880783944e771bb7bca710f4a40f0dcafcc608c8b2231b12087bea
7
- data.tar.gz: 9cbefb46f31a222904ecc7cf968330bb0933bf0755bc5ddeefff4e299b34c318554cad26f39e8d2ea001cfb7dc0396486a44d9d50277729c7892600b9dd858cd
6
+ metadata.gz: fa39a709023a1423f00f009d01026972f7a71a8ecd718082df99b4b6c07c2718c13c0dcc2aaa3ee045fadbcde476b768ac34d0bf4f8fdcde90a7732cdbd910ac
7
+ data.tar.gz: 6f9b027bf848f621fc4d98620d516611bb51f42a3675d99eebc2fd03aa163f72a4c6085aa8329b234df4a0e67fa3f08375486021a50423df2efb53fd76ad9ffa
@@ -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
@@ -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.10'
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.10
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-02-20 00:00:00.000000000 Z
11
+ date: 2022-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parallel