Class: Textus::Protocol::VerbRegistry::VerbSpec

Inherits:
Data
  • Object
show all
Defined in:
lib/textus/protocol/verb_registry/verb_spec.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#argsObject (readonly)

Returns the value of attribute args

Returns:

  • (Object)

    the current value of args



11
12
13
# File 'lib/textus/protocol/verb_registry/verb_spec.rb', line 11

def args
  @args
end

#categoryObject (readonly)

Returns the value of attribute category

Returns:

  • (Object)

    the current value of category



11
12
13
# File 'lib/textus/protocol/verb_registry/verb_spec.rb', line 11

def category
  @category
end

#summaryObject (readonly)

Returns the value of attribute summary

Returns:

  • (Object)

    the current value of summary



11
12
13
# File 'lib/textus/protocol/verb_registry/verb_spec.rb', line 11

def summary
  @summary
end

#surfacesObject (readonly)

Returns the value of attribute surfaces

Returns:

  • (Object)

    the current value of surfaces



11
12
13
# File 'lib/textus/protocol/verb_registry/verb_spec.rb', line 11

def surfaces
  @surfaces
end

#verbObject (readonly)

Returns the value of attribute verb

Returns:

  • (Object)

    the current value of verb



11
12
13
# File 'lib/textus/protocol/verb_registry/verb_spec.rb', line 11

def verb
  @verb
end

Instance Method Details

#cli?Boolean

Returns:

  • (Boolean)


20
# File 'lib/textus/protocol/verb_registry/verb_spec.rb', line 20

def cli? = surfaces.include?(:cli)

#cli_groupObject



23
# File 'lib/textus/protocol/verb_registry/verb_spec.rb', line 23

def cli_group = cli_words.size > 1 ? cli_words.first : nil

#cli_leafObject



24
# File 'lib/textus/protocol/verb_registry/verb_spec.rb', line 24

def cli_leaf  = cli_words.last

#cli_pathObject



21
# File 'lib/textus/protocol/verb_registry/verb_spec.rb', line 21

def cli_path = verb.to_s.tr("_", " ")

#cli_wordsObject



22
# File 'lib/textus/protocol/verb_registry/verb_spec.rb', line 22

def cli_words = cli_path.split

#input_schemaObject



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

#laneObject



17
# File 'lib/textus/protocol/verb_registry/verb_spec.rb', line 17

def lane = @lane

#maintenance?Boolean

Returns:

  • (Boolean)


28
# File 'lib/textus/protocol/verb_registry/verb_spec.rb', line 28

def maintenance? = category == :maintenance

#mcp?Boolean

Returns:

  • (Boolean)


19
# File 'lib/textus/protocol/verb_registry/verb_spec.rb', line 19

def mcp? = surfaces.include?(:mcp)

#read?Boolean

Returns:

  • (Boolean)


26
# File 'lib/textus/protocol/verb_registry/verb_spec.rb', line 26

def read? = category == :read

#required_argsObject



25
# File 'lib/textus/protocol/verb_registry/verb_spec.rb', line 25

def required_args = args.select(&:required)

#system?Boolean

Returns:

  • (Boolean)


18
# File 'lib/textus/protocol/verb_registry/verb_spec.rb', line 18

def system? = SYSTEM_VERBS.include?(verb)

#write?Boolean

Returns:

  • (Boolean)


27
# File 'lib/textus/protocol/verb_registry/verb_spec.rb', line 27

def write? = category == :write