Class: Textus::Protocol::VerbRegistry::VerbSpec
- Inherits:
-
Data
- Object
- Data
- Textus::Protocol::VerbRegistry::VerbSpec
- Defined in:
- lib/textus/protocol/verb_registry/verb_spec.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#category ⇒ Object
readonly
Returns the value of attribute category.
-
#summary ⇒ Object
readonly
Returns the value of attribute summary.
-
#surfaces ⇒ Object
readonly
Returns the value of attribute surfaces.
-
#verb ⇒ Object
readonly
Returns the value of attribute verb.
Instance Method Summary collapse
- #cli? ⇒ Boolean
- #cli_group ⇒ Object
- #cli_leaf ⇒ Object
- #cli_path ⇒ Object
- #cli_words ⇒ Object
-
#initialize(verb:, summary:, args:, surfaces:, category:, lane: nil) ⇒ VerbSpec
constructor
A new instance of VerbSpec.
- #input_schema ⇒ Object
- #lane ⇒ Object
- #maintenance? ⇒ Boolean
- #mcp? ⇒ Boolean
- #read? ⇒ Boolean
- #required_args ⇒ Object
- #system? ⇒ Boolean
- #write? ⇒ Boolean
Constructor Details
#initialize(verb:, summary:, args:, surfaces:, category:, lane: nil) ⇒ VerbSpec
Returns a new instance of VerbSpec.
12 13 14 15 |
# File 'lib/textus/protocol/verb_registry/verb_spec.rb', line 12 def initialize(verb:, summary:, args:, surfaces:, category:, lane: nil) @lane = lane super(verb:, summary:, args:, surfaces:, category:) end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args
11 12 13 |
# File 'lib/textus/protocol/verb_registry/verb_spec.rb', line 11 def args @args end |
#category ⇒ Object (readonly)
Returns the value of attribute category
11 12 13 |
# File 'lib/textus/protocol/verb_registry/verb_spec.rb', line 11 def category @category end |
#summary ⇒ Object (readonly)
Returns the value of attribute summary
11 12 13 |
# File 'lib/textus/protocol/verb_registry/verb_spec.rb', line 11 def summary @summary end |
#surfaces ⇒ Object (readonly)
Returns the value of attribute surfaces
11 12 13 |
# File 'lib/textus/protocol/verb_registry/verb_spec.rb', line 11 def surfaces @surfaces end |
#verb ⇒ Object (readonly)
Returns the value of attribute verb
11 12 13 |
# File 'lib/textus/protocol/verb_registry/verb_spec.rb', line 11 def verb @verb end |
Instance Method Details
#cli? ⇒ Boolean
20 |
# File 'lib/textus/protocol/verb_registry/verb_spec.rb', line 20 def cli? = surfaces.include?(:cli) |
#cli_group ⇒ Object
23 |
# File 'lib/textus/protocol/verb_registry/verb_spec.rb', line 23 def cli_group = cli_words.size > 1 ? cli_words.first : nil |
#cli_leaf ⇒ Object
24 |
# File 'lib/textus/protocol/verb_registry/verb_spec.rb', line 24 def cli_leaf = cli_words.last |
#cli_path ⇒ Object
21 |
# File 'lib/textus/protocol/verb_registry/verb_spec.rb', line 21 def cli_path = verb.to_s.tr("_", " ") |
#cli_words ⇒ Object
22 |
# File 'lib/textus/protocol/verb_registry/verb_spec.rb', line 22 def cli_words = cli_path.split |
#input_schema ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/textus/protocol/verb_registry/verb_spec.rb', line 30 def input_schema props = args.to_h do |a| json_type = VerbRegistry::TYPE_MAP[a.type] || "string" h = { "type" => json_type } h["description"] = a.description if a.description [a.wire.to_s, h] end { type: "object", properties: props, required: required_args.map { |a| a.wire.to_s } } end |
#lane ⇒ Object
17 |
# File 'lib/textus/protocol/verb_registry/verb_spec.rb', line 17 def lane = @lane |
#maintenance? ⇒ Boolean
28 |
# File 'lib/textus/protocol/verb_registry/verb_spec.rb', line 28 def maintenance? = category == :maintenance |
#mcp? ⇒ Boolean
19 |
# File 'lib/textus/protocol/verb_registry/verb_spec.rb', line 19 def mcp? = surfaces.include?(:mcp) |
#read? ⇒ Boolean
26 |
# File 'lib/textus/protocol/verb_registry/verb_spec.rb', line 26 def read? = category == :read |
#required_args ⇒ Object
25 |
# File 'lib/textus/protocol/verb_registry/verb_spec.rb', line 25 def required_args = args.select(&:required) |
#system? ⇒ Boolean
18 |
# File 'lib/textus/protocol/verb_registry/verb_spec.rb', line 18 def system? = SYSTEM_VERBS.include?(verb) |
#write? ⇒ Boolean
27 |
# File 'lib/textus/protocol/verb_registry/verb_spec.rb', line 27 def write? = category == :write |