Class: VCPort::Base::VCPkg

Inherits:
Object
  • Object
show all
Defined in:
lib/vcpkg_pipeline/extension/vcport_vpl.rb

Overview

VCPort::Base::VCPkg

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ VCPkg

Returns a new instance of VCPkg.



36
37
38
39
40
41
42
43
44
# File 'lib/vcpkg_pipeline/extension/vcport_vpl.rb', line 36

def initialize(path)
  @path = path
  @content_path = "#{path}/vcpkg.json"

  VPL.error("#{@content_path} Not Found") unless File.exist? @content_path
  @content = File.read(@content_path)

  parse_content(@content)
end

Instance Attribute Details

#contentObject

Returns the value of attribute content.



34
35
36
# File 'lib/vcpkg_pipeline/extension/vcport_vpl.rb', line 34

def content
  @content
end

#content_pathObject

Returns the value of attribute content_path.



34
35
36
# File 'lib/vcpkg_pipeline/extension/vcport_vpl.rb', line 34

def content_path
  @content_path
end

#jsonObject

Returns the value of attribute json.



34
35
36
# File 'lib/vcpkg_pipeline/extension/vcport_vpl.rb', line 34

def json
  @json
end

#nameObject

Returns the value of attribute name.



34
35
36
# File 'lib/vcpkg_pipeline/extension/vcport_vpl.rb', line 34

def name
  @name
end

#pathObject

Returns the value of attribute path.



34
35
36
# File 'lib/vcpkg_pipeline/extension/vcport_vpl.rb', line 34

def path
  @path
end

#versionObject

Returns the value of attribute version.



34
35
36
# File 'lib/vcpkg_pipeline/extension/vcport_vpl.rb', line 34

def version
  @version
end

Instance Method Details

#parse_content(content) ⇒ Object



46
47
48
49
50
# File 'lib/vcpkg_pipeline/extension/vcport_vpl.rb', line 46

def parse_content(content)
  @json = JSON.parse(content)
  @name = @json['name']
  @version = @json['version']
end

#to_sObject



58
59
60
# File 'lib/vcpkg_pipeline/extension/vcport_vpl.rb', line 58

def to_s
  "#{json['name']}-#{json['version']}"
end

#version_update(new_version) ⇒ Object



52
53
54
55
56
# File 'lib/vcpkg_pipeline/extension/vcport_vpl.rb', line 52

def version_update(new_version)
  @json['version'] = new_version
  File.write(@content_path, JSON.dump(@json))
  VPL.info("Port 版本号更新: #{@version} -> #{new_version}")
end