Sha256: fa6127fb197b6a83517c8948097f6cf6ad6620a2208abbf86b6bf6006783e397
Contents?: true
Size: 1.24 KB
Versions: 5
Compression:
Stored size: 1.24 KB
Contents
module PluginTool # NOTE: Also update packing.rb if this changes ALLOWED_PLUGIN_DIRS = ['js', 'static', 'template', 'test', 'data'] def self.generate_manifest(directory) manifest = Hash.new Dir.glob("#{directory}/**/*").sort.each do |pathname| # Ignore directories next unless File.file? pathname # Check file filename = pathname.slice(directory.length + 1, pathname.length) raise "Bad filename for #{filename}" unless filename =~ /\A([a-zA-Z0-9_\/\-]+\/)?([a-z0-9_-]+\.[a-z0-9]+)\z/ dir = $1 name = $2 if dir != nil dir = dir.gsub(/\/\z/,'') raise "Bad directory #{dir}" unless dir =~ /\A([a-zA-Z0-9_\-]+)[a-zA-Z0-9_\/\-]*\z/ raise "Bad root directory #{$1}" unless ALLOWED_PLUGIN_DIRS.include?($1) end # Get hash of file digest = File.open(pathname) { |f| Digest::SHA1.hexdigest(f.read) } # And add to manifest manifest[filename] = digest end manifest end def self.determine_manifest_changes(from, to) changes = [] from.each_key do |name| changes << [name, :delete] unless to.has_key?(name) end to.each do |name,hash| changes << [name, hash] unless from[name] == hash end changes end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
oneis-1.2.1-java | lib/manifest.rb |
oneis-1.2.0-java | lib/manifest.rb |
oneis-1.1.0-java | lib/manifest.rb |
oneis-1.0.4-java | lib/manifest.rb |
oneis-1.0.1-java | lib/manifest.rb |