def update_gemspec(attribute, new_value, literal = false)

      unless literal
        new_value = case new_value
          when Array        then "%w(#{new_value.join(' ')})"
          when Hash, String then new_value.inspect
          when Date         then new_value.strftime('%Y-%m-%d').inspect
          else              raise "Cannot write value #{new_value.inspect} to gemspec file!"
        end
      end

      spec   = File.read(gemspec_file)
      regexp = Regexp.new('^(\s+\w+\.' + Regexp.quote(attribute.to_s) + '\s*=\s*)[^\s].*$')
      if spec.sub!(regexp) { $1 + new_value }
        File.open(gemspec_file, 'w') { |f| f << spec }
        modified_files << gemspec_file

        # Reload the gemspec so the changes are incorporated
        load_gemspec!
        
        # Also mark the Gemfile.lock file as changed because of the new version.
        modified_files << 'Gemfile.lock' if File.exist?(File.join(root_dir, 'Gemfile.lock'))
      end
    end
def update_gemspec(attribute, new_value, literal = false)

      unless literal
        new_value = case new_value
          when Array        then "%w(#{new_value.join(' ')})"
          when Hash, String then new_value.inspect
          when Date         then new_value.strftime('%Y-%m-%d').inspect
          else              raise "Cannot write value #{new_value.inspect} to gemspec file!"
        end
      end

      spec   = File.read(gemspec_file)
      regexp = Regexp.new('^(\s+\w+\.' + Regexp.quote(attribute.to_s) + '\s*=\s*)[^\s].*$')
      if spec.sub!(regexp) { $1 + new_value }
        File.open(gemspec_file, 'w') { |f| f << spec }
        modified_files << gemspec_file

        # Reload the gemspec so the changes are incorporated
        load_gemspec!
        
        # Also mark the Gemfile.lock file as changed because of the new version.
        modified_files << 'Gemfile.lock' if File.exist?(File.join(root_dir, 'Gemfile.lock'))
      end
    end
Updates an attribute of the gemspec file.
 This function will open the file, and search/replace the attribute using a regular expression.