aml 0.0.9 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 269daf118df596cb722b1e749453e59a03c24fd7
4
- data.tar.gz: 21f56707e802f9a1f8183b1abc65d3aee99f76b9
3
+ metadata.gz: d46123901065fe56b8a4c50b0f238a15ca7e59ff
4
+ data.tar.gz: 4a9a0cf2415bc9e6685aef3d7715c284b5051859
5
5
  SHA512:
6
- metadata.gz: 1d3fc6f980e8141150b6d496840d1e71c82287eb16506aca3192c401b09b808593658be1e2ec358473dfbae3d381fd01e503ae9319931d9a39ad8a716f2166dd
7
- data.tar.gz: 1995da921b1f8e4822575c52b375ca5b535648a5421f140df37334c72ee6e231620a1cc6358696517a54e278b8ddae868f1abfccd1937b60ff87e178f9aa3fe5
6
+ metadata.gz: 9c59f3a70af0b23062c3c5be6ece1d05661a330b64661a5decf137021f583d3ffaf66e25297f9626eb333d8dc1100a535819a58f7a30dbefb66e4413ea8b7a64
7
+ data.tar.gz: 1b90d8a2e4dd82266714ff9d526cdf67d7f2ae764d41d9a6e3058c9fe3f44e783512b365b7b275fef0ca779b7b924d0b7506f6e6e03ab81e25b87512b68d4fea
data/lib/aml/compile.rb CHANGED
@@ -28,11 +28,12 @@ class Compile
28
28
  end
29
29
 
30
30
  def prepare_method_structure(lines,definition)
31
- #Placeholder
32
31
  lines.each_with_index do |line,index|
33
32
  if line[:type] == :method
34
33
  line[:type] = :string
35
- line[:value] = "<aml bundle=\"#{line[:bundle]}\" method=\"#{line[:name]}\" />"
34
+ bundle = line[:bundle]
35
+ bundle = "Core" if bundle == 'core'
36
+ line[:value] = AbstractMarkupLanguage::Base.const_get(bundle).method(line[:name]).call(line[:index],line[:attributes])
36
37
  end
37
38
  end
38
39
  lines
@@ -1,19 +1,24 @@
1
1
  class Core
2
+
2
3
  def self.loop(index=0, a={})
3
4
  return "loop"
4
5
  end
5
- def self.date(index=0, a={:format=>'%Y-%m-%d %H:%M:%S'})
6
+
7
+ def self.date(index=0, a={}, d={:format=>'%Y-%m-%d %H:%M:%S'})
8
+ a = d.merge(a)
6
9
  time = Time.new
7
10
  return time.strftime(a[:format])
8
11
  end
12
+
13
+ def self.year(index=0, a={})
14
+ return self.date(index,{:format=>'%Y'})
15
+ end
16
+
9
17
  def self.ipsum(index=0, a={})
10
18
  return "%p lorem ipsum sit amet dolor"
11
19
  end
20
+
12
21
  def self.random(index=0, a={})
13
22
  return "random"
14
23
  end
15
- def self.copyright(index=0, a={})
16
- time = Time.new
17
- return "%p &copy; #{time.year}"
18
- end
19
24
  end
data/lib/aml/line_type.rb CHANGED
@@ -37,15 +37,15 @@ LineType = Struct.new(:regex) do
37
37
  end
38
38
  def stringHashToHash(string)
39
39
  hash = {}
40
- regex = /:(?<name>\w+)\s?=>\s?(?<hash>{(.+?)?}|(?<quote>'|")(?<value>.+?)?\k<quote>)/
40
+ regex = /:(?<name>\w+)\s?=>\s?(?<hash>{(.+?)?}|(?<quote>'|")(?<value>.+?)??\k<quote>)/
41
41
  names = regex.names
42
42
  if string != nil
43
43
  string.scan(regex){|match|
44
44
  thisHash = Hash[names.zip(match)]
45
- if thisHash["value"] != nil
46
- hash[thisHash["name"].to_sym] = thisHash["value"].to_s
47
- else
45
+ if thisHash["hash"].to_s[0] == "{"
48
46
  hash[thisHash["name"].to_sym] = stringHashToHash(thisHash["hash"])
47
+ else
48
+ hash[thisHash["name"].to_sym] = thisHash["value"].to_s
49
49
  end
50
50
  }
51
51
  end
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.9
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Esquivias
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-27 00:00:00.000000000 Z
11
+ date: 2014-03-07 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.