Module: Dnnbundler

Defined in:
lib/dnnbundler.rb,
lib/dnnbundler/cli.rb,
lib/dnnbundler/version.rb,
lib/dnnbundler/jsonConfig.rb,
lib/dnnbundler/packageVersionReplacer.rb

Defined Under Namespace

Modules: JsonConfig, ManifestVersionRegex Classes: CLI

Constant Summary collapse

VERSION =
"0.1.8"

Class Method Summary collapse

Class Method Details

.formatVersion(version) ⇒ Object

converts version numbers array into string <year>.<sprint>.<build> Params:

version

integer array: [year, sprint, build]



44
45
46
# File 'lib/dnnbundler/cli.rb', line 44

def self.formatVersion(version)
    "#{version[0].to_s.rjust(4, "0")}.#{version[1].to_s.rjust(2, "0")}.#{version[2].to_s.rjust(4, "0")}"
end

.getVersionFromManifest(file_name) ⇒ Object



17
18
19
20
# File 'lib/dnnbundler/packageVersionReplacer.rb', line 17

def self.getVersionFromManifest(file_name)
    text = File.read(file_name)
    (ManifestVersionRegex::NewManifestRegex.match(text) || ManifestVersionRegex::OldManifestRegex.match(text)).captures[1]
end

.replaceVersionInManifestFiles(file_names, new_version) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/dnnbundler/packageVersionReplacer.rb', line 2

def self.replaceVersionInManifestFiles(file_names, new_version)
    file_names.each do |file_name|
        text = File.read(file_name)
        replace_expr = '\1' + new_version + '\3'
        text.gsub!(ManifestVersionRegex::NewManifestRegex, replace_expr )
        text.gsub!(ManifestVersionRegex::OldManifestRegex, replace_expr )

        # To merely print the contents of the file, use:
        # puts new_contents

        # To write changes to the file, use:
        File.open(file_name, "w") {|file| file.puts text }
    end
end

.splitVersionNumbers(version_string) ⇒ Object

splits string version into integers Params:

version_string

string version, format is dot separated numbers <year>.<sprint>.<build>



51
52
53
# File 'lib/dnnbundler/cli.rb', line 51

def self.splitVersionNumbers(version_string)
    version_string.split(".").map { |x| x.to_i }
end