class Jackasset::Cli

The main class

Constants

BAD_CALL_MSG
PORT_RANGE

Public Class Methods

call() click to toggle source
# File lib/jackasset/cli.rb, line 9
def self.call
  new.call
end

Public Instance Methods

call() click to toggle source
# File lib/jackasset/cli.rb, line 13
def call
  if valid_args_without_port?
    check_assets source_dir: ARGV.first
  elsif valid_args_with_port?
    check_assets host: "http://localhost:#{ARGV[1]}", source_dir: ARGV.last
  else
    puts BAD_CALL_MSG.red
  end
end

Private Instance Methods

check_assets(args) click to toggle source
# File lib/jackasset/cli.rb, line 25
def check_assets(args)
  Jackasset::AssetsChecker.call args
end
valid_args_with_port?() click to toggle source
# File lib/jackasset/cli.rb, line 29
def valid_args_with_port?
  ARGV.length == 3 && valid_port_arg? && valid_dir_arg?
end
valid_args_without_port?() click to toggle source
# File lib/jackasset/cli.rb, line 33
def valid_args_without_port?
  ARGV.length == 1 && valid_dir_arg?
end
valid_dir_arg?() click to toggle source
# File lib/jackasset/cli.rb, line 37
def valid_dir_arg?
  File.directory? ARGV.last
end
valid_port_arg?() click to toggle source
# File lib/jackasset/cli.rb, line 41
def valid_port_arg?
  ARGV.first == '-p' && PORT_RANGE.include?(ARGV[1].to_i)
end