Class: Aspera::BundleRegistry::Plugin

Inherits:
Data
  • Object
show all
Defined in:
lib/aspera/bundle_registry.rb

Overview

Plugin found in a source

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#error ⇒ Object (readonly)

Why the manifest is invalid, nil if valid



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/aspera/bundle_registry.rb', line 83

Plugin = Data.define(:name, :form, :path, :security, :manifest, :error) do
  # @return [Boolean] `true` for a bundle
  def bundle? = form.eql?(:bundle)
  # @return [String, nil] Title of a bundle
  def title = manifest['title']
  # @return [String, nil] Section of the instructions of the MCP server about the bundle
  def mcp = manifest['mcp']
  # @return [Boolean] `true` if the plugin provides a top level command
  def commands? = manifest['commands'].eql?(true)
  # @return [Array<Symbol>] Bundles referenced by this one
  def depends = manifest.fetch('depends', []).map(&:to_sym)
  # @return [Array<String>] Gems required by the code
  def gems = manifest.fetch('gems', [])
  # @return [Hash{Symbol => String}] Schema file of an entry, relative to the folder of the bundle, by name of the extension points it declares
  def extension_points = manifest.fetch('extension_points', []).to_h { |point| [point['name'].to_sym, point['schema']] }

  # @return [Array<Extension>] Entries of this bundle for extension points, in the order of the manifest
  def extensions
    manifest.fetch('extensions', {}).flat_map do |point, entries|
      entries.map do |entry|
        Extension.new(bundle: name, point: point.to_sym, fields: entry.except('file', 'class').freeze, file: entry['file'], constant: entry['class'])
      end
    end
  end

  # @return [Array<Mount>] Modules mounted by this bundle, in the order of the manifest
  def mounts = manifest.fetch('mounts', []).map { |mount| Mount.new(bundle: name, target: mount['target'].to_sym, file: mount['file'], constant: mount['module']) }
  # @return [Array<Service>] Services provided by this bundle, in the order of the manifest
  def services = manifest.fetch('services', []).map { |service| Service.new(bundle: name, name: service['name'].to_sym, file: service['file'], constant: service['class']) }

  # @return [Array<Array(Symbol, Symbol)>] Names declared by this bundle, in the order of the manifest, with repetitions:
  #   `[:service, <name>]`, `[:extension_point, <name>]` and `[:schema, <name>]`
  def declared
    services.map { |service| [:service, service.name] }
      .concat(manifest.fetch('extension_points', []).map { |point| [:extension_point, point['name'].to_sym] })
      .concat(schemas.map { |schema| [:schema, schema.key] })
  end

  # @return [Array<SchemaFile>] Schemas of this bundle, in the order of the manifest
  def schemas
    manifest.fetch('schemas', []).map do |schema|
      SchemaFile.new(bundle: name, key: schema['key'].to_sym, file: File.join(path, schema['file']), owned: schema.fetch('owned', false), source: schema['source'])
    end
  end
end

#path ⇒ Object (readonly)

File of a single file, folder of a bundle



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/aspera/bundle_registry.rb', line 83

Plugin = Data.define(:name, :form, :path, :security, :manifest, :error) do
  # @return [Boolean] `true` for a bundle
  def bundle? = form.eql?(:bundle)
  # @return [String, nil] Title of a bundle
  def title = manifest['title']
  # @return [String, nil] Section of the instructions of the MCP server about the bundle
  def mcp = manifest['mcp']
  # @return [Boolean] `true` if the plugin provides a top level command
  def commands? = manifest['commands'].eql?(true)
  # @return [Array<Symbol>] Bundles referenced by this one
  def depends = manifest.fetch('depends', []).map(&:to_sym)
  # @return [Array<String>] Gems required by the code
  def gems = manifest.fetch('gems', [])
  # @return [Hash{Symbol => String}] Schema file of an entry, relative to the folder of the bundle, by name of the extension points it declares
  def extension_points = manifest.fetch('extension_points', []).to_h { |point| [point['name'].to_sym, point['schema']] }

  # @return [Array<Extension>] Entries of this bundle for extension points, in the order of the manifest
  def extensions
    manifest.fetch('extensions', {}).flat_map do |point, entries|
      entries.map do |entry|
        Extension.new(bundle: name, point: point.to_sym, fields: entry.except('file', 'class').freeze, file: entry['file'], constant: entry['class'])
      end
    end
  end

  # @return [Array<Mount>] Modules mounted by this bundle, in the order of the manifest
  def mounts = manifest.fetch('mounts', []).map { |mount| Mount.new(bundle: name, target: mount['target'].to_sym, file: mount['file'], constant: mount['module']) }
  # @return [Array<Service>] Services provided by this bundle, in the order of the manifest
  def services = manifest.fetch('services', []).map { |service| Service.new(bundle: name, name: service['name'].to_sym, file: service['file'], constant: service['class']) }

  # @return [Array<Array(Symbol, Symbol)>] Names declared by this bundle, in the order of the manifest, with repetitions:
  #   `[:service, <name>]`, `[:extension_point, <name>]` and `[:schema, <name>]`
  def declared
    services.map { |service| [:service, service.name] }
      .concat(manifest.fetch('extension_points', []).map { |point| [:extension_point, point['name'].to_sym] })
      .concat(schemas.map { |schema| [:schema, schema.key] })
  end

  # @return [Array<SchemaFile>] Schemas of this bundle, in the order of the manifest
  def schemas
    manifest.fetch('schemas', []).map do |schema|
      SchemaFile.new(bundle: name, key: schema['key'].to_sym, file: File.join(path, schema['file']), owned: schema.fetch('owned', false), source: schema['source'])
    end
  end
