lib/indexer/components/requirement.rb in indexer-0.1.0 vs lib/indexer/components/requirement.rb in indexer-0.2.0

- old
+ new

@@ -252,25 +252,26 @@ # requirement.engines = [ # 'ruby 1.8~' # ] # def engines=(engines) - @data['engines'] = Array(engines).map do |engine| - case engine - when String - name, vers = engine.strip.split(/\s+/) - vers = nil if vers.empty? - when Array - name, vers = *engine - when Hash - name = engine['name'] - vers = engine['version'] - end - e = {} - e['name'] = name - e['version'] = Version::Constraint.parse(vers) if vers - e + @data[:engines] = Array(engines).map do |engine| + Engine.parse(engine) + #case engine + #when String + # name, vers = engine.strip.split(/\s+/) + # vers = nil if vers.empty? + #when Array + # name, vers = *engine + #when Hash + # name = engine['name'] + # vers = engine['version'] + #end + #e = {} + #e['name'] = name + #e['version'] = Version::Constraint.parse(vers) if vers + #e end end alias_method :engine, :engines alias_method :engine=, :engines= @@ -332,9 +333,10 @@ def to_h h = super h['version'] = version.to_s if version h['repository'] = repository.to_h if repository + h['engines'] = engines.map{ |e| e.to_h } h.delete('groups') if h['groups'] && h['groups'].empty? h.delete('engines') if h['engines'] && h['engines'].empty? h.delete('platforms') if h['platforms'] && h['platforms'].empty? h.delete('sources') if h['sources'] && h['sources'].empty?