aml 0.1.1.1 → 0.1.2
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/lib/aml.rb +8 -145
- data/lib/aml/Argument.rb +100 -0
- data/lib/aml/Build.rb +203 -0
- data/lib/aml/Cluster.rb +201 -0
- data/lib/aml/Compile.rb +217 -0
- data/lib/aml/Definition.rb +71 -0
- data/lib/aml/Line.rb +80 -0
- data/lib/aml/Parse.rb +24 -0
- data/lib/aml/Prepare.rb +59 -0
- data/lib/aml/core/method.rb +17 -2
- data/lib/aml/core/mixin.aml +1 -1
- metadata +10 -14
- data/bin/aml-bundle +0 -3
- data/lib/aml-bundle.rb +0 -52
- data/lib/aml/argument.rb +0 -80
- data/lib/aml/compile.rb +0 -325
- data/lib/aml/definition.rb +0 -71
- data/lib/aml/error.rb +0 -97
- data/lib/aml/line_type.rb +0 -57
- data/lib/aml/make.rb +0 -12
- data/lib/aml/parse.rb +0 -81
- data/lib/aml/requirement.rb +0 -9
- data/lib/aml/watch.rb +0 -38
data/lib/aml/definition.rb
DELETED
@@ -1,71 +0,0 @@
|
|
1
|
-
class DefinitionVariable
|
2
|
-
@variable = {}
|
3
|
-
def initialize(variable)
|
4
|
-
@variable = variable
|
5
|
-
end
|
6
|
-
def variable(name,line,bundle=false)
|
7
|
-
@variable[bundle].select{|variable| variable == name}.first[1].select{|line_number,value| line_number <= line}.values.last if (@variable.has_key?(bundle) and @variable[bundle].has_key?(name))
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
class Definition
|
12
|
-
def initialize(parse,scope=false,add_bundle=true,add_mixin=true,add_variable=true)
|
13
|
-
@bundle = {}
|
14
|
-
@mixin = {}
|
15
|
-
@variable = {}
|
16
|
-
add(parse,scope,add_bundle,add_mixin,add_variable)
|
17
|
-
end
|
18
|
-
def add(parse,scope=false,add_bundle=true,add_mixin=true,add_variable=true)
|
19
|
-
#define bundles
|
20
|
-
parse[:line].select{|k,v| k[:type] == :method or k[:type] == :partial or k[:type] == :mixin}.each do |bundle|
|
21
|
-
@bundle[bundle[:bundle]] = camelCase(bundle[:bundle]) if @bundle.has_key?(bundle[:bundle]) == false and bundle[:bundle] != false
|
22
|
-
end if add_bundle
|
23
|
-
#define mixins
|
24
|
-
mixin_def = parse[:line].reject{|k,v| k[:type] != :mixin_def}
|
25
|
-
mixin_end = parse[:line].reject{|k,v| k[:type] != :mixin_end}
|
26
|
-
if(mixin_def.count == mixin_end.count)
|
27
|
-
mixin_def.each_with_index do |mixin,index|
|
28
|
-
mixin[:bundle] = scope if scope
|
29
|
-
@mixin[mixin[:bundle]] = {} if @mixin.has_key?(mixin[:bundle]) == false
|
30
|
-
@mixin[mixin[:bundle]][mixin[:name]] = {} if @mixin[mixin[:bundle]].has_key?(mixin[:name]) == false
|
31
|
-
@mixin[mixin[:bundle]][mixin[:name]] = {
|
32
|
-
:attribute => mixin[:attributes],
|
33
|
-
:structure => parse[:line].reject{|k,v| k[:number].between?(mixin[:number]+1,mixin_end[index][:number]-1) == false}
|
34
|
-
}
|
35
|
-
@mixin[mixin[:bundle]][mixin[:name]][:structure].each do |line|
|
36
|
-
line[:index]-=1
|
37
|
-
end
|
38
|
-
parse[:line] = parse[:line].reject{|k,v| k[:number].between?(mixin[:number],mixin_end[index][:number])}
|
39
|
-
end
|
40
|
-
end if add_mixin
|
41
|
-
#define variables
|
42
|
-
variable = parse[:line].reject{|k,v| k[:type] != :variable_def}
|
43
|
-
variable.each do |var|
|
44
|
-
var[:bundle] = scope if scope
|
45
|
-
@variable[var[:bundle]] = {} if @variable.has_key?(var[:bundle]) == false
|
46
|
-
@variable[var[:bundle]][var[:name]] = {} if @variable[var[:bundle]].has_key?(var[:name]) == false
|
47
|
-
@variable[var[:bundle]][var[:name]][var[:number]] = var[:value]
|
48
|
-
end if add_variable
|
49
|
-
end
|
50
|
-
def camelCase(value)
|
51
|
-
value.split('-').each{|i|i.capitalize!}.join if value != false
|
52
|
-
end
|
53
|
-
def bundles
|
54
|
-
@bundle
|
55
|
-
end
|
56
|
-
def variables
|
57
|
-
@variable
|
58
|
-
end
|
59
|
-
def variable(name,line,bundle=false)
|
60
|
-
@variable[bundle].select{|variable| variable == name}.first[1].select{|line_number,value| line_number <= line}.values.last if (@variable.has_key?(bundle) and @variable[bundle].has_key?(name))
|
61
|
-
end
|
62
|
-
def mixins
|
63
|
-
@mixin
|
64
|
-
end
|
65
|
-
def mixins_of(bundle=false)
|
66
|
-
@mixin[bundle]
|
67
|
-
end
|
68
|
-
def mixin(name,bundle=false)
|
69
|
-
@mixin[bundle].select{|mixin|mixin==name}.first[1] if(@mixin.has_key?(bundle) and @mixin[bundle].has_key?(name))
|
70
|
-
end
|
71
|
-
end
|
data/lib/aml/error.rb
DELETED
@@ -1,97 +0,0 @@
|
|
1
|
-
class Error
|
2
|
-
@errors
|
3
|
-
@warnings
|
4
|
-
def initialize
|
5
|
-
@errors = []
|
6
|
-
@warnings = []
|
7
|
-
end
|
8
|
-
def warnings
|
9
|
-
@warnings
|
10
|
-
end
|
11
|
-
def log(bundle,partial,file,line,message,warning=false)
|
12
|
-
file = "partial/#{file}" if partial != false
|
13
|
-
file = "#{bundle}/#{file}" if bundle != false
|
14
|
-
line = line ? "::#{line}" : nil
|
15
|
-
text = "#{file}#{line} #{message}"
|
16
|
-
if warning
|
17
|
-
@warnings << text
|
18
|
-
else
|
19
|
-
@errors << text
|
20
|
-
end
|
21
|
-
end
|
22
|
-
def count
|
23
|
-
@errors.count
|
24
|
-
end
|
25
|
-
def log_delete
|
26
|
-
begin
|
27
|
-
File.delete(File.join(AbstractMarkupLanguage::Base.basePath,'aml-log'))
|
28
|
-
rescue Exception => e
|
29
|
-
end
|
30
|
-
end
|
31
|
-
def log_create
|
32
|
-
error_output = ""
|
33
|
-
@errors.each do |error|
|
34
|
-
error_output += "Error: #{error}\r\n"
|
35
|
-
end
|
36
|
-
@warnings.each do |warning|
|
37
|
-
error_output += "Warning: #{warning}\r\n"
|
38
|
-
end
|
39
|
-
File.write(File.join(AbstractMarkupLanguage::Base.basePath,'aml-log'),error_output)
|
40
|
-
end
|
41
|
-
def output
|
42
|
-
@errors.each do |error|
|
43
|
-
error
|
44
|
-
end
|
45
|
-
end
|
46
|
-
def match
|
47
|
-
/\((\w+)\)\:(?<line>\d+)\:(\s{1,})?(?<message>.+)/
|
48
|
-
end
|
49
|
-
def compile(parse,definition,error)
|
50
|
-
error.syntax(parse,false,false,error)
|
51
|
-
#Check Tag, Partial, Mixin Call, and Method Call Attributes for Errors
|
52
|
-
parse.watch.each do |file|
|
53
|
-
if file[:partial]
|
54
|
-
file_path = File.join(AbstractMarkupLanguage::Base.basePath,'partial')
|
55
|
-
file_path = File.join(AbstractMarkupLanguage::Base.basePath,file[:bundle],'partial') if file[:bundle]
|
56
|
-
partial_parse = Parse.new(file_path,file[:file])
|
57
|
-
error.syntax(partial_parse,file[:bundle],file[:partial],error)
|
58
|
-
end
|
59
|
-
end
|
60
|
-
#Check Mixin Definitions for Errors
|
61
|
-
definition.mixins.each do |bundle,mixins|
|
62
|
-
if(bundle != false and bundle != 'core')
|
63
|
-
file_path = File.join(AbstractMarkupLanguage::Base.basePath,bundle)
|
64
|
-
mixin_parse = Parse.new(file_path,'mixin.aml')
|
65
|
-
error.syntax(mixin_parse,bundle,false,error)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
def syntax(parse,bundle=false,partial=false,error)
|
70
|
-
parse.file[:line].each do |line|
|
71
|
-
if(line[:attributes] && line[:attributes][:abstract_markup_language_exception] or partial && line[:type] == :mixin_def)
|
72
|
-
#Mixin definition in partials is not possible...
|
73
|
-
if line[:type] == :mixin_def and partial
|
74
|
-
file_to_define = bundle ? "#{bundle}/minxin.aml" : AbstractMarkupLanguage::Base.watchFile
|
75
|
-
error.log(bundle,partial,parse.file[:name],line[:number],"mixin must be defined in #{file_to_define}; #{line[:name]} cannot be defined in a partial")
|
76
|
-
else
|
77
|
-
line[:type] = "mixin definition" if line[:type] == :mixin_def
|
78
|
-
error.log(bundle,partial,parse.file[:name],line[:number],"attribute syntax error on #{line[:name]} #{line[:type]}")
|
79
|
-
end
|
80
|
-
end
|
81
|
-
if line[:type] == :method
|
82
|
-
begin
|
83
|
-
#ap AbstractMarkupLanguage::Base.const_get(definition.camelCase(line[:bundle])).method(line[:name]).call()
|
84
|
-
rescue Exception => e
|
85
|
-
message = "#{line[:name]} method undefined in #{line[:bundle]} bundle"
|
86
|
-
if !AbstractMarkupLanguage::Base.constants.include? definition.camelCase(line[:bundle]).to_sym
|
87
|
-
message = "#{line[:bundle]} bundle undefined"
|
88
|
-
end
|
89
|
-
error.log(bundle,partial,parse.file[:name],line[:number],message)
|
90
|
-
false
|
91
|
-
end
|
92
|
-
#.method(line[:name]).call()
|
93
|
-
#ap Base.const_get(line[:bundle]).method(line[:name]).call()
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
data/lib/aml/line_type.rb
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
LineType = Struct.new(:regex) do
|
2
|
-
def match?(string)
|
3
|
-
string.match(regex)
|
4
|
-
end
|
5
|
-
def attributes(match)
|
6
|
-
begin
|
7
|
-
stringHashToHash(match[:attributes])
|
8
|
-
rescue Exception => e
|
9
|
-
{:abstract_markup_language_exception=>true}
|
10
|
-
end
|
11
|
-
end
|
12
|
-
def bundle(match)
|
13
|
-
match[:bundle].to_s
|
14
|
-
end
|
15
|
-
def class(match)
|
16
|
-
match[:class].to_s.split('.').join(' ').strip!
|
17
|
-
end
|
18
|
-
def name(match)
|
19
|
-
match[:name].to_s
|
20
|
-
end
|
21
|
-
def text(match)
|
22
|
-
match[:text].to_s.strip!
|
23
|
-
end
|
24
|
-
def value(match)
|
25
|
-
match[:value].to_s
|
26
|
-
end
|
27
|
-
def id_first(match)
|
28
|
-
match[:id_first].to_s
|
29
|
-
end
|
30
|
-
def id_last(match)
|
31
|
-
match[:id_last].to_s
|
32
|
-
end
|
33
|
-
def close(match)
|
34
|
-
# => </tag> /self> >
|
35
|
-
type = %w(tag self none)
|
36
|
-
type[match[:close].to_s.length]
|
37
|
-
end
|
38
|
-
def tab_reset(match)
|
39
|
-
match[:tab_reset].to_s
|
40
|
-
end
|
41
|
-
def stringHashToHash(string)
|
42
|
-
hash = {}
|
43
|
-
regex = /:(?<name>\w+)\s?=>\s?(?<hash>{(.+?)?}|(?<quote>'|")(?<value>.+?)??\k<quote>)/
|
44
|
-
names = regex.names
|
45
|
-
if string != nil
|
46
|
-
string.scan(regex){|match|
|
47
|
-
thisHash = Hash[names.zip(match)]
|
48
|
-
if thisHash["hash"].to_s[0] == "{"
|
49
|
-
hash[thisHash["name"].to_sym] = stringHashToHash(thisHash["hash"])
|
50
|
-
else
|
51
|
-
hash[thisHash["name"].to_sym] = thisHash["value"].to_s
|
52
|
-
end
|
53
|
-
}
|
54
|
-
end
|
55
|
-
hash
|
56
|
-
end
|
57
|
-
end
|
data/lib/aml/make.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
class Make
|
2
|
-
def initialize(structure)
|
3
|
-
makeFile = File.join(AbstractMarkupLanguage::Base.basePath,AbstractMarkupLanguage::Base.makeFile)
|
4
|
-
File.open(makeFile, 'w'){|file|
|
5
|
-
struct_count = structure.count-1
|
6
|
-
structure.each_with_index do |line,index|
|
7
|
-
new_line = (index < struct_count) ? $/ : ""
|
8
|
-
file.write(line+new_line) if line.strip.length > 0
|
9
|
-
end
|
10
|
-
}
|
11
|
-
end
|
12
|
-
end
|
data/lib/aml/parse.rb
DELETED
@@ -1,81 +0,0 @@
|
|
1
|
-
class Parse
|
2
|
-
def file
|
3
|
-
return @file
|
4
|
-
end
|
5
|
-
def watch
|
6
|
-
return @watch
|
7
|
-
end
|
8
|
-
def mixin
|
9
|
-
return @mixin
|
10
|
-
end
|
11
|
-
def initialize(path, file, partial=false, bundle=false)
|
12
|
-
@path = path
|
13
|
-
@regex = {
|
14
|
-
:attribute => /@\(\:(?<name>[\w|\-]+)\)/,
|
15
|
-
:comment => /%!--[^%]*--%$/,
|
16
|
-
:variable => /\@\(((?<bundle>[\w|\-]+)\.)?(?<name>[\w|\-]+)\)/
|
17
|
-
}
|
18
|
-
@types = {
|
19
|
-
:method => LineType.new(/^(\s{1,})?::((?<bundle>[\w|\-]+)\.)?(?<name>[\w|\-]+)(\{(?<attributes>.+)\})?(?<value>.+)?/),
|
20
|
-
:variable_def => LineType.new(/^(\s{1,})?\@((?<bundle>[\w|\-]+)\.)?(?<name>[\w|\-]+)\s?(\=)\s?(?<value>.+)?$/),
|
21
|
-
:mixin => LineType.new(/^(\s{1,})?%\(((?<bundle>[\w|\-]+)\.)?(?<name>[^~][\w|\-]+)\)(\{(?<attributes>.+)\})?[^\{]?/),
|
22
|
-
:mixin_def => LineType.new(/^%%(?<name>[\w|\-]+)(\((?<attributes>.+?)\))?{/),
|
23
|
-
:mixin_end => LineType.new(/^\}$/),
|
24
|
-
:partial => LineType.new(/^(\s{1,})?%\(\~((?<bundle>[\w|\-]+)\.)?(?<name>[\w|\-]+)\)(\{(?<attributes>.+)\}[^\{]?)?$/),
|
25
|
-
:tag => LineType.new(/^(\s{1,})?(?<!%)%(?<close>\/{0,2})?(?<name>[\w|\-]+)(?<tab_reset>\*{1,})?(\#(?<id_first>(\@\(([\w|-]+\.)?)?[\w|\-]+(\))?))?(?<class>(\.[\w|\-]+)?{1,})?(\#(?<id_last>[\w|\-]+))?(\{(?<attributes>.+)\})?(?<text>.+)?/),
|
26
|
-
:empty => LineType.new(/^$/),
|
27
|
-
:eval => LineType.new(/^(\s{1,})?==(\s{1,})(?<value>.+)?/),
|
28
|
-
:string => LineType.new(/(\s{1,})?(?<value>.+)?/)
|
29
|
-
}
|
30
|
-
@file = {}
|
31
|
-
@watch = []
|
32
|
-
@mixin = []
|
33
|
-
read(file, partial, bundle)
|
34
|
-
end
|
35
|
-
def read(file, partial, bundle)
|
36
|
-
line_number = 0
|
37
|
-
line_struct = []
|
38
|
-
File.open(File.join(@path,file)).read.gsub(@regex[:comment],'').each_line do |line|
|
39
|
-
@types.each do |type, line_type|
|
40
|
-
if match = line_type.match?(line)
|
41
|
-
struct = Hash[match.names.zip(match.captures)]
|
42
|
-
struct = Hash[struct.map{|(k,v)| [k.to_sym,v]}]
|
43
|
-
struct[:index] = line.match(/^\t{0,}/).to_s.length
|
44
|
-
struct[:number] = line_number+=1
|
45
|
-
struct[:type] = type
|
46
|
-
match.names.each do |name|
|
47
|
-
struct[name.to_sym] = line_type.send(name.to_s, match)
|
48
|
-
end
|
49
|
-
if struct[:name].to_s[0,1] == '.'
|
50
|
-
#set undefined bundle
|
51
|
-
struct[:bundle] = 'core'
|
52
|
-
struct[:name] = struct[:name][1,struct[:name].length]
|
53
|
-
end
|
54
|
-
struct[:bundle] = false if struct[:bundle].to_s.length == 0
|
55
|
-
#set undefined method bundle
|
56
|
-
struct[:bundle] = 'core' if struct[:type] == :method and !struct[:bundle]
|
57
|
-
struct[:bundle] = bundle if bundle != false
|
58
|
-
struct[:id] = struct[:id_first].to_s.length > 0 ? struct[:id_first] : struct[:id_last]
|
59
|
-
struct.delete(:id_first)
|
60
|
-
struct.delete(:id_last)
|
61
|
-
line_struct << Hash[struct.sort] if struct[:type] != :empty
|
62
|
-
break
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
@file = {:name => file, :line => line_struct}
|
67
|
-
@watch << {:file => file, :bundle => false, :partial => false}
|
68
|
-
partial_watch(line_struct)
|
69
|
-
mixin_watch(line_struct)
|
70
|
-
end
|
71
|
-
def partial_watch(struct)
|
72
|
-
struct.reject{|k,v| k[:type] != :partial}.each do |partial|
|
73
|
-
@watch << {:file => "#{partial[:name]}.aml", :bundle=> partial[:bundle], :partial => true}
|
74
|
-
end
|
75
|
-
end
|
76
|
-
def mixin_watch(struct)
|
77
|
-
struct.reject{|k,v| k[:type] != :mixin}.each do |partial|
|
78
|
-
@mixin << {:file => "mixin.aml", :bundle=> partial[:bundle], :partial => false} if partial[:bundle] != 'core'
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
data/lib/aml/requirement.rb
DELETED
data/lib/aml/watch.rb
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
class Watch
|
2
|
-
def initialize(filenames, arguments, instance, build)
|
3
|
-
@arguments = arguments
|
4
|
-
@instance = instance
|
5
|
-
filenames = [filenames] if(filenames.kind_of?String)
|
6
|
-
@last_mtimes = {}
|
7
|
-
filenames.each do |filename|
|
8
|
-
@last_mtimes[filename] = File.stat(filename).mtime if File.exists?(filename)
|
9
|
-
end
|
10
|
-
@filenames = filenames
|
11
|
-
watch
|
12
|
-
end
|
13
|
-
def watch(sleep=1)
|
14
|
-
loop do
|
15
|
-
begin
|
16
|
-
Kernel.sleep sleep until file_updated?
|
17
|
-
rescue SystemExit,Interrupt
|
18
|
-
puts ""
|
19
|
-
Kernel.exit!
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
def file_updated?
|
24
|
-
@filenames.each do |filename|
|
25
|
-
if File.exists?(filename)
|
26
|
-
mtime = File.stat(filename).mtime
|
27
|
-
updated = @last_mtimes[filename] < mtime
|
28
|
-
@last_mtimes[filename] = mtime
|
29
|
-
if(updated)
|
30
|
-
exec("aml #{@arguments} --aml-watch-instance #{@instance}")
|
31
|
-
Kernel.exit!
|
32
|
-
return true
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
return false
|
37
|
-
end
|
38
|
-
end
|