end

Instance Method Details

#bundle? ⇒ Boolean

Returns true for a bundle.

Returns:

  • (Boolean) —

    true for a bundle



85
86
# File 'lib/aspera/bundle_registry.rb', line 85

def bundle? = form.eql?(:bundle)
# @return [String, nil] Title of a bundle

#commands? ⇒ Boolean

Returns true if the plugin provides a top level command.

Returns:

  • (Boolean) —

    true if the plugin provides a top level command



91
92
# File 'lib/aspera/bundle_registry.rb', line 91

def commands? = manifest['commands'].eql?(true)
# @return [Array<Symbol>] Bundles referenced by this one

#declared ⇒ Array<Array(Symbol, Symbol)>

Returns Names declared by this bundle, in the order of the manifest, with repetitions: [:service, <name>], [:extension_point, <name>] and [:schema, <name>].

Returns:

  • (Array<Array(Symbol, Symbol)>) —

    Names declared by this bundle, in the order of the manifest, with repetitions: [:service, <name>], [:extension_point, <name>] and [:schema, <name>]



115
116
117
118
119
# File 'lib/aspera/bundle_registry.rb', line 115

def declared
  services.map { |service| [:service, service.name] }
    .concat(manifest.fetch('extension_points', []).map { |point| [:extension_point, point['name'].to_sym] })
    .concat(schemas.map { |schema| [:schema, schema.key] })
end

#depends ⇒ Array<Symbol>

Returns Bundles referenced by this one.

Returns:

  • (Array<Symbol>) —

    Bundles referenced by this one



93
94
# File 'lib/aspera/bundle_registry.rb', line 93

def depends = manifest.fetch('depends', []).map(&:to_sym)
# @return [Array<String>] Gems required by the code

#extension_points ⇒ Hash{Symbol => String}

Returns Schema file of an entry, relative to the folder of the bundle, by name of the extension points it declares.

Returns:

  • (Hash{Symbol => String}) —

    Schema file of an entry, relative to the folder of the bundle, by name of the extension points it declares



97
# File 'lib/aspera/bundle_registry.rb', line 97

def extension_points = manifest.fetch('extension_points', []).to_h { |point| [point['name'].to_sym, point['schema']] }

#extensions ⇒ Array<Extension>

Returns Entries of this bundle for extension points, in the order of the manifest.

Returns:

  • (Array<Extension>) —

    Entries of this bundle for extension points, in the order of the manifest



100
101
102
103
104
105
106
# File 'lib/aspera/bundle_registry.rb', line 100

def extensions
  manifest.fetch('extensions', {}).flat_map do |point, entries|
    entries.map do |entry|
      Extension.new(bundle: name, point: point.to_sym, fields: entry.except('file', 'class').freeze, file: entry['file'], constant: entry['class'])
    end
  end
end

#form=(value) ⇒ Object

:single (file <name>.rb: commands only) or :bundle (folder <name>/ with a manifest)



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/aspera/bundle_registry.rb', line 83

