lib/manifest_handler.rb in inqlude-0.0.3 vs lib/manifest_handler.rb in inqlude-0.0.4

- old
+ new

@@ -22,14 +22,38 @@ @settings = settings @manifests = Array.new end + def manifest name + read_remote + @manifests.each do |manifest| + if manifest["name"] == name + return manifest + end + end + nil + end + def read_remote - Dir.glob( "#{@settings.manifest_dir}/*.manifest" ).sort.each do |filename| + fetch_remote + + Dir.glob( "#{@settings.manifest_path}/*.manifest" ).sort.each do |filename| File.open filename do |file| manifests.push JSON file.read end + end + end + + def fetch_remote + if !File.exists? @settings.manifest_path + "/.git" + if File.exists? @settings.manifest_path + system "rm -r #{@settings.manifest_path}" + end + system "git clone https://github.com/cornelius/inqlude_data.git " + + "#{@settings.manifest_path}" + else + system "cd #{@settings.manifest_path}; git pull" end end end