Sha256: 6b6f346dc43aeda067e1676c11f714bcedcb49d36c98e206c262cbc0ab42e5ba

Contents?: true

Size: 986 Bytes

Versions: 15

Compression:

Stored size: 986 Bytes

Contents

module BigKeeper
  class VersionConfigOperator
    def self.change_version(version_config_file, modules, version)
      temp_file = Tempfile.new('.version-config.gradle.tmp')
      begin
        File.open(version_config_file, 'r') do |file|
          file.each_line do |line|
            temp_file.puts(replace_module_version(line, modules, version))
          end
        end
        temp_file.close
        FileUtils.mv(temp_file.path, version_config_file)
      ensure
        temp_file.close
        temp_file.unlink
      end
    end

    def self.replace_module_version(line, modules, version)
      modules.each do |module_name|
        version_alias = BigkeeperParser.module_version_alias(module_name)
        if !version_alias.nil? && !version_alias.empty? && line.match(/\s*#{version_alias}\s*=\s*('|")([\s\S]*)('|")\s*/)
          return line.sub(/(\s*#{version_alias}\s*=\s*)('|")([\s\S]*)('|")\s*/){"#{$1}\'#{version}\'"}
        end
      end
      line
    end
  end
end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
kookeeper-3.0.0 lib/big_keeper/util/version_config_operator.rb
kookeeper-2.0.0 lib/big_keeper/util/version_config_operator.rb
kookeeper-1.0.0 lib/big_keeper/util/version_config_operator.rb
bigkeeper-0.9.21 lib/big_keeper/util/version_config_operator.rb
bigkeeper-0.9.20 lib/big_keeper/util/version_config_operator.rb
bigkeeper-0.9.19 lib/big_keeper/util/version_config_operator.rb
bigkeeper-0.9.18 lib/big_keeper/util/version_config_operator.rb
bigkeeper-0.9.17 lib/big_keeper/util/version_config_operator.rb
bigkeeper-0.9.16 lib/big_keeper/util/version_config_operator.rb
bigkeeper-0.9.15 lib/big_keeper/util/version_config_operator.rb
bigkeeper-0.9.14 lib/big_keeper/util/version_config_operator.rb
bigkeeper-0.9.13 lib/big_keeper/util/version_config_operator.rb
bigkeeper-0.9.12 lib/big_keeper/util/version_config_operator.rb
bigkeeper-0.9.11 lib/big_keeper/util/version_config_operator.rb
bigkeeper-0.9.10 lib/big_keeper/util/version_config_operator.rb