lib/rocktumbler/gem.rb in rocktumbler-0.1.0 vs lib/rocktumbler/gem.rb in rocktumbler-0.1.1

- old
+ new

@@ -9,13 +9,26 @@ def print(prepend="") gem_info = retrieve_gem_information(@gem_dependency.name) str = "#{prepend}# #{gem_info.summary}\n" str += "#{prepend}# #{gem_info.homepage}\n" str += "#{prepend}gem '#{@gem_dependency.name}'" - str += ",'#{@gem_dependency.requirement}'" if @gem_dependency.requirement.specific? + str += ",'#{@gem_dependency.requirement}'" unless @gem_dependency.requirement.none? str += generate_gem_source(@gem_dependency.source.options) if @gem_dependency.source - str += ", require: #{!@gem_dependency.autorequire.empty?}" if @gem_dependency.autorequire + str += generate_require(@gem_dependency.autorequire) if @gem_dependency.autorequire str += "\n\n" + end + + private + + def generate_require(autorequire) + if autorequire.count > 1 + # Array.to_s will output double quotes so we gsub them to singles. + return ", require: #{autorequire.to_s.gsub(/"/,'\'')}" + elsif autorequire.first.is_a?(String) + return ", require: '#{autorequire.first}'" + else + return ", require: #{!autorequire.empty?}" + end end def generate_gem_source(source_options) return ", github: '#{source_options['github']}'" if source_options['github'] return ", path: '#{source_options['path']}'" if source_options['path']