module FileParser

Public Class Methods

make_hash(path, file, parent_dir) click to toggle source
# File lib/codefusion/file_parser.rb, line 2
def self.make_hash(path, file, parent_dir)
  { folder_name:  "",
    files:        FileParser.return_file(path, file, parent_dir) }
end
shortened_path(path, parent_dir) click to toggle source
# File lib/codefusion/file_parser.rb, line 7
def self.shortened_path(path, parent_dir)
  path.slice!(parent_dir)
  path[1..-1]
end

Private Class Methods

return_file(path, file, parent_dir) click to toggle source
# File lib/codefusion/file_parser.rb, line 13
def self.return_file(path, file, parent_dir)
  begin
    if File.read( File.join(path, file) ).to_json
  [ { file_name:    FileParser.shortened_path( File.join(path, file), parent_dir ),
      file_content: File.read( File.join(path, file) )
    }
  ]
    end
  rescue Exception => e
    View.wrong_filetype_message( File.extname(file) )
    exit
  end
end