cmdlet 0.1.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/.builders/.templates/{require_all_cmdlets.rb → cmdlets_require_all.rb} +0 -0
  3. data/.builders/.templates/handlebars_helper.rb +17 -0
  4. data/.builders/.templates/handlebars_helper_require_all.rb +5 -0
  5. data/.builders/.templates/handlebars_helper_spec.rb +26 -0
  6. data/.builders/boot.rb +4 -0
  7. data/.builders/data/cmdlets/case.json +313 -0
  8. data/.builders/data/cmdlets/inflection.json +129 -0
  9. data/.builders/director/category_director.rb +6 -1
  10. data/.builders/director/cmdlet_director.rb +8 -0
  11. data/.builders/generators/cmdlets/array.rb +0 -38
  12. data/.builders/generators/cmdlets/case.rb +184 -0
  13. data/.builders/generators/cmdlets/comparison.rb +1 -39
  14. data/.builders/generators/cmdlets/inflection.rb +93 -0
  15. data/CHANGELOG.md +22 -0
  16. data/lib/cmdlet/_.rb +19 -0
  17. data/lib/cmdlet/base_cmdlet.rb +1 -1
  18. data/lib/cmdlet/case/back_slash.rb +16 -0
  19. data/lib/cmdlet/case/camel.rb +16 -0
  20. data/lib/cmdlet/case/constant.rb +16 -0
  21. data/lib/cmdlet/case/dash.rb +16 -0
  22. data/lib/cmdlet/case/dot.rb +16 -0
  23. data/lib/cmdlet/case/double_colon.rb +16 -0
  24. data/lib/cmdlet/case/human.rb +20 -0
  25. data/lib/cmdlet/case/lamel.rb +16 -0
  26. data/lib/cmdlet/case/lower.rb +18 -0
  27. data/lib/cmdlet/case/sentence.rb +20 -0
  28. data/lib/cmdlet/case/slash.rb +16 -0
  29. data/lib/cmdlet/case/snake.rb +16 -0
  30. data/lib/cmdlet/case/title.rb +21 -0
  31. data/lib/cmdlet/case/upper.rb +18 -0
  32. data/lib/cmdlet/inflection/ordinal.rb +20 -0
  33. data/lib/cmdlet/inflection/ordinalize.rb +20 -0
  34. data/lib/cmdlet/inflection/pluralize.rb +20 -0
  35. data/lib/cmdlet/inflection/pluralize_by_number.rb +28 -0
  36. data/lib/cmdlet/inflection/singularize.rb +20 -0
  37. data/lib/cmdlet/version.rb +1 -1
  38. data/lib/cmdlet.rb +2 -0
  39. data/package-lock.json +2 -2
  40. data/package.json +1 -1
  41. metadata +29 -3
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Cmdlet
4
- VERSION = '0.1.2'
4
+ VERSION = '0.3.0'
5
5
  end
data/lib/cmdlet.rb CHANGED
@@ -2,6 +2,8 @@
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'
7
9
  require_relative 'cmdlet/base_cmdlet'
data/package-lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "cmdlet",
3
- "version": "0.1.2",
3
+ "version": "0.3.0",
4
4
  "lockfileVersion": 2,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "cmdlet",
9
- "version": "0.1.2",
9
+ "version": "0.3.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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cmdlet",
3
- "version": "0.1.2",
3
+ "version": "0.3.0",
4
4
  "description": "Cmdlet provides a set of functions (wrapped in the command pattern) that perform simple actions",
5
5
  "scripts": {
6
6
  "release": "semantic-release"
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.1.2
4
+ version: 0.3.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-10 00:00:00.000000000 Z
11
+ date: 2022-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -49,12 +49,17 @@ files:
49
49
  - ".builders/.templates/FUNCTIONS.MD"
50
50
  - ".builders/.templates/cmdlet.rb"
51
51
  - ".builders/.templates/cmdlet_spec.rb"
52
- - ".builders/.templates/require_all_cmdlets.rb"
52
+ - ".builders/.templates/cmdlets_require_all.rb"
53
+ - ".builders/.templates/handlebars_helper.rb"
54
+ - ".builders/.templates/handlebars_helper_require_all.rb"
55
+ - ".builders/.templates/handlebars_helper_spec.rb"
53
56
  - ".builders/_.rb"
54
57
  - ".builders/boot.rb"
55
58
  - ".builders/data/categories.json"
56
59
  - ".builders/data/cmdlets/array.json"
60
+ - ".builders/data/cmdlets/case.json"
57
61
  - ".builders/data/cmdlets/comparison.json"
62
+ - ".builders/data/cmdlets/inflection.json"
58
63
  - ".builders/director/category_builder.rb"
59
64
  - ".builders/director/category_dao.rb"
60
65
  - ".builders/director/category_director.rb"
@@ -70,7 +75,9 @@ files:
70
75
  - ".builders/generators/20-categories.rb"
71
76
  - ".builders/generators/30-commands-bak.rb"
72
77
  - ".builders/generators/cmdlets/array.rb"
78
+ - ".builders/generators/cmdlets/case.rb"
73
79
  - ".builders/generators/cmdlets/comparison.rb"
80
+ - ".builders/generators/cmdlets/inflection.rb"
74
81
  - ".releaserc.json"
75
82
  - ".rspec"
76
83
  - ".rubocop.yml"
@@ -90,6 +97,20 @@ files:
90
97
  - lib/cmdlet/array/join_post.rb
91
98
  - lib/cmdlet/array/join_pre.rb
92
99
  - lib/cmdlet/base_cmdlet.rb
100
+ - lib/cmdlet/case/back_slash.rb
101
+ - lib/cmdlet/case/camel.rb
102
+ - lib/cmdlet/case/constant.rb
103
+ - lib/cmdlet/case/dash.rb
104
+ - lib/cmdlet/case/dot.rb
105
+ - lib/cmdlet/case/double_colon.rb
106
+ - lib/cmdlet/case/human.rb
107
+ - lib/cmdlet/case/lamel.rb
108
+ - lib/cmdlet/case/lower.rb
109
+ - lib/cmdlet/case/sentence.rb
110
+ - lib/cmdlet/case/slash.rb
111
+ - lib/cmdlet/case/snake.rb
112
+ - lib/cmdlet/case/title.rb
113
+ - lib/cmdlet/case/upper.rb
93
114
  - lib/cmdlet/comparison/and.rb
94
115
  - lib/cmdlet/comparison/default.rb
95
116
  - lib/cmdlet/comparison/eq.rb
@@ -100,6 +121,11 @@ files:
100
121
  - lib/cmdlet/comparison/ne.rb
101
122
  - lib/cmdlet/comparison/or.rb
102
123
  - lib/cmdlet/configuration.rb
124
+ - lib/cmdlet/inflection/ordinal.rb
125
+ - lib/cmdlet/inflection/ordinalize.rb
126
+ - lib/cmdlet/inflection/pluralize.rb
127
+ - lib/cmdlet/inflection/pluralize_by_number.rb
128
+ - lib/cmdlet/inflection/singularize.rb
103
129
  - lib/cmdlet/string_tokenizer.rb
104
130
  - lib/cmdlet/version.rb
105
131
  - package-lock.json