Class: Middleman::Presentation::Component

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/middleman-presentation-core/component.rb

Overview

A component

Direct Known Subclasses

AssetComponent, FrontendComponent

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resource_locator: nil, version: nil, name: nil, github: nil, importable_files: [], loadable_files: [], ignorable_files: [], output_paths: []) ⇒ Component

Create new component

rubocop:disable Metrics/ParameterLists

Parameters:

  • resource_locator (String) (defaults to: nil)

    The locator to look for the resource, e.g. example.org/test or latest

  • name (String) (defaults to: nil)

    (nil) Alternative name for the resource, otherwise the base name of the resource_locator’s path is used: example.org/test => test

  • github (String) (defaults to: nil)

    Name of github repository, e.g. <account>/<repository>



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/middleman-presentation-core/component.rb', line 21

def initialize(
  resource_locator: nil,
  version: nil,
  name: nil,
  github: nil,
  importable_files: [],
  loadable_files: [],
  ignorable_files: [],
  output_paths: []
)

  @name               = name
  @resource_locator   = resource_locator
  @version            = version
  @github             = github
  @loadable_files     = Array(loadable_files).map { |o| Regexp.new o }
  @importable_files   = Array(importable_files).map { |o| Regexp.new o }
  @ignorable_files    = Array(ignorable_files).map { |o| Regexp.new o }
  @output_paths       = Array(output_paths)
end

Instance Attribute Details

#ignorable_filesObject (readonly)

Returns the value of attribute ignorable_files.



8
9
10
# File 'lib/middleman-presentation-core/component.rb', line 8

def ignorable_files
  @ignorable_files
end

#importable_filesObject (readonly)

Returns the value of attribute importable_files.



8
9
10
# File 'lib/middleman-presentation-core/component.rb', line 8

def importable_files
  @importable_files
end

#loadable_filesObject (readonly)

Returns the value of attribute loadable_files.



8
9
10
# File 'lib/middleman-presentation-core/component.rb', line 8

def loadable_files
  @loadable_files
end

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/middleman-presentation-core/component.rb', line 8

def name
  @name
end

#output_pathsObject (readonly)

Returns the value of attribute output_paths.



8
9
10
# File 'lib/middleman-presentation-core/component.rb', line 8

def output_paths
  @output_paths
end

#resource_locatorString (readonly)

Return resource locator

Returns:

  • (String)

    The resource locator



76
77
78
# File 'lib/middleman-presentation-core/component.rb', line 76

def resource_locator
  @resource_locator
end

#versionObject (readonly)

Returns the value of attribute version.



8
9
10
# File 'lib/middleman-presentation-core/component.rb', line 8

def version
  @version
end

Instance Method Details

#<=>(other) ⇒ Object



81
82
83
# File 'lib/middleman-presentation-core/component.rb', line 81

def <=>(other)
  name.to_s <=> other.name.to_s
end

#base_pathObject

Base path for component

The path where the component can be found.



53
54
55
# File 'lib/middleman-presentation-core/component.rb', line 53

def base_path
  fail NoMethodError, :base_path
end

#fetchable?Boolean

Should middleman-presentation fetch the component

Returns:

  • (Boolean)


68
69
70
# File 'lib/middleman-presentation-core/component.rb', line 68

def fetchable?
  false
end

#pathObject

Return path to component

If root directory is set, it will be prepended to name.



46
47
48
# File 'lib/middleman-presentation-core/component.rb', line 46

def path
  fail NoMethodError, :path
end

#root_directoryObject

Configure accessor for root directory



58
59
60
# File 'lib/middleman-presentation-core/component.rb', line 58

def root_directory
  fail NoMethodError, :root_directory
end

#root_directory=Object

Configure accessor for root directory



63
64
65
# File 'lib/middleman-presentation-core/component.rb', line 63

def root_directory=(*)
  fail NoMethodError, :root_directory=
end