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.
- .detect_from_file(filename, regex, verbose) ⇒ Object
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 |
# File 'lib/raykit/version.rb', line 7 def self.detect(name,verbose=false) version=detect_from_file("#{name}/#{name}.csproj",/<Version>([\d.]+)</,verbose) return version if(version.length>0) version=detect_from_file("#{name}/Properties/AssemblyInfo.cs",/^\[assembly: AssemblyVersion\(\"([.\w]+)/,verbose) return version if(version.length>0) version=detect_from_file("#{name}.gemspec",/version[\s]+=[\s]+['"]([\w.]+)['"]/,verbose) return version if(version.length>0) version=detect_from_file("#{name}.nuspec",/<[Vv]ersion>([\d.]+)</,verbose) return version if(version.length>0) if(verbose) warning="\u26A0" symbol=Rainbow(warning.encode('utf-8')).yellow puts symbol + ' version not detected' end '' end |
.detect_from_file(filename, regex, verbose) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/raykit/version.rb', line 28 def self.detect_from_file(filename,regex,verbose) version='' if(File.exists?(filename)) match = IO.read(filename).match(regex) if(!match.nil? && match.captures.length>0) version = match.captures[0] end else return '' end if(verbose) if(version.length > 0) puts "version detected in #{filename}" else puts "no version detected in #{filename}, regex #{regex.source}" end end version end |