class Object

Public Instance Methods

determine_directory!() click to toggle source

require 'commands/serve'

this was added for testability because I couldn't figure out something better.
# File lib/commands/commands.rb, line 10
def determine_directory!
  files = Dir['*/pass.json']
  @directory ||= case files.length
                 when 0 then nil
                 when 1 then File.dirname(files.first)
                 else
                   @directory = choose "Select a directory:", *files.collect{|f| File.dirname(f)}
                 end
end
determine_type!() click to toggle source
# File lib/commands/generate.rb, line 37
def determine_type!
  @type ||= choose "Select a pass type", *Passbook::PKPass::TYPES
end
validate_certificate!() click to toggle source
# File lib/commands/commands.rb, line 26
def validate_certificate!
  say_error "Missing or invalid certificate file" and abort if @certificate.nil? or not File.exist?(@certificate) 
end
validate_directory!() click to toggle source
# File lib/commands/commands.rb, line 20
def validate_directory!
  say_error "Missing argument" and abort if @directory.nil?
  say_error "Directory #{@directory} does not exist" and abort unless File.directory?(@directory)
  say_error "Directory #{@directory} is not a valid pass" and abort unless File.exist?(File.join(@directory, "pass.json"))
end
validate_output_filepath!() click to toggle source
# File lib/commands/build.rb, line 59
def validate_output_filepath!
  say_error "Filepath required" and abort if @filepath.nil? or @filepath.empty?
  say_error "#{@filepath} already exists" and abort if File.exist?(@filepath)
end
validate_type!() click to toggle source
# File lib/commands/generate.rb, line 41
def validate_type!
  say_error %{Invalid type: "#{@type}", expected one of: [#{Passbook::PKPass::TYPES.join(', ')}]} and abort unless Passbook::PKPass::TYPES.include?(@type)
end