~ubuntu-branches/ubuntu/vivid/foodcritic/vivid-proposed

« back to all changes in this revision

Viewing changes to lib/foodcritic/template.rb

  • Committer: Package Import Robot
  • Author(s): Stefano Rivera
  • Date: 2013-06-11 00:34:40 UTC
  • Revision ID: package-import@ubuntu.com-20130611003440-czusooxs9rrpe6sb
Tags: upstream-2.1.0
ImportĀ upstreamĀ versionĀ 2.1.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
module FoodCritic
 
2
  module Template
 
3
 
 
4
    # Extract expressions <%= expr %> from Erb templates.
 
5
    class ExpressionExtractor
 
6
 
 
7
      include Erubis::Basic::Converter
 
8
 
 
9
      def initialize
 
10
        init_converter({})
 
11
      end
 
12
 
 
13
      def extract(template_code)
 
14
        @expressions = []
 
15
        convert(template_code)
 
16
        @expressions
 
17
      end
 
18
 
 
19
      def add_expr(src, code, indicator)
 
20
        if indicator == '='
 
21
          @expressions << {:type => :expression, :code => code.strip}
 
22
        end
 
23
      end
 
24
 
 
25
      def add_text(src, text)
 
26
 
 
27
      end
 
28
 
 
29
      def add_preamble(codebuf)
 
30
 
 
31
      end
 
32
 
 
33
      def add_postamble(codebuf)
 
34
 
 
35
      end
 
36
 
 
37
      def add_stmt(src, code)
 
38
        @expressions << {:type => :statement, :code => code.strip}
 
39
      end
 
40
 
 
41
    end
 
42
 
 
43
  end
 
44
end