Plugin = Data.define(:name, :form, :path, :security, :manifest, :error) do
  # @return [Boolean] `true` for a bundle
  def bundle? = form.eql?(:bundle)
  # @return [String, nil] Title of a bundle
  def title = manifest['title']
  # @return [String, nil] Section of the instructions of the MCP server about the bundle
  def mcp = manifest['mcp']
  # @return [Boolean] `true` if the plugin provides a top level command
  def commands? = manifest['commands'].eql?(true)
  # @return [Array<Symbol>] Bundles referenced by this one
  def depends = manifest.fetch('depends', []).map(&:to_sym)
  # @return [Array<String>] Gems required by the code
  def gems = manifest.fetch('gems', [])
  # @return [Hash{Symbol => String}] Schema file of an entry, relative to the folder of the bundle, by name of the extension points it declares
  def extension_points = manifest.fetch('extension_points', []).to_h { |point| [point['name'].to_sym, point['schema']] }

  # @return [Array<Extension>] Entries of this bundle for extension points, in the order of the manifest
  def extensions
    manifest.fetch('extensions', {}).flat_map do |point, entries|
      entries.map do |entry|
        Extension.new(bundle: name, point: point.to_sym, fields: entry.except('file', 'class').freeze, file: entry['file'], constant: entry['class'])
      end
    end
  end

  # @return [Array<Mount>] Modules mounted by this bundle, in the order of the manifest
  def mounts = manifest.fetch('mounts', []).map { |mount| Mount.new(bundle: name, target: mount['target'].to_sym, file: mount['file'], constant: mount['module']) }
  # @return [Array<Service>] Services provided by this bundle, in the order of the manifest
  def services = manifest.fetch('services', []).map { |service| Service.new(bundle: name, name: service['name'].to_sym, file: service['file'], constant: service['class']) }

  # @return [Array<Array(Symbol, Symbol)>] Names declared by this bundle, in the order of the manifest, with repetitions:
  #   `[:service, <name>]`, `[:extension_point, <name>]` and `[:schema, <name>]`
  def declared
    services.map { |service| [:service, service.name] }
      .concat(manifest.fetch('extension_points', []).map { |point| [:extension_point, point['name'].to_sym] })
      .concat(schemas.map { |schema| [:schema, schema.key] })
  end

  # @return [Array<SchemaFile>] Schemas of this bundle, in the order of the manifest
  def schemas
    manifest.fetch('schemas', []).map do |schema|
      SchemaFile.new(bundle: name, key: schema['key'].to_sym, file: File.join(path, schema['file']), owned: schema.fetch('owned', false), source: schema['source'])
    end
  end
end

#gems ⇒ Array<String>

Returns Gems required by the code.

Returns:

  • (Array<String>) —

    Gems required by the code



95
96
# File 'lib/aspera/bundle_registry.rb', line 95

def gems = manifest.fetch('gems', [])
# @return [Hash{Symbol => String}] Schema file of an entry, relative to the folder of the bundle, by name of the extension points it declares

#manifest=(value) ⇒ Object

Manifest of a bundle (empty if invalid); for a single file: name and commands



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/aspera/bundle_registry.rb', line 83

Plugin = Data.define(:name, :form, :path, :security, :manifest, :error) do
  # @return [Boolean] `true` for a bundle
  def bundle? = form.eql?(:bundle)
  # @return [String, nil] Title of a bundle
  def title = manifest['title']
  # @return [String, nil] Section of the instructions of the MCP server about the bundle
  def mcp = manifest['mcp']
  # @return [Boolean] `true` if the plugin provides a top level command
  def commands? = manifest['commands'].eql?(true)
  # @return [Array<Symbol>] Bundles referenced by this one
  def depends = manifest.fetch('depends', []).map(&:to_sym)
  # @return [Array<String>] Gems required by the code
  def gems = manifest.fetch('gems', [])
  # @return [Hash{Symbol => String}] Schema file of an entry, relative to the folder of the bundle, by name of the extension points it declares
  def extension_points = manifest.fetch('extension_points', []).to_h { |point| [point['name'].to_sym, point['schema']] }

  # @return [Array<Extension>] Entries of this bundle for extension points, in the order of the manifest
  def extensions
    manifest.fetch('extensions', {}).flat_map do |point, entries|
      entries.map do |entry|
        Extension.new(bundle: name, point: point.to_sym, fields: entry.except('file', 'class').freeze, file: entry['file'], constant: entry['class'])
      end
    end
  end

  # @return [Array<Mount>] Modules mounted by this bundle, in the order of the manifest
  def mounts = manifest.fetch('mounts', []).map { |mount| Mount.new(bundle: name, target: mount['target'].to_sym, file: mount['file'], constant: mount['module']) }
  # @return [Array<Service>] Services provided by this bundle, in the order of the manifest
  def services = manifest.fetch('services', []).map { |service| Service.new(bundle: name, name: service['name'].to_sym, file: service['file'], constant: service['class']) }

  # @return [Array<Array(Symbol, Symbol)>] Names declared by this bundle, in the order of the manifest, with repetitions:
  #   `[:service, <name>]`, `[:extension_point, <name>]` and `[:schema, <name>]`
  def declared
    services.map { |service| [:service, service.name] }
      .concat(manifest.fetch('extension_points', []).map { |point| [:extension_point, point['name'].to_sym] })
      .concat(schemas.map { |schema| [:schema, schema.key] })
  end

  # @return [Array<SchemaFile>] Schemas of this bundle, in the order of the manifest
  def schemas
    manifest.fetch('schemas', []).map do |schema|
      SchemaFile.new(bundle: name, key: schema['key'].to_sym, file: File.join(path, schema['file']), owned: schema.fetch('owned', false), source: schema['source'])
    end
  end
