cmdlet 0.4.2 → 0.6.1
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_default_configuration.rb +7 -0
- data/.builders/boot.rb +5 -28
- data/.builders/data/cmdlets/array.json +0 -29
- data/.builders/data/cmdlets/inflection.json +3 -10
- data/.builders/director/cmdlet_director.rb +10 -0
- data/.builders/generators/cmdlets/array.rb +0 -15
- data/.builders/generators/cmdlets/inflection.rb +5 -12
- data/CHANGELOG.md +21 -0
- data/lib/cmdlet/_.rb +0 -1
- data/lib/cmdlet/base_cmdlet.rb +1 -0
- data/lib/cmdlet/version.rb +1 -1
- data/package-lock.json +2 -2
- data/package.json +1 -1
- metadata +5 -5
- data/lib/cmdlet/inflection/pluralize_by_number.rb +0 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5faa2f1cc957beed6274a4da073eae8f3c8dd9b937a99f2edb1fee7adcefe36
|
4
|
+
data.tar.gz: 9baead36a85c44b8427f5cbf14164f18adf13dbaf2a05d6cacc7cbdd444e8ab2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5bd1875dcf63c87dfd8f7b589083a8b6919857cbae800934872637fb949143181851ae026683f20245927ec84a012b3fb6bf7647bde66f742f5ed6fbbcf9de3b
|
7
|
+
data.tar.gz: b856cca6babb797456e7411ae43b21c47580460d514a3d4d8d3e7f22e5ba886644c83b599bda5ee60dc1d6e65dbc96aadf38c09722786c86a30fa7505b86733d
|
data/.builders/boot.rb
CHANGED
@@ -8,34 +8,11 @@ CONFIG_KEY = :cmdlet
|
|
8
8
|
|
9
9
|
log.kv 'working folder', Dir.pwd
|
10
10
|
|
11
|
-
|
12
|
-
config.
|
13
|
-
config.
|
14
|
-
|
15
|
-
|
16
|
-
def camel
|
17
|
-
require 'handlebars/helpers/string_formatting/camel'
|
18
|
-
Handlebars::Helpers::StringFormatting::Camel.new
|
19
|
-
end
|
20
|
-
|
21
|
-
def titleize
|
22
|
-
require 'handlebars/helpers/string_formatting/titleize'
|
23
|
-
Handlebars::Helpers::StringFormatting::Titleize.new
|
24
|
-
end
|
25
|
-
|
26
|
-
def pluralize
|
27
|
-
require 'handlebars/helpers/inflection/pluralize'
|
28
|
-
Handlebars::Helpers::Inflection::Pluralize.new
|
29
|
-
end
|
30
|
-
|
31
|
-
def singularize
|
32
|
-
require 'handlebars/helpers/inflection/singularize'
|
33
|
-
Handlebars::Helpers::Inflection::Singularize.new
|
34
|
-
end
|
35
|
-
|
36
|
-
def dasherize
|
37
|
-
require 'handlebars/helpers/string_formatting/dasherize'
|
38
|
-
Handlebars::Helpers::StringFormatting::Dasherize.new
|
11
|
+
KConfig.configure do |config|
|
12
|
+
config.handlebars.defaults.add_array_defaults
|
13
|
+
config.handlebars.defaults.add_case_defaults
|
14
|
+
config.handlebars.defaults.add_comparison_defaults
|
15
|
+
config.handlebars.defaults.add_inflection_defaults
|
39
16
|
end
|
40
17
|
|
41
18
|
def k_builder
|
@@ -59,35 +59,6 @@
|
|
59
59
|
],
|
60
60
|
"ruby": " return '' if values.nil? || !values.is_a?(::Array)\n values = values.reject(&:blank?)\n return '' if values.length.zero?\n\n \"#{separator}#{values.join(separator)}\"\n"
|
61
61
|
},
|
62
|
-
{
|
63
|
-
"name": "join_pre",
|
64
|
-
"description": "join an array of values with separator as a string and using the separator at the beginning of string",
|
65
|
-
"result": null,
|
66
|
-
"category": "array",
|
67
|
-
"category_description": "Array handling routines, eg. join, join_prefix, join_post",
|
68
|
-
"base_class_require": null,
|
69
|
-
"base_class": null,
|
70
|
-
"parameters": [
|
71
|
-
{
|
72
|
-
"name": "values",
|
73
|
-
"description": "array of values to join",
|
74
|
-
"splat": null,
|
75
|
-
"default": null,
|
76
|
-
"param_type": "String|Int"
|
77
|
-
},
|
78
|
-
{
|
79
|
-
"name": "separator",
|
80
|
-
"description": "separator between values, defaults to comma",
|
81
|
-
"splat": null,
|
82
|
-
"default": "','",
|
83
|
-
"param_type": "String"
|
84
|
-
}
|
85
|
-
],
|
86
|
-
"examples": [
|
87
|
-
|
88
|
-
],
|
89
|
-
"ruby": " return '' if values.nil? || !values.is_a?(::Array)\n values = values.reject(&:blank?)\n return '' if values.length.zero?\n\n \"#{separator}#{values.join(separator)}\"\n"
|
90
|
-
},
|
91
62
|
{
|
92
63
|
"name": "join_post",
|
93
64
|
"description": "join an array of values with separator as a string and using the separator at the end of string",
|
@@ -68,8 +68,8 @@
|
|
68
68
|
"ruby": " return '' if value.nil?\n\n value = value.to_s if value.is_a?(Symbol)\n\n value.pluralize\n"
|
69
69
|
},
|
70
70
|
{
|
71
|
-
"name": "
|
72
|
-
"description": "Returns the plural form of the word based on a count",
|
71
|
+
"name": "pluralize_number",
|
72
|
+
"description": "Returns the plural form of the word based on a count in the format \"categories\"",
|
73
73
|
"result": "value and number are used to calculate plural/singular form",
|
74
74
|
"category": "inflection",
|
75
75
|
"category_description": "Inflection handling routines, eg. pluralize, singular, ordinalize",
|
@@ -89,19 +89,12 @@
|
|
89
89
|
"splat": null,
|
90
90
|
"default": null,
|
91
91
|
"param_type": "Int"
|
92
|
-
},
|
93
|
-
{
|
94
|
-
"name": "format",
|
95
|
-
"description": "(Optional) what format should output be. :word, :number_word",
|
96
|
-
"splat": null,
|
97
|
-
"default": null,
|
98
|
-
"param_type": "String"
|
99
92
|
}
|
100
93
|
],
|
101
94
|
"examples": [
|
102
95
|
|
103
96
|
],
|
104
|
-
"ruby": " return '' if value.nil?\n\n count = count.to_i if count.is_a? String\n
|
97
|
+
"ruby": " return '' if value.nil?\n\n count = count.to_i if count.is_a? String\n\n value.pluralize(count)\n"
|
105
98
|
},
|
106
99
|
{
|
107
100
|
"name": "pluralize_number_word",
|
@@ -48,6 +48,16 @@ class CmdletDirector < KDirector::Directors::BaseDirector
|
|
48
48
|
add(handlebars_spec_file, template_file: 'handlebars_helper_spec.rb', cmdlet: cmdlet, on_exist: :skip)
|
49
49
|
end
|
50
50
|
|
51
|
+
if builder.cmdlets.length.positive?
|
52
|
+
cd(:handlebars_lib)
|
53
|
+
|
54
|
+
category = builder.cmdlets.first[:category]
|
55
|
+
handlebars_category_configuration_file = "handlebarsjs/helpers/#{category}/default_configuration.rb"
|
56
|
+
|
57
|
+
add(handlebars_category_configuration_file, template_file: 'handlebars_helper_default_configuration.rb', cmdlets: builder.cmdlets)
|
58
|
+
end
|
59
|
+
|
60
|
+
|
51
61
|
self
|
52
62
|
end
|
53
63
|
|
@@ -35,21 +35,6 @@ KManager.action :array_commands do
|
|
35
35
|
"#{separator}#{values.join(separator)}"
|
36
36
|
RUBY
|
37
37
|
end
|
38
|
-
.cmdlet do
|
39
|
-
name :join_pre
|
40
|
-
description 'join an array of values with separator as a string and using the separator at the beginning of string'
|
41
|
-
|
42
|
-
parameter :values, 'array of values to join', param_type: 'String|Int'
|
43
|
-
parameter :separator, 'separator between values, defaults to comma', default: "','"
|
44
|
-
|
45
|
-
ruby <<-'RUBY'
|
46
|
-
return '' if values.nil? || !values.is_a?(::Array)
|
47
|
-
values = values.reject(&:blank?)
|
48
|
-
return '' if values.length.zero?
|
49
|
-
|
50
|
-
"#{separator}#{values.join(separator)}"
|
51
|
-
RUBY
|
52
|
-
end
|
53
38
|
.cmdlet do
|
54
39
|
name :join_post
|
55
40
|
description 'join an array of values with separator as a string and using the separator at the end of string'
|
@@ -50,26 +50,19 @@ KManager.action :inflection_commands do
|
|
50
50
|
RUBY
|
51
51
|
end
|
52
52
|
.cmdlet do
|
53
|
-
name :
|
54
|
-
description 'Returns the plural form of the word based on a count'
|
53
|
+
name :pluralize_number
|
54
|
+
description 'Returns the plural form of the word based on a count in the format "categories"'
|
55
55
|
result 'value and number are used to calculate plural/singular form'
|
56
56
|
|
57
57
|
parameter :value, 'value - value to pluralize', param_type: 'String'
|
58
58
|
parameter :count, 'count used to determine pluralization', param_type: 'Int'
|
59
|
-
|
60
|
-
|
59
|
+
|
61
60
|
ruby <<-'RUBY'
|
62
61
|
return '' if value.nil?
|
63
62
|
|
64
63
|
count = count.to_i if count.is_a? String
|
65
|
-
|
66
|
-
|
67
|
-
case format.to_sym
|
68
|
-
when :number_word, :number_and_word
|
69
|
-
"#{count} #{value.pluralize(count)}"
|
70
|
-
else # aka :word
|
71
|
-
value.pluralize(count)
|
72
|
-
end
|
64
|
+
|
65
|
+
value.pluralize(count)
|
73
66
|
RUBY
|
74
67
|
end
|
75
68
|
.cmdlet do
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,24 @@
|
|
1
|
+
# [0.6.0](https://github.com/klueless-io/cmdlet/compare/v0.5.0...v0.6.0) (2022-07-13)
|
2
|
+
|
3
|
+
|
4
|
+
### Features
|
5
|
+
|
6
|
+
* align cmdlet/helper GEM versions ([3fcf532](https://github.com/klueless-io/cmdlet/commit/3fcf532686d646492095cbb31ab08a9213b283b9))
|
7
|
+
|
8
|
+
# [0.5.0](https://github.com/klueless-io/cmdlet/compare/v0.4.2...v0.5.0) (2022-07-12)
|
9
|
+
|
10
|
+
|
11
|
+
### Features
|
12
|
+
|
13
|
+
* add inflection: pluralize_number and pluralize_number_word ([53b1d00](https://github.com/klueless-io/cmdlet/commit/53b1d00fa44da710a480935d41f26966702d1ae6))
|
14
|
+
|
15
|
+
## [0.4.2](https://github.com/klueless-io/cmdlet/compare/v0.4.1...v0.4.2) (2022-07-12)
|
16
|
+
|
17
|
+
|
18
|
+
### Bug Fixes
|
19
|
+
|
20
|
+
* add inflection: pluralize_number and pluralize_number_word ([a97bbe1](https://github.com/klueless-io/cmdlet/commit/a97bbe1a7960d1dfc26ee37dbf93804ba571fe0d))
|
21
|
+
|
1
22
|
## [0.4.1](https://github.com/klueless-io/cmdlet/compare/v0.4.0...v0.4.1) (2022-07-12)
|
2
23
|
|
3
24
|
|
data/lib/cmdlet/_.rb
CHANGED
@@ -28,7 +28,6 @@ require_relative 'comparison/or'
|
|
28
28
|
require_relative 'inflection/ordinal'
|
29
29
|
require_relative 'inflection/ordinalize'
|
30
30
|
require_relative 'inflection/pluralize'
|
31
|
-
require_relative 'inflection/pluralize_by_number'
|
32
31
|
require_relative 'inflection/pluralize_number'
|
33
32
|
require_relative 'inflection/pluralize_number_word'
|
34
33
|
require_relative 'inflection/singularize'
|
data/lib/cmdlet/base_cmdlet.rb
CHANGED
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.6.1",
|
4
4
|
"lockfileVersion": 2,
|
5
5
|
"requires": true,
|
6
6
|
"packages": {
|
7
7
|
"": {
|
8
8
|
"name": "cmdlet",
|
9
|
-
"version": "0.
|
9
|
+
"version": "0.6.1",
|
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.6.1
|
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-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0
|
33
|
+
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0
|
40
|
+
version: '0'
|
41
41
|
description: " Cmdlet provides a set of functions (wrapped in the command pattern)
|
42
42
|
that perform simple actions\n"
|
43
43
|
email:
|
@@ -51,6 +51,7 @@ files:
|
|
51
51
|
- ".builders/.templates/cmdlet_spec.rb"
|
52
52
|
- ".builders/.templates/cmdlets_require_all.rb"
|
53
53
|
- ".builders/.templates/handlebars_helper.rb"
|
54
|
+
- ".builders/.templates/handlebars_helper_default_configuration.rb"
|
54
55
|
- ".builders/.templates/handlebars_helper_require_all.rb"
|
55
56
|
- ".builders/.templates/handlebars_helper_spec.rb"
|
56
57
|
- ".builders/_.rb"
|
@@ -122,7 +123,6 @@ files:
|
|
122
123
|
- lib/cmdlet/inflection/ordinal.rb
|
123
124
|
- lib/cmdlet/inflection/ordinalize.rb
|
124
125
|
- lib/cmdlet/inflection/pluralize.rb
|
125
|
-
- lib/cmdlet/inflection/pluralize_by_number.rb
|
126
126
|
- lib/cmdlet/inflection/pluralize_number.rb
|
127
127
|
- lib/cmdlet/inflection/pluralize_number_word.rb
|
128
128
|
- lib/cmdlet/inflection/singularize.rb
|
@@ -1,28 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Cmdlet
|
4
|
-
# Inflection handling routines, eg. pluralize, singular, ordinalize
|
5
|
-
module Inflection
|
6
|
-
# PluralizeByNumber: Returns the plural form of the word based on a count
|
7
|
-
class PluralizeByNumber < Cmdlet::BaseCmdlet
|
8
|
-
#
|
9
|
-
# @param [String] value - value - value to pluralize
|
10
|
-
# @param [Int] count - count used to determine pluralization
|
11
|
-
# @param [String] format - (Optional) what format should output be. :word, :number_word
|
12
|
-
# @return [String] value and number are used to calculate plural/singular form
|
13
|
-
def call(value, count, format)
|
14
|
-
return '' if value.nil?
|
15
|
-
|
16
|
-
count = count.to_i if count.is_a? String
|
17
|
-
format = :word if format.nil?
|
18
|
-
|
19
|
-
case format.to_sym
|
20
|
-
when :number_word, :number_and_word
|
21
|
-
"#{count} #{value.pluralize(count)}"
|
22
|
-
else # aka :word
|
23
|
-
value.pluralize(count)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|