Class: Mod
Direct Known Subclasses
RvMod
Constant Summary
collapse
- OVERRIDE_MODEL =
Mod
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#associated_valid?, #no_errors_in_associated?, #save_associated, #save_associated!, #save_with_unsaved_flag, #to_label, #unsaved=, #unsaved?
Instance Attribute Details
Workaround for missing db fields
22
23
24
|
# File 'lib/six-updater-web/app/models/mod.rb', line 22
def aliases
@aliases
end
|
Workaround for missing db fields
22
23
24
|
# File 'lib/six-updater-web/app/models/mod.rb', line 22
def author
@author
end
|
#changelog ⇒ Object
Workaround for missing db fields
22
23
24
|
# File 'lib/six-updater-web/app/models/mod.rb', line 22
def changelog
@changelog
end
|
Workaround for missing db fields
22
23
24
|
# File 'lib/six-updater-web/app/models/mod.rb', line 22
def cpp_name
@cpp_name
end
|
#dependencies ⇒ Object
19
20
21
|
# File 'lib/six-updater-web/app/models/mod.rb', line 19
def dependencies
@dependencies
end
|
#description ⇒ Object
Workaround for missing db fields
22
23
24
|
# File 'lib/six-updater-web/app/models/mod.rb', line 22
def description
@description
end
|
Workaround for missing db fields
22
23
24
|
# File 'lib/six-updater-web/app/models/mod.rb', line 22
def details
@details
end
|
#full_name ⇒ Object
Workaround for missing db fields
22
23
24
|
# File 'lib/six-updater-web/app/models/mod.rb', line 22
def full_name
@full_name
end
|
Workaround for missing db fields
22
23
24
|
# File 'lib/six-updater-web/app/models/mod.rb', line 22
def guid
@guid
end
|
Workaround for missing db fields
22
23
24
|
# File 'lib/six-updater-web/app/models/mod.rb', line 22
def homepage
@homepage
end
|
Workaround for missing db fields
22
23
24
|
# File 'lib/six-updater-web/app/models/mod.rb', line 22
def license
@license
end
|
#license_url ⇒ Object
Workaround for missing db fields
22
23
24
|
# File 'lib/six-updater-web/app/models/mod.rb', line 22
def license_url
@license_url
end
|
Workaround for missing db fields
22
23
24
|
# File 'lib/six-updater-web/app/models/mod.rb', line 22
def maxbuild
@maxbuild
end
|
Workaround for missing db fields
22
23
24
|
# File 'lib/six-updater-web/app/models/mod.rb', line 22
def minbuild
@minbuild
end
|
#mod_version ⇒ Object
Workaround for missing db fields
22
23
24
|
# File 'lib/six-updater-web/app/models/mod.rb', line 22
def mod_version
@mod_version
end
|
Workaround for missing db fields
22
23
24
|
# File 'lib/six-updater-web/app/models/mod.rb', line 22
def readme
@readme
end
|
#repository_yml ⇒ Object
Workaround for missing db fields
22
23
24
|
# File 'lib/six-updater-web/app/models/mod.rb', line 22
def repository_yml
@repository_yml
end
|
Workaround for missing db fields
22
23
24
|
# File 'lib/six-updater-web/app/models/mod.rb', line 22
def size_wd
@size_wd
end
|
Class Method Details
38
39
40
|
# File 'lib/six-updater-web/app/models/mod.rb', line 38
def self.appset
Kernel.const_get(self.short+"Appsetting")
end
|
arma2 mod: works for all subclasses armaoa mod; works for arma2-oa-st, arma2-oa-
97
98
99
|
# File 'lib/six-updater-web/app/models/mod.rb', line 97
def self.label
self.appset.label
end
|
.read_modfolders(setting) ⇒ Object
236
237
238
239
240
241
242
243
244
245
246
247
248
|
# File 'lib/six-updater-web/app/models/mod.rb', line 236
def self.read_modfolders(setting)
Dir.chdir setting.real_modpath.clone do
Dir["@*"].each do |dir|
next unless File.directory?(dir)
m = Mod.find(:first, :conditions => ["name LIKE ?", dir])
unless m
m = Mod.new :name => dir
m.save
end
logger.debug "#{m.inspect}"
end
end
end
|
101
102
103
|
# File 'lib/six-updater-web/app/models/mod.rb', line 101
def self.short
self.to_s.sub("Mod", "")
end
|
105
106
107
108
109
110
111
112
113
114
|
# File 'lib/six-updater-web/app/models/mod.rb', line 105
def self.types
return [Arma2Mod] if self.class == Appsetting
e = self
types = []
unless e.nil? || [Mod, ActiveRecord::Base].include?(e)
types << e
e = e.class
end
types
end
|
Instance Method Details
#all_dependentmods(mods = []) ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/six-updater-web/app/models/mod.rb', line 26
def all_dependentmods(mods = [])
mods += [self]
self.mods.each do |mod|
next if mods.include?(mod)
mods += mod.all_dependentmods(mods)
mods << mod
end
mods -= [self]
mods += [self]
mods.uniq
end
|
#all_repositories ⇒ Object
188
189
190
191
192
193
194
195
196
197
198
199
|
# File 'lib/six-updater-web/app/models/mod.rb', line 188
def all_repositories
rep = if self.networks.empty?
Repository.find(:all)
else
repos = []
self.networks.each { |net| repos += net.repositories unless net.disabled }
repos
end
prio = nil
rep.each {|e| unless e.priority.nil?; prio = true; break; end }
prio ? rep.sort{|a, b| a.prio <=> b.prio} : rep.shuffle
end
|
#exists?(setting) ⇒ Boolean
145
146
147
148
149
|
# File 'lib/six-updater-web/app/models/mod.rb', line 145
def exists?(setting)
path = self.my_path(setting)
return false unless path
File.exists?(path)
end
|
#has_rsync?(setting) ⇒ Boolean
151
152
153
154
155
|
# File 'lib/six-updater-web/app/models/mod.rb', line 151
def has_rsync?(setting)
path = self.my_path(setting)
return false unless path
File.exists?(File.join(path, ".rsync"))
end
|
#installed? ⇒ Boolean
136
137
138
|
# File 'lib/six-updater-web/app/models/mod.rb', line 136
def installed?
self.version_local && !self.version_local.empty?
end
|
#my_path(setting) ⇒ Object
140
141
142
143
|
# File 'lib/six-updater-web/app/models/mod.rb', line 140
def my_path(setting)
return nil if setting.real_modpath.nil? || self.real_name.nil?
File.join(self.real_path(setting), self.real_name).gsub("\\", "/")
end
|
#process(setting, reset, autoskip, force = false) ⇒ Object
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/six-updater-web/app/models/mod.rb', line 42
def process(setting, reset, autoskip, force = false)
self.update_version(setting) if reset && !autoskip
self.skip = false
else
self.update_skip if autoskip
end
self.save unless self.new_record?
unless force
self.disabled = true if (!self.exists?(setting) || self.installed? || self.class.appset::SPECIFIC) && !self.version_match?(setting)
end
end
|
#read_version(setting) ⇒ Object
165
166
167
168
169
170
171
172
173
|
# File 'lib/six-updater-web/app/models/mod.rb', line 165
def read_version(setting)
path = self.my_path(setting)
return unless path
cfg = File.join(path, '.rsync', '.repository.yml')
return nil unless File.exists?(cfg)
conf = YAML::load_file(cfg)
return nil unless conf
begin; conf[:version]; rescue; nil; end
end
|
#real_name ⇒ Object
126
127
128
129
130
131
132
133
134
|
# File 'lib/six-updater-web/app/models/mod.rb', line 126
def real_name
return unless self.name
case RUBY_PLATFORM
when /-mingw32$/, /-mswin32$/
self.name
else
self.name.downcase
end
end
|
#real_path(setting) ⇒ Object
184
185
186
|
# File 'lib/six-updater-web/app/models/mod.rb', line 184
def real_path(setting)
self.path.nil? || self.path.empty? ? setting.real_modpath : self.path
end
|
161
162
163
|
# File 'lib/six-updater-web/app/models/mod.rb', line 161
def rema
"mods/show"
end
|
157
158
159
|
# File 'lib/six-updater-web/app/models/mod.rb', line 157
def remote
end
|
205
206
207
|
# File 'lib/six-updater-web/app/models/mod.rb', line 205
def special
self.incl && !self.incl.empty?
end
|
#status(setting = Appsetting.new) ⇒ Object
85
86
87
88
89
90
91
92
93
|
# File 'lib/six-updater-web/app/models/mod.rb', line 85
def status(setting = Appsetting.new)
return :special if self.special
return :disabled if self.disabled
if self.installed? || self.exists?(setting)
self.skip ? :skip : :check
else
:install
end
end
|
#to_updater_yml ⇒ Object
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
|
# File 'lib/six-updater-web/app/models/mod.rb', line 209
def to_updater_yml
return unless self.real_name
hash = Hash.new
hash[:folder] = self.real_name
hash[:repository] = []
hash[:skip] = self.skip
hash[:disabled] = self.disabled
if self.incl
hash[:include] = self.incl.split(";")
hash[:force] = true unless hash[:include].empty?
end
if self.excl
hash[:exclude] = self.excl.split(";")
end
hash[:priority] = self.priority
name = self.real_name.clone
name.gsub!("@", '')
unless self.new_record?
self.all_repositories.each do |rep|
hash[:repository] << "#{rep.to_updater_yml}/rel/#{name.downcase}/." unless rep.disabled
end
end
hash
end
|
#uconfig_name ⇒ Object
58
59
60
|
# File 'lib/six-updater-web/app/models/mod.rb', line 58
def uconfig_name
self.real_name.sub(/^@/, "")
end
|
#update_skip ⇒ Object
201
202
203
|
# File 'lib/six-updater-web/app/models/mod.rb', line 201
def update_skip
self.skip = if self.new_record?; true ; else; ((self.version == self.version_local) && !self.version.nil?); end
end
|
#update_skip_by_version(setting) ⇒ Object
179
180
181
182
|
# File 'lib/six-updater-web/app/models/mod.rb', line 179
def update_skip_by_version(setting)
self.update_version(setting)
self.update_skip
end
|
#update_version(setting) ⇒ Object
175
176
177
|
# File 'lib/six-updater-web/app/models/mod.rb', line 175
def update_version(setting)
self.version_local = self.read_version(setting).to_s
end
|
#userconfig(setting = Appsetting.new) ⇒ Object
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
# File 'lib/six-updater-web/app/models/mod.rb', line 62
def userconfig(setting = Appsetting.new)
rpath = self.real_path(setting)
path = File.join(rpath, 'store', 'userconfig.tar')
path = File.join(rpath, 'store', 'userconfig') unless File.exists?(path)
path = File.join(rpath, 'userconfig') unless File.exists?(path)
if File.exists?(path)
if File.directory? path
else
end
end
end
|
#version_match?(setting) ⇒ Boolean
116
117
118
119
120
121
122
123
124
|
# File 'lib/six-updater-web/app/models/mod.rb', line 116
def version_match?(setting)
return nil if setting.nil?
self.type.nil? ? true : setting.found_types.map{|e| e.short }.include?(self.class.short)
end
|