Top Level Namespace
Defined Under Namespace
Modules: ConstraintClean
Instance Method Summary collapse
Instance Method Details
#cleanupConstraints(file) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/constraintClean.rb', line 4 def cleanupConstraints(file) print "\r #{file}" STDOUT.flush f = File.open(file) doc = Nokogiri::XML(f) f.close excluded = doc.xpath('//exclude') included = doc.xpath('//include') result = [] excluded.each do |node| found = false for includedNode in included if node.attr('reference') == includedNode.attr('reference') found = true break end end if !found result.push(node) nodeID = node.attr('reference') constraints = doc.xpath("//constraint[@id='#{nodeID}']") result += constraints end end if result.count > 0 f1 = File.open(file, 'w') result.each{ |node| node.remove } f1.write(doc.to_xml) f1.close p "removed #{result.count} constraint(s) from #{file}" end end |
#notifyAboutUpdates ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/version_update.rb', line 5 def notifyAboutUpdates json_object = JSON.parse(open("https://rubygems.org/api/v1/versions/constraintClean/latest.json").read) highest_version = Gem.loaded_specs['constraintClean'].version.to_s if json_object["version"].nil? return end if json_object["version"] > highest_version puts "Updates are available!".green puts "Your current version of constraintClean is #{highest_version}".green puts "Run 'gem update constraintClean' to get latest version #{json_object['version']}".green puts "" end end |