Class: DataMetaDom::Ver

Inherits:
Object
  • Object
show all
Defined in:
lib/dataMetaDom/ver.rb

Overview

Version info.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(specs) ⇒ Ver

Creates an instance with the given full version.



178
179
180
181
182
183
184
185
186
# File 'lib/dataMetaDom/ver.rb', line 178

def initialize(specs)
    @full = if specs.kind_of?(Integer)
                raise ArgumentError,
                      %|Invalid version specs: "#{specs
                      }"; a version must be of a valid Semantic format|
            else
               SemVer.fromSpecs(specs)
            end
end

Instance Attribute Details

#fullObject

Full version info.



173
174
175
# File 'lib/dataMetaDom/ver.rb', line 173

def full
  @full
end

Class Method Details

.reVersion(path, namespace, globs, srcVer, trgVer) ⇒ Object

Reversions all the files in the given paths recursively



190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
# File 'lib/dataMetaDom/ver.rb', line 190

def reVersion(path, namespace, globs, srcVer, trgVer)
    vPat = srcVer ? srcVer.toVarName : '\d+_\d+_\d+'
    globs.each { |g|
        Dir.glob("#{path}/#{g}").each { |f|
            origLines = IO.read(f).split("\n")
            newLines = []
            origLines.each { |line|
                newLines << (line.end_with?('KEEP') ? line :
                        line.gsub(%r~#{namespace.gsub(/\./, '\.')}\.v#{vPat}~, "#{namespace}.v#{trgVer.toVarName}"))
            }
            IO.write(f, newLines.join("\n"), mode: 'wb')
        }
    }
    Dir.entries(path).select{|e| File.directory?(File.join(path, e))}.reject{|e| e.start_with?('.')}.each {|d|
        reVersion File.join(path, d), namespace, globs, srcVer, trgVer
    }

end

Instance Method Details

#to_sObject

Textual presentation for the instance.



214
# File 'lib/dataMetaDom/ver.rb', line 214

def to_s; "ver #{full}" end