Class: Plugin::Metadata

Inherits:
Object
  • Object
show all
Defined in:
lib/plugin/metadata.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.parse(text) ⇒ Object



107
108
109
110
111
# File 'lib/plugin/metadata.rb', line 107

def self.parse(text)
   = self.new
  text.each_line { |line| break unless .parse_line(line) }
  
end

Instance Method Details

#official?Boolean

Returns:

  • (Boolean)


113
114
115
# File 'lib/plugin/metadata.rb', line 113

def official?
  OFFICIAL_PLUGINS.include?(name)
end

#parse_line(line) ⇒ Object



117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/plugin/metadata.rb', line 117

def parse_line(line)
  line = line.strip

  unless line.empty?
    return false unless line[0] == "#"
    attribute, *description = line[1..-1].split(":")

    description = description.join(":")
    attribute = attribute.strip.gsub(/ /, "_").to_sym

    self.public_send("#{attribute}=", description.strip) if FIELDS.include?(attribute)
  end

  true
end