Module: Dnnbundler

Defined in:
lib/dnnbundler.rb,
lib/dnnbundler/cli.rb,
lib/dnnbundler/version.rb,
lib/dnnbundler/fileEntry.rb,
lib/dnnbundler/jsonConfig.rb,
lib/dnnbundler/fileEntryType.rb,
lib/dnnbundler/zipFileGenerator.rb,
lib/dnnbundler/fileStringReplacer/fileStringReplacer.rb

Defined Under Namespace

Modules: FileEntryType, JsonConfig, ManifestVersionRegex Classes: CLI, FileEntry, ZipFileGenerator

Constant Summary collapse

VERSION =
"0.1.6"

Class Method Summary collapse

Class Method Details

.formatVersion(version) ⇒ Object



40
41
42
# File 'lib/dnnbundler/cli.rb', line 40

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/fileStringReplacer/fileStringReplacer.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/fileStringReplacer/fileStringReplacer.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