cmdlet 0.3.0 → 0.4.2
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/.builders/.templates/handlebars_helper.rb +1 -1
- data/.builders/data/cmdlets/case.json +0 -22
- data/.builders/data/cmdlets/inflection.json +29 -0
- data/.builders/director/cmdlet_director.rb +4 -0
- data/.builders/generators/cmdlets/case.rb +0 -15
- data/.builders/generators/cmdlets/inflection.rb +16 -0
- data/CHANGELOG.md +21 -0
- data/lib/cmdlet/_.rb +2 -1
- data/lib/cmdlet/inflection/pluralize_number.rb +21 -0
- data/lib/cmdlet/inflection/pluralize_number_word.rb +21 -0
- data/lib/cmdlet/version.rb +1 -1
- data/package-lock.json +2 -2
- data/package.json +1 -1
- metadata +4 -4
- data/.builders/documents/commands.rb +0 -225
- data/lib/cmdlet/case/sentence.rb +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9506e418e3b6a429f7022e585a9252980d9bb6ddc7a5e63701ffb3500b9388b8
|
4
|
+
data.tar.gz: '038194a239e9fb9e440c6c697837a6172a2aa3cee05ae6f5b6a2104a231a84bc'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8743f42553160393f595bc4d10b486d8ff35faf28b391346cc471ccc11bb4a351552a59f4bc9fa46778d90cc78caae8ea6e255564010303160216309869b757
|
7
|
+
data.tar.gz: d38a9aba60cad381a19bbf1da0e81423116fb07c6ef4e7a88fb1105ea6c6e1522e5be782bd20e6b34a95d98d13f216da2e41895b68f54213423400be90be50c0
|
@@ -9,7 +9,7 @@ module Handlebarsjs
|
|
9
9
|
register_cmdlet(Cmdlet::{{camel cmdlet.category}}::{{camel cmdlet.name}})
|
10
10
|
|
11
11
|
def to_proc
|
12
|
-
->({{#each cmdlet.parameters}}{{#if ./splat}}{{./splat}}{{/if}}{{./name}}{{#if @last}}{{^}}, {{/if}}{{/each}}, _opts) { wrapper(cmdlet.call({{#each cmdlet.parameters}}{{#if ./splat}}{{./splat}}{{/if}}{{./name}}{{#if @last}}{{^}}, {{/if}}{{/each}})) }
|
12
|
+
->({{#each cmdlet.parameters}}{{#if ./splat}}{{./splat}}{{/if}}{{./name}}{{#if ./default}} = {{{./default}}}{{/if}}{{#if @last}}{{^}}, {{/if}}{{/each}}, _opts) { wrapper(cmdlet.call({{#each cmdlet.parameters}}{{#if ./splat}}{{./splat}}{{/if}}{{./name}}{{#if @last}}{{^}}, {{/if}}{{/each}})) }
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -199,28 +199,6 @@
|
|
199
199
|
],
|
200
200
|
"ruby": " return '' if value.nil?\n\n value.downcase\n"
|
201
201
|
},
|
202
|
-
{
|
203
|
-
"name": "sentence",
|
204
|
-
"description": "Sentence case the characters in the given 'string'",
|
205
|
-
"result": "value converted to sentence case",
|
206
|
-
"category": "case",
|
207
|
-
"category_description": "Tokenize and apply case and/or separator",
|
208
|
-
"base_class_require": null,
|
209
|
-
"base_class": null,
|
210
|
-
"parameters": [
|
211
|
-
{
|
212
|
-
"name": "value",
|
213
|
-
"description": "value - to be converted",
|
214
|
-
"splat": null,
|
215
|
-
"default": null,
|
216
|
-
"param_type": "String|Int"
|
217
|
-
}
|
218
|
-
],
|
219
|
-
"examples": [
|
220
|
-
|
221
|
-
],
|
222
|
-
"ruby": " tokenizer.parse(value,\n separator: ' ',\n preserve_case: true,\n compress_prefix_numerals: false,\n compress_suffix_numerals: false).titleize\n"
|
223
|
-
},
|
224
202
|
{
|
225
203
|
"name": "slash",
|
226
204
|
"description": "Slash case the characters in the given 'string'",
|
@@ -103,6 +103,35 @@
|
|
103
103
|
],
|
104
104
|
"ruby": " return '' if value.nil?\n\n count = count.to_i if count.is_a? String\n format = :word if format.nil?\n\n case format.to_sym\n when :number_word, :number_and_word\n \"#{count} #{value.pluralize(count)}\"\n else # aka :word\n value.pluralize(count)\n end\n"
|
105
105
|
},
|
106
|
+
{
|
107
|
+
"name": "pluralize_number_word",
|
108
|
+
"description": "Returns the plural form of the word based on a count with the count prefixed in the format \"3 categories\"",
|
109
|
+
"result": "value and number are used to calculate plural/singular form",
|
110
|
+
"category": "inflection",
|
111
|
+
"category_description": "Inflection handling routines, eg. pluralize, singular, ordinalize",
|
112
|
+
"base_class_require": null,
|
113
|
+
"base_class": null,
|
114
|
+
"parameters": [
|
115
|
+
{
|
116
|
+
"name": "value",
|
117
|
+
"description": "value - value to pluralize",
|
118
|
+
"splat": null,
|
119
|
+
"default": null,
|
120
|
+
"param_type": "String"
|
121
|
+
},
|
122
|
+
{
|
123
|
+
"name": "count",
|
124
|
+
"description": "count used to determine pluralization",
|
125
|
+
"splat": null,
|
126
|
+
"default": null,
|
127
|
+
"param_type": "Int"
|
128
|
+
}
|
129
|
+
],
|
130
|
+
"examples": [
|
131
|
+
|
132
|
+
],
|
133
|
+
"ruby": " return '' if value.nil?\n\n count = count.to_i if count.is_a? String\n\n \"#{count} #{value.pluralize(count)}\"\n"
|
134
|
+
},
|
106
135
|
{
|
107
136
|
"name": "singularize",
|
108
137
|
"description": "The reverse of #pluralize, returns the singular form of a word in a string",
|
@@ -109,21 +109,6 @@ KManager.action :case_commands do
|
|
109
109
|
value.downcase
|
110
110
|
RUBY
|
111
111
|
end
|
112
|
-
.cmdlet do
|
113
|
-
name :sentence
|
114
|
-
description "Sentence case the characters in the given 'string'"
|
115
|
-
result 'value converted to sentence case'
|
116
|
-
|
117
|
-
parameter :value, 'value - to be converted', param_type: 'String|Int'
|
118
|
-
|
119
|
-
ruby <<-'RUBY'
|
120
|
-
tokenizer.parse(value,
|
121
|
-
separator: ' ',
|
122
|
-
preserve_case: true,
|
123
|
-
compress_prefix_numerals: false,
|
124
|
-
compress_suffix_numerals: false).titleize
|
125
|
-
RUBY
|
126
|
-
end
|
127
112
|
.cmdlet do
|
128
113
|
name :slash
|
129
114
|
description "Slash case the characters in the given 'string'"
|
@@ -72,6 +72,22 @@ KManager.action :inflection_commands do
|
|
72
72
|
end
|
73
73
|
RUBY
|
74
74
|
end
|
75
|
+
.cmdlet do
|
76
|
+
name :pluralize_number_word
|
77
|
+
description 'Returns the plural form of the word based on a count with the count prefixed in the format "3 categories"'
|
78
|
+
result 'value and number are used to calculate plural/singular form'
|
79
|
+
|
80
|
+
parameter :value, 'value - value to pluralize', param_type: 'String'
|
81
|
+
parameter :count, 'count used to determine pluralization', param_type: 'Int'
|
82
|
+
|
83
|
+
ruby <<-'RUBY'
|
84
|
+
return '' if value.nil?
|
85
|
+
|
86
|
+
count = count.to_i if count.is_a? String
|
87
|
+
|
88
|
+
"#{count} #{value.pluralize(count)}"
|
89
|
+
RUBY
|
90
|
+
end
|
75
91
|
.cmdlet do
|
76
92
|
name :singularize
|
77
93
|
description 'The reverse of #pluralize, returns the singular form of a word in a string'
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,24 @@
|
|
1
|
+
## [0.4.1](https://github.com/klueless-io/cmdlet/compare/v0.4.0...v0.4.1) (2022-07-12)
|
2
|
+
|
3
|
+
|
4
|
+
### Bug Fixes
|
5
|
+
|
6
|
+
* add spec for singularlize ([ae1fc2d](https://github.com/klueless-io/cmdlet/commit/ae1fc2d144caa3ed1eda94fb7e4ee5520c12eaa8))
|
7
|
+
|
8
|
+
# [0.4.0](https://github.com/klueless-io/cmdlet/compare/v0.3.0...v0.4.0) (2022-07-12)
|
9
|
+
|
10
|
+
|
11
|
+
### Features
|
12
|
+
|
13
|
+
* remove sentence ([20961b8](https://github.com/klueless-io/cmdlet/commit/20961b89efae5f9738e24959010318eb284e2af4))
|
14
|
+
|
15
|
+
# [0.3.0](https://github.com/klueless-io/cmdlet/compare/v0.2.1...v0.3.0) (2022-07-11)
|
16
|
+
|
17
|
+
|
18
|
+
### Features
|
19
|
+
|
20
|
+
* update handlebars templates ([599246d](https://github.com/klueless-io/cmdlet/commit/599246d9521381106524c263ccc1c157f093389d))
|
21
|
+
|
1
22
|
## [0.2.1](https://github.com/klueless-io/cmdlet/compare/v0.2.0...v0.2.1) (2022-07-10)
|
2
23
|
|
3
24
|
|
data/lib/cmdlet/_.rb
CHANGED
@@ -12,7 +12,6 @@ require_relative 'case/double_colon'
|
|
12
12
|
require_relative 'case/human'
|
13
13
|
require_relative 'case/lamel'
|
14
14
|
require_relative 'case/lower'
|
15
|
-
require_relative 'case/sentence'
|
16
15
|
require_relative 'case/slash'
|
17
16
|
require_relative 'case/snake'
|
18
17
|
require_relative 'case/title'
|
@@ -30,4 +29,6 @@ require_relative 'inflection/ordinal'
|
|
30
29
|
require_relative 'inflection/ordinalize'
|
31
30
|
require_relative 'inflection/pluralize'
|
32
31
|
require_relative 'inflection/pluralize_by_number'
|
32
|
+
require_relative 'inflection/pluralize_number'
|
33
|
+
require_relative 'inflection/pluralize_number_word'
|
33
34
|
require_relative 'inflection/singularize'
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cmdlet
|
4
|
+
# Inflection handling routines, eg. pluralize, singular, ordinalize
|
5
|
+
module Inflection
|
6
|
+
# PluralizeNumber: Returns the plural form of the word based on a count in the format "categories"
|
7
|
+
class PluralizeNumber < Cmdlet::BaseCmdlet
|
8
|
+
#
|
9
|
+
# @param [String] value - value - value to pluralize
|
10
|
+
# @param [Int] count - count used to determine pluralization
|
11
|
+
# @return [String] value and number are used to calculate plural/singular form
|
12
|
+
def call(value, count)
|
13
|
+
return '' if value.nil?
|
14
|
+
|
15
|
+
count = count.to_i if count.is_a? String
|
16
|
+
|
17
|
+
value.pluralize(count)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cmdlet
|
4
|
+
# Inflection handling routines, eg. pluralize, singular, ordinalize
|
5
|
+
module Inflection
|
6
|
+
# PluralizeNumberWord: Returns the plural form of the word based on a count with the count prefixed in the format "3 categories"
|
7
|
+
class PluralizeNumberWord < Cmdlet::BaseCmdlet
|
8
|
+
#
|
9
|
+
# @param [String] value - value - value to pluralize
|
10
|
+
# @param [Int] count - count used to determine pluralization
|
11
|
+
# @return [String] value and number are used to calculate plural/singular form
|
12
|
+
def call(value, count)
|
13
|
+
return '' if value.nil?
|
14
|
+
|
15
|
+
count = count.to_i if count.is_a? String
|
16
|
+
|
17
|
+
"#{count} #{value.pluralize(count)}"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/cmdlet/version.rb
CHANGED
data/package-lock.json
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
{
|
2
2
|
"name": "cmdlet",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.4.2",
|
4
4
|
"lockfileVersion": 2,
|
5
5
|
"requires": true,
|
6
6
|
"packages": {
|
7
7
|
"": {
|
8
8
|
"name": "cmdlet",
|
9
|
-
"version": "0.
|
9
|
+
"version": "0.4.2",
|
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,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cmdlet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Cruwys
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-07-
|
11
|
+
date: 2022-07-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -68,7 +68,6 @@ files:
|
|
68
68
|
- ".builders/director/cmdlet_dao.rb"
|
69
69
|
- ".builders/director/cmdlet_director.rb"
|
70
70
|
- ".builders/director/dao.rb"
|
71
|
-
- ".builders/documents/commands.rb"
|
72
71
|
- ".builders/documents/use_cases.rb"
|
73
72
|
- ".builders/documents/x_functions.rb"
|
74
73
|
- ".builders/generators/01-bootstrap.rb"
|
@@ -106,7 +105,6 @@ files:
|
|
106
105
|
- lib/cmdlet/case/human.rb
|
107
106
|
- lib/cmdlet/case/lamel.rb
|
108
107
|
- lib/cmdlet/case/lower.rb
|
109
|
-
- lib/cmdlet/case/sentence.rb
|
110
108
|
- lib/cmdlet/case/slash.rb
|
111
109
|
- lib/cmdlet/case/snake.rb
|
112
110
|
- lib/cmdlet/case/title.rb
|
@@ -125,6 +123,8 @@ files:
|
|
125
123
|
- lib/cmdlet/inflection/ordinalize.rb
|
126
124
|
- lib/cmdlet/inflection/pluralize.rb
|
127
125
|
- lib/cmdlet/inflection/pluralize_by_number.rb
|
126
|
+
- lib/cmdlet/inflection/pluralize_number.rb
|
127
|
+
- lib/cmdlet/inflection/pluralize_number_word.rb
|
128
128
|
- lib/cmdlet/inflection/singularize.rb
|
129
129
|
- lib/cmdlet/string_tokenizer.rb
|
130
130
|
- lib/cmdlet/version.rb
|
@@ -1,225 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
def commands
|
4
|
-
return @commands unless @commands.nil?
|
5
|
-
|
6
|
-
result = KDoc.model :document do
|
7
|
-
table :rows do
|
8
|
-
fields :category, :name, :alias, :description, :ruby # , f(name: :params, default: [:value])
|
9
|
-
|
10
|
-
# context 'when array of string' do
|
11
|
-
# let(:value) { %w[the quick fox] }
|
12
|
-
|
13
|
-
# it { is_expected.to eq('the,quick,fox') }
|
14
|
-
# end
|
15
|
-
|
16
|
-
# context 'when array of numbers' do
|
17
|
-
# let(:value) { [1, 2, 3] }
|
18
|
-
|
19
|
-
# it { is_expected.to eq('1,2,3') }
|
20
|
-
# end
|
21
|
-
|
22
|
-
# context 'when array of symbol' do
|
23
|
-
# let(:value) { %i[the quick fox] }
|
24
|
-
|
25
|
-
# it { is_expected.to eq('the,quick,fox') }
|
26
|
-
# end
|
27
|
-
|
28
|
-
row :array , :join , [] , 'join an array of values with separator as a string', <<-'RUBY'
|
29
|
-
return '' if value.nil? || !value.is_a?(Array)
|
30
|
-
values = value.reject(&:blank?)
|
31
|
-
return '' if value.length.zero?
|
32
|
-
|
33
|
-
separator = ','
|
34
|
-
values.join(separator)
|
35
|
-
RUBY
|
36
|
-
|
37
|
-
row :array , :join_pre , [] , 'join an array of values with separator as a string and using the separator at the beginning of string', <<-'RUBY'
|
38
|
-
return '' if value.nil? || !value.is_a?(Array)
|
39
|
-
values = value.reject(&:blank?)
|
40
|
-
return '' if value.length.zero?
|
41
|
-
|
42
|
-
separator = ','
|
43
|
-
"#{separator}#{value.join(separator)}"
|
44
|
-
RUBY
|
45
|
-
|
46
|
-
# row :array , :join_post , [] , "join an array of values with separator as a string and using the separator at the end of string", <<-'RUBY'
|
47
|
-
# return '' if value.nil? || !value.is_a?(Array)
|
48
|
-
# values = value.reject(&:blank?)
|
49
|
-
# return '' if value.length.zero?
|
50
|
-
|
51
|
-
# separator = ','
|
52
|
-
# "#{value.join(separator)}#{separator}"
|
53
|
-
# RUBY
|
54
|
-
|
55
|
-
# row :a_transform , :backslash , [:back_slash] , "convert to back slash notation", <<-'RUBY'
|
56
|
-
# tokenizer.parse(value, preserve_case: true, separator: '\\')
|
57
|
-
# RUBY
|
58
|
-
|
59
|
-
# row :a_transform , :camel , [:upper_camel, :pascal] , "convert to camel notation", <<-'RUBY'
|
60
|
-
# tokenizer.parse(value).underscore.camelize
|
61
|
-
# RUBY
|
62
|
-
|
63
|
-
# row :a_transform , :constant , [:constantize] , "", <<-'RUBY'
|
64
|
-
# tokenizer.parse(value, separator: '_').upcase
|
65
|
-
# RUBY
|
66
|
-
|
67
|
-
# row :a_transform , :dash , [:dasherize] , "convert to dash notation", <<-'RUBY'
|
68
|
-
# tokenizer.parse(value)
|
69
|
-
# RUBY
|
70
|
-
|
71
|
-
# row :a_transform , :dot , [:dotirize] , "", <<-'RUBY'
|
72
|
-
# tokenizer.parse(value, separator: '.')
|
73
|
-
# RUBY
|
74
|
-
|
75
|
-
# row :a_transform , :double_colon , [] , "", <<-'RUBY'
|
76
|
-
# tokenizer.parse(value, preserve_case: true, separator: '::')
|
77
|
-
# RUBY
|
78
|
-
|
79
|
-
# row :a_transform , :lower , [:lowercase, :downcase] , "", <<-'RUBY'
|
80
|
-
# return '' if value.nil?
|
81
|
-
|
82
|
-
# value.downcase
|
83
|
-
# RUBY
|
84
|
-
|
85
|
-
# # row :a_transform , :format_as , [] , "", <<-'RUBY'
|
86
|
-
|
87
|
-
# # RUBY
|
88
|
-
|
89
|
-
# row :a_transform , :proper , [] , "Proper case capitalizes the first letter of ALL words in a string", <<-'RUBY'
|
90
|
-
# tokenizer.parse(value,
|
91
|
-
# separator: ' ',
|
92
|
-
# preserve_case: true,
|
93
|
-
# compress_prefix_numerals: false,
|
94
|
-
# compress_suffix_numerals: false)
|
95
|
-
# .titleize
|
96
|
-
# RUBY
|
97
|
-
|
98
|
-
# row :a_transform , :sentence , [:human, :humanize] , "Upper case for first letter only. Numbers will maintain their spacing", <<-'RUBY'
|
99
|
-
# tokenizer.parse(value,
|
100
|
-
# separator: ' ',
|
101
|
-
# preserve_case: true,
|
102
|
-
# compress_prefix_numerals: false,
|
103
|
-
# compress_suffix_numerals: false)
|
104
|
-
# .humanize
|
105
|
-
# RUBY
|
106
|
-
|
107
|
-
# row :a_transform , :lamel , [:lower_camel] , "", <<-'RUBY'
|
108
|
-
# tokenizer.parse(value, separator: '_').camelize(:lower)
|
109
|
-
# RUBY
|
110
|
-
|
111
|
-
# row :a_transform , :slash , [:forwardslash, :forward_slash] , "", <<-'RUBY'
|
112
|
-
# tokenizer.parse(value, preserve_case: true, separator: '/')
|
113
|
-
# RUBY
|
114
|
-
|
115
|
-
# row :a_transform , :snake , [:snake] , "", <<-'RUBY'
|
116
|
-
# tokenizer.parse(value, separator: '_', forced_separator: true)
|
117
|
-
# RUBY
|
118
|
-
|
119
|
-
# row :a_transform , :title , [:titleize] , "", <<-'RUBY'
|
120
|
-
# tokenizer.parse(value,
|
121
|
-
# separator: ' ',
|
122
|
-
# preserve_case: true,
|
123
|
-
# compress_prefix_numerals: false,
|
124
|
-
# compress_suffix_numerals: false)
|
125
|
-
# .titleize
|
126
|
-
# RUBY
|
127
|
-
|
128
|
-
# row :a_transform , :upper , [:upper_case, :upcase] , "", <<-'RUBY'
|
129
|
-
# return '' if value.nil?
|
130
|
-
|
131
|
-
# value.upcase
|
132
|
-
# RUBY
|
133
|
-
|
134
|
-
# row :a_comparison , :and , [:all] , "", <<-'RUBY'
|
135
|
-
# values.all? { |value| value }
|
136
|
-
# RUBY
|
137
|
-
|
138
|
-
# # DEFAULT does not make sense in comparison
|
139
|
-
# row :a_comparison , :default , [:fallback] , "", <<-'RUBY'
|
140
|
-
# default_value = values[-1]
|
141
|
-
|
142
|
-
# find_value = values[0..-2].find { |value| !value.nil? }
|
143
|
-
|
144
|
-
# find_value || default_value
|
145
|
-
# RUBY
|
146
|
-
|
147
|
-
# row :a_comparison , :eq , [:equal] , "", <<-'RUBY'
|
148
|
-
# lhs = lhs.to_s if lhs.is_a?(Symbol)
|
149
|
-
# rhs = rhs.to_s if rhs.is_a?(Symbol)
|
150
|
-
|
151
|
-
# lhs == rhs
|
152
|
-
# RUBY
|
153
|
-
|
154
|
-
# row :a_comparison , :gt , [] , "", <<-'RUBY'
|
155
|
-
# lhs > rhs
|
156
|
-
# RUBY
|
157
|
-
|
158
|
-
# row :a_comparison , :gte , [] , "", <<-'RUBY'
|
159
|
-
# lhs >= rhs
|
160
|
-
# RUBY
|
161
|
-
|
162
|
-
# row :a_comparison , :lt , [:less_than] , "# Lt: (less than) Block helper that renders a block if `a` is **less than** `b`. If an inverse block is specified it will be rendered when falsy.", <<-'RUBY'
|
163
|
-
# lhs < rhs
|
164
|
-
# RUBY
|
165
|
-
|
166
|
-
# row :a_comparison , :lte , [:less_than_or_equal_to] , "# Lte: (less than or equal to) Block helper that renders a block if `a` is **less than or equal to** `b`. If an inverse block is specified it will be rendered when falsy.", <<-'RUBY'
|
167
|
-
# lhs <= rhs
|
168
|
-
# RUBY
|
169
|
-
|
170
|
-
# row :a_comparison , :ne , [:not_equal] , "# Ne: (not equal) Block helper that renders a block if `a` is **not equal to** `b`. If an inverse block is specified it will be rendered when falsy.", <<-'RUBY'
|
171
|
-
# lhs = lhs.to_s if lhs.is_a?(Symbol)
|
172
|
-
# rhs = rhs.to_s if rhs.is_a?(Symbol)
|
173
|
-
|
174
|
-
# lhs != rhs
|
175
|
-
# RUBY
|
176
|
-
|
177
|
-
# row :a_comparison , :or , [:any] , "", <<-'RUBY'
|
178
|
-
# values.any? { |value| value }
|
179
|
-
# RUBY
|
180
|
-
|
181
|
-
# row :a_inflection , :ordinal , [] , "The suffix that should be added to a number to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th", <<-RUBY
|
182
|
-
# return '' if value.nil?
|
183
|
-
|
184
|
-
# value = value.to_i if value.is_a? String
|
185
|
-
|
186
|
-
# value.ordinal
|
187
|
-
# RUBY
|
188
|
-
|
189
|
-
# row :a_inflection , :ordinalize , [] , "Turns a number into an ordinal string used to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th.", <<-RUBY
|
190
|
-
# return '' if value.nil?
|
191
|
-
|
192
|
-
# value = value.to_i if value.is_a? String
|
193
|
-
|
194
|
-
# value.ordinalize
|
195
|
-
# RUBY
|
196
|
-
|
197
|
-
# row :a_inflection , :pluralize , [] , "Returns the plural form of the word in the string", <<-RUBY
|
198
|
-
# return '' if value.nil?
|
199
|
-
|
200
|
-
# value = value.to_s if value.is_a?(Symbol)
|
201
|
-
|
202
|
-
# value.pluralize
|
203
|
-
# RUBY
|
204
|
-
|
205
|
-
# row :a_inflection , :pluralize_by_number , [] , "Uses both a word and number to decide if the plural or singular form should be used.", <<-'RUBY'
|
206
|
-
# return '' if value.nil?
|
207
|
-
|
208
|
-
# count = count.to_i if count.is_a? String
|
209
|
-
# format = :word if format.nil?
|
210
|
-
|
211
|
-
# case format.to_sym
|
212
|
-
# when :number_word, :number_and_word
|
213
|
-
# "#{count} #{value.pluralize(count)}"
|
214
|
-
# else # aka :word
|
215
|
-
# value.pluralize(count)
|
216
|
-
# end
|
217
|
-
# RUBY
|
218
|
-
|
219
|
-
# row :a_inflection , :singularize , [] , ""
|
220
|
-
end
|
221
|
-
end
|
222
|
-
|
223
|
-
@commands = result.raw_data_struct.rows
|
224
|
-
end
|
225
|
-
@commands = nil
|
data/lib/cmdlet/case/sentence.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Cmdlet
|
4
|
-
# Tokenize and apply case and/or separator
|
5
|
-
module Case
|
6
|
-
# Sentence: Sentence case the characters in the given 'string'
|
7
|
-
class Sentence < Cmdlet::BaseCmdlet
|
8
|
-
#
|
9
|
-
# @param [String|Int] value - value - to be converted
|
10
|
-
# @return [String] value converted to sentence case
|
11
|
-
def call(value)
|
12
|
-
tokenizer.parse(value,
|
13
|
-
separator: ' ',
|
14
|
-
preserve_case: true,
|
15
|
-
compress_prefix_numerals: false,
|
16
|
-
compress_suffix_numerals: false).titleize
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|