Class: ThorSCMVersion::P4Version
Constant Summary
Constants inherited
from ScmVersion
ScmVersion::VERSION_FILENAME, ScmVersion::VERSION_FORMAT
Instance Attribute Summary collapse
Attributes inherited from ScmVersion
#build, #major, #minor, #patch, #prerelease
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from ScmVersion
#<=>, #bump!, from_path, from_tag, #reset_for, retrieve_tags, #to_s, #write_version
Constructor Details
#initialize(major = 0, minor = 0, patch = 0, prerelease = nil, build = 1) ⇒ P4Version
Returns a new instance of P4Version.
84
85
86
87
88
|
# File 'lib/thor-scmversion/p4_version.rb', line 84
def initialize(major = 0, minor = 0, patch = 0, prerelease = nil, build = 1)
self.p4_depot_path = self.class.depot_path('.')
self.p4_module_name = self.class.module_name('.')
super
end
|
Instance Attribute Details
#p4_depot_path ⇒ Object
Returns the value of attribute p4_depot_path.
91
92
93
|
# File 'lib/thor-scmversion/p4_version.rb', line 91
def p4_depot_path
@p4_depot_path
end
|
#p4_module_name ⇒ Object
Returns the value of attribute p4_module_name.
92
93
94
|
# File 'lib/thor-scmversion/p4_version.rb', line 92
def p4_module_name
@p4_module_name
end
|
#version_file_path ⇒ Object
Returns the value of attribute version_file_path.
90
91
92
|
# File 'lib/thor-scmversion/p4_version.rb', line 90
def version_file_path
@version_file_path
end
|
Class Method Details
.all_from_path(path) ⇒ Object
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/thor-scmversion/p4_version.rb', line 49
def all_from_path(path)
Dir.chdir(path) do
all_labels_array = `p4 labels -e \"#{module_name(path)}*\"`.split("\n")
thor_scmversion_labels = get_thor_scmversion_labels(all_labels_array, module_name(path))
current_versions = thor_scmversion_labels.collect do |label|
new_instance = new(*parse_label(label, module_name(path)))
end.sort.reverse
if current_versions.empty?
first_instance = new(0, 0, 0)
end
current_versions << first_instance if current_versions.empty?
current_versions
end
end
|
.depot_path(path) ⇒ Object
67
68
69
|
# File 'lib/thor-scmversion/p4_version.rb', line 67
def depot_path(path)
`p4 dirs #{File.expand_path(path)}`.chomp
end
|
.get_thor_scmversion_labels(labels, p4_module_name) ⇒ Object
79
80
81
|
# File 'lib/thor-scmversion/p4_version.rb', line 79
def get_thor_scmversion_labels(labels, p4_module_name)
labels.select{|label| label.split(" ")[1].gsub("#{p4_module_name}-", "").match(ScmVersion::VERSION_FORMAT)}
end
|
.module_name(path) ⇒ Object
71
72
73
|
# File 'lib/thor-scmversion/p4_version.rb', line 71
def module_name(path)
File.expand_path(path).split("/").last
end
|
.parse_label(label, p4_module_name) ⇒ Object
75
76
77
|
# File 'lib/thor-scmversion/p4_version.rb', line 75
def parse_label(label, p4_module_name)
label.split(" ")[1].gsub("#{p4_module_name}-", "").split('.')
end
|
Instance Method Details
#auto_bump ⇒ Object
107
108
109
110
|
# File 'lib/thor-scmversion/p4_version.rb', line 107
def auto_bump
bump!(:patch)
end
|
94
95
96
97
|
# File 'lib/thor-scmversion/p4_version.rb', line 94
def retrieve_tags
end
|
#tag ⇒ Object
99
100
101
102
103
104
105
|
# File 'lib/thor-scmversion/p4_version.rb', line 99
def tag
if windows?
`type #{File.expand_path(get_p4_label_file).gsub(File::Separator, File::ALT_SEPARATOR)} | p4 label -i`
else
`cat #{File.expand_path(get_p4_label_file)} | p4 label -i`
end
end
|