class Rugular::AppChecker

Attributes

root_directory[R]
task_name[R]

Public Class Methods

check_for_rugular_directory(task_name:, root_directory:) click to toggle source
# File lib/rugular/tasks/helpers/app_checker.rb, line 5
def self.check_for_rugular_directory(task_name:, root_directory:)
  new(
    task_name: task_name,
    root_directory: root_directory
  ).check_for_rugular_directory
end
new(task_name:, root_directory:) click to toggle source
# File lib/rugular/tasks/helpers/app_checker.rb, line 12
def initialize(task_name:, root_directory:)
  @task_name = task_name
  @root_directory = root_directory
end

Public Instance Methods

check_for_rugular_directory() click to toggle source
# File lib/rugular/tasks/helpers/app_checker.rb, line 17
def check_for_rugular_directory
  fail(rugular_app_message) unless rugular_app?

  return true
end

Private Instance Methods

rugular_app?() click to toggle source
# File lib/rugular/tasks/helpers/app_checker.rb, line 31
def rugular_app?
  [
    'bower.json',
    'package.json',
    'Gemfile',
    'src/index.haml'
  ].each do |file_name|
    destination_file_name = root_directory + '/' + file_name

    return false unless File.exists?(destination_file_name)
  end
end
rugular_app_message() click to toggle source
# File lib/rugular/tasks/helpers/app_checker.rb, line 27
def rugular_app_message
  "#{task_name} can only be ran in the root folder of a Rugular app"
end