Class: VPL::Spec
- Inherits:
-
Object
- Object
- VPL::Spec
- Defined in:
- lib/vcpkg_pipeline/core/spec.rb
Overview
VPL::Spec
Instance Attribute Summary collapse
-
#content ⇒ Object
spec file.
-
#content_path ⇒ Object
spec file.
-
#dependencies ⇒ Object
port info.
-
#description ⇒ Object
port info.
-
#disturl ⇒ Object
dist info.
-
#homepage ⇒ Object
port info.
-
#name ⇒ Object
port info.
-
#path ⇒ Object
spec file.
-
#sources ⇒ Object
dist info.
-
#user ⇒ Object
port info.
-
#version ⇒ Object
port info.
Class Method Summary collapse
Instance Method Summary collapse
- #distfile_name ⇒ Object
- #distfile_package(output_path = nil) ⇒ Object
-
#initialize {|_self| ... } ⇒ Spec
constructor
A new instance of Spec.
- #to_s ⇒ Object
- #version_increased ⇒ Object
- #version_update(new_version = nil) ⇒ Object
- #write(property, value) ⇒ Object
Constructor Details
#initialize {|_self| ... } ⇒ Spec
Returns a new instance of Spec.
38 39 40 |
# File 'lib/vcpkg_pipeline/core/spec.rb', line 38 def initialize yield self if block_given? end |
Instance Attribute Details
#content ⇒ Object
spec file
11 12 13 |
# File 'lib/vcpkg_pipeline/core/spec.rb', line 11 def content @content end |
#content_path ⇒ Object
spec file
11 12 13 |
# File 'lib/vcpkg_pipeline/core/spec.rb', line 11 def content_path @content_path end |
#dependencies ⇒ Object
port info
14 15 16 |
# File 'lib/vcpkg_pipeline/core/spec.rb', line 14 def dependencies @dependencies end |
#description ⇒ Object
port info
14 15 16 |
# File 'lib/vcpkg_pipeline/core/spec.rb', line 14 def description @description end |
#disturl ⇒ Object
dist info
17 18 19 |
# File 'lib/vcpkg_pipeline/core/spec.rb', line 17 def disturl @disturl end |
#homepage ⇒ Object
port info
14 15 16 |
# File 'lib/vcpkg_pipeline/core/spec.rb', line 14 def homepage @homepage end |
#name ⇒ Object
port info
14 15 16 |
# File 'lib/vcpkg_pipeline/core/spec.rb', line 14 def name @name end |
#path ⇒ Object
spec file
11 12 13 |
# File 'lib/vcpkg_pipeline/core/spec.rb', line 11 def path @path end |
#sources ⇒ Object
dist info
17 18 19 |
# File 'lib/vcpkg_pipeline/core/spec.rb', line 17 def sources @sources end |
#user ⇒ Object
port info
14 15 16 |
# File 'lib/vcpkg_pipeline/core/spec.rb', line 14 def user @user end |
#version ⇒ Object
port info
14 15 16 |
# File 'lib/vcpkg_pipeline/core/spec.rb', line 14 def version @version end |
Class Method Details
.eval_vplspec(content, content_path) ⇒ Object
19 20 21 22 23 |
# File 'lib/vcpkg_pipeline/core/spec.rb', line 19 def self.eval_vplspec(content, content_path) instance_eval(content) rescue RescueException => e VPL.error("Invalid `#{content_path.basename}` file: #{e.}") end |
.load(path) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/vcpkg_pipeline/core/spec.rb', line 25 def self.load(path) content_path_list = Dir["#{path}/*.vplspec"] VPL.error('未找到或存在多个 *.vplspec 文件') if content_path_list.empty? || content_path_list.count > 1 content_path = content_path_list.first content = File.read(content_path) spec = eval_vplspec(content, content_path) spec.path = path spec.content_path = content_path spec.content = content spec end |
Instance Method Details
#distfile_name ⇒ Object
42 43 44 |
# File 'lib/vcpkg_pipeline/core/spec.rb', line 42 def distfile_name "#{name}-#{version}.zip" end |
#distfile_package(output_path = nil) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/vcpkg_pipeline/core/spec.rb', line 46 def distfile_package(output_path = nil) output_path ||= '.' distfile_path = "#{output_path}/#{distfile_name}" zip_sources = [] @sources.each do |source| zip_sources += Dir[source] end VPL.info(zip_sources.join('\n')) `zip #{distfile_path} #{zip_sources.join(' ')}` VPL.error("Dist包 打包失败: #{distfile_path}") unless File.exist? distfile_path VCPkg.hash(distfile_path) end |
#to_s ⇒ Object
83 84 85 86 87 88 89 90 |
# File 'lib/vcpkg_pipeline/core/spec.rb', line 83 def to_s "#{@name} (#{@version})\ \nuser: #{@user}\ \nhomepage: #{@homepage}\ \ndescription: #{@description}\ \nsources: #{@sources}\ \ndependencies: #{@dependencies}" end |
#version_increased ⇒ Object
68 69 70 71 72 73 74 75 76 |
# File 'lib/vcpkg_pipeline/core/spec.rb', line 68 def version_increased versions = @version.split('.') new_version_last = (versions.last.to_i + 1).to_s versions.pop versions.push(new_version_last) versions.join('.') end |
#version_update(new_version = nil) ⇒ Object
78 79 80 81 |
# File 'lib/vcpkg_pipeline/core/spec.rb', line 78 def version_update(new_version = nil) new_version ||= version_increased write('version', new_version) end |
#write(property, value) ⇒ Object
61 62 63 64 65 66 |
# File 'lib/vcpkg_pipeline/core/spec.rb', line 61 def write(property, value) VPL.info("写入 #{File.basename(@content_path)} : #{property} = #{value}") new_content = @content.gsub!(/(.*.#{property}.*=.*)('.*')/, "\\1'#{value}'") File.write(@content_path, new_content) end |