cmdlet 0.0.5 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/.builders/.templates/FUNCTIONS.MD +19 -0
  3. data/.builders/.templates/cmdlet.rb +26 -0
  4. data/.builders/.templates/cmdlet_spec.rb +22 -0
  5. data/.builders/.templates/require_all_cmdlets.rb +5 -0
  6. data/.builders/_.rb +11 -1
  7. data/.builders/boot.rb +6 -3
  8. data/.builders/data/categories.json +28 -0
  9. data/.builders/data/cmdlets/array.json +121 -0
  10. data/.builders/data/cmdlets/comparison.json +245 -0
  11. data/.builders/director/category_builder.rb +26 -0
  12. data/.builders/director/category_dao.rb +38 -0
  13. data/.builders/director/category_director.rb +39 -0
  14. data/.builders/director/cmdlet_builder.rb +67 -0
  15. data/.builders/director/cmdlet_child.rb +39 -0
  16. data/.builders/director/cmdlet_dao.rb +29 -0
  17. data/.builders/director/cmdlet_director.rb +60 -0
  18. data/.builders/director/dao.rb +16 -0
  19. data/.builders/documents/commands.rb +222 -28
  20. data/.builders/documents/use_cases.rb +32 -34
  21. data/.builders/documents/x_functions.rb +7 -10
  22. data/.builders/generators/01-bootstrap.rb +112 -112
  23. data/.builders/generators/20-categories.rb +16 -0
  24. data/.builders/generators/30-commands-bak.rb +53 -0
  25. data/.builders/generators/cmdlets/array.rb +109 -0
  26. data/.builders/generators/cmdlets/comparison.rb +164 -0
  27. data/CHANGELOG.md +36 -0
  28. data/Guardfile +1 -1
  29. data/lib/cmdlet/_.rb +14 -0
  30. data/lib/cmdlet/all_commands.rb +3 -0
  31. data/lib/cmdlet/array/join.rb +22 -0
  32. data/lib/cmdlet/array/join_post.rb +22 -0
  33. data/lib/cmdlet/array/join_pre.rb +22 -0
  34. data/lib/cmdlet/base_cmdlet.rb +17 -0
  35. data/lib/cmdlet/comparison/and.rb +16 -0
  36. data/lib/cmdlet/comparison/default.rb +20 -0
  37. data/lib/cmdlet/comparison/eq.rb +20 -0
  38. data/lib/cmdlet/comparison/gt.rb +17 -0
  39. data/lib/cmdlet/comparison/gte.rb +17 -0
  40. data/lib/cmdlet/comparison/lt.rb +17 -0
  41. data/lib/cmdlet/comparison/lte.rb +17 -0
  42. data/lib/cmdlet/comparison/ne.rb +20 -0
  43. data/lib/cmdlet/comparison/or.rb +16 -0
  44. data/lib/cmdlet/configuration.rb +1 -1
  45. data/lib/cmdlet/version.rb +1 -1
  46. data/lib/cmdlet.rb +3 -0
  47. data/package-lock.json +2 -2
  48. data/package.json +1 -1
  49. metadata +39 -5
  50. data/.builders/documents/_.rb +0 -4
  51. data/.builders/documents/categories.rb +0 -24
  52. data/.builders/documents/functions.rb +0 -226
@@ -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
@@ -21,7 +21,7 @@ module Cmdlet
21
21
  attr_accessor :padr_char
22
22
 
23
23
  def initialize
24
- # @tokenizer = Funcky::StringTokenizer.new
24
+ @tokenizer = Cmdlet::StringTokenizer.new
25
25
  @padr_count = 30
26
26
  @padr_char = ' '
27
27
  @padl_count = 30
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Cmdlet
4
- VERSION = '0.0.5'
4
+ VERSION = '0.1.2'
5
5
  end
data/lib/cmdlet.rb CHANGED
@@ -4,8 +4,11 @@
4
4
  require 'k_config'
5
5
  require_relative 'cmdlet/version'
6
6
  require_relative 'cmdlet/configuration'
7
+ require_relative 'cmdlet/base_cmdlet'
7
8
  require_relative 'cmdlet/string_tokenizer'
8
9
 
10
+ require_relative 'cmdlet/_'
11
+
9
12
  module Cmdlet
