Class: Raykit::Version
- Inherits:
-
Object
- Object
- Raykit::Version
- Defined in:
- lib/raykit/version.rb
Overview
Version functionality
Instance Attribute Summary collapse
-
#start_time ⇒ Object
Returns the value of attribute start_time.
Class Method Summary collapse
-
.detect(name, verbose = false) ⇒ Object
detect a version number based on the NAME variable, if defined.
Instance Attribute Details
#start_time ⇒ Object
Returns the value of attribute start_time.
4 5 6 |
# File 'lib/raykit/version.rb', line 4 def start_time @start_time end |
Class Method Details
.detect(name, verbose = false) ⇒ Object
detect a version number based on the NAME variable, if defined
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 41 |
# File 'lib/raykit/version.rb', line 7 def self.detect(name,verbose=false) puts 'detecting version' if(verbose) csproj_filename = "#{name}/#{name}.csproj" if(File.exists?(csproj_filename)) puts "checking version in #{csproj_filename}" if(verbose) match = IO.read(csproj_filename).match(/<Version>([\d.]+)</) if(!match.nil? && match.captures.length>0) return match.captures[0] end else puts "#{csproj_filename} not found" if(verbose) end assembly_info_filename = "#{name}/Properties/AssemblyInfo.cs" if(File.exists?(assembly_info_filename)) puts "checking version in #{assembly_info_filename}" if(verbose) match = IO.read(csproj_filename).match(/AssemblyVersion\(\"([.\w]+)/) if(!match.nil? && match.captures.length>0) return match.captures[0] end else puts "#{assembly_info_filename} not found" if(verbose) end gemspec_filename = "#{name}.gemspec" if(File.exists?(gemspec_filename)) return IO.read(gemspec_filename).match(/version[\s]+=[\s]+['"]([\w.]+)['"]/).captures[0] end nuspec_filename="#{name}.nuspec" if(File.exists?(nuspec_filename)) match = IO.read(nuspec_filename).match(/<[Vv]ersion>([\d.]+)</) if(!match.nil? && match.captures.length>0) return match.captures[0] end end '0.0.0' end |