Sha256: 5ea459da293c2f3df60d017f2cf315c8fddab25e576f7bc2d8ae6c77dda74f9a
Contents?: true
Size: 1.17 KB
Versions: 3
Compression:
Stored size: 1.17 KB
Contents
require 'pathname' require_relative './util' require_relative './setup' class Scan #初始化 def initialize() @util = Util.instance @setup = Setup.instance @files = Array.new end #返回已经获取的文件列表 def files return @files end #获取文件 def fetch(dir) Dir::entries(dir).each do |filename| #忽略的文件 next if @util.is_shadow_file?(filename) #检查是否配置文件中所忽略的文件 #这里需要用相对路径 next if @setup.is_user_ignore_file?(filename) file = File::join(dir, filename) #如果是文件夹类型, 则继承查找 if(File.ftype(file) == 'directory') self.fetch file next end #如果文件扩展名是md, 则加入到files中 if @util.is_markdown_file?(filename) current_dir = Pathname.new file @files.push current_dir.relative_path_from(@setup.content_dir) end end end #执行 def execute() fetch @setup.content_dir end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
m2m-0.2.3 | lib/scan.rb |
m2m-0.2.1 | lib/scan.rb |
m2m-0.2.0 | lib/scan.rb |