Files

Class/Module Index [+]

Quicksearch

Gem2Rpm::Helpers

Public Class Methods

expand_pessimistic_requirement(requirements) click to toggle source

Expands the pesimistic version operator '~>' into equivalent '>=' and '<' pair.

# File lib/gem2rpm/helpers.rb, line 11
def self.expand_pessimistic_requirement(requirements)
  requirements.inject([]) do |output, r|
    if r.first == '~>'
      next_version = Gem::Version.create(r.last).bump
      output << ['=>', r.last]
      output << ['<', next_version]
    else
      output << r
    end
  end
end
requirement_versions_to_rpm(requirement) click to toggle source

Converts Gem::Requirement into array of requirements strings compatible with RPM .spec file.

# File lib/gem2rpm/helpers.rb, line 25
def self.requirement_versions_to_rpm(requirement)
  self.expand_pessimistic_requirement(requirement.requirements).map do |op, version|
    version == Gem::Version.new(0) ? "" : "#{op} #{version}"
  end
end
word_wrap(text, line_width = 80) click to toggle source

Taken with modification from the word_wrap method in ActionPack. Text::Format does the same thing better.

# File lib/gem2rpm/helpers.rb, line 5
def self.word_wrap(text, line_width = 80)
  text.gsub(/\n/, "\n\n").gsub(/(.{1,#{line_width}})(\s+|$)/, "\\1\n").strip
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.