./lib/dubai/commands/generate.rb in dubai-0.1.2 vs ./lib/dubai/commands/generate.rb in dubai-0.2.0

- old
+ new

@@ -1,5 +1,7 @@ +# frozen_string_literal: true + require 'fileutils' command :generate do |c| c.syntax = 'pk generate PASSNAME' c.summary = 'Generates a template pass directory' @@ -8,15 +10,15 @@ c.example 'description', 'pk generate mypass' c.option '-T', '--type [boardingPass|coupon|eventTicket|storeCard|generic]', 'Type of pass' c.action do |args, options| @directory = args.first - @directory ||= ask "Enter a passbook name: " + @directory ||= ask 'Enter a passbook name: ' - say_error "Missing pass name" and abort if @directory.nil? or @directory.empty? - say_error "Directory #{@directory} already exists" and abort if File.directory?(@directory) - say_error "File exists at #{@directory}" and abort if File.exist?(@directory) + say_error('Missing pass name') && abort if @directory.nil? || @directory.empty? + say_error("Directory #{@directory} already exists") && abort if File.directory?(@directory) + say_error("File exists at #{@directory}") && abort if File.exist?(@directory) @type = options.type determine_type! unless @type validate_type! @@ -34,11 +36,11 @@ alias_command :g, :generate private def determine_type! - @type ||= choose "Select a pass type", *Dubai::Passbook::Pass::TYPES + @type ||= choose 'Select a pass type', *Dubai::Passbook::Pass::TYPES end def validate_type! - say_error %{Invalid type: "#{@type}", expected one of: [#{Dubai::Passbook::Pass::TYPES.join(', ')}]} unless Dubai::Passbook::Pass::TYPES.include?(@type) + say_error %(Invalid type: "#{@type}", expected one of: [#{Dubai::Passbook::Pass::TYPES.join(', ')}]) unless Dubai::Passbook::Pass::TYPES.include?(@type) end