Class: Textus::Step::Discovery

Inherits:
Data
  • Object
show all
Defined in:
lib/textus/step/discovery.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#kindObject (readonly)

Returns the value of attribute kind

Returns:

  • (Object)

    the current value of kind



11
12
13
# File 'lib/textus/step/discovery.rb', line 11

def kind
  @kind
end

#nameObject (readonly)

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



11
12
13
# File 'lib/textus/step/discovery.rb', line 11

def name
  @name
end

Class Method Details

.parse(path, base:) ⇒ Object

Raises:



12
13
14
15
16
17
18
19
20
21
# File 'lib/textus/step/discovery.rb', line 12

def self.parse(path, base:)
  rel = path.delete_prefix(base.to_s).delete_prefix("/")
  parts = rel.split("/")
  raise UsageError.new("step #{rel} must live under steps/<kind>/<name>.rb") unless parts.length == 2

  kind = parts[0].to_sym
  raise UsageError.new("unknown step kind '#{parts[0]}' (expected one of: #{KINDS.join(", ")})") unless KINDS.include?(kind)

  new(kind: kind, name: File.basename(parts[1], ".rb").to_sym)
end