cmdlet 0.0.6 → 0.2.0
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/FUNCTIONS.MD +19 -0
- data/.builders/.templates/cmdlet.rb +26 -0
- data/.builders/.templates/cmdlet_spec.rb +22 -0
- data/.builders/.templates/require_all_cmdlets.rb +5 -0
- data/.builders/_.rb +11 -1
- data/.builders/boot.rb +6 -3
- data/.builders/data/categories.json +28 -0
- data/.builders/data/cmdlets/array.json +121 -0
- data/.builders/data/cmdlets/comparison.json +245 -0
- data/.builders/data/cmdlets/inflection.json +129 -0
- data/.builders/director/category_builder.rb +26 -0
- data/.builders/director/category_dao.rb +38 -0
- data/.builders/director/category_director.rb +39 -0
- data/.builders/director/cmdlet_builder.rb +67 -0
- data/.builders/director/cmdlet_child.rb +39 -0
- data/.builders/director/cmdlet_dao.rb +29 -0
- data/.builders/director/cmdlet_director.rb +60 -0
- data/.builders/director/dao.rb +16 -0
- data/.builders/documents/commands.rb +222 -28
- data/.builders/documents/use_cases.rb +32 -34
- data/.builders/documents/x_functions.rb +7 -10
- data/.builders/generators/01-bootstrap.rb +112 -112
- data/.builders/generators/20-categories.rb +16 -0
- data/.builders/generators/30-commands-bak.rb +53 -0
- data/.builders/generators/cmdlets/array.rb +71 -0
- data/.builders/generators/cmdlets/comparison.rb +126 -0
- data/.builders/generators/cmdlets/inflection.rb +93 -0
- data/CHANGELOG.md +37 -0
- data/Guardfile +1 -1
- data/lib/cmdlet/_.rb +19 -0
- data/lib/cmdlet/all_commands.rb +3 -0
- data/lib/cmdlet/array/join.rb +22 -0
- data/lib/cmdlet/array/join_post.rb +22 -0
- data/lib/cmdlet/array/join_pre.rb +22 -0
- data/lib/cmdlet/base_cmdlet.rb +17 -0
- data/lib/cmdlet/comparison/and.rb +16 -0
- data/lib/cmdlet/comparison/default.rb +20 -0
- data/lib/cmdlet/comparison/eq.rb +20 -0
- data/lib/cmdlet/comparison/gt.rb +17 -0
- data/lib/cmdlet/comparison/gte.rb +17 -0
- data/lib/cmdlet/comparison/lt.rb +17 -0
- data/lib/cmdlet/comparison/lte.rb +17 -0
- data/lib/cmdlet/comparison/ne.rb +20 -0
- data/lib/cmdlet/comparison/or.rb +16 -0
- data/lib/cmdlet/inflection/ordinal.rb +20 -0
- data/lib/cmdlet/inflection/ordinalize.rb +20 -0
- data/lib/cmdlet/inflection/pluralize.rb +20 -0
- data/lib/cmdlet/inflection/pluralize_by_number.rb +28 -0
- data/lib/cmdlet/inflection/singularize.rb +20 -0
- data/lib/cmdlet/version.rb +1 -1
- data/lib/cmdlet.rb +5 -0
- data/package-lock.json +2 -2
- data/package.json +1 -1
- metadata +46 -5
- data/.builders/documents/_.rb +0 -4
- data/.builders/documents/categories.rb +0 -24
- data/.builders/documents/functions.rb +0 -226
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc4888cd594af0dd224a836be55e28d9b6cdf153ac89e770807d412b14d11982
|
4
|
+
data.tar.gz: 00b2044a9a53f53afbe109a443aabd7cc38db54782fd1a1eebfbdc563db3de7c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f7470c8c5cc637bfc48aa1e5d9a63d73748831e71d323cdf3a09d2cb1b5b0e8e40970300072eafbbe00976334d7021e3e22ce66f5626b4983faa2d02f5e4ca70
|
7
|
+
data.tar.gz: e04137866c533b774510d0964be0a27f98110c23237da9d55b8c560d371f1a32d55e8e2af67799b0f58b3240434b1fb7b46f40915cb1baacf4adcfb5f037a496
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# Funcky Functions
|
2
|
+
|
3
|
+
> Funcky provides a set of functions (wrapped in the command pattern) that perform simple actions
|
4
|
+
|
5
|
+
## List of categories
|
6
|
+
|
7
|
+
| Name | Description |
|
8
|
+
|-|-|
|
9
|
+
{{#each categories}}
|
10
|
+
| {{titleize name}} | {{description}} |
|
11
|
+
{{/each}}
|
12
|
+
|
13
|
+
## List of functions
|
14
|
+
|
15
|
+
| Category | Name | Alias | Description |
|
16
|
+
|-|-|-|-|
|
17
|
+
{{#each functions}}
|
18
|
+
| {{titleize category}} | `{{name}}` | {{#each alias}}{{surround . '`' '` '}}{{/each}} | {{description}} |
|
19
|
+
{{/each}}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cmdlet
|
4
|
+
# {{cmdlet.category_description}}
|
5
|
+
module {{camel cmdlet.category}}
|
6
|
+
# {{camel cmdlet.name}}: {{cmdlet.description}}
|
7
|
+
class {{camel cmdlet.name}} < Cmdlet::BaseCmdlet
|
8
|
+
{{#each cmdlet.usecases}}
|
9
|
+
# @example
|
10
|
+
#
|
11
|
+
# puts {{camel ./function}}.new.call({{{nice_inputs}}})
|
12
|
+
#
|
13
|
+
# {{expected_output}}
|
14
|
+
#
|
15
|
+
{{/each}}
|
16
|
+
#
|
17
|
+
{{#each cmdlet.parameters}}
|
18
|
+
# @param [{{./param_type}}] {{./name}} - {{./description}}
|
19
|
+
{{/each}}
|
20
|
+
# @return [String] {{cmdlet.result}}
|
21
|
+
def call({{#each cmdlet.parameters}}{{#if ./splat}}{{./splat}}{{/if}}{{./name}}{{#if ./default}} = {{{./default}}}{{/if}}{{#if @last}}{{^}}, {{/if}}{{/each}})
|
22
|
+
{{{cmdlet.ruby}}}
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# {{camel cmdlet.name}}: {{cmdlet.description}}
|
4
|
+
RSpec.describe Cmdlet::{{camel cmdlet.category}}::{{camel cmdlet.name}} do
|
5
|
+
let(:instance) { described_class.new }
|
6
|
+
|
7
|
+
describe 'initialize' do
|
8
|
+
subject { instance }
|
9
|
+
|
10
|
+
it { is_expected.not_to be_nil }
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '#call' do
|
14
|
+
subject { instance.call(value) }
|
15
|
+
|
16
|
+
let(:value) { nil }
|
17
|
+
|
18
|
+
context 'safely handle nil' do
|
19
|
+
it { is_expected.to eq('') }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/.builders/_.rb
CHANGED
@@ -1 +1,11 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative './director/category_dao'
|
4
|
+
require_relative './director/cmdlet_dao'
|
5
|
+
require_relative './director/dao'
|
6
|
+
|
7
|
+
require_relative './director/category_builder'
|
8
|
+
require_relative './director/category_director'
|
9
|
+
require_relative './director/cmdlet_builder'
|
10
|
+
require_relative './director/cmdlet_director'
|
11
|
+
require_relative './director/cmdlet_child'
|
data/.builders/boot.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Boot Sequence
|
2
4
|
|
3
5
|
include KLog::Logging
|
@@ -49,10 +51,10 @@ KConfig.configure(CONFIG_KEY) do |config|
|
|
49
51
|
config.template_folders.add(:template , File.expand_path('.templates', Dir.pwd))
|
50
52
|
|
51
53
|
config.target_folders.add(:app , base_folder)
|
52
|
-
config.target_folders.add(:lib , :app, 'lib/
|
53
|
-
config.target_folders.add(:spec , :app, 'spec/
|
54
|
+
config.target_folders.add(:lib , :app, 'lib/cmdlet')
|
55
|
+
config.target_folders.add(:spec , :app, 'spec/cmdlet')
|
54
56
|
config.target_folders.add(:builder , builder_folder)
|
55
|
-
|
57
|
+
config.target_folders.add(:builder_data , :builder, 'data')
|
56
58
|
end
|
57
59
|
|
58
60
|
KConfig.configuration(CONFIG_KEY).debug
|
@@ -62,6 +64,7 @@ resource_manager = area.resource_manager
|
|
62
64
|
resource_manager
|
63
65
|
.fileset
|
64
66
|
.glob('*.rb', exclude: ['boot.rb'])
|
67
|
+
.glob('documents/**/*.rb')
|
65
68
|
.glob('generators/**/*.rb')
|
66
69
|
resource_manager.add_resources
|
67
70
|
|
@@ -0,0 +1,28 @@
|
|
1
|
+
{
|
2
|
+
"categories": [
|
3
|
+
{
|
4
|
+
"name": "case",
|
5
|
+
"description": "Tokenize and apply case and/or separator"
|
6
|
+
},
|
7
|
+
{
|
8
|
+
"name": "comparison",
|
9
|
+
"description": "Comparison helpers, eg. or, and, equal, not equal, less than, greater than etc."
|
10
|
+
},
|
11
|
+
{
|
12
|
+
"name": "inflection",
|
13
|
+
"description": "Inflection handling routines, eg. pluralize, singular, ordinalize"
|
14
|
+
},
|
15
|
+
{
|
16
|
+
"name": "string",
|
17
|
+
"description": "String handling helpers"
|
18
|
+
},
|
19
|
+
{
|
20
|
+
"name": "array",
|
21
|
+
"description": "Array handling routines, eg. join, join_prefix, join_post"
|
22
|
+
},
|
23
|
+
{
|
24
|
+
"name": "transform",
|
25
|
+
"description": "Tokenize and apply case and/or separator"
|
26
|
+
}
|
27
|
+
]
|
28
|
+
}
|
@@ -0,0 +1,121 @@
|
|
1
|
+
{
|
2
|
+
"category_key": "array",
|
3
|
+
"cmdlets": [
|
4
|
+
{
|
5
|
+
"name": "join",
|
6
|
+
"description": "join an array of values with separator as a string",
|
7
|
+
"result": "new String formed by joining the array elements with seperator",
|
8
|
+
"category": "array",
|
9
|
+
"category_description": "Array handling routines, eg. join, join_prefix, join_post",
|
10
|
+
"base_class_require": null,
|
11
|
+
"base_class": null,
|
12
|
+
"parameters": [
|
13
|
+
{
|
14
|
+
"name": "values",
|
15
|
+
"description": "array of values to join",
|
16
|
+
"splat": null,
|
17
|
+
"default": null,
|
18
|
+
"param_type": "String|Int"
|
19
|
+
},
|
20
|
+
{
|
21
|
+
"name": "separator",
|
22
|
+
"description": "separator between values, defaults to comma",
|
23
|
+
"splat": null,
|
24
|
+
"default": "','",
|
25
|
+
"param_type": "String"
|
26
|
+
}
|
27
|
+
],
|
28
|
+
"examples": [
|
29
|
+
|
30
|
+
],
|
31
|
+
"ruby": " return false if values.nil? || values.length == 0\n values = values.reject(&:blank?)\n return '' if values.length.zero?\n\n values.join(separator)\n"
|
32
|
+
},
|
33
|
+
{
|
34
|
+
"name": "join_pre",
|
35
|
+
"description": "join an array of values with separator as a string and using the separator at the beginning of string",
|
36
|
+
"result": null,
|
37
|
+
"category": "array",
|
38
|
+
"category_description": "Array handling routines, eg. join, join_prefix, join_post",
|
39
|
+
"base_class_require": null,
|
40
|
+
"base_class": null,
|
41
|
+
"parameters": [
|
42
|
+
{
|
43
|
+
"name": "values",
|
44
|
+
"description": "array of values to join",
|
45
|
+
"splat": null,
|
46
|
+
"default": null,
|
47
|
+
"param_type": "String|Int"
|
48
|
+
},
|
49
|
+
{
|
50
|
+
"name": "separator",
|
51
|
+
"description": "separator between values, defaults to comma",
|
52
|
+
"splat": null,
|
53
|
+
"default": "','",
|
54
|
+
"param_type": "String"
|
55
|
+
}
|
56
|
+
],
|
57
|
+
"examples": [
|
58
|
+
|
59
|
+
],
|
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
|
+
},
|
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
|
+
{
|
92
|
+
"name": "join_post",
|
93
|
+
"description": "join an array of values with separator as a string and using the separator at the end of string",
|
94
|
+
"result": null,
|
95
|
+
"category": "array",
|
96
|
+
"category_description": "Array handling routines, eg. join, join_prefix, join_post",
|
97
|
+
"base_class_require": null,
|
98
|
+
"base_class": null,
|
99
|
+
"parameters": [
|
100
|
+
{
|
101
|
+
"name": "values",
|
102
|
+
"description": "array of values to join",
|
103
|
+
"splat": null,
|
104
|
+
"default": null,
|
105
|
+
"param_type": "String|Int"
|
106
|
+
},
|
107
|
+
{
|
108
|
+
"name": "separator",
|
109
|
+
"description": "separator between values, defaults to comma",
|
110
|
+
"splat": null,
|
111
|
+
"default": "','",
|
112
|
+
"param_type": "String"
|
113
|
+
}
|
114
|
+
],
|
115
|
+
"examples": [
|
116
|
+
|
117
|
+
],
|
118
|
+
"ruby": " return '' if values.nil? || !values.is_a?(::Array)\n values = values.reject(&:blank?)\n return '' if values.length.zero?\n\n \"#{values.join(separator)}#{separator}\"\n"
|
119
|
+
}
|
120
|
+
]
|
121
|
+
}
|
@@ -0,0 +1,245 @@
|
|
1
|
+
{
|
2
|
+
"category_key": "comparison",
|
3
|
+
"cmdlets": [
|
4
|
+
{
|
5
|
+
"name": "and",
|
6
|
+
"description": "Return true if **all of** the given values are truthy.",
|
7
|
+
"result": "return true when every value is truthy",
|
8
|
+
"category": "comparison",
|
9
|
+
"category_description": "Comparison helpers, eg. or, and, equal, not equal, less than, greater than etc.",
|
10
|
+
"base_class_require": null,
|
11
|
+
"base_class": null,
|
12
|
+
"parameters": [
|
13
|
+
{
|
14
|
+
"name": "values",
|
15
|
+
"description": "list of values (via *splat) to be checked via AND condition",
|
16
|
+
"splat": "*",
|
17
|
+
"default": null,
|
18
|
+
"param_type": "Object"
|
19
|
+
}
|
20
|
+
],
|
21
|
+
"examples": [
|
22
|
+
|
23
|
+
],
|
24
|
+
"ruby": " values.all? { |value| value }\n"
|
25
|
+
},
|
26
|
+
{
|
27
|
+
"name": "default",
|
28
|
+
"description": "Return true if **all of** the given values are truthy.",
|
29
|
+
"result": "return true when every value is truthy",
|
30
|
+
"category": "comparison",
|
31
|
+
"category_description": "Comparison helpers, eg. or, and, equal, not equal, less than, greater than etc.",
|
32
|
+
"base_class_require": null,
|
33
|
+
"base_class": null,
|
34
|
+
"parameters": [
|
35
|
+
{
|
36
|
+
"name": "values",
|
37
|
+
"description": "one or more paramaters that may or may not contain nil",
|
38
|
+
"splat": "*",
|
39
|
+
"default": null,
|
40
|
+
"param_type": "Object"
|
41
|
+
}
|
42
|
+
],
|
43
|
+
"examples": [
|
44
|
+
|
45
|
+
],
|
46
|
+
"ruby": " default_value = values[-1]\n\n find_value = values[0..-2].find { |value| !value.nil? }\n\n find_value || default_value\n"
|
47
|
+
},
|
48
|
+
{
|
49
|
+
"name": "eq",
|
50
|
+
"description": "Return true if two values are equal",
|
51
|
+
"result": "return truthy value if left hand side equals right hand side",
|
52
|
+
"category": "comparison",
|
53
|
+
"category_description": "Comparison helpers, eg. or, and, equal, not equal, less than, greater than etc.",
|
54
|
+
"base_class_require": null,
|
55
|
+
"base_class": null,
|
56
|
+
"parameters": [
|
57
|
+
{
|
58
|
+
"name": "lhs",
|
59
|
+
"description": "lhs - left hand side value",
|
60
|
+
"splat": null,
|
61
|
+
"default": null,
|
62
|
+
"param_type": "Object"
|
63
|
+
},
|
64
|
+
{
|
65
|
+
"name": "rhs",
|
66
|
+
"description": "rhs - right hand side value",
|
67
|
+
"splat": null,
|
68
|
+
"default": null,
|
69
|
+
"param_type": "Object"
|
70
|
+
}
|
71
|
+
],
|
72
|
+
"examples": [
|
73
|
+
|
74
|
+
],
|
75
|
+
"ruby": " lhs = lhs.to_s if lhs.is_a?(Symbol)\n rhs = rhs.to_s if rhs.is_a?(Symbol)\n\n lhs == rhs\n"
|
76
|
+
},
|
77
|
+
{
|
78
|
+
"name": "gt",
|
79
|
+
"description": "Return true if left hand side GREATER THAN right hand side",
|
80
|
+
"result": "truthy value if left hand side GREATER THAN right hand side",
|
81
|
+
"category": "comparison",
|
82
|
+
"category_description": "Comparison helpers, eg. or, and, equal, not equal, less than, greater than etc.",
|
83
|
+
"base_class_require": null,
|
84
|
+
"base_class": null,
|
85
|
+
"parameters": [
|
86
|
+
{
|
87
|
+
"name": "lhs",
|
88
|
+
"description": "lhs - left hand side value",
|
89
|
+
"splat": null,
|
90
|
+
"default": null,
|
91
|
+
"param_type": "Object"
|
92
|
+
},
|
93
|
+
{
|
94
|
+
"name": "rhs",
|
95
|
+
"description": "rhs - right hand side value",
|
96
|
+
"splat": null,
|
97
|
+
"default": null,
|
98
|
+
"param_type": "Object"
|
99
|
+
}
|
100
|
+
],
|
101
|
+
"examples": [
|
102
|
+
|
103
|
+
],
|
104
|
+
"ruby": " lhs > rhs\n"
|
105
|
+
},
|
106
|
+
{
|
107
|
+
"name": "gte",
|
108
|
+
"description": "Return true if left hand side GREATER THAN or EQUAL TO right hand side",
|
109
|
+
"result": "truthy value if left hand side GREATER THAN or EQUAL TO right hand side",
|
110
|
+
"category": "comparison",
|
111
|
+
"category_description": "Comparison helpers, eg. or, and, equal, not equal, less than, greater than etc.",
|
112
|
+
"base_class_require": null,
|
113
|
+
"base_class": null,
|
114
|
+
"parameters": [
|
115
|
+
{
|
116
|
+
"name": "lhs",
|
117
|
+
"description": "lhs - left hand side value",
|
118
|
+
"splat": null,
|
119
|
+
"default": null,
|
120
|
+
"param_type": "Object"
|
121
|
+
},
|
122
|
+
{
|
123
|
+
"name": "rhs",
|
124
|
+
"description": "rhs - right hand side value",
|
125
|
+
"splat": null,
|
126
|
+
"default": null,
|
127
|
+
"param_type": "Object"
|
128
|
+
}
|
129
|
+
],
|
130
|
+
"examples": [
|
131
|
+
|
132
|
+
],
|
133
|
+
"ruby": " lhs >= rhs\n"
|
134
|
+
},
|
135
|
+
{
|
136
|
+
"name": "lt",
|
137
|
+
"description": "Return true if left hand side LESS THAN right hand side",
|
138
|
+
"result": "truthy value if left hand side LESS THAN right hand side",
|
139
|
+
"category": "comparison",
|
140
|
+
"category_description": "Comparison helpers, eg. or, and, equal, not equal, less than, greater than etc.",
|
141
|
+
"base_class_require": null,
|
142
|
+
"base_class": null,
|
143
|
+
"parameters": [
|
144
|
+
{
|
145
|
+
"name": "lhs",
|
146
|
+
"description": "lhs - left hand side value",
|
147
|
+
"splat": null,
|
148
|
+
"default": null,
|
149
|
+
"param_type": "Object"
|
150
|
+
},
|
151
|
+
{
|
152
|
+
"name": "rhs",
|
153
|
+
"description": "rhs - right hand side value",
|
154
|
+
"splat": null,
|
155
|
+
"default": null,
|
156
|
+
"param_type": "Object"
|
157
|
+
}
|
158
|
+
],
|
159
|
+
"examples": [
|
160
|
+
|
161
|
+
],
|
162
|
+
"ruby": " lhs < rhs\n"
|
163
|
+
},
|
164
|
+
{
|
165
|
+
"name": "lte",
|
166
|
+
"description": "Return true if left hand side LESS THAN or EQUAL TO right hand side",
|
167
|
+
"result": "truthy value if left hand side LESS THAN or EQUAL TO right hand side",
|
168
|
+
"category": "comparison",
|
169
|
+
"category_description": "Comparison helpers, eg. or, and, equal, not equal, less than, greater than etc.",
|
170
|
+
"base_class_require": null,
|
171
|
+
"base_class": null,
|
172
|
+
"parameters": [
|
173
|
+
{
|
174
|
+
"name": "lhs",
|
175
|
+
"description": "lhs - left hand side value",
|
176
|
+
"splat": null,
|
177
|
+
"default": null,
|
178
|
+
"param_type": "Object"
|
179
|
+
},
|
180
|
+
{
|
181
|
+
"name": "rhs",
|
182
|
+
"description": "rhs - right hand side value",
|
183
|
+
"splat": null,
|
184
|
+
"default": null,
|
185
|
+
"param_type": "Object"
|
186
|
+
}
|
187
|
+
],
|
188
|
+
"examples": [
|
189
|
+
|
190
|
+
],
|
191
|
+
"ruby": " lhs <= rhs\n"
|
192
|
+
},
|
193
|
+
{
|
194
|
+
"name": "ne",
|
195
|
+
"description": "Return true if left hand side is NOT equal to right hand side",
|
196
|
+
"result": "truthy value if left hand side is NOT equal to right hand side",
|
197
|
+
"category": "comparison",
|
198
|
+
"category_description": "Comparison helpers, eg. or, and, equal, not equal, less than, greater than etc.",
|
199
|
+
"base_class_require": null,
|
200
|
+
"base_class": null,
|
201
|
+
"parameters": [
|
202
|
+
{
|
203
|
+
"name": "lhs",
|
204
|
+
"description": "lhs - left hand side value",
|
205
|
+
"splat": null,
|
206
|
+
"default": null,
|
207
|
+
"param_type": "Object"
|
208
|
+
},
|
209
|
+
{
|
210
|
+
"name": "rhs",
|
211
|
+
"description": "rhs - right hand side value",
|
212
|
+
"splat": null,
|
213
|
+
"default": null,
|
214
|
+
"param_type": "Object"
|
215
|
+
}
|
216
|
+
],
|
217
|
+
"examples": [
|
218
|
+
|
219
|
+
],
|
220
|
+
"ruby": " lhs = lhs.to_s if lhs.is_a?(Symbol)\n rhs = rhs.to_s if rhs.is_a?(Symbol)\n\n lhs != rhs\n"
|
221
|
+
},
|
222
|
+
{
|
223
|
+
"name": "or",
|
224
|
+
"description": "Return true if any value is truthy.",
|
225
|
+
"result": "return true when first value is truthy",
|
226
|
+
"category": "comparison",
|
227
|
+
"category_description": "Comparison helpers, eg. or, and, equal, not equal, less than, greater than etc.",
|
228
|
+
"base_class_require": null,
|
229
|
+
"base_class": null,
|
230
|
+
"parameters": [
|
231
|
+
{
|
232
|
+
"name": "values",
|
233
|
+
"description": "list of values (via *splat) to be checked via AND condition",
|
234
|
+
"splat": "*",
|
235
|
+
"default": null,
|
236
|
+
"param_type": "Object"
|
237
|
+
}
|
238
|
+
],
|
239
|
+
"examples": [
|
240
|
+
|
241
|
+
],
|
242
|
+
"ruby": " values.any? { |value| value }\n"
|
243
|
+
}
|
244
|
+
]
|
245
|
+
}
|
@@ -0,0 +1,129 @@
|
|
1
|
+
{
|
2
|
+
"category_key": "inflection",
|
3
|
+
"cmdlets": [
|
4
|
+
{
|
5
|
+
"name": "ordinal",
|
6
|
+
"description": "The suffix that should be added to a number to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th",
|
7
|
+
"result": "ordinal suffix that would be required for a number",
|
8
|
+
"category": "inflection",
|
9
|
+
"category_description": "Inflection handling routines, eg. pluralize, singular, ordinalize",
|
10
|
+
"base_class_require": null,
|
11
|
+
"base_class": null,
|
12
|
+
"parameters": [
|
13
|
+
{
|
14
|
+
"name": "value",
|
15
|
+
"description": "value - numeric value",
|
16
|
+
"splat": null,
|
17
|
+
"default": null,
|
18
|
+
"param_type": "String|Int"
|
19
|
+
}
|
20
|
+
],
|
21
|
+
"examples": [
|
22
|
+
|
23
|
+
],
|
24
|
+
"ruby": " return '' if value.nil?\n\n value = value.to_i if value.is_a? String\n\n value.ordinal\n"
|
25
|
+
},
|
26
|
+
{
|
27
|
+
"name": "ordinalize",
|
28
|
+
"description": "Turns a number into an ordinal string used to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th.",
|
29
|
+
"result": "number value turned to 1st, 2nd, 3rd, 4th etc.",
|
30
|
+
"category": "inflection",
|
31
|
+
"category_description": "Inflection handling routines, eg. pluralize, singular, ordinalize",
|
32
|
+
"base_class_require": null,
|
33
|
+
"base_class": null,
|
34
|
+
"parameters": [
|
35
|
+
{
|
36
|
+
"name": "value",
|
37
|
+
"description": "value - numeric value",
|
38
|
+
"splat": null,
|
39
|
+
"default": null,
|
40
|
+
"param_type": "Int"
|
41
|
+
}
|
42
|
+
],
|
43
|
+
"examples": [
|
44
|
+
|
45
|
+
],
|
46
|
+
"ruby": " return '' if value.nil?\n\n value = value.to_i if value.is_a? String\n\n value.ordinalize\n"
|
47
|
+
},
|
48
|
+
{
|
49
|
+
"name": "pluralize",
|
50
|
+
"description": "Returns the plural form of the word in the string",
|
51
|
+
"result": "value in plural form",
|
52
|
+
"category": "inflection",
|
53
|
+
"category_description": "Inflection handling routines, eg. pluralize, singular, ordinalize",
|
54
|
+
"base_class_require": null,
|
55
|
+
"base_class": null,
|
56
|
+
"parameters": [
|
57
|
+
{
|
58
|
+
"name": "value",
|
59
|
+
"description": "value - value to pluralize",
|
60
|
+
"splat": null,
|
61
|
+
"default": null,
|
62
|
+
"param_type": "String"
|
63
|
+
}
|
64
|
+
],
|
65
|
+
"examples": [
|
66
|
+
|
67
|
+
],
|
68
|
+
"ruby": " return '' if value.nil?\n\n value = value.to_s if value.is_a?(Symbol)\n\n value.pluralize\n"
|
69
|
+
},
|
70
|
+
{
|
71
|
+
"name": "pluralize_by_number",
|
72
|
+
"description": "Returns the plural form of the word based on a count",
|
73
|
+
"result": "value and number are used to calculate plural/singular form",
|
74
|
+
"category": "inflection",
|
75
|
+
"category_description": "Inflection handling routines, eg. pluralize, singular, ordinalize",
|
76
|
+
"base_class_require": null,
|
77
|
+
"base_class": null,
|
78
|
+
"parameters": [
|
79
|
+
{
|
80
|
+
"name": "value",
|
81
|
+
"description": "value - value to pluralize",
|
82
|
+
"splat": null,
|
83
|
+
"default": null,
|
84
|
+
"param_type": "String"
|
85
|
+
},
|
86
|
+
{
|
87
|
+
"name": "count",
|
88
|
+
"description": "count used to determine pluralization",
|
89
|
+
"splat": null,
|
90
|
+
"default": null,
|
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
|
+
}
|
100
|
+
],
|
101
|
+
"examples": [
|
102
|
+
|
103
|
+
],
|
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
|
+
},
|
106
|
+
{
|
107
|
+
"name": "singularize",
|
108
|
+
"description": "The reverse of #pluralize, returns the singular form of a word in a string",
|
109
|
+
"result": "plural value turned to singular value",
|
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 singularized",
|
118
|
+
"splat": null,
|
119
|
+
"default": null,
|
120
|
+
"param_type": "String"
|
121
|
+
}
|
122
|
+
],
|
123
|
+
"examples": [
|
124
|
+
|
125
|
+
],
|
126
|
+
"ruby": " return '' if value.nil?\n\n value = value.to_s if value.is_a?(Symbol)\n\n value.singularize\n"
|
127
|
+
}
|
128
|
+
]
|
129
|
+
}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class CategoryBuilder < KDirector::Builders::ActionsBuilder
|
4
|
+
def category(name, description)
|
5
|
+
value = {
|
6
|
+
name: name,
|
7
|
+
description: description
|
8
|
+
}
|
9
|
+
|
10
|
+
add(:categories, value: value)
|
11
|
+
|
12
|
+
self
|
13
|
+
end
|
14
|
+
|
15
|
+
def save_categories(**opts)
|
16
|
+
k_builder
|
17
|
+
.cd(:builder_data)
|
18
|
+
.add('categories.json', content: to_json, **opts)
|
19
|
+
|
20
|
+
self
|
21
|
+
end
|
22
|
+
|
23
|
+
def osave_categories(**opts)
|
24
|
+
save_categories(**{ open: true }.merge(opts))
|
25
|
+
end
|
26
|
+
end
|