end

#mcp ⇒ String?

Returns Section of the instructions of the MCP server about the bundle.

Returns:

  • (String, nil) —

    Section of the instructions of the MCP server about the bundle



89
90
# File 'lib/aspera/bundle_registry.rb', line 89

def mcp = manifest['mcp']
# @return [Boolean] `true` if the plugin provides a top level command

#mounts ⇒ Array<Mount>

Returns Modules mounted by this bundle, in the order of the manifest.

Returns:

  • (Array<Mount>) —

    Modules mounted by this bundle, in the order of the manifest



109
110
# File 'lib/aspera/bundle_registry.rb', line 109

def mounts = manifest.fetch('mounts', []).map { |mount| Mount.new(bundle: name, target: mount['target'].to_sym, file: mount['file'], constant: mount['module']) }
# @return [Array<Service>] Services provided by this bundle, in the order of the manifest

#name=(value) ⇒ Object

Name of the plugin



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/aspera/bundle_registry.rb', line 83

Plugin = Data.define(:name, :form, :path, :security, :manifest, :error) do
  # @return [Boolean] `true` for a bundle
  def bundle? = form.eql?(:bundle)
  # @return [String, nil] Title of a bundle
  def title = manifest['title']
  # @return [String, nil] Section of the instructions of the MCP server about the bundle
  def mcp = manifest['mcp']
  # @return [Boolean] `true` if the plugin provides a top level command
  def commands? = manifest['commands'].eql?(true)
  # @return [Array<Symbol>] Bundles referenced by this one
  def depends = manifest.fetch('depends', []).map(&:to_sym)
  # @return [Array<String>] Gems required by the code
  def gems = manifest.fetch('gems', [])
  # @return [Hash{Symbol => String}] Schema file of an entry, relative to the folder of the bundle, by name of the extension points it declares
  def extension_points = manifest.fetch('extension_points', []).to_h { |point| [point['name'].to_sym, point['schema']] }

  # @return [Array<Extension>] Entries of this bundle for extension points, in the order of the manifest
  def extensions
    manifest.fetch('extensions', {}).flat_map do |point, entries|
      entries.map do |entry|
        Extension.new(bundle: name, point: point.to_sym, fields: entry.except('file', 'class').freeze, file: entry['file'], constant: entry['class'])
      end
    end
  end

  # @return [Array<Mount>] Modules mounted by this bundle, in the order of the manifest
  def mounts = manifest.fetch('mounts', []).map { |mount| Mount.new(bundle: name, target: mount['target'].to_sym, file: mount['file'], constant: mount['module']) }
  # @return [Array<Service>] Services provided by this bundle, in the order of the manifest
  def services = manifest.fetch('services', []).map { |service| Service.new(bundle: name, name: service['name'].to_sym, file: service['file'], constant: service['class']) }

  # @return [Array<Array(Symbol, Symbol)>] Names declared by this bundle, in the order of the manifest, with repetitions:
  #   `[:service, <name>]`, `[:extension_point, <name>]` and `[:schema, <name>]`
  def declared
    services.map { |service| [:service, service.name] }
      .concat(manifest.fetch('extension_points', []).map { |point| [:extension_point, point['name'].to_sym] })
      .concat(schemas.map { |schema| [:schema, schema.key] })
  end

  # @return [Array<SchemaFile>] Schemas of this bundle, in the order of the manifest
  def schemas
    manifest.fetch('schemas', []).map do |schema|
      SchemaFile.new(bundle: name, key: schema['key'].to_sym, file: File.join(path, schema['file']), owned: schema.fetch('owned', false), source: schema['source'])
    end
  end
