class String
Polisher
Core Ruby Extensions
Licensed under the MIT license Copyright © 2013-2014 Red Hat, Inc.
Public Instance Methods
gem?()
click to toggle source
Return bool indicating if self is a path to a gem
# File lib/polisher/util/core_ext.rb, line 8 def gem? File.extname(self) == ".gem" end
gemfile?()
click to toggle source
Return bool indicating if self is a path to a Gemfile
# File lib/polisher/util/core_ext.rb, line 18 def gemfile? File.basename(self) == "Gemfile" end
gemspec?()
click to toggle source
Return bool indicating if self is a path to a gemspec
# File lib/polisher/util/core_ext.rb, line 13 def gemspec? File.extname(self) == ".gemspec" end
rpmize()
click to toggle source
Replace all occurrances of non-rpm macro strings in self with their macro correspondences and add %doc macro or lib’s bin path if necessary
# File lib/polisher/util/core_ext.rb, line 37 def rpmize require 'polisher/gem' require 'polisher/rpm/spec' matchers = Polisher::RPM::Spec::FILE_MACRO_MATCHERS replacements = Polisher::RPM::Spec::FILE_MACRO_REPLACEMENTS.invert f = replacements.keys.inject(self) { |file, r| file.gsub(r, replacements[r]) } special = (matchers + replacements.values).any? { |matcher| f =~ /^#{matcher}.*/ } f = special ? f : "%{gem_instdir}/#{f}" include_lib_bin = (f =~ /\A%{_bindir}.*/) f = include_lib_bin ? "#{f}\n%{gem_instdir}/#{self}" : f doc_file = Polisher::Gem.doc_file?(self) || Polisher::Gem.license_file?(self) mark_as_doc = doc_file && !(self =~ /%doc .*/) f = mark_as_doc ? "%doc #{f}" : f f end
to_polisher_class()
click to toggle source
# File lib/polisher/util/core_ext.rb, line 56 def to_polisher_class "Polisher::#{self}".constantize end
unrpmize()
click to toggle source
Remove and replace all occurances of rpm macros in self with non-rpm macro correspondents. If no rpm macro is specified macro will simply be removed
# File lib/polisher/util/core_ext.rb, line 25 def unrpmize require 'polisher/rpm/spec' matchers = Polisher::RPM::Spec::FILE_MACRO_MATCHERS replacements = Polisher::RPM::Spec::FILE_MACRO_REPLACEMENTS f = matchers.inject(self) { |file, matcher| file.gsub(matcher, '') } f = replacements.keys.inject(f) { |file, r| file.gsub(Regexp.new(r), replacements[r]) } f end