Class: Mmi::ModFileProcessor

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content) ⇒ ModFileProcessor

Returns a new instance of ModFileProcessor.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/mmi/mod_file_processor.rb', line 15

def initialize(content)
	@content = content
	
	@version     = content['version'    ]
	@profile_dir = content['profile_dir'] || Mmi.minecraft_dir
	
	version     = SemVer.parse(self.version)
	lib_version = SemVer.parse(Mmi::VERSION)
	
	if self.version
		if version.major <= lib_version.major
			if version.minor > lib_version.minor
				Mmi.warn %Q{Config file specified "version" #{version}, but MMI is at #{lib_version}. Some features might not be supported.}
			end
			
			ml         = content['modloader']
			@modloader = if ml
				case ml['name']
				when 'none'
					Modloader::None.new(ml)
				when 'fabric'
					Modloader::Fabric.new(ml)
				else
					raise Mmi::InvalidAttributeError, %Q{Unkown modloader #{ml['name'].inspect}.}
				end
			else
				Modloader::None.new
			end
			
			@assets = AssetsProcessor.new(self.profile_dir, content['assets'])
		else
			raise Mmi::InvalidAttributeError, %Q{Config file specified "version" #{version}, but MMI is at #{lib_version}.}
		end
	else
		raise Mmi::MissingAttributeError, 'Missing "version".'
	end
end

Instance Attribute Details

#assetsObject (readonly)

Returns the value of attribute assets.



13
14
15
# File 'lib/mmi/mod_file_processor.rb', line 13

def assets
  @assets
end

#contentObject (readonly)

Returns the value of attribute content.



7
8
9
# File 'lib/mmi/mod_file_processor.rb', line 7

def content
  @content
end

#modloaderObject (readonly)

Returns the value of attribute modloader.



12
13
14
# File 'lib/mmi/mod_file_processor.rb', line 12

def modloader
  @modloader
end

#profile_dirObject (readonly)

Returns the value of attribute profile_dir.



10
11
12
# File 'lib/mmi/mod_file_processor.rb', line 10

def profile_dir
  @profile_dir
end

#versionObject (readonly)

Returns the value of attribute version.



9
10
11
# File 'lib/mmi/mod_file_processor.rb', line 9

def version
  @version
end

Instance Method Details

#installObject



53
54
55
56
# File 'lib/mmi/mod_file_processor.rb', line 53

def install
	self.modloader.install
	self.assets.install
end