class Swarker::Readers::PathsReader
Attributes
paths[R]
Public Class Methods
new(dir)
click to toggle source
# File lib/swarker/readers/paths_reader.rb, line 8 def initialize(dir) @paths = read_paths(dir) end
Private Instance Methods
base_dir(dir)
click to toggle source
# File lib/swarker/readers/paths_reader.rb, line 28 def base_dir(dir) dir.split('/').slice(0..-2).join('/') end
path_name(dir, file_path)
click to toggle source
# File lib/swarker/readers/paths_reader.rb, line 20 def path_name(dir, file_path) file_path.sub(base_dir(dir), '').scan(%r{\A[\/\w]+}).first.gsub(/__(\w+)/, '{\1}') + '.json' end
paths_files(dir)
click to toggle source
# File lib/swarker/readers/paths_reader.rb, line 24 def paths_files(dir) Dir["#{dir}/**/*.json"] + Dir["#{dir}/**/*.json.yml"] + Dir["#{dir}/**/*.json.yml.erb"] end
read_paths(dir)
click to toggle source
# File lib/swarker/readers/paths_reader.rb, line 14 def read_paths(dir) paths_files(dir).collect do |file| Swarker::Path.new(path_name(dir, file), FileReader.new(file).read) end end