class Crusade::APNS::ManifestGenerator

Attributes

directory[RW]

Public Class Methods

new(directory) click to toggle source
# File lib/crusade/apns/push_package/manifest_generator.rb, line 8
def initialize directory
  self.directory = directory
end

Public Instance Methods

generate() click to toggle source
# File lib/crusade/apns/push_package/manifest_generator.rb, line 12
def generate
  to_hash.to_json
end

Private Instance Methods

digest(file_path) click to toggle source
# File lib/crusade/apns/push_package/manifest_generator.rb, line 37
def digest file_path
  Digest::SHA1.hexdigest File.read(file_path)
end
relative_path(absolute_path) click to toggle source
# File lib/crusade/apns/push_package/manifest_generator.rb, line 29
def relative_path absolute_path
  Pathname.new(absolute_path).relative_path_from(Pathname.new(directory))
end
should_digest?(absolute_path) click to toggle source
# File lib/crusade/apns/push_package/manifest_generator.rb, line 33
def should_digest? absolute_path
  File.file? absolute_path
end
to_hash() click to toggle source
# File lib/crusade/apns/push_package/manifest_generator.rb, line 20
def to_hash
  Dir.glob("#{directory}/**/*").inject({}) do |memo,file_path|
    if should_digest? file_path
      memo[relative_path(file_path)] = digest file_path
    end
    memo
  end
end