Class: Xcvm::VersionManager

Inherits:
Object
  • Object
show all
Defined in:
lib/xcvm.rb

Class Method Summary collapse

Class Method Details

.decrement(attribute, path) ⇒ Object



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/xcvm.rb', line 101

def self.decrement(attribute, path)
	project = Xcvm::Project.new(path)

	if attribute == "major" then
		project.version.decrement! :major
		project.save
		puts project.version
	elsif attribute == "minor" then
		project.version.decrement! :minor
		project.save
		puts project.version
	elsif attribute == "revision" then
		project.version.decrement! :revision
		project.save
		puts project.version
	elsif attribute == "build" then
		project.build.decrement!
		project.save
		puts project.build
	elsif attribute == nil then
		raise "Missing attribute"
	else
		raise "Invalid attribute '#{attribute}'"
	end
end

.increment(attribute, path) ⇒ Object



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/xcvm.rb', line 73

def self.increment(attribute, path)
	project = Xcvm::Project.new(path)

	if attribute == "major" then
		project.version.increment! :major
		project.save
		puts project.version
	elsif attribute == "minor" then
		project.version.increment! :minor
		project.save
		puts project.version
	elsif attribute == "revision" then
		project.version.increment! :revision
		project.save
		puts project.version
	elsif attribute == "build" then
		project.build.increment!
		project.save
		puts project.build
	elsif attribute == nil then
		raise "Missing attribute"
	else
		raise "Invalid attribute '#{attribute}'"
	end

	
end


29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/xcvm.rb', line 29

def self.print(attribute, path)
	project = Xcvm::Project.new(path)

	if attribute == "version" then
		puts project.version
	elsif attribute == "build" then
		puts project.build
	elsif attribute == nil then
		raise "Missing attribute"
	else
		raise "Invalid attribute '#{attribute}'"
	end
end

.run(action, attribute, value = nil, path = nil) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/xcvm.rb', line 7

def self.run(action, attribute, value = nil, path = nil)
	if path == nil then
		path = 'Info.plist'
	end

	if action == "print" then
		print attribute, path
	elsif action == "set" then
		set attribute, value, path
	elsif action == "bump" then
		increment attribute, path
	elsif action == "increment" then
		increment attribute, path
	elsif action == "decrement" then
		decrement attribute, path
	elsif action == nil then
		raise "Missing action"
	else
		raise "Invalid action '#{action}'"
	end
end

.set(attribute, value, path) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/xcvm.rb', line 43

def self.set(attribute, value, path)
	project = Xcvm::Project.new(path)

	if attribute == "version" then
		project.version = Xcvm::SemanticVersion.new(value)
		project.save
		puts project.version
	elsif attribute == "major" then
		project.version.major = value.to_i
		project.save
		puts project.version
	elsif attribute == "minor" then
		project.version.minor = value.to_i
		project.save
		puts project.version
	elsif attribute == "revision" then
		project.revision = value.to_i
		project.save
		puts project.version
	elsif
		project.build = Xcvm::Build.new(value.to_i)
		project.save
		puts project.build
	elsif attribute == nil then
		raise "Missing attribute"
	else
		raise "Invalid attribute '#{attribute}'"
	end
end