cmdx 1.20.0 → 2.0.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.
Files changed (195) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +131 -1
  3. data/README.md +37 -24
  4. data/lib/cmdx/.DS_Store +0 -0
  5. data/lib/cmdx/callbacks.rb +179 -0
  6. data/lib/cmdx/chain.rb +78 -175
  7. data/lib/cmdx/coercions/array.rb +19 -33
  8. data/lib/cmdx/coercions/big_decimal.rb +12 -29
  9. data/lib/cmdx/coercions/boolean.rb +25 -45
  10. data/lib/cmdx/coercions/coerce.rb +32 -0
  11. data/lib/cmdx/coercions/complex.rb +12 -27
  12. data/lib/cmdx/coercions/date.rb +29 -33
  13. data/lib/cmdx/coercions/date_time.rb +29 -33
  14. data/lib/cmdx/coercions/float.rb +8 -29
  15. data/lib/cmdx/coercions/hash.rb +17 -43
  16. data/lib/cmdx/coercions/integer.rb +8 -32
  17. data/lib/cmdx/coercions/rational.rb +12 -33
  18. data/lib/cmdx/coercions/string.rb +6 -24
  19. data/lib/cmdx/coercions/symbol.rb +12 -26
  20. data/lib/cmdx/coercions/time.rb +31 -35
  21. data/lib/cmdx/coercions.rb +174 -0
  22. data/lib/cmdx/configuration.rb +45 -225
  23. data/lib/cmdx/context.rb +263 -242
  24. data/lib/cmdx/deprecation.rb +67 -0
  25. data/lib/cmdx/deprecators/error.rb +22 -0
  26. data/lib/cmdx/deprecators/log.rb +22 -0
  27. data/lib/cmdx/deprecators/warn.rb +21 -0
  28. data/lib/cmdx/deprecators.rb +101 -0
  29. data/lib/cmdx/errors.rb +145 -79
  30. data/lib/cmdx/executors/fiber.rb +42 -0
  31. data/lib/cmdx/executors/thread.rb +36 -0
  32. data/lib/cmdx/executors.rb +95 -0
  33. data/lib/cmdx/fault.rb +85 -78
  34. data/lib/cmdx/i18n_proxy.rb +104 -0
  35. data/lib/cmdx/input.rb +294 -0
  36. data/lib/cmdx/inputs.rb +218 -0
  37. data/lib/cmdx/log_formatters/json.rb +9 -20
  38. data/lib/cmdx/log_formatters/key_value.rb +10 -21
  39. data/lib/cmdx/log_formatters/line.rb +7 -19
  40. data/lib/cmdx/log_formatters/logstash.rb +8 -21
  41. data/lib/cmdx/log_formatters/raw.rb +8 -20
  42. data/lib/cmdx/logger_proxy.rb +30 -0
  43. data/lib/cmdx/mergers/deep_merge.rb +23 -0
  44. data/lib/cmdx/mergers/last_write_wins.rb +23 -0
  45. data/lib/cmdx/mergers/no_merge.rb +20 -0
  46. data/lib/cmdx/mergers.rb +95 -0
  47. data/lib/cmdx/middlewares.rb +128 -0
  48. data/lib/cmdx/output.rb +115 -0
  49. data/lib/cmdx/outputs.rb +66 -0
  50. data/lib/cmdx/pipeline.rb +144 -131
  51. data/lib/cmdx/railtie.rb +10 -36
  52. data/lib/cmdx/result.rb +252 -473
  53. data/lib/cmdx/retriers/bounded_random.rb +24 -0
  54. data/lib/cmdx/retriers/decorrelated_jitter.rb +28 -0
  55. data/lib/cmdx/retriers/exponential.rb +23 -0
  56. data/lib/cmdx/retriers/fibonacci.rb +39 -0
  57. data/lib/cmdx/retriers/full_random.rb +23 -0
  58. data/lib/cmdx/retriers/half_random.rb +24 -0
  59. data/lib/cmdx/retriers/linear.rb +23 -0
  60. data/lib/cmdx/retriers.rb +106 -0
  61. data/lib/cmdx/retry.rb +117 -138
  62. data/lib/cmdx/runtime.rb +251 -0
  63. data/lib/cmdx/settings.rb +68 -196
  64. data/lib/cmdx/signal.rb +165 -0
  65. data/lib/cmdx/task.rb +443 -336
  66. data/lib/cmdx/telemetry.rb +108 -0
  67. data/lib/cmdx/util.rb +73 -0
  68. data/lib/cmdx/validators/absence.rb +10 -39
  69. data/lib/cmdx/validators/exclusion.rb +33 -52
  70. data/lib/cmdx/validators/format.rb +19 -49
  71. data/lib/cmdx/validators/inclusion.rb +33 -54
  72. data/lib/cmdx/validators/length.rb +125 -127
  73. data/lib/cmdx/validators/numeric.rb +123 -123
  74. data/lib/cmdx/validators/presence.rb +10 -39
  75. data/lib/cmdx/validators/validate.rb +31 -0
  76. data/lib/cmdx/validators.rb +161 -0
  77. data/lib/cmdx/version.rb +2 -4
  78. data/lib/cmdx/workflow.rb +74 -82
  79. data/lib/cmdx.rb +111 -42
  80. data/lib/generators/cmdx/install_generator.rb +7 -17
  81. data/lib/generators/cmdx/task_generator.rb +12 -29
  82. data/lib/generators/cmdx/templates/install.rb +128 -52
  83. data/lib/generators/cmdx/templates/task.rb.tt +1 -1
  84. data/lib/generators/cmdx/templates/workflow.rb.tt +1 -2
  85. data/lib/generators/cmdx/workflow_generator.rb +12 -29
  86. data/lib/locales/en.yml +9 -6
  87. data/mkdocs.yml +25 -23
  88. metadata +39 -138
  89. data/lib/cmdx/attribute.rb +0 -440
  90. data/lib/cmdx/attribute_registry.rb +0 -185
  91. data/lib/cmdx/attribute_value.rb +0 -252
  92. data/lib/cmdx/callback_registry.rb +0 -169
  93. data/lib/cmdx/coercion_registry.rb +0 -138
  94. data/lib/cmdx/deprecator.rb +0 -77
  95. data/lib/cmdx/exception.rb +0 -46
  96. data/lib/cmdx/executor.rb +0 -374
  97. data/lib/cmdx/identifier.rb +0 -30
  98. data/lib/cmdx/locale.rb +0 -78
  99. data/lib/cmdx/middleware_registry.rb +0 -148
  100. data/lib/cmdx/middlewares/correlate.rb +0 -140
  101. data/lib/cmdx/middlewares/runtime.rb +0 -62
  102. data/lib/cmdx/middlewares/timeout.rb +0 -78
  103. data/lib/cmdx/parallelizer.rb +0 -100
  104. data/lib/cmdx/utils/call.rb +0 -53
  105. data/lib/cmdx/utils/condition.rb +0 -71
  106. data/lib/cmdx/utils/format.rb +0 -82
  107. data/lib/cmdx/utils/normalize.rb +0 -52
  108. data/lib/cmdx/utils/wrap.rb +0 -38
  109. data/lib/cmdx/validator_registry.rb +0 -143
  110. data/lib/generators/cmdx/locale_generator.rb +0 -39
  111. data/lib/locales/af.yml +0 -53
  112. data/lib/locales/ar.yml +0 -53
  113. data/lib/locales/az.yml +0 -53
  114. data/lib/locales/be.yml +0 -53
  115. data/lib/locales/bg.yml +0 -53
  116. data/lib/locales/bn.yml +0 -53
  117. data/lib/locales/bs.yml +0 -53
  118. data/lib/locales/ca.yml +0 -53
  119. data/lib/locales/cnr.yml +0 -53
  120. data/lib/locales/cs.yml +0 -53
  121. data/lib/locales/cy.yml +0 -53
  122. data/lib/locales/da.yml +0 -53
  123. data/lib/locales/de.yml +0 -53
  124. data/lib/locales/dz.yml +0 -53
  125. data/lib/locales/el.yml +0 -53
  126. data/lib/locales/eo.yml +0 -53
  127. data/lib/locales/es.yml +0 -53
  128. data/lib/locales/et.yml +0 -53
  129. data/lib/locales/eu.yml +0 -53
  130. data/lib/locales/fa.yml +0 -53
  131. data/lib/locales/fi.yml +0 -53
  132. data/lib/locales/fr.yml +0 -53
  133. data/lib/locales/fy.yml +0 -53
  134. data/lib/locales/gd.yml +0 -53
  135. data/lib/locales/gl.yml +0 -53
  136. data/lib/locales/he.yml +0 -53
  137. data/lib/locales/hi.yml +0 -53
  138. data/lib/locales/hr.yml +0 -53
  139. data/lib/locales/hu.yml +0 -53
  140. data/lib/locales/hy.yml +0 -53
  141. data/lib/locales/id.yml +0 -53
  142. data/lib/locales/is.yml +0 -53
  143. data/lib/locales/it.yml +0 -53
  144. data/lib/locales/ja.yml +0 -53
  145. data/lib/locales/ka.yml +0 -53
  146. data/lib/locales/kk.yml +0 -53
  147. data/lib/locales/km.yml +0 -53
  148. data/lib/locales/kn.yml +0 -53
  149. data/lib/locales/ko.yml +0 -53
  150. data/lib/locales/lb.yml +0 -53
  151. data/lib/locales/lo.yml +0 -53
  152. data/lib/locales/lt.yml +0 -53
  153. data/lib/locales/lv.yml +0 -53
  154. data/lib/locales/mg.yml +0 -53
  155. data/lib/locales/mk.yml +0 -53
  156. data/lib/locales/ml.yml +0 -53
  157. data/lib/locales/mn.yml +0 -53
  158. data/lib/locales/mr-IN.yml +0 -53
  159. data/lib/locales/ms.yml +0 -53
  160. data/lib/locales/nb.yml +0 -53
  161. data/lib/locales/ne.yml +0 -53
  162. data/lib/locales/nl.yml +0 -53
  163. data/lib/locales/nn.yml +0 -53
  164. data/lib/locales/oc.yml +0 -53
  165. data/lib/locales/or.yml +0 -53
  166. data/lib/locales/pa.yml +0 -53
  167. data/lib/locales/pl.yml +0 -53
  168. data/lib/locales/pt.yml +0 -53
  169. data/lib/locales/rm.yml +0 -53
  170. data/lib/locales/ro.yml +0 -53
  171. data/lib/locales/ru.yml +0 -53
  172. data/lib/locales/sc.yml +0 -53
  173. data/lib/locales/sk.yml +0 -53
  174. data/lib/locales/sl.yml +0 -53
  175. data/lib/locales/sq.yml +0 -53
  176. data/lib/locales/sr.yml +0 -53
  177. data/lib/locales/st.yml +0 -53
  178. data/lib/locales/sv.yml +0 -53
  179. data/lib/locales/sw.yml +0 -53
  180. data/lib/locales/ta.yml +0 -53
  181. data/lib/locales/te.yml +0 -53
  182. data/lib/locales/th.yml +0 -53
  183. data/lib/locales/tl.yml +0 -53
  184. data/lib/locales/tr.yml +0 -53
  185. data/lib/locales/tt.yml +0 -53
  186. data/lib/locales/ug.yml +0 -53
  187. data/lib/locales/uk.yml +0 -53
  188. data/lib/locales/ur.yml +0 -53
  189. data/lib/locales/uz.yml +0 -53
  190. data/lib/locales/vi.yml +0 -53
  191. data/lib/locales/wo.yml +0 -53
  192. data/lib/locales/zh-CN.yml +0 -53
  193. data/lib/locales/zh-HK.yml +0 -53
  194. data/lib/locales/zh-TW.yml +0 -53
  195. data/lib/locales/zh-YUE.yml +0 -53
