Class: Ace::Support::Nav::Models::ProtocolSource
- Inherits:
-
Object
- Object
- Ace::Support::Nav::Models::ProtocolSource
- Defined in:
- lib/ace/support/nav/models/protocol_source.rb
Overview
Represents a source registration for a protocol
Instance Attribute Summary collapse
-
#alias_name ⇒ Object
readonly
Returns the value of attribute alias_name.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#config_dir ⇒ Object
readonly
Returns the value of attribute config_dir.
-
#config_file ⇒ Object
readonly
Returns the value of attribute config_file.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#origin ⇒ Object
readonly
Returns the value of attribute origin.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#priority ⇒ Object
readonly
Returns the value of attribute priority.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #exists? ⇒ Boolean
-
#full_path ⇒ Object
Get the full path for this source.
-
#initialize(name:, type:, path:, priority:, description: nil, origin: nil, config_file: nil, config_dir: nil, config: nil) ⇒ ProtocolSource
constructor
A new instance of ProtocolSource.
- #to_h ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(name:, type:, path:, priority:, description: nil, origin: nil, config_file: nil, config_dir: nil, config: nil) ⇒ ProtocolSource
Returns a new instance of ProtocolSource.
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/ace/support/nav/models/protocol_source.rb', line 11 def initialize(name:, type:, path:, priority:, description: nil, origin: nil, config_file: nil, config_dir: nil, config: nil) @name = name @type = type @path = path @priority = priority @description = description @origin = origin @config_file = config_file @config_dir = config_dir @config = config @alias_name = "@#{name}" end |
Instance Attribute Details
#alias_name ⇒ Object (readonly)
Returns the value of attribute alias_name.
9 10 11 |
# File 'lib/ace/support/nav/models/protocol_source.rb', line 9 def alias_name @alias_name end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
9 10 11 |
# File 'lib/ace/support/nav/models/protocol_source.rb', line 9 def config @config end |
#config_dir ⇒ Object (readonly)
Returns the value of attribute config_dir.
9 10 11 |
# File 'lib/ace/support/nav/models/protocol_source.rb', line 9 def config_dir @config_dir end |
#config_file ⇒ Object (readonly)
Returns the value of attribute config_file.
9 10 11 |
# File 'lib/ace/support/nav/models/protocol_source.rb', line 9 def config_file @config_file end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
9 10 11 |
# File 'lib/ace/support/nav/models/protocol_source.rb', line 9 def description @description end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/ace/support/nav/models/protocol_source.rb', line 9 def name @name end |
#origin ⇒ Object (readonly)
Returns the value of attribute origin.
9 10 11 |
# File 'lib/ace/support/nav/models/protocol_source.rb', line 9 def origin @origin end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
9 10 11 |
# File 'lib/ace/support/nav/models/protocol_source.rb', line 9 def path @path end |
#priority ⇒ Object (readonly)
Returns the value of attribute priority.
9 10 11 |
# File 'lib/ace/support/nav/models/protocol_source.rb', line 9 def priority @priority end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
9 10 11 |
# File 'lib/ace/support/nav/models/protocol_source.rb', line 9 def type @type end |
Instance Method Details
#exists? ⇒ Boolean
65 66 67 |
# File 'lib/ace/support/nav/models/protocol_source.rb', line 65 def exists? Dir.exist?(full_path) end |
#full_path ⇒ Object
Get the full path for this source
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/ace/support/nav/models/protocol_source.rb', line 25 def full_path case @type when "gem" # For gem type, resolve through RubyGems require "rubygems" begin spec = Gem::Specification.find_by_name(@name) gem_dir = spec.gem_dir # Get relative path from config, or use default relative = @config&.dig("relative_path") || "handbook/workflow-instructions" File.join(gem_dir, relative) rescue Gem::LoadError => e # Gem not found, return a placeholder path warn "Gem '#{@name}' not found: #{e.}" if ENV["VERBOSE"] "/gem-not-found/#{@name}" end else # Original path resolution logic for directory/path types return path if path&.start_with?("/") if config_dir && path # Resolve relative paths from project root (parent of .ace directory) project_dir = find_project_root(config_dir) if project_dir File.(File.join(project_dir, path)) else File.(path) end elsif path # Fallback to expand from current directory File.(path) else # No path specified "/no-path-specified" end end end |
#to_h ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/ace/support/nav/models/protocol_source.rb', line 69 def to_h { name: name, type: type, path: path, full_path: full_path, priority: priority, description: description, origin: origin, exists: exists? } end |
#to_s ⇒ Object
82 83 84 |
# File 'lib/ace/support/nav/models/protocol_source.rb', line 82 def to_s "#{name} (#{type}): #{full_path}" end |