Class: Arfi::Commands::Project

Inherits:
Thor
  • Object
show all
Defined in:
lib/arfi/commands/project.rb

Overview

Arfi::Commands::Project class is used to create ‘db/functions` directory.

Constant Summary collapse

ADAPTERS =
%i[postgresql mysql].freeze

Instance Method Summary collapse

Instance Method Details

#createvoid

This method returns an undefined value.

Arfi::Commands::Project#create -> void

This command is used to create ‘db/functions` directory.

Examples:

bundle exec arfi project create

Raises:



29
30
31
32
33
34
35
# File 'lib/arfi/commands/project.rb', line 29

def create
  raise Arfi::Errors::InvalidSchemaFormat unless ActiveRecord.schema_format == :ruby # steep:ignore NoMethod
  return puts "Directory #{functions_dir} already exists" if Dir.exist?(functions_dir)

  FileUtils.mkdir_p(functions_dir)
  puts "Created: #{functions_dir}"
end

#functions_dirPathname (private)

Arfi::Commands::Project#functions_dir -> Pathname

Helper method to get path to ‘db/functions` directory.

Returns:

  • (Pathname)

    Path to ‘db/functions` directory



46
47
48
49
50
51
52
53
54
55
56
# File 'lib/arfi/commands/project.rb', line 46

def functions_dir
  # steep:ignore:start
  if options[:adapter]
    raise Arfi::Errors::AdapterNotSupported unless ADAPTERS.include?(options[:adapter].to_sym)

    Rails.root.join("db/functions/#{options[:adapter]}")
    # steep:ignore:end
  else
    Rails.root.join('db/functions')
  end
end