@@ -1,71 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module CMDx
4
- module Utils
5
- # Provides conditional evaluation utilities for CMDx tasks and workflows.
6
- #
7
- # This module handles conditional logic evaluation with support for `if` and `unless`
8
- # conditions using various callable types including symbols, procs, and objects
9
- # responding to `call`.
10
- module Condition
11
-
12
- extend self
13
-
14
- # @rbs EVAL: Proc
15
- EVAL = proc do |target, callable, *args, **kwargs, &block|
16
- case callable
17
- when NilClass, FalseClass, TrueClass then !!callable
18
- when Symbol then target.send(callable, *args, **kwargs, &block)
19
- when Proc then target.instance_exec(*args, **kwargs, &callable)
20
- else
21
- raise "cannot evaluate #{callable.inspect}" unless callable.respond_to?(:call)
22
-
23
- callable.call(*args, **kwargs, &block)
24
- end
25
- end.freeze
26
- private_constant :EVAL
27
-
28
- # Evaluates conditional logic based on provided options.
29
- #
30
- # Supports both `if` and `unless` conditions, with `unless` taking precedence
31
- # when both are specified. Returns true if no conditions are provided.
32
- #
33
- # @param target [Object] The target object to evaluate conditions against
34
- # @param options [Hash] Conditional options hash
35
- # @option options [Object] :if Condition that must be true for evaluation to succeed
36
- # @option options [Object] :unless Condition that must be false for evaluation to succeed
37
- #
38
- # @return [Boolean] true if conditions are met, false otherwise
39
- #
40
- # @raise [RuntimeError] When a callable cannot be evaluated
41
- #
42
- # @example Basic if condition
43
- # Condition.evaluate(user, if: :active?)
44
- # # => true if user.active? returns true
45
- # @example Unless condition
46
- # Condition.evaluate(user, unless: :blocked?)
47
- # # => true if user.blocked? returns false
48
- # @example Combined conditions
49
- # Condition.evaluate(user, if: :verified?, unless: :suspended?)
50
- # # => true if user.verified? is true AND user.suspended? is false
51
- # @example With arguments and block
52
- # Condition.evaluate(user, if: ->(u) { u.has_permission?(:admin) }, :admin)
53
- # # => true if the proc returns true when called with user and :admin
54
- #
55
- # @rbs (untyped target, Hash[Symbol, untyped] options, *untyped) ?{ () -> untyped } -> bool
56
- def evaluate(target, options, ...)
57
- case options
58
- in if: if_cond, unless: unless_cond
59
- EVAL.call(target, if_cond, ...) && !EVAL.call(target, unless_cond, ...)
60
- in if: if_cond
61
- EVAL.call(target, if_cond, ...)
62
- in unless: unless_cond
63
- !EVAL.call(target, unless_cond, ...)
64
- else
65
- true
66
- end
67
- end
68
-
69
- end
70
- end
71
- end
@@ -1,82 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module CMDx
4
- module Utils
5
- # Utility module for formatting data structures into log-friendly strings
6
- # and converting messages to appropriate formats for logging
7
- module Format
8
-
9
- extend self
10
-
11
- # @rbs FORMATTER: Proc
12
- FORMATTER = proc do |key, value|
13
- "#{key}=#{value.inspect}"
14
- end.freeze
15
- private_constant :FORMATTER
16
-
17
- # Converts a message to a format suitable for logging
18
- #
19
- # @param message [Object] The message to format
20
- #
21
- # @return [Hash, Object] Returns a hash if the message responds to to_h and is a CMDx object, otherwise returns the original message
22
- #
23
- # @example Hash like objects
24
- # Format.to_log({user_id: 123, action: "login"})
25
- # # => {user_id: 123, action: "login"}
26
- # @example Simple message
27
- # Format.to_log("simple message")
28
- # # => "simple message"
29
- # @example CMDx object
30
- # Format.to_log(CMDx::Task.new(name: "task1"))
31
- # # => {name: "task1"}
32
- #
33
- # @rbs (untyped message) -> untyped
34
- def to_log(message)
35
- if message.respond_to?(:to_h) && cmdx_based_object?(message.class)
36
- message.to_h
37
- else
38
- message
39
- end
40
- end
41
-
42
- # Converts a hash to a formatted string using a custom formatter
43
- #
44
- # @param hash [Hash] The hash to convert to string
45
- # @param block [Proc, nil] Optional custom formatter block
46
- # @option block [String] :key The hash key
47
- # @option block [Object] :value The hash value
48
- #
49
- # @return [String] Space-separated formatted key-value pairs
50
- #
51
- # @example Default formatter
52
- # Format.to_str({user_id: 123, status: "active"})
53
- # # => "user_id=123 status=\"active\""
54
- # @example Custom formatter
55
- # Format.to_str({count: 5, total: 100}) { |k, v| "#{k}:#{v}" }
56
- # # => "count:5 total:100"
57
- #
58
- # @rbs (Hash[untyped, untyped] hash) ?{ (untyped, untyped) -> String } -> String
59
- def to_str(hash, &block)
60
- block ||= FORMATTER
61
- hash.map(&block).join(" ")
62
- end
63
-
64
- private
65
-
66
- # Checks if a class belongs to the CMDx namespace, caching per class.
67
- #
68
- # @param klass [Class] The class to check
69
- #
70
- # @return [Boolean] true if the class is in the CMDx namespace
71
- #
72
- # @rbs (Class klass) -> bool
73
- def cmdx_based_object?(klass)
74
- @cmdx_classes ||= {}
75
- return @cmdx_classes[klass] if @cmdx_classes.key?(klass)
76
-
77
- @cmdx_classes[klass] = klass.ancestors.any? { |a| a.name&.start_with?("CMDx::") }
78
- end
79
-
80
- end
81
- end
82
- end
@@ -1,52 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module CMDx
4
- module Utils
5
- # Provides normalization utilities for a variety of objects
6
- # into consistent formats.
7
- module Normalize
8
-
9
- extend self
10
-
11
- # Normalizes an exception into a string representation.
12
- #
13
- # @param exception [Exception] The exception to normalize
14
- #
15
- # @return [String] The normalized exception string
16
- #
17
- # @example From exception
18
- # Normalize.exception(StandardError.new("test"))
19
- # # => "[StandardError] test"
20
- #
21
- # @rbs (Exception exception) -> String
22
- def exception(exception)
23
- "[#{exception.class}] #{exception.message}"
24
- end
25
-
26
- # Normalizes an object into an array of unique status strings.
27
- #
28
- # @param object [Object] The object to normalize into status strings
29
- #
30
- # @return [Array<String>] Unique status strings
31
- #
32
- # @example From array of symbols
33
- # Normalize.statuses([:success, :pending, :success])
34
- # # => ["success", "pending"]
35
- # @example From single value
36
- # Normalize.statuses(:success)
37
- # # => ["success"]
38
- # @example From nil
39
- # Normalize.statuses(nil)
40
- # # => []
41
- #
42
- # @rbs (untyped object) -> Array[String]
43
- def statuses(object)
44
- ary = Wrap.array(object)
45
- return EMPTY_ARRAY if ary.empty?
46
-
47
- ary.map(&:to_s).uniq
48
- end
49
-
50
- end
51
- end
52
- end
@@ -1,38 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module CMDx
4
- module Utils
5
- # Provides array wrapping utilities for normalizing input values
6
- # into consistent array structures.
7
- module Wrap
8
-
9
- extend self
10
-
11
- # Wraps an object in an array if it is not already an array.
12
- #
13
- # @param object [Object] The object to wrap in an array
14
- #
15
- # @return [Array] The wrapped array
16
- #
17
- # @example Already an array
18
- # Wrap.array([1, 2, 3])
19
- # # => [1, 2, 3]
20
- # @example Single value
21
- # Wrap.array(1)
22
- # # => [1]
23
- # @example Nil value
24
- # Wrap.array(nil)
25
- # # => []
26
- #
27
- # @rbs (untyped object) -> Array[untyped]
28
- def array(object)
29
- case object
30
- when Array then object
31
- when NilClass then EMPTY_ARRAY
32
- else Array(object)
33
- end
34
- end
35
-
36
- end
37
- end
38
- end
@@ -1,143 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module CMDx
4
- # Registry for managing validation rules and their corresponding validator classes.
5
- # Provides methods to register, deregister, and execute validators against task values.
6
- #
7
- # Supports copy-on-write semantics: a duped registry shares the parent's
8
- # data until a write operation triggers materialization.
9
- class ValidatorRegistry
10
-
11
- extend Forwardable
12
-
13
- def_delegators :registry, :keys
14
-
15
- # Initialize a new validator registry with default validators.
16
- #
17
- # @param registry [Hash, nil] Optional hash mapping validator names to validator classes
18
- #
19
- # @return [ValidatorRegistry] A new validator registry instance
20
- #
21
- # @rbs (?Hash[Symbol, Class]? registry) -> void
22
- def initialize(registry = nil)
23
- @registry = registry || {
24
- absence: Validators::Absence,
25
- exclusion: Validators::Exclusion,
26
- format: Validators::Format,
27
- inclusion: Validators::Inclusion,
28
- length: Validators::Length,
29
- numeric: Validators::Numeric,
30
- presence: Validators::Presence
31
- }
32
- end
33
-
34
- # Sets up copy-on-write state when duplicated via dup.
35
- #
36
- # @param source [ValidatorRegistry] The registry being duplicated
37
- #
38
- # @rbs (ValidatorRegistry source) -> void
39
- def initialize_dup(source)
40
- @parent = source
41
- @registry = nil
42
- super
43
- end
44
-
45
- # Returns the internal registry mapping validator types to classes.
46
- # Delegates to the parent registry when not yet materialized.
47
- #
48
- # @return [Hash{Symbol => Class}] Hash of validator type names to validator classes
49
- #
50
- # @example
51
- # registry.registry # => { presence: Validators::Presence, format: Validators::Format }
52
- #
53
- # @rbs () -> Hash[Symbol, Class]
54
- def registry
55
- @registry || @parent.registry
56
- end
57
- alias to_h registry
58
-
59
- # Register a new validator class with the given name.
60
- #
61
- # @param name [String, Symbol] The name to register the validator under
62
- # @param validator [Class] The validator class to register
63
- #
64
- # @return [ValidatorRegistry] Returns self for method chaining
65
- #
66
- # @example
67
- # registry.register(:custom, CustomValidator)
68
- # registry.register("email", EmailValidator)
69
- #
70
- # @rbs ((String | Symbol) name, Class validator) -> self
71
- def register(name, validator)
72
- materialize!
73
-
74
- @registry[name.to_sym] = validator
75
- self
76
- end
77
-
78
- # Remove a validator from the registry by name.
79
- #
80
- # @param name [String, Symbol] The name of the validator to remove
81
- #
82
- # @return [ValidatorRegistry] Returns self for method chaining
83
- #
84
- # @example
85
- # registry.deregister(:format)
86
- # registry.deregister("presence")
87
- #
88
- # @rbs ((String | Symbol) name) -> self
89
- def deregister(name)
90
- materialize!
91
-
92
- @registry.delete(name.to_sym)
93
- self
94
- end
95
-
96
- # Validate a value using the specified validator type and options.
97
- #
98
- # @param type [Symbol] The type of validator to use
99
- # @param task [Task] The task context for validation
100
- # @param value [Object] The value to validate
101
- # @param options [Hash, Object] Validation options or condition
102
- # @option options [Boolean] :allow_nil Whether to allow nil values
103
- #
104
- # @raise [TypeError] When the validator type is not registered
105
- #
106
- # @example
107
- # registry.validate(:presence, task, user.name, presence: true)
108
- # registry.validate(:length, task, password, { min: 8, allow_nil: false })
109
- #
110
- # @rbs (Symbol type, Task task, untyped value, untyped options) -> untyped
111
- def validate(type, task, value, options = EMPTY_HASH)
112
- raise TypeError, "unknown validator type #{type.inspect}" unless registry.key?(type)
113
-
114
- match =
115
- if options.is_a?(Hash)
116
- case options
117
- in allow_nil: then !(allow_nil && value.nil?)
118
- else Utils::Condition.evaluate(task, options, value)
119
- end
120
- else
121
- options
122
- end
123
-
124
- return unless match
125
-
126
- Utils::Call.invoke(task, registry[type], value, options)
127
- end
128
-
129
- private
130
-
131
- # Copies the parent's registry data into this instance,
132
- # severing the copy-on-write link.
133
- #
134
- # @rbs () -> void
135
- def materialize!
136
- return if @registry
137
-
138
- @registry = @parent.registry.dup
139
- @parent = nil
140
- end
141
-
142
- end
143
- end
@@ -1,39 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Cmdx
4
- # Generates CMDx locale files for Rails applications
5
- #
6
- # Rails generator that copies CMDx locale files into the application's
7
- # config/locales directory. This allows applications to customize and extend
8
- # the default CMDx locale files.
9
- class LocaleGenerator < Rails::Generators::Base
10
-
11
- source_root File.expand_path("../../locales", __dir__)
12
-
13
- desc "Copies the locale with the given ISO 639 code"
14
-
15
- argument :locale, type: :string, default: "en", banner: "locale: en, es, fr, etc"
16
-
17
- # Copies the locale template to the Rails application
18
- #
19
- # Copies the specified locale file from the gem's locales directory to the
20
- # application's config/locales directory. If the locale file doesn't exist
21
- # in the gem, the generator will fail gracefully.
22
- #
23
- # @return [void]
24
- #
25
- # @example Copy default (English) locale file
26
- # generator = Cmdx::LocaleGenerator.new(["en"])
27
- # generator.copy_locale_files
28
- # # => Creates config/locales/en.yml
29
- #
30
- # @example Copy Spanish locale file
31
- # generator = Cmdx::LocaleGenerator.new(["es"])
32
- # generator.copy_locale_files
33
- # # => Creates config/locales/es.yml
34
- def copy_locale_files
35
- copy_file("#{locale}.yml", "config/locales/#{locale}.yml")
36
- end
37
-
38
- end
39
- end
data/lib/locales/af.yml DELETED
@@ -1,53 +0,0 @@
1
- af:
2
- cmdx:
3
- attributes:
4
- required: "moet toeganklik wees via die %{method} bronmetode"
5
- undefined: "delegeer na ongedefinieerde metode %{method}"
6
- coercions:
7
- into_a: "kon nie na %{type} omskep word nie"
8
- into_an: "kon nie na %{type} omskep word nie"
9
- into_any: "kon nie na een van: %{types} omskep word nie"
10
- unknown: "onbekende %{type} omskep tipe"
11
- returns:
12
- missing: "moet in die konteks gestel word"
13
- faults:
14
- invalid: "Ongeldig"
15
- unspecified: "Ongespesifiseer"
16
- types:
17
- array: "skikking"
18
- big_decimal: "groot desimale"
19
- boolean: "booleaanse"
20
- complex: "kompleks"
21
- date_time: "datum en tyd"
22
- date: "datum"
23
- float: "drywende punt"
24
- hash: "hash"
25
- integer: "heelgetal"
26
- rational: "rasionaal"
27
- string: "string"
28
- symbol: "simbool"
29
- time: "tyd"
30
- validators:
31
- absence: "moet leeg wees"
32
- exclusion:
33
- of: "moet nie een van wees nie: %{values}"
34
- within: "moet nie binne %{min} en %{max} wees nie"
35
- format: "is 'n ongeldige formaat"
36
- inclusion:
37
- of: "moet een van wees: %{values}"
38
- within: "moet binne %{min} en %{max} wees"
39
- length:
40
- is: "lengte moet %{is} wees"
41
- is_not: "lengte moet nie %{is_not} wees nie"
42
- min: "lengte moet ten minste %{min} wees"
43
- max: "lengte kan maksimum %{max} wees"
44
- not_within: "lengte moet nie binne %{min} en %{max} wees nie"
45
- within: "lengte moet binne %{min} en %{max} wees"
46
- numeric:
47
- is: "moet %{is} wees"
48
- is_not: "moet nie %{is_not} wees nie"
49
- min: "moet ten minste %{min} wees"
50
- max: "kan maksimum %{max} wees"
51
- not_within: "moet nie binne %{min} en %{max} wees nie"
52
- within: "moet binne %{min} en %{max} wees"
53
- presence: "kan nie leeg wees nie"
data/lib/locales/ar.yml DELETED
@@ -1,53 +0,0 @@
1
- ar:
2
- cmdx:
3
- attributes:
4
- required: "يجب أن يكون قابلاً للوصول عبر طريقة المصدر %{method}"
5
- undefined: "يفوض إلى طريقة غير معرفة %{method}"
6
- coercions:
7
- into_a: "لا يمكن تحويله إلى %{type}"
8
- into_an: "لا يمكن تحويله إلى %{type}"
9
- into_any: "لا يمكن تحويله إلى واحد من: %{types}"
10
- unknown: "نوع تحويل %{type} غير معروف"
11
- returns:
12
- missing: "يجب تعيينه في السياق"
13
- faults:
14
- invalid: "غير صالح"
15
- unspecified: "غير محدد"
16
- types:
17
- array: "مصفوفة"
18
- big_decimal: "عدد عشري كبير"
19
- boolean: "منطقي"
20
- complex: "مركب"
21
- date_time: "التاريخ والوقت"
22
- date: "التاريخ"
23
- float: "رقم عشري"
24
- hash: "جدول تجزئة"
25
- integer: "عدد صحيح"
26
- rational: "عدد نسبي"
27
- string: "سلسلة نصية"
28
- symbol: "رمز"
29
- time: "الوقت"
30
- validators:
31
- absence: "يجب أن يكون فارغاً"
32
- exclusion:
33
- of: "يجب ألا يكون واحداً من: %{values}"
34
- within: "يجب ألا يكون بين %{min} و %{max}"
35
- format: "تنسيق غير صالح"
36
- inclusion:
37
- of: "يجب أن يكون واحداً من: %{values}"
38
- within: "يجب أن يكون بين %{min} و %{max}"
39
- length:
40
- is: "يجب أن يكون الطول %{is}"
41
- is_not: "يجب ألا يكون الطول %{is_not}"
42
- min: "يجب أن يكون الطول على الأقل %{min}"
43
- max: "يجب أن يكون الطول على الأكثر %{max}"
44
- not_within: "يجب ألا يكون الطول بين %{min} و %{max}"
45
- within: "يجب أن يكون الطول بين %{min} و %{max}"
46
- numeric:
47
- is: "يجب أن يكون %{is}"
48
- is_not: "يجب ألا يكون %{is_not}"
49
- min: "يجب أن يكون على الأقل %{min}"
50
- max: "يجب أن يكون على الأكثر %{max}"
51
- not_within: "يجب ألا يكون بين %{min} و %{max}"
52
- within: "يجب أن يكون بين %{min} و %{max}"
53
- presence: "لا يمكن أن يكون فارغاً"
data/lib/locales/az.yml DELETED
@@ -1,53 +0,0 @@
1
- az:
2
- cmdx:
3
- attributes:
4
- required: "%{method} mənbə metodu vasitəsilə əlçatan olmalıdır"
5
- undefined: "müəyyən edilməmiş metoda %{method} təyin edir"
6
- coercions:
7
- into_a: "%{type} tipinə çevrilə bilmədi"
8
- into_an: "%{type} tipinə çevrilə bilmədi"
9
- into_any: "aşağıdakılardan birinə çevrilə bilmədi: %{types}"
10
- unknown: "naməlum %{type} çevrilmə tipi"
11
- returns:
12
- missing: "kontekstdə təyin edilməlidir"
13
- faults:
14
- invalid: "Etibarsız"
15
- unspecified: "Göstərilməyib"
16
- types:
17
- array: "massiv"
18
- big_decimal: "böyük onluq"
19
- boolean: "məntiqi"
20
- complex: "mürəkkəb"
21
- date_time: "tarix və vaxt"
22
- date: "tarix"
23
- float: "üzən nöqtə"
24
- hash: "haş"
25
- integer: "tam ədəd"
26
- rational: "rasional"
27
- string: "sətir"
28
- symbol: "simvol"
29
- time: "vaxt"
30
- validators:
31
- absence: "boş olmalıdır"
32
- exclusion:
33
- of: "aşağıdakılardan biri ola bilməz: %{values}"
34
- within: "%{min} və %{max} arasında ola bilməz"
35
- format: "etibarsız formatdır"
36
- inclusion:
37
- of: "aşağıdakılardan biri olmalıdır: %{values}"
38
- within: "%{min} və %{max} arasında olmalıdır"
39
- length:
40
- is: "uzunluq %{is} olmalıdır"
41
- is_not: "uzunluq %{is_not} ola bilməz"
42
- min: "uzunluq ən azı %{min} olmalıdır"
43
- max: "uzunluq ən çoxu %{max} ola bilər"
44
- not_within: "uzunluq %{min} və %{max} arasında ola bilməz"
45
- within: "uzunluq %{min} və %{max} arasında olmalıdır"
46
- numeric:
47
- is: "%{is} olmalıdır"
48
- is_not: "%{is_not} ola bilməz"
49
- min: "ən azı %{min} olmalıdır"
50
- max: "ən çoxu %{max} ola bilər"
51
- not_within: "%{min} və %{max} arasında ola bilməz"
52
- within: "%{min} və %{max} arasında olmalıdır"
53
- presence: "boş ola bilməz"
data/lib/locales/be.yml DELETED
@@ -1,53 +0,0 @@
1
- be:
2
- cmdx:
3
- attributes:
4
- required: "павінен быць даступны праз зыходны метад %{method}"
5
- undefined: "дэлегуе невызначанаму метаду %{method}"
6
- coercions:
7
- into_a: "не ўдалося пераўтварыць у %{type}"
8
- into_an: "не ўдалося пераўтварыць у %{type}"
9
- into_any: "не ўдалося пераўтварыць у адзін з: %{types}"
10
- unknown: "невядомы тып пераўтварэння %{type}"
11
- returns:
12
- missing: "павінна быць усталявана ў кантэксце"
13
- faults:
14
- invalid: "Няправільныя"
15
- unspecified: "Не паказана"
16
- types:
17
- array: "масіў"
18
- big_decimal: "вялікае дзесятковае лік"
19
- boolean: "лагічны"
20
- complex: "камплексны"
21
- date_time: "дата і час"
22
- date: "дата"
23
- float: "лік з плаваючай коскай"
24
- hash: "хэш"
25
- integer: "цэлы лік"
26
- rational: "рацыянальны"
27
- string: "радок"
28
- symbol: "сімвал"
29
- time: "час"
30
- validators:
31
- absence: "павінна быць пустым"
32
- exclusion:
33
- of: "не можа быць адным з: %{values}"
34
- within: "не можа быць паміж %{min} і %{max}"
35
- format: "з'яўляецца несапраўдным фарматам"
36
- inclusion:
37
- of: "павінна быць адным з: %{values}"
38
- within: "павінна быць паміж %{min} і %{max}"
39
- length:
40
- is: "даўжыня павінна быць %{is}"
41
- is_not: "даўжыня не можа быць %{is_not}"
42
- min: "даўжыня павінна быць не менш %{min}"
43
- max: "даўжыня можа быць не больш %{max}"
44
- not_within: "даўжыня не можа быць паміж %{min} і %{max}"
45
- within: "даўжыня павінна быць паміж %{min} і %{max}"
46
- numeric:
47
- is: "павінна быць %{is}"
48
- is_not: "не можа быць %{is_not}"
49
- min: "павінна быць не менш %{min}"
50
- max: "можа быць не больш %{max}"
51
- not_within: "не можа быць паміж %{min} і %{max}"
52
- within: "павінна быць паміж %{min} і %{max}"
53
- presence: "не можа быць пустым"