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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9506e418e3b6a429f7022e585a9252980d9bb6ddc7a5e63701ffb3500b9388b8
4
- data.tar.gz: '038194a239e9fb9e440c6c697837a6172a2aa3cee05ae6f5b6a2104a231a84bc'
3
+ metadata.gz: d5faa2f1cc957beed6274a4da073eae8f3c8dd9b937a99f2edb1fee7adcefe36
4
+ data.tar.gz: 9baead36a85c44b8427f5cbf14164f18adf13dbaf2a05d6cacc7cbdd444e8ab2
5
5
  SHA512:
6
- metadata.gz: e8743f42553160393f595bc4d10b486d8ff35faf28b391346cc471ccc11bb4a351552a59f4bc9fa46778d90cc78caae8ea6e255564010303160216309869b757
7
- data.tar.gz: d38a9aba60cad381a19bbf1da0e81423116fb07c6ef4e7a88fb1105ea6c6e1522e5be782bd20e6b34a95d98d13f216da2e41895b68f54213423400be90be50c0
6
+ metadata.gz: 5bd1875dcf63c87dfd8f7b589083a8b6919857cbae800934872637fb949143181851ae026683f20245927ec84a012b3fb6bf7647bde66f742f5ed6fbbcf9de3b
7
+ data.tar.gz: b856cca6babb797456e7411ae43b21c47580460d514a3d4d8d3e7f22e5ba886644c83b599bda5ee60dc1d6e65dbc96aadf38c09722786c86a30fa7505b86733d
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ KConfig.configure do |config|
4
+ {{#each cmdlets}}
5
+ config.handlebars.helper(:{{name}}, Handlebarsjs::Helpers::{{camel category}}::{{camel name}}.new)
6
+ {{/each}}
7
+ end
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
- Handlebars::Helpers.configure do |config|
12
- config.helper_config_file = File.join(Gem.loaded_specs['handlebars-helpers'].full_gem_path, '.handlebars_helpers.json')
13
- config.string_formatter_config_file = File.join(Gem.loaded_specs['handlebars-helpers'].full_gem_path, '.handlebars_string_formatters.json')
14
- end
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": "pluralize_by_number",
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 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"
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 :pluralize_by_number
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
- parameter :format, '(Optional) what format should output be. :word, :number_word'
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
- format = :word if format.nil?
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'
@@ -6,6 +6,7 @@ module Cmdlet
6
6
  def call(value)
7
7
  value
8
8
  end
9
+ alias parse call
9
10
 
10
11
  # String tokenizer will clean up a string so that
11
12
  # all sorts of case formatted strings can be
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Cmdlet
4
- VERSION = '0.4.2'
4
+ VERSION = '0.6.1'
5
5
  end
data/package-lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "cmdlet",
3
- "version": "0.4.2",
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.4.2",
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cmdlet",
3
- "version": "0.4.2",
3
+ "version": "0.6.1",
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.4.2
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-12 00:00:00.000000000 Z
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.0.3
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.0.3
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