Class: ReaPack::Index::Source
- Inherits:
-
Object
- Object
- ReaPack::Index::Source
- Defined in:
- lib/reapack/index/source.rb
Constant Summary collapse
- TAG =
'source'.freeze
- PLATFORM =
'platform'.freeze
- TYPE =
'type'.freeze
- FILE =
'file'.freeze
- MAIN =
'main'.freeze
- PLATFORMS =
{ all: nil, windows: :all, win32: :windows, win64: :windows, 'windows-arm64ec': :windows, darwin: :all, darwin32: :darwin, darwin64: :darwin, 'darwin-arm64': :darwin, linux: :all, linux32: :linux, linux64: :linux, 'linux-armv7l': :linux, 'linux-aarch64': :linux }.freeze
- SECTIONS =
[ :main, :midi_editor, :midi_inlineeditor, :midi_eventlisteditor, :mediaexplorer ].freeze
Instance Attribute Summary collapse
-
#file ⇒ Object
Returns the value of attribute file.
-
#platform ⇒ Object
Returns the value of attribute platform.
-
#sections ⇒ Object
Returns the value of attribute sections.
-
#type ⇒ Object
Returns the value of attribute type.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
- #detect_sections(pkg) ⇒ Object
-
#initialize(url) ⇒ Source
constructor
A new instance of Source.
- #make_node(parent) ⇒ Object
Constructor Details
#initialize(url) ⇒ Source
Returns a new instance of Source.
28 29 30 31 32 |
# File 'lib/reapack/index/source.rb', line 28 def initialize(url) @url = url @sections = [] @platform = :all end |
Instance Attribute Details
#file ⇒ Object
Returns the value of attribute file.
35 36 37 |
# File 'lib/reapack/index/source.rb', line 35 def file @file end |
#platform ⇒ Object
Returns the value of attribute platform.
34 35 36 |
# File 'lib/reapack/index/source.rb', line 34 def platform @platform end |
#sections ⇒ Object
Returns the value of attribute sections.
34 35 36 |
# File 'lib/reapack/index/source.rb', line 34 def sections @sections end |
#type ⇒ Object
Returns the value of attribute type.
34 35 36 |
# File 'lib/reapack/index/source.rb', line 34 def type @type end |
#url ⇒ Object
Returns the value of attribute url.
35 36 37 |
# File 'lib/reapack/index/source.rb', line 35 def url @url end |
Class Method Details
.is_platform?(input) ⇒ Boolean
23 24 25 |
# File 'lib/reapack/index/source.rb', line 23 def is_platform?(input) PLATFORMS.has_key? input&.to_sym end |
Instance Method Details
#detect_sections(pkg) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/reapack/index/source.rb', line 57 def detect_sections(pkg) @sections = [] if (@type || pkg.type) == :script @sections << case pkg.topdir.downcase when 'midi editor' :midi_editor when 'midi inline editor' :midi_inlineeditor when 'midi event list editor' :midi_eventlisteditor when 'media explorer' :mediaexplorer else :main end end @sections.freeze # force going through sections=() for validation end |
#make_node(parent) ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/reapack/index/source.rb', line 89 def make_node(parent) @node = Nokogiri::XML::Node.new TAG, parent.document @node[MAIN] = @sections.join "\x20" unless @sections.empty? @node[PLATFORM] = @platform if @platform != :all @node[TYPE] = @type if @type @node[FILE] = @file if @file @node.content = Addressable::URI.parse(@url).normalize.to_s @node.parent = parent rescue Addressable::URI::InvalidURIError => e raise Error, e. end |