w-stdlib 0.0.9 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cecbee5e3aa41749ef12eb7baa007b80d838b7116583b827c3fc24678061d9ec
4
- data.tar.gz: e56d2494c0d9207c20dc9e18ff8d3ed32f0f766be29dc36f257276cc6fb94efa
3
+ metadata.gz: 91974a1619f3422256a2242641122ae6d6772987f951a14f5ee9b0a14d181898
4
+ data.tar.gz: 382a6972fd190d20e01ff8db0462b161ef23b92d983f5d373e30cc07e2f5061d
5
5
  SHA512:
6
- metadata.gz: e4ec2e7376b8ae6e2d72ebe191cdfddcfd43ae259e7ba8edee671dafafbb8ee8959e151a32f1fff7d14d909dedbc2d87537832d40bc57eee576cd962b7637f4a
7
- data.tar.gz: a47816d547d543c4587c05083d0bc16e96ec97c7c0501391842e028c6fd305d9f2fc34134d5881ad6eab67f29f7953fd2b08e9b5def5ac849cb51246dd8fd6ce
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.length
124
+ scan(/^\s+/).first&.length || 0
117
125
  end
118
126
  end
119
127
  end
@@ -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.9'
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.9
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-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