10
13
  # raise Cmdlet::Error, 'Sample message'
11
14
  Error = Class.new(StandardError)
data/package-lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "cmdlet",
3
- "version": "0.0.5",
3
+ "version": "0.1.2",
4
4
  "lockfileVersion": 2,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "cmdlet",
9
- "version": "0.0.5",
9
+ "version": "0.1.2",
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.0.5",
3
+ "version": "0.1.2",
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.0.5
4
+ version: 0.1.2
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-08 00:00:00.000000000 Z
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,31 @@ 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/documents/_.rb"
52
- - ".builders/documents/categories.rb"
55
+ - ".builders/data/categories.json"
56
+ - ".builders/data/cmdlets/array.json"
57
+ - ".builders/data/cmdlets/comparison.json"
58
+ - ".builders/director/category_builder.rb"
59
+ - ".builders/director/category_dao.rb"
60
+ - ".builders/director/category_director.rb"
61
+ - ".builders/director/cmdlet_builder.rb"
62
+ - ".builders/director/cmdlet_child.rb"
63
+ - ".builders/director/cmdlet_dao.rb"
64
+ - ".builders/director/cmdlet_director.rb"
65
+ - ".builders/director/dao.rb"
53
66
  - ".builders/documents/commands.rb"
54
- - ".builders/documents/functions.rb"
55
67
  - ".builders/documents/use_cases.rb"
56
68
  - ".builders/documents/x_functions.rb"
57
69
  - ".builders/generators/01-bootstrap.rb"
70
+ - ".builders/generators/20-categories.rb"
71
+ - ".builders/generators/30-commands-bak.rb"
72
+ - ".builders/generators/cmdlets/array.rb"
73
+ - ".builders/generators/cmdlets/comparison.rb"
58
74
  - ".releaserc.json"
59
75
  - ".rspec"
60
76
  - ".rubocop.yml"
@@ -68,6 +84,21 @@ files:
68
84
  - bin/console
69
85
  - bin/setup
70
86
  - lib/cmdlet.rb
87
+ - lib/cmdlet/_.rb
88
+ - lib/cmdlet/all_commands.rb
89
+ - lib/cmdlet/array/join.rb
90
+ - lib/cmdlet/array/join_post.rb
91
+ - lib/cmdlet/array/join_pre.rb
92
+ - lib/cmdlet/base_cmdlet.rb
93
+ - lib/cmdlet/comparison/and.rb
94
+ - lib/cmdlet/comparison/default.rb
95
+ - lib/cmdlet/comparison/eq.rb
96
+ - lib/cmdlet/comparison/gt.rb
97
+ - lib/cmdlet/comparison/gte.rb
98
+ - lib/cmdlet/comparison/lt.rb
99
+ - lib/cmdlet/comparison/lte.rb
100
+ - lib/cmdlet/comparison/ne.rb
101
+ - lib/cmdlet/comparison/or.rb
71
102
  - lib/cmdlet/configuration.rb
72
103
  - lib/cmdlet/string_tokenizer.rb
73
104
  - lib/cmdlet/version.rb
@@ -78,6 +109,9 @@ homepage: http://appydave.com/gems/cmdlet
78
109
  licenses:
79
110
  - MIT
80
111
  metadata:
112
+ homepage_uri: http://appydave.com/gems/cmdlet
113
+ source_code_uri: https://github.com/klueless-io/cmdlet
114
+ changelog_uri: https://github.com/klueless-io/cmdlet/blob/main/CHANGELOG.md
81
115
  rubygems_mfa_required: 'true'
82
116
  post_install_message:
83
117
  rdoc_options: []
