Sha256: 3d99c5f9b08ec0baccee2e27ed45534368dab75bccb27b3ec84f7b3628a432e6
Contents?: true
Size: 1.42 KB
Versions: 1
Compression:
Stored size: 1.42 KB
Contents
# header_detector.rb # Copyright (C) RĂ©mi Even 2016 # # This file is part of Xolti. # # Xolti is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Xolti is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Xolti. If not, see <http://www.gnu.org/licenses/>. require_relative "comment" require_relative "template_utils" module HeaderDetector def HeaderDetector.detect(path, template, comment_tokens) template_lines = Comment.comment(template, comment_tokens).lines("\n") template_regexp_lines = template_lines.map do |line| TemplateUtils.create_detection_regexp_for_line(line) end potential_header_start = 0 matches = [] File.open(path, "r").each do |line| match = template_regexp_lines[matches.length].match(line) if match matches << match if matches.length == template_regexp_lines.length return { start: potential_header_start, matches: matches } end else potential_header_start += matches.length + 1 matches = [] end end nil end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
xolti-0.2.0 | lib/header_detector.rb |