Class: Textigniter::Parsers::ManifestParser
- Inherits:
-
Object
- Object
- Textigniter::Parsers::ManifestParser
- Defined in:
- lib/textigniter/parsers/manifest_parser.rb
Instance Method Summary collapse
-
#get_manifest(filename) ⇒ Object
get the manifest.
-
#initialize ⇒ ManifestParser
constructor
A new instance of ManifestParser.
- #write_manifest(format) ⇒ Object
Constructor Details
#initialize ⇒ ManifestParser
Returns a new instance of ManifestParser.
3 4 5 |
# File 'lib/textigniter/parsers/manifest_parser.rb', line 3 def initialize end |
Instance Method Details
#get_manifest(filename) ⇒ Object
get the manifest
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/textigniter/parsers/manifest_parser.rb', line 26 def get_manifest(filename) # manifiest file path file = "#{$twd}/manifests/#{filename}.yml" # check to see if manifest exists if File.file?(file) # get the contents the_manifest = YAML::load(File.open(file)) else # fake contents the_manifest = Array.new end # return the manifiest return the_manifest end |
#write_manifest(format) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/textigniter/parsers/manifest_parser.rb', line 7 def write_manifest(format) # get the items items = Dir.glob("#{$twd}/#{format}/**/*") # create an array to store the new build list in manifest = Array.new # Clean up the build list items.each do |l| # if not a directory keep the file unless File.directory?(l) manifest.push({ filename: l, modified_at: File.mtime(l) }) end end # write the manifest to file File.open("#{$twd}/manifests/#{format}.yml", 'w') do |file| file.write manifest.to_yaml end end |