Class: Mod
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?
Class Method Details
.read_modfolders(setting) ⇒ Object
102
103
104
105
106
107
108
109
110
111
112
113
114
|
# File 'lib/six-updater-web/app/models/mod.rb', line 102
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
|
Instance Method Details
#all_repositories ⇒ Object
68
69
70
71
72
73
74
75
76
|
# File 'lib/six-updater-web/app/models/mod.rb', line 68
def all_repositories
if self.networks.empty?
Repository.find(:all)
else
repos = []
self.networks.each { |net| repos += net.repositories unless net.disabled }
repos
end
end
|
#exists?(setting) ⇒ Boolean
23
24
25
26
|
# File 'lib/six-updater-web/app/models/mod.rb', line 23
def exists?(setting)
return false unless setting.real_modpath && self.real_name
File.exists?(File.join(setting.real_modpath, self.real_name))
end
|
#installed? ⇒ Boolean
19
20
21
|
# File 'lib/six-updater-web/app/models/mod.rb', line 19
def installed?
!self.version_local.empty?
end
|
#read_version(path) ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/six-updater-web/app/models/mod.rb', line 36
def read_version(path)
return unless path && self.real_name
cfg = File.join(path, self.real_name, '.rsync', '.repository.yml')
if File.exists?(cfg)
conf = YAML::load_file(cfg)
if conf
conf[:version]
else
nil
end
else
nil
end
end
|
#real_name ⇒ Object
9
10
11
12
13
14
15
16
17
|
# File 'lib/six-updater-web/app/models/mod.rb', line 9
def real_name
return unless self.name
case RUBY_PLATFORM
when /-mingw32$/, /-mswin32$/
self.name
else
self.name.downcase
end
end
|
#real_path(appsetting) ⇒ Object
60
61
62
63
64
65
66
|
# File 'lib/six-updater-web/app/models/mod.rb', line 60
def real_path(appsetting)
if self.path
self.path
else
appsetting.real_modpath
end
end
|
32
33
34
|
# File 'lib/six-updater-web/app/models/mod.rb', line 32
def rema
"mods/show"
end
|
28
29
30
|
# File 'lib/six-updater-web/app/models/mod.rb', line 28
def remote
end
|
#to_updater_yml ⇒ Object
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
# File 'lib/six-updater-web/app/models/mod.rb', line 82
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
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
|
#update_skip ⇒ Object
78
79
80
|
# File 'lib/six-updater-web/app/models/mod.rb', line 78
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(path) ⇒ Object
55
56
57
58
|
# File 'lib/six-updater-web/app/models/mod.rb', line 55
def update_skip_by_version(path)
self.update_version(path)
self.update_skip
end
|
#update_version(path) ⇒ Object
51
52
53
|
# File 'lib/six-updater-web/app/models/mod.rb', line 51
def update_version(path)
self.version_local = self.read_version(path).to_s
end
|