cmdlet 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/lib/cmdlet/string_tokenizer.rb +41 -0
- data/lib/cmdlet/version.rb +1 -1
- data/lib/cmdlet.rb +1 -0
- data/package-lock.json +2 -2
- data/package.json +1 -1
- metadata +16 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae44ce26b73b2f24d493ad916c12328b2814e5e670cf8828079e4e7e32cc9f4a
|
4
|
+
data.tar.gz: a9efa32929e26af9cdda7d207834d025039c049dd365ae79abacd1d7da33c5b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c79358c0e425a5dbe5f5441c69afc489eb86034c52122c14a217a2fa0eeb3b19249c578bc002118852a635c1404db62f905f1245813f66edf91db39909d6a18b
|
7
|
+
data.tar.gz: 795edc645cc8747e9551ac5f8027b738c4d579ca6943b20ec82072d383172e3af7e39e1f6f4788205d80abeb8ba2749c23e1b553b56bef92c6fe04cece21d726
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## [0.0.4](https://github.com/klueless-io/cmdlet/compare/v0.0.3...v0.0.4) (2022-07-08)
|
2
|
+
|
3
|
+
|
4
|
+
### Bug Fixes
|
5
|
+
|
6
|
+
* add basic configuration ([d8ecbb1](https://github.com/klueless-io/cmdlet/commit/d8ecbb17f61600de3b3f5d8987cc132d6e5ba0b2))
|
7
|
+
|
1
8
|
## [0.0.3](https://github.com/klueless-io/cmdlet/compare/v0.0.2...v0.0.3) (2022-07-08)
|
2
9
|
|
3
10
|
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/core_ext/string'
|
4
|
+
|
5
|
+
module Cmdlet
|
6
|
+
# String tokenizer will clean up a string so that all sorts of formatted strings can be
|
7
|
+
# represented in a consistent fashion
|
8
|
+
class StringTokenizer
|
9
|
+
# Tokenize string
|
10
|
+
# rubocop:disable Metrics/ParameterLists
|
11
|
+
def parse(value,
|
12
|
+
preserve_case: false,
|
13
|
+
compress_prefix_numerals: true,
|
14
|
+
compress_suffix_numerals: true,
|
15
|
+
separator: '-',
|
16
|
+
forced_separator: false)
|
17
|
+
return '' if value.nil?
|
18
|
+
|
19
|
+
# Insert space before any lowercaseUppercase
|
20
|
+
value = value.gsub(/(?<=[a-z])(?=[A-Z])/, ' ')
|
21
|
+
|
22
|
+
# make sure that any numbers followed by space and then some text has the white space removed
|
23
|
+
value = value.gsub(/^(\d*)(\s*)/, '\1') if compress_prefix_numerals
|
24
|
+
|
25
|
+
# Technique1: make sure that trailing space followed by number is compressed
|
26
|
+
# NOTE: named groups don't seem to work with \1, \2 etc.
|
27
|
+
# ex = /(?<space>[\s]*)(?<number>[\d]*)$/
|
28
|
+
# value =value.sub(ex) { |_| Regexp.last_match[:number] }
|
29
|
+
|
30
|
+
# Technique2: make sure that trailing space followed by number is compressed
|
31
|
+
value = value.gsub(/(\s*)(\d*)$/, '\2') if compress_suffix_numerals
|
32
|
+
|
33
|
+
value = value.parameterize(preserve_case: preserve_case, separator: separator) # (separator: ' ')
|
34
|
+
|
35
|
+
value = value.gsub(/[-_]/, separator) if forced_separator
|
36
|
+
|
37
|
+
value
|
38
|
+
end
|
39
|
+
# rubocop:enable Metrics/ParameterLists
|
40
|
+
end
|
41
|
+
end
|
data/lib/cmdlet/version.rb
CHANGED
data/lib/cmdlet.rb
CHANGED
data/package-lock.json
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
{
|
2
2
|
"name": "cmdlet",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.5",
|
4
4
|
"lockfileVersion": 2,
|
5
5
|
"requires": true,
|
6
6
|
"packages": {
|
7
7
|
"": {
|
8
8
|
"name": "cmdlet",
|
9
|
-
"version": "0.0.
|
9
|
+
"version": "0.0.5",
|
10
10
|
"devDependencies": {
|
11
11
|
"@klueless-js/semantic-release-rubygem": "github:klueless-js/semantic-release-rubygem",
|
12
12
|
"@semantic-release/changelog": "^6.0.1",
|
data/package.json
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cmdlet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Cruwys
|
@@ -10,6 +10,20 @@ bindir: exe
|
|
10
10
|
cert_chain: []
|
11
11
|
date: 2022-07-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '6'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '6'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: k_config
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -55,6 +69,7 @@ files:
|
|
55
69
|
- bin/setup
|
56
70
|
- lib/cmdlet.rb
|
57
71
|
- lib/cmdlet/configuration.rb
|
72
|
+
- lib/cmdlet/string_tokenizer.rb
|
58
73
|
- lib/cmdlet/version.rb
|
59
74
|
- package-lock.json
|
60
75
|
- package.json
|