Class: Mmi::AssetsProcessor

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(profile_dir, assets) ⇒ AssetsProcessor

Returns a new instance of AssetsProcessor.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/mmi/assets_processor.rb', line 8

def initialize(profile_dir, assets)
	@profile_dir = profile_dir
	
	assets ||= []
	
	if assets.is_a?(Array)
		@assets = assets.map.with_index do |asset, index|
			source = asset['source']
			
			if source
				type = source['type']
				
				case type
				when 'github'
					Source::Github.new(source)
				else
					raise Mmi::InvalidAttributeError, %Q{Invalid "source.type" in asset #{index.inspect}: #{type.inspect}}
				end
			else
				raise Mmi::MissingAttributeError, %Q{Missing "source" in asset #{index.inspect}.}
			end
		end
	else
		raise Mmi::InvalidAttributeError, %Q{Invalid "assets": expected Array or nothing, got #{self.assets.inspect}.}
	end
end

Instance Attribute Details

#assetsObject (readonly)

Returns the value of attribute assets.



6
7
8
# File 'lib/mmi/assets_processor.rb', line 6

def assets
  @assets
end

#profile_dirObject (readonly)

Returns the value of attribute profile_dir.



5
6
7
# File 'lib/mmi/assets_processor.rb', line 5

def profile_dir
  @profile_dir
end

Instance Method Details

#installObject



35
36
37
38
39
# File 'lib/mmi/assets_processor.rb', line 35

def install
	assets.each do |asset|
		asset.install(self.profile_dir)
	end
end