Class: AbstractMarkupLanguage::Base

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

Class Method Summary collapse

Class Method Details

.basePathObject



140
141
142
# File 'lib/aml.rb', line 140

def self.basePath
	@basePath
end

.initialize(arguments, instance) ⇒ Object



7
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
34
35
36
37
38
39
40
41
42
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
72
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
100
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
126
127
128
129
130
131
132
133
134
# File 'lib/aml.rb', line 7

def self.initialize(arguments, instance)
	error = Error.new()
	argument = Argument.new(arguments,error)
	argument.required('watch','The required --watch argument has not been defined.')
	if(argument.has_requirements? == false)
		argument.clear_required
		argument.required('build','The required --build argument has not been defined.')
		if(argument.has_requirements?)
			argument.clear_required
			argument.create('watch',argument.read('build'))
			argument.create('build','true')
		end
	else
		argument.create('build','false')
	end
	if argument.has_requirements? and File.exist?(argument.read('watch'))
		basePath = File.dirname(argument.read('watch'))
		@basePath = basePath
		watchFile = File.basename(argument.read('watch'))
		@watchFile = watchFile
		#Arguments from aml-config
		configFile = File.join(basePath,'aml-config')
		argument.parse(File.read(configFile)) if File.exist?(configFile)
		#Arguments
		argument.create('watch',watchFile)
		argument.create_if_empty('basePath',basePath)
		argument.create_if_empty('fileExtension','html')
		argument.create_if_empty('fileOutput',"#{File.basename(argument.read('watch'), ".*")}.#{argument.read('fileExtension')}")
		argument.create_if_empty('selfClosing',"area,base,basefont,bgsound,br,col,frame,hr,img,isindex,input,keygen,link,meta,param,source,track,wbr")

		argument.create_if_empty('aml-watch-instance', "#{instance}")

		parse = Parse.new(argument.read('basePath'), argument.read('watch'))
		files = []

		#Watch Partials
		parse.watch.each do |this|
			file = File.join(basePath, this[:bundle] ? File.join(this[:bundle],'partial') : this[:partial] ? 'partial' : '' , this[:file])
			files << file
		end

		#Watch Mixins
		parse.mixin.each do |this|
			file = File.join(basePath, this[:bundle] ? File.join(this[:bundle]) : this[:partial] ? 'partial' : '' , this[:file]) if this[:bundle] != false
			files << file if file != nil
		end

		#Define Core Bundle's Methods, Mixins, & Variables...
		core_definition =  false
		if(File.exists?(File.join(File.dirname(File.expand_path(__FILE__)),'aml','core','mixin.aml')))
			bundle = Parse.new(File.join(File.dirname(File.expand_path(__FILE__)), 'aml','core'),'mixin.aml')
			definition = Definition.new(bundle.file,"core",false,true,true)
			core_definition = true
		else
			error.log('core',false,'mixin.aml',false,'file does not exist')
		end

		if(File.exists?(File.join(File.dirname(File.expand_path(__FILE__)),'aml','core','method.rb')))
		 	begin
		 		class_eval File.read(File.join(File.dirname(File.expand_path(__FILE__)),'aml','core','method.rb'))
		 	rescue Exception => e
				x = e.message.match(error.match)
				error.log('core',false,"method.rb",x[:line],x[:message])
			end
		else
			error.log('core',false,'method.rb',false,'file does not exist')
		end

		#Define --watch Methods, Mixins, & Variables...
		if core_definition
			definition.add(parse.file,false,true,true,true)
		else
			definition = Definition.new(parse.file,false,true,true,true)
		end

		#Define Additional Bundle Methods & Mixins
		definition.bundles.each do |directory,name|
			if directory != 'core' then
				if File.exists?(File.join(basePath,directory,'method.rb'))
					begin
						class_eval File.read(File.join(basePath,directory,'method.rb'))
					rescue Exception => e
						x = e.message.match(error.match)
						error.log(directory,false,"method.rb",x[:line],x[:message])
					end
				else
					error.log(directory,false,'method.rb',false,'file does not exist')
				end
				if File.exists?(File.join(basePath,directory,'mixin.aml'))
					bundle = Parse.new(File.join(basePath,directory),'mixin.aml')
					definition.add(bundle.file,directory,false,true,true)
				else
					error.log(directory,false,'mixin.aml',false,'file does not exist')
				end
				#Watch Additional Bundle Partials
				Dir[File.join(basePath,directory,'partial','*.aml')].each do |partial|
					files << partial
				end
			end
		end

		#Watch or Build
		@makeFile = argument.read('fileOutput')
		compile = Compile.new(parse,argument,definition,error)
		error.log_delete if error.count == 0
		error.log_create if error.count > 0	
		if argument.read('build') == 'false'
			if(error.count == 0)
				print "\r\b\e[0KWatching #{files.count} file#{files.count != 1 ? "s" : ""}"" for updates... "
			else
				print "\r\b\e[0KPlease resolve all issues found in aml-error... "	
			end
			watch = Watch.new(files, arguments, argument.read('aml-watch-instance').to_i+1, argument.read('build'))
		else
			if(error.count == 0)
				puts "Build complete."
			else
				puts "Please resolve all issues found in aml-error."	
			end	
		end
	else
		if argument.defined('version')
			puts Gem.loaded_specs['aml'].version.to_s
		else
			puts argument.read('watch').to_s.length == 0 ? "Please define the --watch or --build argument." : "File not found."
		end
	end
end

.makeFileObject



136
137
138
# File 'lib/aml.rb', line 136

def self.makeFile
	@makeFile
end

.watchFileObject



144
145
146
# File 'lib/aml.rb', line 144

def self.watchFile
	@watchFile
end