cmdlet 0.0.6 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,40 @@
|
|
1
|
+
## [0.1.2](https://github.com/klueless-io/cmdlet/compare/v0.1.1...v0.1.2) (2022-07-10)
|
2
|
+
|
3
|
+
|
4
|
+
### Bug Fixes
|
5
|
+
|
6
|
+
* add comparison :or ([633633d](https://github.com/klueless-io/cmdlet/commit/633633d2a22b98a0de1acf6257feb3603a2f2c39))
|
7
|
+
* add comparison :or, :and, :lt, :lte, :gt, :gte, :ne, :eq, :default ([000cb1a](https://github.com/klueless-io/cmdlet/commit/000cb1a3cbd643abcb5dac6828972ec94c9f53a8))
|
8
|
+
|
9
|
+
## [0.1.1](https://github.com/klueless-io/cmdlet/compare/v0.1.0...v0.1.1) (2022-07-10)
|
10
|
+
|
11
|
+
|
12
|
+
### Bug Fixes
|
13
|
+
|
14
|
+
* add specs ([80f384f](https://github.com/klueless-io/cmdlet/commit/80f384f9f7cd1c1ea67396bb12d3119c433ea139))
|
15
|
+
|
16
|
+
# [0.1.0](https://github.com/klueless-io/cmdlet/compare/v0.0.7...v0.1.0) (2022-07-09)
|
17
|
+
|
18
|
+
|
19
|
+
### Features
|
20
|
+
|
21
|
+
* generate commandlets ([a61948e](https://github.com/klueless-io/cmdlet/commit/a61948e285d488d3aab68a9ef3bd0c136b87170f))
|
22
|
+
|
23
|
+
## [0.0.7](https://github.com/klueless-io/cmdlet/compare/v0.0.6...v0.0.7) (2022-07-09)
|
24
|
+
|
25
|
+
|
26
|
+
### Bug Fixes
|
27
|
+
|
28
|
+
* add category director ([3b72b72](https://github.com/klueless-io/cmdlet/commit/3b72b72d9f739c9a3711f14a640bb6d527e17140))
|
29
|
+
* add category director ([cea0f1a](https://github.com/klueless-io/cmdlet/commit/cea0f1ae37bfbb67d634f18cf1d315a80c1f6082))
|
30
|
+
|
31
|
+
## [0.0.6](https://github.com/klueless-io/cmdlet/compare/v0.0.5...v0.0.6) (2022-07-08)
|
32
|
+
|
33
|
+
|
34
|
+
### Bug Fixes
|
35
|
+
|
36
|
+
* add tests for configuration ([59a764f](https://github.com/klueless-io/cmdlet/commit/59a764f99f84dbe1c5b1022e8fdc2386fcced92a))
|
37
|
+
|
1
38
|
## [0.0.5](https://github.com/klueless-io/cmdlet/compare/v0.0.4...v0.0.5) (2022-07-08)
|
2
39
|
|
3
40
|
|
data/Guardfile
CHANGED
@@ -19,7 +19,7 @@ group :green_pass_then_cop, halt_on_fail: true do
|
|
19
19
|
# Ruby files
|
20
20
|
ruby = dsl.ruby
|
21
21
|
dsl.watch_spec_files_for(ruby.lib_files)
|
22
|
-
watch(%r{^lib//(.+)\.rb$}) { |m| "spec
|
22
|
+
watch(%r{^lib//(.+)\.rb$}) { |m| "spec/**/#{m[1]}_spec.rb" }
|
23
23
|
watch(%r{^lib//commands/(.+)\.rb$}) { |m| "spec/unit/commands/#{m[1]}_spec.rb" }
|
24
24
|
end
|
25
25
|
|
data/lib/cmdlet/_.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'array/join'
|
4
|
+
require_relative 'array/join_post'
|
5
|
+
require_relative 'array/join_pre'
|
6
|
+
require_relative 'comparison/and'
|
7
|
+
require_relative 'comparison/default'
|
8
|
+
require_relative 'comparison/eq'
|
9
|
+
require_relative 'comparison/gt'
|
10
|
+
require_relative 'comparison/gte'
|
11
|
+
require_relative 'comparison/lt'
|
12
|
+
require_relative 'comparison/lte'
|
13
|
+
require_relative 'comparison/ne'
|
14
|
+
require_relative 'comparison/or'
|
15
|
+
require_relative 'inflection/ordinal'
|
16
|
+
require_relative 'inflection/ordinalize'
|
17
|
+
require_relative 'inflection/pluralize'
|
18
|
+
require_relative 'inflection/pluralize_by_number'
|
19
|
+
require_relative 'inflection/singularize'
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cmdlet
|
4
|
+
# Array handling routines, eg. join, join_prefix, join_post
|
5
|
+
module Array
|
6
|
+
# Join: join an array of values with separator as a string
|
7
|
+
class Join < Cmdlet::BaseCmdlet
|
8
|
+
#
|
9
|
+
# @param [String|Int] values - array of values to join
|
10
|
+
# @param [String] separator - separator between values, defaults to comma
|
11
|
+
# @return [String] new String formed by joining the array elements with seperator
|
12
|
+
def call(values, separator = ',')
|
13
|
+
return false if values.nil? || values.length.zero?
|
14
|
+
|
15
|
+
values = values.reject(&:blank?)
|
16
|
+
return '' if values.length.zero?
|
17
|
+
|
18
|
+
values.join(separator)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cmdlet
|
4
|
+
# Array handling routines, eg. join, join_prefix, join_post
|
5
|
+
module Array
|
6
|
+
# JoinPost: join an array of values with separator as a string and using the separator at the end of string
|
7
|
+
class JoinPost < Cmdlet::BaseCmdlet
|
8
|
+
#
|
9
|
+
# @param [String|Int] values - array of values to join
|
10
|
+
# @param [String] separator - separator between values, defaults to comma
|
11
|
+
# @return [String]
|
12
|
+
def call(values, separator = ',')
|
13
|
+
return '' if values.nil? || !values.is_a?(::Array)
|
14
|
+
|
15
|
+
values = values.reject(&:blank?)
|
16
|
+
return '' if values.length.zero?
|
17
|
+
|
18
|
+
"#{values.join(separator)}#{separator}"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cmdlet
|
4
|
+
# Array handling routines, eg. join, join_prefix, join_post
|
5
|
+
module Array
|
6
|
+
# JoinPre: join an array of values with separator as a string and using the separator at the beginning of string
|
7
|
+
class JoinPre < Cmdlet::BaseCmdlet
|
8
|
+
#
|
9
|
+
# @param [String|Int] values - array of values to join
|
10
|
+
# @param [String] separator - separator between values, defaults to comma
|
11
|
+
# @return [String]
|
12
|
+
def call(values, separator = ',')
|
13
|
+
return '' if values.nil? || !values.is_a?(::Array)
|
14
|
+
|
15
|
+
values = values.reject(&:blank?)
|
16
|
+
return '' if values.length.zero?
|
17
|
+
|
18
|
+
"#{separator}#{values.join(separator)}"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cmdlet
|
4
|
+
# base cmdlet provides an interface for cmdlets
|
5
|
+
class BaseCmdlet
|
6
|
+
def call(value)
|
7
|
+
value
|
8
|
+
end
|
9
|
+
|
10
|
+
# String tokenizer will clean up a string so that
|
11
|
+
# all sorts of case formatted strings can be
|
12
|
+
# represented in a consistent fashion
|
13
|
+
def tokenizer
|
14
|
+
@_tokenizer ||= Funcky.configuration.tokenizer
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cmdlet
|
4
|
+
# Comparison helpers, eg. or, and, equal, not equal, less than, greater than etc.
|
5
|
+
module Comparison
|
6
|
+
# And: Return true if **all of** the given values are truthy.
|
7
|
+
class And < Cmdlet::BaseCmdlet
|
8
|
+
#
|
9
|
+
# @param [Object] values - list of values (via *splat) to be checked via AND condition
|
10
|
+
# @return [String] return true when every value is truthy
|
11
|
+
def call(*values)
|
12
|
+
values.all? { |value| value }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cmdlet
|
4
|
+
# Comparison helpers, eg. or, and, equal, not equal, less than, greater than etc.
|
5
|
+
module Comparison
|
6
|
+
# Default: Return true if **all of** the given values are truthy.
|
7
|
+
class Default < Cmdlet::BaseCmdlet
|
8
|
+
#
|
9
|
+
# @param [Object] values - one or more paramaters that may or may not contain nil
|
10
|
+
# @return [String] return true when every value is truthy
|
11
|
+
def call(*values)
|
12
|
+
default_value = values[-1]
|
13
|
+
|
14
|
+
find_value = values[0..-2].find { |value| !value.nil? }
|
15
|
+
|
16
|
+
find_value || default_value
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cmdlet
|
4
|
+
# Comparison helpers, eg. or, and, equal, not equal, less than, greater than etc.
|
5
|
+
module Comparison
|
6
|
+
# Eq: Return true if two values are equal
|
7
|
+
class Eq < Cmdlet::BaseCmdlet
|
8
|
+
#
|
9
|
+
# @param [Object] lhs - lhs - left hand side value
|
10
|
+
# @param [Object] rhs - rhs - right hand side value
|
11
|
+
# @return [String] return truthy value if left hand side equals right hand side
|
12
|
+
def call(lhs, rhs)
|
13
|
+
lhs = lhs.to_s if lhs.is_a?(Symbol)
|
14
|
+
rhs = rhs.to_s if rhs.is_a?(Symbol)
|
15
|
+
|
16
|
+
lhs == rhs
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cmdlet
|
4
|
+
# Comparison helpers, eg. or, and, equal, not equal, less than, greater than etc.
|
5
|
+
module Comparison
|
6
|
+
# Gt: Return true if left hand side GREATER THAN right hand side
|
7
|
+
class Gt < Cmdlet::BaseCmdlet
|
8
|
+
#
|
9
|
+
# @param [Object] lhs - lhs - left hand side value
|
10
|
+
# @param [Object] rhs - rhs - right hand side value
|
11
|
+
# @return [String] truthy value if left hand side GREATER THAN right hand side
|
12
|
+
def call(lhs, rhs)
|
13
|
+
lhs > rhs
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cmdlet
|
4
|
+
# Comparison helpers, eg. or, and, equal, not equal, less than, greater than etc.
|
5
|
+
module Comparison
|
6
|
+
# Gte: Return true if left hand side GREATER THAN or EQUAL TO right hand side
|
7
|
+
class Gte < Cmdlet::BaseCmdlet
|
8
|
+
#
|
9
|
+
# @param [Object] lhs - lhs - left hand side value
|
10
|
+
# @param [Object] rhs - rhs - right hand side value
|
11
|
+
# @return [String] truthy value if left hand side GREATER THAN or EQUAL TO right hand side
|
12
|
+
def call(lhs, rhs)
|
13
|
+
lhs >= rhs
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cmdlet
|
4
|
+
# Comparison helpers, eg. or, and, equal, not equal, less than, greater than etc.
|
5
|
+
module Comparison
|
6
|
+
# Lt: Return true if left hand side LESS THAN right hand side
|
7
|
+
class Lt < Cmdlet::BaseCmdlet
|
8
|
+
#
|
9
|
+
# @param [Object] lhs - lhs - left hand side value
|
10
|
+
# @param [Object] rhs - rhs - right hand side value
|
11
|
+
# @return [String] truthy value if left hand side LESS THAN right hand side
|
12
|
+
def call(lhs, rhs)
|
13
|
+
lhs < rhs
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cmdlet
|
4
|
+
# Comparison helpers, eg. or, and, equal, not equal, less than, greater than etc.
|
5
|
+
module Comparison
|
6
|
+
# Lte: Return true if left hand side LESS THAN or EQUAL TO right hand side
|
7
|
+
class Lte < Cmdlet::BaseCmdlet
|
8
|
+
#
|
9
|
+
# @param [Object] lhs - lhs - left hand side value
|
10
|
+
# @param [Object] rhs - rhs - right hand side value
|
11
|
+
# @return [String] truthy value if left hand side LESS THAN or EQUAL TO right hand side
|
12
|
+
def call(lhs, rhs)
|
13
|
+
lhs <= rhs
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cmdlet
|
4
|
+
# Comparison helpers, eg. or, and, equal, not equal, less than, greater than etc.
|
5
|
+
module Comparison
|
6
|
+
# Ne: Return true if left hand side is NOT equal to right hand side
|
7
|
+
class Ne < Cmdlet::BaseCmdlet
|
8
|
+
#
|
9
|
+
# @param [Object] lhs - lhs - left hand side value
|
10
|
+
# @param [Object] rhs - rhs - right hand side value
|
11
|
+
# @return [String] truthy value if left hand side is NOT equal to right hand side
|
12
|
+
def call(lhs, rhs)
|
13
|
+
lhs = lhs.to_s if lhs.is_a?(Symbol)
|
14
|
+
rhs = rhs.to_s if rhs.is_a?(Symbol)
|
15
|
+
|
16
|
+
lhs != rhs
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cmdlet
|
4
|
+
# Comparison helpers, eg. or, and, equal, not equal, less than, greater than etc.
|
5
|
+
module Comparison
|
6
|
+
# Or: Return true if any value is truthy.
|
7
|
+
class Or < Cmdlet::BaseCmdlet
|
8
|
+
#
|
9
|
+
# @param [Object] values - list of values (via *splat) to be checked via AND condition
|
10
|
+
# @return [String] return true when first value is truthy
|
11
|
+
def call(*values)
|
12
|
+
values.any? { |value| value }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cmdlet
|
4
|
+
# Inflection handling routines, eg. pluralize, singular, ordinalize
|
5
|
+
module Inflection
|
6
|
+
# Ordinal: The suffix that should be added to a number to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th
|
7
|
+
class Ordinal < Cmdlet::BaseCmdlet
|
8
|
+
#
|
9
|
+
# @param [String|Int] value - value - numeric value
|
10
|
+
# @return [String] ordinal suffix that would be required for a number
|
11
|
+
def call(value)
|
12
|
+
return '' if value.nil?
|
13
|
+
|
14
|
+
value = value.to_i if value.is_a? String
|
15
|
+
|
16
|
+
value.ordinal
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cmdlet
|
4
|
+
# Inflection handling routines, eg. pluralize, singular, ordinalize
|
5
|
+
module Inflection
|
6
|
+
# Ordinalize: Turns a number into an ordinal string used to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th.
|
7
|
+
class Ordinalize < Cmdlet::BaseCmdlet
|
8
|
+
#
|
9
|
+
# @param [Int] value - value - numeric value
|
10
|
+
# @return [String] number value turned to 1st, 2nd, 3rd, 4th etc.
|
11
|
+
def call(value)
|
12
|
+
return '' if value.nil?
|
13
|
+
|
14
|
+
value = value.to_i if value.is_a? String
|
15
|
+
|
16
|
+
value.ordinalize
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cmdlet
|
4
|
+
# Inflection handling routines, eg. pluralize, singular, ordinalize
|
5
|
+
module Inflection
|
6
|
+
# Pluralize: Returns the plural form of the word in the string
|
7
|
+
class Pluralize < Cmdlet::BaseCmdlet
|
8
|
+
#
|
9
|
+
# @param [String] value - value - value to pluralize
|
10
|
+
# @return [String] value in plural form
|
11
|
+
def call(value)
|
12
|
+
return '' if value.nil?
|
13
|
+
|
14
|
+
value = value.to_s if value.is_a?(Symbol)
|
15
|
+
|
16
|
+
value.pluralize
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,28 @@
|
|
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
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cmdlet
|
4
|
+
# Inflection handling routines, eg. pluralize, singular, ordinalize
|
5
|
+
module Inflection
|
6
|
+
# Singularize: The reverse of #pluralize, returns the singular form of a word in a string
|
7
|
+
class Singularize < Cmdlet::BaseCmdlet
|
8
|
+
#
|
9
|
+
# @param [String] value - value - value to singularized
|
10
|
+
# @return [String] plural value turned to singular value
|
11
|
+
def call(value)
|
12
|
+
return '' if value.nil?
|
13
|
+
|
14
|
+
value = value.to_s if value.is_a?(Symbol)
|
15
|
+
|
16
|
+
value.singularize
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/cmdlet/version.rb
CHANGED
data/lib/cmdlet.rb
CHANGED
@@ -2,10 +2,15 @@
|
|
2
2
|
|
3
3
|
# require 'k_log'
|
4
4
|
require 'k_config'
|
5
|
+
require 'active_support/core_ext/integer/inflections'
|
6
|
+
|
5
7
|
require_relative 'cmdlet/version'
|
6
8
|
require_relative 'cmdlet/configuration'
|
9
|
+
require_relative 'cmdlet/base_cmdlet'
|
7
10
|
require_relative 'cmdlet/string_tokenizer'
|
8
11
|
|
12
|
+
require_relative 'cmdlet/_'
|
13
|
+
|
9
14
|
module Cmdlet
|
10
15
|
# raise Cmdlet::Error, 'Sample message'
|
11
16
|
Error = Class.new(StandardError)
|
data/package-lock.json
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
{
|
2
2
|
"name": "cmdlet",
|
3
|
-
"version": "0.0
|
3
|
+
"version": "0.2.0",
|
4
4
|
"lockfileVersion": 2,
|
5
5
|
"requires": true,
|
6
6
|
"packages": {
|
7
7
|
"": {
|
8
8
|
"name": "cmdlet",
|
9
|
-
"version": "0.0
|
9
|
+
"version": "0.2.0",
|
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.0
|
4
|
+
version: 0.2.0
|
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-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -46,15 +46,33 @@ executables: []
|
|
46
46
|
extensions: []
|
47
47
|
extra_rdoc_files: []
|
48
48
|
files:
|
49
|
+
- ".builders/.templates/FUNCTIONS.MD"
|
50
|
+
- ".builders/.templates/cmdlet.rb"
|
51
|
+
- ".builders/.templates/cmdlet_spec.rb"
|
52
|
+
- ".builders/.templates/require_all_cmdlets.rb"
|
49
53
|
- ".builders/_.rb"
|
50
54
|
- ".builders/boot.rb"
|
51
|
-
- ".builders/
|
52
|
-
- ".builders/
|
55
|
+
- ".builders/data/categories.json"
|
56
|
+
- ".builders/data/cmdlets/array.json"
|
57
|
+
- ".builders/data/cmdlets/comparison.json"
|
58
|
+
- ".builders/data/cmdlets/inflection.json"
|
59
|
+
- ".builders/director/category_builder.rb"
|
60
|
+
- ".builders/director/category_dao.rb"
|
61
|
+
- ".builders/director/category_director.rb"
|
62
|
+
- ".builders/director/cmdlet_builder.rb"
|
63
|
+
- ".builders/director/cmdlet_child.rb"
|
64
|
+
- ".builders/director/cmdlet_dao.rb"
|
65
|
+
- ".builders/director/cmdlet_director.rb"
|
66
|
+
- ".builders/director/dao.rb"
|
53
67
|
- ".builders/documents/commands.rb"
|
54
|
-
- ".builders/documents/functions.rb"
|
55
68
|
- ".builders/documents/use_cases.rb"
|
56
69
|
- ".builders/documents/x_functions.rb"
|
57
70
|
- ".builders/generators/01-bootstrap.rb"
|
71
|
+
- ".builders/generators/20-categories.rb"
|
72
|
+
- ".builders/generators/30-commands-bak.rb"
|
73
|
+
- ".builders/generators/cmdlets/array.rb"
|
74
|
+
- ".builders/generators/cmdlets/comparison.rb"
|
75
|
+
- ".builders/generators/cmdlets/inflection.rb"
|
58
76
|
- ".releaserc.json"
|
59
77
|
- ".rspec"
|
60
78
|
- ".rubocop.yml"
|
@@ -68,7 +86,27 @@ files:
|
|
68
86
|
- bin/console
|
69
87
|
- bin/setup
|
70
88
|
- lib/cmdlet.rb
|
89
|
+
- lib/cmdlet/_.rb
|
90
|
+
- lib/cmdlet/all_commands.rb
|
91
|
+
- lib/cmdlet/array/join.rb
|
92
|
+
- lib/cmdlet/array/join_post.rb
|
93
|
+
- lib/cmdlet/array/join_pre.rb
|
94
|
+
- lib/cmdlet/base_cmdlet.rb
|
95
|
+
- lib/cmdlet/comparison/and.rb
|
96
|
+
- lib/cmdlet/comparison/default.rb
|
97
|
+
- lib/cmdlet/comparison/eq.rb
|
98
|
+
- lib/cmdlet/comparison/gt.rb
|
99
|
+
- lib/cmdlet/comparison/gte.rb
|
100
|
+
- lib/cmdlet/comparison/lt.rb
|
101
|
+
- lib/cmdlet/comparison/lte.rb
|
102
|
+
- lib/cmdlet/comparison/ne.rb
|
103
|
+
- lib/cmdlet/comparison/or.rb
|
71
104
|
- lib/cmdlet/configuration.rb
|
105
|
+
- lib/cmdlet/inflection/ordinal.rb
|
106
|
+
- lib/cmdlet/inflection/ordinalize.rb
|
107
|
+
- lib/cmdlet/inflection/pluralize.rb
|
108
|
+
- lib/cmdlet/inflection/pluralize_by_number.rb
|
109
|
+
- lib/cmdlet/inflection/singularize.rb
|
72
110
|
- lib/cmdlet/string_tokenizer.rb
|
73
111
|
- lib/cmdlet/version.rb
|
74
112
|
- package-lock.json
|
@@ -78,6 +116,9 @@ homepage: http://appydave.com/gems/cmdlet
|
|
78
116
|
licenses:
|
79
117
|
- MIT
|
80
118
|
metadata:
|
119
|
+
homepage_uri: http://appydave.com/gems/cmdlet
|
120
|
+
source_code_uri: https://github.com/klueless-io/cmdlet
|
121
|
+
changelog_uri: https://github.com/klueless-io/cmdlet/blob/main/CHANGELOG.md
|
81
122
|
rubygems_mfa_required: 'true'
|
82
123
|
post_install_message:
|
83
124
|
rdoc_options: []
|
data/.builders/documents/_.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
def categories
|
2
|
-
return @categories unless @categories.nil?
|
3
|
-
|
4
|
-
|
5
|
-
result = KDoc.model :document do
|
6
|
-
table :rows do
|
7
|
-
fields :name, :description
|
8
|
-
|
9
|
-
row :case , "Tokenize and apply case and/or separator"
|
10
|
-
row :comparison , "Comparison helpers, eg. or, and, equal, not equal, less than, greater than etc."
|
11
|
-
row :inflection , "Inflection handling routines, eg. pluralize, singular, ordinalize"
|
12
|
-
row :string , "String handling helpers"
|
13
|
-
|
14
|
-
row :a_array , "Array handling routines, eg. join, join_prefix, join_post"
|
15
|
-
row :a_transform , "Tokenize and apply case and/or separator"
|
16
|
-
row :a_comparison , "Comparison helpers, eg. or, and, equal, not equal, less than, greater than etc."
|
17
|
-
row :a_inflection , "Inflection handling routines, eg. pluralize, singular, ordinalize"
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
@categories = result.raw_data_struct.rows
|
22
|
-
end
|
23
|
-
@categories = nil
|
24
|
-
|