Class: Nuget
- Inherits:
-
Object
- Object
- Nuget
- Defined in:
- lib/apps/nuget.rb
Overview
puts __FILE__ if defined?(DEBUG)
Class Method Summary collapse
- .get_build_commands(nuspec_file) ⇒ Object
- .get_versions(filename) ⇒ Object
- .set_versions(filename, versions) ⇒ Object
- .update_versions(source_filename, destination_filename) ⇒ Object
Class Method Details
.get_build_commands(nuspec_file) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/apps/nuget.rb', line 12 def self.get_build_commands nuspec_file build_commands=nil if(File.exists?(nuspec_file)) build_commands=Array.new if build_commands.nil? if(defined?(INCLUDE_REFERENCED_PROJECTS)) build_commands << "nuget pack #{nuspec_file} -IncludeReferencedProjects" else build_commands << "nuget pack #{nuspec_file}" end end build_commands end |
.get_versions(filename) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/apps/nuget.rb', line 25 def self.get_versions filename versions=Hash.new if(filename.include?('.nuspec')) nuspec_text=File.read(filename,:encoding=>'UTF-8') nuspec_text.scan(/<dependency[\s]+id="([\w\.]+)"[\s]+version="([\d\.]+[-\w]+)"/).each{|row| versions[row[0]] = row[1] } return versions end if(filename.include?('packages.config')) config_text=File.read(filename,:encoding=>'UTF-8') config_text.scan(/<package[\s]+id="([\w\.]+)"[\s]+version="([\d\.]+[-\w]+)"/).each{|row| versions[row[0]] = row[1] } return versions end if(filename.include?('.csproj')) config_text=File.read(filename,:encoding=>'UTF-8') config_text.scan(/<PackageReference[\s]+Include="([\w\.]+)"[\s]+Version="([\d\.]+[-\w]+)"/).each{|row| versions[row[0]] = row[1] } return versions end versions end |
.set_versions(filename, versions) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/apps/nuget.rb', line 51 def self.set_versions filename,versions text=File.read(filename,:encoding=>'UTF-8') text_versions=text.scan(/id="[\w\.]+"[\s]+version="[\d\.]+[-\w]+"/) text2=text versions.each{|k,v| text_versions.each{|line| if(line.include?("\"#{k}\"")) new_line = "id=\"#{k}\" version=\"#{v}\"" text2 = text2.gsub(line,new_line) end } } unless text==text2 File.open(filename,"w") { |f| f.puts text2 } end end |
.update_versions(source_filename, destination_filename) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/apps/nuget.rb', line 68 def self.update_versions(source_filename,destination_filename) old_versions=Nuget.get_versions(destination_filename) source_versions=Nuget.get_versions(source_filename) new_versions=Hash.new old_versions.each{|k,v| if(source_versions.has_key?(k)) new_versions[k]=source_versions[k] end } Nuget.set_versions(destination_filename,new_versions) end |