aml 0.0.4 → 0.0.5
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/lib/aml/compile.rb +39 -4
- data/lib/aml/definition.rb +10 -0
- data/lib/aml/parse.rb +5 -3
- data/lib/aml/requirement.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56b842efcba90148f5942d42734c201b2ad9a50f
|
4
|
+
data.tar.gz: 3fe39d419cc1b58aa15023ef03a63c66eeb9fce2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 212d3cdc3ef4380fe682a7ae76ed1171858169bf226c87c34c898b554e432ab5cf6d289b90473bfd902c40dd97e4929fd3f98cc281a4b0fb0cd56d5984c7d8a3
|
7
|
+
data.tar.gz: f21a2425a47952923c091cdfd4b3438f930efe6ac77f302c422ad96049daa8a326b095602e3f5903a3cf8c4c0d611113a193e44ad04eb6b3a5bc7a9d8a71eaa4
|
data/lib/aml/compile.rb
CHANGED
@@ -7,6 +7,7 @@ class Compile
|
|
7
7
|
if(error.count == 0)
|
8
8
|
prepare_line_variable(parse.file[:line],definition)
|
9
9
|
prepare_mixin_structure(parse.file[:line],definition)
|
10
|
+
prepare_partial_structure(parse.file[:line],definition)
|
10
11
|
structure = prepare_structure(parse.file[:line])
|
11
12
|
structure.each do |group|
|
12
13
|
recursive_close(group)
|
@@ -15,6 +16,39 @@ class Compile
|
|
15
16
|
end
|
16
17
|
end
|
17
18
|
|
19
|
+
def prepare_partial_structure(lines,definition)
|
20
|
+
definition_partial = definition.variables.clone
|
21
|
+
bundle = nil
|
22
|
+
lines.each_with_index do |line,index|
|
23
|
+
if line[:type] == :partial
|
24
|
+
lines.delete_at index
|
25
|
+
bundle = line[:bundle]
|
26
|
+
directory = 'partial'
|
27
|
+
directory = File.join(line[:bundle],directory) if line[:bundle]
|
28
|
+
directory = File.join(AbstractMarkupLanguage::Base.basePath, directory)
|
29
|
+
variable = {}
|
30
|
+
definition.variables[line[:bundle]].each do |var,val|
|
31
|
+
value = val.count > 1 ? val.to_a.last[1] : val[1]
|
32
|
+
value = line[:attributes][var.to_sym] if line[:attributes].has_key?(var.to_sym)
|
33
|
+
variable[var] = {1 => value} if value != nil
|
34
|
+
end
|
35
|
+
partial = Parse.new(File.join(directory),"#{line[:name]}.aml",true, line[:bundle])
|
36
|
+
partial.file[:line].each_with_index do |pline,pindex|
|
37
|
+
pline[:index] += line[:index]
|
38
|
+
pline[:number] = line[:number]
|
39
|
+
lines.insert(index+pindex,pline)
|
40
|
+
end
|
41
|
+
definition_partial[line[:bundle]] = definition_partial[line[:bundle]].merge(variable)
|
42
|
+
vars = DefinitionVariable.new(definition_partial)
|
43
|
+
prepare_line_variable(lines,vars)
|
44
|
+
break
|
45
|
+
end
|
46
|
+
end
|
47
|
+
prepare_partial_structure(lines,definition) if(lines.select{|k|k[:type]==:partial}).count > 0
|
48
|
+
prepare_line_variable(lines,definition)
|
49
|
+
lines
|
50
|
+
end
|
51
|
+
|
18
52
|
def prepare_line_variable(lines,definition)
|
19
53
|
regex = /\@\(((?<bundle>[\w|\-]+)\.)?(?<name>[\w|\-]+)\)/
|
20
54
|
if lines.kind_of?(Array)
|
@@ -150,16 +184,17 @@ class Compile
|
|
150
184
|
|
151
185
|
end
|
152
186
|
|
153
|
-
def tag_line_attributes(line)
|
187
|
+
def tag_line_attributes(line,base="")
|
154
188
|
if line[:type] == :tag
|
155
189
|
line[:attributes][:id] = line[:id] if line[:id].to_s.length > 0 and line[:attributes][:id].to_s.length == 0
|
156
190
|
line[:attributes][:class] = line[:class] if line[:class].to_s.length > 0 and line[:attributes][:class].to_s.length == 0
|
157
191
|
attributes = ""
|
158
|
-
line[:attributes].each do |
|
159
|
-
attributes
|
160
|
-
attributes
|
192
|
+
line[:attributes].each do |key,value|
|
193
|
+
attributes << " #{key.to_s}=\"#{value.to_s}\"" if(value.to_s.length) > 0 and value.to_s != 'nil'
|
194
|
+
attributes << " #{key.to_s}" if(value.to_s) == "nil"
|
161
195
|
end
|
162
196
|
attributes
|
163
197
|
end
|
164
198
|
end
|
199
|
+
|
165
200
|
end
|
data/lib/aml/definition.rb
CHANGED
@@ -1,3 +1,13 @@
|
|
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
|
+
|
1
11
|
class Definition
|
2
12
|
def initialize(parse,scope=false,add_bundle=true,add_mixin=true,add_variable=true)
|
3
13
|
@bundle = {}
|
data/lib/aml/parse.rb
CHANGED
@@ -5,7 +5,7 @@ class Parse
|
|
5
5
|
def watch
|
6
6
|
return @watch
|
7
7
|
end
|
8
|
-
def initialize(path, file)
|
8
|
+
def initialize(path, file, partial=false, bundle=false)
|
9
9
|
@path = path
|
10
10
|
@regex = {
|
11
11
|
:attribute => /@\(\:(?<name>[\w|\-]+)\)/,
|
@@ -26,9 +26,9 @@ class Parse
|
|
26
26
|
}
|
27
27
|
@file = {}
|
28
28
|
@watch = []
|
29
|
-
read(file,
|
29
|
+
read(file, partial, bundle)
|
30
30
|
end
|
31
|
-
def read(file, partial)
|
31
|
+
def read(file, partial, bundle)
|
32
32
|
line_number = 0
|
33
33
|
line_struct = []
|
34
34
|
File.open(File.join(@path,file)).read.gsub(@regex[:comment],'').each_line do |line|
|
@@ -50,6 +50,8 @@ class Parse
|
|
50
50
|
struct[:bundle] = false if struct[:bundle].to_s.length == 0
|
51
51
|
#set undefined method bundle
|
52
52
|
struct[:bundle] = 'core' if struct[:type] == :method and !struct[:bundle]
|
53
|
+
|
54
|
+
struct[:bundle] = bundle if bundle != false
|
53
55
|
struct[:id] = struct[:id_first].to_s.length > 0 ? struct[:id_first] : struct[:id_last]
|
54
56
|
struct.delete(:id_first)
|
55
57
|
struct.delete(:id_last)
|
data/lib/aml/requirement.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.5
|
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-12-10 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.
|