dryml 1.3.0.pre16 → 1.3.0.pre18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/VERSION +1 -1
  2. data/lib/dryml/dryml_doc.rb +15 -6
  3. metadata +7 -7
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.0.pre16
1
+ 1.3.0.pre18
@@ -32,15 +32,21 @@ require 'rexml/xpath'
32
32
 
33
33
  def initialize(home, filename, name=nil)
34
34
  @name = name || filename.sub(/.dryml$/, '')[home.length+1..-1]
35
+ @source = File.read(filename)
35
36
  @doc = Dryml::Parser::Document.new(File.read(filename), filename)
36
37
  parse_tag_defs
37
38
  end
38
-
39
- attr_reader :name, :doc, :tag_defs
40
-
39
+
40
+ attr_reader :name, :doc, :tag_defs, :source
41
+
41
42
  def comment
42
43
  first_node = doc[0][0]
43
- doc.restore_erb_scriptlets(first_node.to_s.strip) if first_node.is_a?(REXML::Comment)
44
+ if first_node.is_a?(REXML::Comment)
45
+ doc.restore_erb_scriptlets(first_node.to_s.strip)
46
+ elsif first_node.to_s.strip.starts_with?("[![DRYML-ERB")
47
+ text = doc.restore_erb_scriptlets(first_node.to_s.strip)
48
+ text.match(/<%#(.*?)%>/m)[1] rescue nil
49
+ end
44
50
  end
45
51
 
46
52
  include CommentMethods
@@ -76,8 +82,8 @@ require 'rexml/xpath'
76
82
  def source
77
83
  doc.restore_erb_scriptlets(node.to_s).strip
78
84
  end
79
-
80
- # The contents of the XML comment, if any, immediately above the tag definition
85
+
86
+ # The contents of the XML or ERB comment, if any, immediately above the tag definition
81
87
  def comment
82
88
  @comment ||= begin
83
89
  space = node.previous_sibling and
@@ -86,6 +92,9 @@ require 'rexml/xpath'
86
92
 
87
93
  if comment_node.is_a?(REXML::Comment)
88
94
  doc.restore_erb_scriptlets(comment_node.to_s.strip)
95
+ elsif space.to_s.strip.starts_with?("[![DRYML-ERB")
96
+ text = doc.restore_erb_scriptlets(space.to_s.strip)
97
+ text.match(/.*<%#(.*?)%>$/m)[1] rescue nil
89
98
  end
90
99
  end
91
100
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dryml
3
3
  version: !ruby/object:Gem::Version
4
- hash: -1637175965
4
+ hash: -1637175967
5
5
  prerelease: true
6
6
  segments:
7
7
  - 1
8
8
  - 3
9
9
  - 0
10
- - pre16
11
- version: 1.3.0.pre16
10
+ - pre18
11
+ version: 1.3.0.pre18
12
12
  platform: ruby
13
13
  authors:
14
14
  - Tom Locke
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-11-08 00:00:00 -04:00
19
+ date: 2010-11-19 00:00:00 -04:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -43,13 +43,13 @@ dependencies:
43
43
  requirements:
44
44
  - - "="
45
45
  - !ruby/object:Gem::Version
46
- hash: -1637175965
46
+ hash: -1637175967
47
47
  segments:
48
48
  - 1
49
49
  - 3
50
50
  - 0
51
- - pre16
52
- version: 1.3.0.pre16
51
+ - pre18
52
+ version: 1.3.0.pre18
53
53
  type: :runtime
54
54
  version_requirements: *id002
55
55
  - !ruby/object:Gem::Dependency