end

#schemas ⇒ Array<SchemaFile>

Returns Schemas of this bundle, in the order of the manifest.

Returns:

  • (Array<SchemaFile>) —

    Schemas of this bundle, in the order of the manifest



122
123
124
125
126
# File 'lib/aspera/bundle_registry.rb', line 122

def schemas
  manifest.fetch('schemas', []).map do |schema|
    SchemaFile.new(bundle: name, key: schema['key'].to_sym, file: File.join(path, schema['file']), owned: schema.fetch('owned', false), source: schema['source'])
  end
end

#security=(value) ⇒ Object

Security level of its source



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/aspera/bundle_registry.rb', line 83

Plugin = Data.define(:name, :form, :path, :security, :manifest, :error) do
  # @return [Boolean] `true` for a bundle
  def bundle? = form.eql?(:bundle)
  # @return [String, nil] Title of a bundle
  def title = manifest['title']
  # @return [String, nil] Section of the instructions of the MCP server about the bundle
  def mcp = manifest['mcp']
  # @return [Boolean] `true` if the plugin provides a top level command
  def commands? = manifest['commands'].eql?(true)
  # @return [Array<Symbol>] Bundles referenced by this one
  def depends = manifest.fetch('depends', []).map(&:to_sym)
  # @return [Array<String>] Gems required by the code
  def gems = manifest.fetch('gems', [])
  # @return [Hash{Symbol => String}] Schema file of an entry, relative to the folder of the bundle, by name of the extension points it declares
  def extension_points = manifest.fetch('extension_points', []).to_h { |point| [point['name'].to_sym, point['schema']] }

  # @return [Array<Extension>] Entries of this bundle for extension points, in the order of the manifest
  def extensions
    manifest.fetch('extensions', {}).flat_map do |point, entries|
      entries.map do |entry|
        Extension.new(bundle: name, point: point.to_sym, fields: entry.except('file', 'class').freeze, file: entry['file'], constant: entry['class'])
      end
    end
  end

  # @return [Array<Mount>] Modules mounted by this bundle, in the order of the manifest
  def mounts = manifest.fetch('mounts', []).map { |mount| Mount.new(bundle: name, target: mount['target'].to_sym, file: mount['file'], constant: mount['module']) }
  # @return [Array<Service>] Services provided by this bundle, in the order of the manifest
  def services = manifest.fetch('services', []).map { |service| Service.new(bundle: name, name: service['name'].to_sym, file: service['file'], constant: service['class']) }

  # @return [Array<Array(Symbol, Symbol)>] Names declared by this bundle, in the order of the manifest, with repetitions:
  #   `[:service, <name>]`, `[:extension_point, <name>]` and `[:schema, <name>]`
  def declared
    services.map { |service| [:service, service.name] }
      .concat(manifest.fetch('extension_points', []).map { |point| [:extension_point, point['name'].to_sym] })
      .concat(schemas.map { |schema| [:schema, schema.key] })
  end

  # @return [Array<SchemaFile>] Schemas of this bundle, in the order of the manifest
  def schemas
    manifest.fetch('schemas', []).map do |schema|
      SchemaFile.new(bundle: name, key: schema['key'].to_sym, file: File.join(path, schema['file']), owned: schema.fetch('owned', false), source: schema['source'])
    end
  end
end

#services ⇒ Array<Service>

Returns Services provided by this bundle, in the order of the manifest.

Returns:

  • (Array<Service>) —

    Services provided by this bundle, in the order of the manifest



111
# File 'lib/aspera/bundle_registry.rb', line 111

def services = manifest.fetch('services', []).map { |service| Service.new(bundle: name, name: service['name'].to_sym, file: service['file'], constant: service['class']) }

#title ⇒ String?

Returns Title of a bundle.

Returns:

  • (String, nil) —

    Title of a bundle



87
88
# File 'lib/aspera/bundle_registry.rb', line 87

def title = manifest['title']
# @return [String, nil] Section of the instructions of the MCP server about the bundle