class Object
Public Instance Methods
validate_gravity!()
click to toggle source
# File lib/acbaker/commands/pack.rb, line 97 def validate_gravity! @gravity ||= "Center" abort("error: Invalid gravity specified.") unless ["NorthWest", "North", "NorthEast", "West", "Center", "East", "SouthWest", "South", "SouthEast"].include?(@gravity) end
validate_image!()
click to toggle source
# File lib/acbaker/commands/pack.rb, line 55 def validate_image! # validate image is set abort("Error: no image specified.") if @image.nil? # validate image exists abort("Error: can't find the image you specified. #{@image}") unless File.exist?(@image) and File.file?(@image) end
validate_image_magick!()
click to toggle source
# File lib/acbaker/commands/pack.rb, line 51 def validate_image_magick! abort('You need to install Image Magick! Check http://www.imagemagick.org for instructions.') unless system("which convert > /dev/null 2>&1") end
validate_json!()
click to toggle source
# File lib/acbaker/commands/pack.rb, line 113 def validate_json! if @json abort("error: JSON file not found.") if !File.exist?(@json) or !File.file?(@json) begin JSON.parse(File.open(@json).read) rescue StandardError abort("error: invalid JSON file: #{@json}") end @type ||= :Custom end end
validate_output_directory!()
click to toggle source
# File lib/acbaker/commands/pack.rb, line 125 def validate_output_directory! @output_directory ||= { AppIcon: "AppIcon.appiconset", LaunchImage: "LaunchImage.launchimage" }[@type] # Create custom output directory if type is set @output_directory = "#{@type}.imageset" if !@output_directory and @type abort("Error: No output directory specified or detected.") if @output_directory.nil? parent_directory = File.expand_path(@output_directory).split("/")[0..-2].join("/") abort("Error: Parent directory '#{parent_directory}' does not exist.") unless File.exist?(parent_directory) and File.directory?(parent_directory) # Prepare output directory if @force FileUtils.rm_rf(@output_directory) if File.directory?(@output_directory) end FileUtils.mkdir(@output_directory) unless File.directory?(@output_directory) end
validate_strategy!()
click to toggle source
# File lib/acbaker/commands/pack.rb, line 102 def validate_strategy! @strategy ||= "Cover" # try to instantiate strategy class begin Object.const_get("Acbaker::Processors::#{@strategy}") rescue StandardError abort("error: Invalid strategy specified.") end end
validate_type!()
click to toggle source
# File lib/acbaker/commands/pack.rb, line 63 def validate_type! unless @type # Detect from image token = @image.split('/')[-1].split('.')[0].downcase.to_sym @type = { appicon: :AppIcon, launchimage: :LaunchImage, icon: :AppIcon, launch: :LaunchImage }[token] end if !@type and @output_directory # Detect from directory token = @output_directory.gsub('.', '').downcase.to_sym @type = { appiconappiconset: :AppIcon, appicon: :AppIcon, launchimagelaunchimage: :LaunchImage, launchimage: :LaunchImage }[token] end # Fill json if @type and !@json if File.file?("lib/acbaker/config/#{@type}.json") @json = "lib/acbaker/config/#{@type}.json" end end abort "error: no JSON configuration found" unless @json abort("error: Could not detect asset type.") unless @type end