aml 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/aml +1 -1
- data/bin/aml-bundle +3 -0
- data/lib/aml/argument.rb +13 -2
- data/lib/aml/compile.rb +163 -0
- data/lib/aml/core/method.rb +19 -0
- data/lib/aml/core/mixin.aml +52 -0
- data/lib/aml/definition.rb +61 -0
- data/lib/aml/error.rb +84 -0
- data/lib/aml/line_type.rb +38 -0
- data/lib/aml/make.rb +12 -0
- data/lib/aml/parse.rb +58 -492
- data/lib/aml/requirement.rb +8 -0
- data/lib/aml/watch.rb +14 -15
- data/lib/aml-bundle.rb +58 -0
- data/lib/aml.rb +129 -54
- metadata +16 -6
- data/lib/aml/log.rb +0 -25
data/lib/aml.rb
CHANGED
@@ -1,67 +1,142 @@
|
|
1
|
+
require 'aml/requirement'
|
1
2
|
module AbstractMarkupLanguage
|
3
|
+
@basePath
|
4
|
+
@watchFile
|
5
|
+
@makeFile
|
6
|
+
|
2
7
|
class Base
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
8
|
+
def self.initialize(arguments, instance)
|
9
|
+
error = Error.new()
|
10
|
+
argument = Argument.new(arguments,error)
|
11
|
+
argument.required('watch','The required --watch argument has not been defined.')
|
12
|
+
|
13
|
+
if(argument.has_requirements? == false)
|
14
|
+
argument.clear_required
|
15
|
+
argument.required('build','The required --build argument has not been defined.')
|
16
|
+
if(argument.has_requirements?)
|
17
|
+
argument.clear_required
|
18
|
+
argument.create('watch',argument.read('build'))
|
19
|
+
argument.create('build','true')
|
20
|
+
end
|
21
|
+
else
|
22
|
+
argument.create('build','false')
|
23
|
+
end
|
24
|
+
|
25
|
+
if argument.has_requirements? and File.exist?(argument.read('watch'))
|
26
|
+
basePath = File.dirname(argument.read('watch'))
|
27
|
+
@basePath = basePath
|
28
|
+
watchFile = File.basename(argument.read('watch'))
|
29
|
+
@watchFile = watchFile
|
30
|
+
#AML Config Arguments
|
31
|
+
configFile = File.join(basePath,'aml-config')
|
32
|
+
argument.parse(File.read(configFile)) if File.exist?(configFile)
|
33
|
+
#Arguments
|
34
|
+
argument.create('watch',watchFile)
|
35
|
+
argument.create_if_empty('basePath',basePath)
|
36
|
+
argument.create_if_empty('fileExtension','html')
|
37
|
+
argument.create_if_empty('fileOutput',"#{File.basename(argument.read('watch'), ".*")}.#{argument.read('fileExtension')}")
|
38
|
+
argument.create_if_empty('selfClosing',"area,base,basefont,bgsound,br,col,frame,hr,img,isindex,input,keygen,link,meta,param,source,track,wbr")
|
39
|
+
argument.create_if_empty('sortAttribute','true')
|
40
|
+
argument.create_if_empty('singleQuote','false')
|
41
|
+
argument.create_if_empty('errorLimit','5')
|
42
|
+
argument.create_if_empty('aml-watch-instance', "#{instance}")
|
43
|
+
|
44
|
+
parse = Parse.new(argument.read('basePath'), argument.read('watch'))
|
45
|
+
files = []
|
7
46
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
argument.create_if_empty('fileOutput',"#{File.basename(argument.read('watch'), ".*")}.#{argument.read('fileExtension')}")
|
20
|
-
argument.create_if_empty('selfClosing',"area,base,basefont,bgsound,br,col,frame,hr,img,isindex,input,keygen,link,meta,param,source,track,wbr")
|
21
|
-
argument.create_if_empty('sortAttribute','true')
|
22
|
-
argument.create_if_empty('singleQuote','false')
|
23
|
-
@@args = argument.hash
|
24
|
-
@@p = Parse.new(@@args)
|
25
|
-
process
|
47
|
+
parse.watch.each do |this|
|
48
|
+
file = File.join(basePath, this[:bundle] ? File.join(this[:bundle],'partial') : this[:partial] ? 'partial' : '' , this[:file])
|
49
|
+
files << file
|
50
|
+
end
|
51
|
+
|
52
|
+
#Define Core Bundle's Methods, Mixins, & Variables...
|
53
|
+
core_definition = false
|
54
|
+
if(File.exists?(File.join(File.dirname(File.expand_path(__FILE__)),'aml','core','mixin.aml')))
|
55
|
+
bundle = Parse.new(File.join(File.dirname(File.expand_path(__FILE__)), 'aml','core'),'mixin.aml')
|
56
|
+
definition = Definition.new(bundle.file,"core",false,true,true)
|
57
|
+
core_definition = true
|
26
58
|
else
|
27
|
-
log
|
28
|
-
|
29
|
-
|
59
|
+
error.log('core',false,'mixin.aml',false,'file does not exist')
|
60
|
+
end
|
61
|
+
if(File.exists?(File.join(File.dirname(File.expand_path(__FILE__)),'aml','core','method.rb')))
|
62
|
+
begin
|
63
|
+
class_eval File.read(File.join(File.dirname(File.expand_path(__FILE__)),'aml','core','method.rb'))
|
64
|
+
rescue Exception => e
|
65
|
+
x = e.message.match(error.match)
|
66
|
+
error.log('core',false,"method.rb",x[:line],x[:message])
|
30
67
|
end
|
31
|
-
|
68
|
+
else
|
69
|
+
error.log('core',false,'method.rb',false,'file does not exist')
|
32
70
|
end
|
33
|
-
|
34
|
-
|
35
|
-
|
71
|
+
|
72
|
+
#Define --watch Methods, Mixins, & Variables...
|
73
|
+
if core_definition
|
74
|
+
definition.add(parse.file,false,true,true,true)
|
75
|
+
else
|
76
|
+
definition = Definition.new(parse.file,false,true,true,true)
|
36
77
|
end
|
37
|
-
|
78
|
+
|
79
|
+
#Define Additional Bundle Methods & Mixins
|
80
|
+
definition.bundles.each do |directory,name|
|
81
|
+
if directory != 'core' then
|
82
|
+
if File.exists?(File.join(basePath,directory,'method.rb'))
|
83
|
+
begin
|
84
|
+
class_eval File.read(File.join(basePath,directory,'method.rb'))
|
85
|
+
rescue Exception => e
|
86
|
+
x = e.message.match(error.match)
|
87
|
+
error.log(directory,false,"method.rb",x[:line],x[:message])
|
88
|
+
end
|
89
|
+
else
|
90
|
+
error.log(directory,false,'method.rb',false,'file does not exist')
|
91
|
+
end
|
92
|
+
if File.exists?(File.join(basePath,directory,'mixin.aml'))
|
93
|
+
bundle = Parse.new(File.join(basePath,directory),'mixin.aml')
|
94
|
+
definition.add(bundle.file,directory,false,true,true)
|
95
|
+
else
|
96
|
+
error.log(directory,false,'mixin.aml',false,'file does not exist')
|
97
|
+
end
|
98
|
+
#Watch Additional Bundle Partials
|
99
|
+
Dir[File.join(basePath,directory,'partial','*.aml')].each do |partial|
|
100
|
+
files << partial
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
@makeFile = argument.read('fileOutput')
|
106
|
+
compile = Compile.new(parse,argument,definition,error)
|
107
|
+
if(error.count == 0)
|
108
|
+
error.log_delete
|
109
|
+
if argument.read('build') == 'false'
|
110
|
+
print "\r\b\e[0K#{Gem.loaded_specs['aml'].summary.to_s} is watching #{files.count-1} partial instance#{files.count-1 != 1 ? "s" : ""}""... (#{argument.read('aml-watch-instance').to_i+1}) "
|
111
|
+
watch = Watch.new(files, arguments, argument.read('aml-watch-instance').to_i+1, argument.read('build'))
|
112
|
+
else
|
113
|
+
puts "Build complete..."
|
114
|
+
end
|
115
|
+
else
|
116
|
+
error_count = error.count == 1 ? "" : "s"
|
117
|
+
if error.count <= argument.read('errorLimit').to_i
|
118
|
+
error.log_delete
|
119
|
+
puts error.output
|
120
|
+
else
|
121
|
+
error.log_create
|
122
|
+
print "\r\n#{error.count} error#{error_count} occured, please see error.log for details.\r\n"
|
123
|
+
end
|
124
|
+
end
|
125
|
+
else
|
126
|
+
puts "Please define the --watch or --build argument."
|
38
127
|
end
|
39
128
|
end
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
file << partial_file if File.exist?(partial_file)
|
48
|
-
end
|
49
|
-
@@watch.process(file)
|
50
|
-
message = "Watching #{file[0]}"
|
51
|
-
message += " and #{file.count-1} partial" if file.count >= 2
|
52
|
-
message += "s" if file.count >= 3
|
53
|
-
message += "...\r\n"
|
54
|
-
puts message
|
55
|
-
@@watch.watch
|
129
|
+
|
130
|
+
def self.makeFile
|
131
|
+
@makeFile
|
132
|
+
end
|
133
|
+
|
134
|
+
def self.basePath
|
135
|
+
@basePath
|
56
136
|
end
|
57
137
|
|
58
|
-
def
|
59
|
-
|
60
|
-
@@p.init(File.join(@@args[:basePath],@@args[:watch]),@@args)
|
138
|
+
def self.watchFile
|
139
|
+
@watchFile
|
61
140
|
end
|
62
141
|
end
|
63
|
-
end
|
64
|
-
require 'aml/argument'
|
65
|
-
require 'aml/log'
|
66
|
-
require 'aml/watch'
|
67
|
-
require 'aml/parse'
|
142
|
+
end
|
metadata
CHANGED
@@ -1,29 +1,39 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Esquivias
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-07-19 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Abstract Markup Language is a robust and feature rich markup language
|
14
14
|
designed to avoid repetition and promote clear, well-indented markup.
|
15
15
|
email: daniel@aml-info.org
|
16
16
|
executables:
|
17
17
|
- aml
|
18
|
+
- aml-bundle
|
18
19
|
extensions: []
|
19
20
|
extra_rdoc_files: []
|
20
21
|
files:
|
22
|
+
- bin/aml-bundle
|
23
|
+
- bin/aml
|
21
24
|
- lib/aml.rb
|
25
|
+
- lib/aml-bundle.rb
|
26
|
+
- lib/aml/definition.rb
|
27
|
+
- lib/aml/error.rb
|
28
|
+
- lib/aml/core/method.rb
|
29
|
+
- lib/aml/core/mixin.aml
|
30
|
+
- lib/aml/parse.rb
|
22
31
|
- lib/aml/argument.rb
|
23
|
-
- lib/aml/
|
32
|
+
- lib/aml/line_type.rb
|
33
|
+
- lib/aml/make.rb
|
24
34
|
- lib/aml/watch.rb
|
25
|
-
- lib/aml/
|
26
|
-
-
|
35
|
+
- lib/aml/compile.rb
|
36
|
+
- lib/aml/requirement.rb
|
27
37
|
homepage: https://aml-info.org/
|
28
38
|
licenses:
|
29
39
|
- MIT
|
@@ -44,7 +54,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
44
54
|
version: '0'
|
45
55
|
requirements: []
|
46
56
|
rubyforge_project:
|
47
|
-
rubygems_version: 2.0.
|
57
|
+
rubygems_version: 2.0.7
|
48
58
|
signing_key:
|
49
59
|
specification_version: 4
|
50
60
|
summary: Abstract Markup Language
|
data/lib/aml/log.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
class Log
|
2
|
-
|
3
|
-
@@introduction = false
|
4
|
-
@@message = []
|
5
|
-
|
6
|
-
def initialize(introduction=false)
|
7
|
-
@@introduction = introduction
|
8
|
-
end
|
9
|
-
|
10
|
-
def introduction(message)
|
11
|
-
@@introduction = message
|
12
|
-
end
|
13
|
-
|
14
|
-
def add(message)
|
15
|
-
@@message << message
|
16
|
-
end
|
17
|
-
|
18
|
-
def display(introduction=true)
|
19
|
-
puts @@introduction if(@@introduction != false) and introduction
|
20
|
-
@@message.each do |message|
|
21
|
-
puts "- #{message}"
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|