@@ -1,4 +0,0 @@
1
- require_relative './categories'
2
- require_relative './functions'
3
- require_relative './use_cases'
4
- require_relative './commands'
@@ -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
-
@@ -1,226 +0,0 @@
1
- def functions
2
- return @functions unless @functions.nil?
3
-
4
- result = KDoc.model :document do
5
- table :rows do
6
- fields :category, :name, :alias, :description, :ruby # , f(name: :params, default: [:value])
7
-
8
- # context 'when array of string' do
9
- # let(:value) { %w[the quick fox] }
10
-
11
- # it { is_expected.to eq('the,quick,fox') }
12
- # end
13
-
14
- # context 'when array of numbers' do
15
- # let(:value) { [1, 2, 3] }
16
-
17
- # it { is_expected.to eq('1,2,3') }
18
- # end
19
-
20
- # context 'when array of symbol' do
21
- # let(:value) { %i[the quick fox] }
22
-
23
- # it { is_expected.to eq('the,quick,fox') }
24
- # end
25
-
26
- row :a_array , :join , [] , "join an array of values with separator as a string", <<-'RUBY'
27
- return '' if value.nil? || !value.is_a?(Array)
28
- values = value.reject(&:blank?)
29
- return '' if value.length.zero?
30
-
31
- separator = ','
32
- value.join(separator)
33
- RUBY
34
-
35
- row :a_array , :join_pre , [] , "join an array of values with separator as a string and using the separator at the beginning of string", <<-'RUBY'
36
- return '' if value.nil? || !value.is_a?(Array)
37
- values = value.reject(&:blank?)
38
- return '' if value.length.zero?
39
-
40
- separator = ','
41
- "#{separator}#{value.join(separator)}"
42
- RUBY
43
-
44
- row :a_array , :join_post , [] , "join an array of values with separator as a string and using the separator at the end of string", <<-'RUBY'
45
- return '' if value.nil? || !value.is_a?(Array)
46
- values = value.reject(&:blank?)
47
- return '' if value.length.zero?
48
-
49
- separator = ','
50
- "#{value.join(separator)}#{separator}"
51
- RUBY
52
-
53
- row :a_transform , :backslash , [:back_slash] , "convert to back slash notation", <<-'RUBY'
54
- tokenizer.parse(value, preserve_case: true, separator: '\\')
55
- RUBY
56
-
57
- row :a_transform , :camel , [:upper_camel, :pascal] , "convert to camel notation", <<-'RUBY'
58
- tokenizer.parse(value).underscore.camelize
59
- RUBY
60
-
61
- row :a_transform , :constant , [:constantize] , "", <<-'RUBY'
62
- tokenizer.parse(value, separator: '_').upcase
63
- RUBY
64
-
65
- row :a_transform , :dash , [:dasherize] , "convert to dash notation", <<-'RUBY'
66
- tokenizer.parse(value)
67
- RUBY
68
-
69
- row :a_transform , :dot , [:dotirize] , "", <<-'RUBY'
70
- tokenizer.parse(value, separator: '.')
71
- RUBY
72
-
73
- row :a_transform , :double_colon , [] , "", <<-'RUBY'
74
- tokenizer.parse(value, preserve_case: true, separator: '::')
75
- RUBY
76
-
77
- row :a_transform , :lower , [:lowercase, :downcase] , "", <<-'RUBY'
78
- return '' if value.nil?
79
-
80
- value.downcase
81
- RUBY
82
-
83
- # row :a_transform , :format_as , [] , "", <<-'RUBY'
84
-
85
- # RUBY
86
-
87
- row :a_transform , :proper , [] , "Proper case capitalizes the first letter of ALL words in a string", <<-'RUBY'
88
- tokenizer.parse(value,
89
- separator: ' ',
90
- preserve_case: true,
91
- compress_prefix_numerals: false,
92
- compress_suffix_numerals: false)
93
- .titleize
94
- RUBY
95
-
96
- row :a_transform , :sentence , [:human, :humanize] , "Upper case for first letter only. Numbers will maintain their spacing", <<-'RUBY'
97
- tokenizer.parse(value,
98
- separator: ' ',
99
- preserve_case: true,
100
- compress_prefix_numerals: false,
101
- compress_suffix_numerals: false)
102
- .humanize
103
- RUBY
104
-
105
- row :a_transform , :lamel , [:lower_camel] , "", <<-'RUBY'
106
- tokenizer.parse(value, separator: '_').camelize(:lower)
107
- RUBY
108
-
109
- row :a_transform , :slash , [:forwardslash, :forward_slash] , "", <<-'RUBY'
110
- tokenizer.parse(value, preserve_case: true, separator: '/')
111
- RUBY
112
-
113
- row :a_transform , :snake , [:snake] , "", <<-'RUBY'
114
- tokenizer.parse(value, separator: '_', forced_separator: true)
115
- RUBY
116
-
117
- row :a_transform , :title , [:titleize] , "", <<-'RUBY'
118
- tokenizer.parse(value,
119
- separator: ' ',
120
- preserve_case: true,
121
- compress_prefix_numerals: false,
122
- compress_suffix_numerals: false)
123
- .titleize
124
- RUBY
125
-
126
- row :a_transform , :upper , [:upper_case, :upcase] , "", <<-'RUBY'
127
- return '' if value.nil?
128
-
129
- value.upcase
130
- RUBY
131
-
132
-
133
- row :a_comparison , :and , [:all] , "", <<-'RUBY'
134
- values.all? { |value| value }
135
- RUBY
136
-
137
- # DEFAULT does not make sense in comparison
138
- row :a_comparison , :default , [:fallback] , "", <<-'RUBY'
139
- default_value = values[-1]
140
-
141
- find_value = values[0..-2].find { |value| !value.nil? }
142
-
143
- find_value || default_value
144
- RUBY
145
-
146
- row :a_comparison , :eq , [:equal] , "", <<-'RUBY'
147
- lhs = lhs.to_s if lhs.is_a?(Symbol)
148
- rhs = rhs.to_s if rhs.is_a?(Symbol)
149
-
150
- lhs == rhs
151
- RUBY
152
-
153
- row :a_comparison , :gt , [] , "", <<-'RUBY'
154
- lhs > rhs
155
- RUBY
156
-
157
- row :a_comparison , :gte , [] , "", <<-'RUBY'
158
- lhs >= rhs
159
- RUBY
160
-
161
- row :a_comparison , :lt , [:less_than] , "# Lt: (less than) Block helper that renders a block if `a` is **less than** `b`. If an inverse block is specified it will be rendered when falsy.", <<-'RUBY'
162
- lhs < rhs
163
- RUBY
164
-
165
- row :a_comparison , :lte , [:less_than_or_equal_to] , "# Lte: (less than or equal to) Block helper that renders a block if `a` is **less than or equal to** `b`. If an inverse block is specified it will be rendered when falsy.", <<-'RUBY'
166
- lhs <= rhs
167
- RUBY
168
-
169
- row :a_comparison , :ne , [:not_equal] , "# Ne: (not equal) Block helper that renders a block if `a` is **not equal to** `b`. If an inverse block is specified it will be rendered when falsy.", <<-'RUBY'
170
- lhs = lhs.to_s if lhs.is_a?(Symbol)
171
- rhs = rhs.to_s if rhs.is_a?(Symbol)
172
-
173
- lhs != rhs
174
- RUBY
175
-
176
- row :a_comparison , :or , [:any] , "", <<-'RUBY'
177
- values.any? { |value| value }
178
- RUBY
179
-
180
-
181
-
182
- row :a_inflection , :ordinal , [] , "The suffix that should be added to a number to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th", <<-RUBY
183
- return '' if value.nil?
184
-
185
- value = value.to_i if value.is_a? String
186
-
187
- value.ordinal
188
- RUBY
189
-
190
- row :a_inflection , :ordinalize , [] , "Turns a number into an ordinal string used to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th.", <<-RUBY
191
- return '' if value.nil?
192
-
193
- value = value.to_i if value.is_a? String
194
-
195
- value.ordinalize
196
- RUBY
197
-
198
- row :a_inflection , :pluralize , [] , "Returns the plural form of the word in the string", <<-RUBY
199
- return '' if value.nil?
200
-
201
- value = value.to_s if value.is_a?(Symbol)
202
-
203
- value.pluralize
204
- RUBY
205
-
206
- row :a_inflection , :pluralize_by_number , [] , "Uses both a word and number to decide if the plural or singular form should be used.", <<-'RUBY'
207
- return '' if value.nil?
208
-
209
- count = count.to_i if count.is_a? String
210
- format = :word if format.nil?
211
-
212
- case format.to_sym
213
- when :number_word, :number_and_word
214
- "#{count} #{value.pluralize(count)}"
215
- else # aka :word
216
- value.pluralize(count)
217
- end
218
- RUBY
219
-
220
- # row :a_inflection , :singularize , [] , ""
221
- end
222
- end
223
-
224
- @functions = result.raw_data_struct.rows
225
- end
226
- @functions = nil