class BridgetownPluginNano::Commands::Nano

Attributes

database_prefix[R]
folder_name[R]

Public Class Methods

source_root() click to toggle source
# File lib/bridgetown-plugin-nano/command.rb, line 27
def self.source_root
  File.expand_path("templates", __dir__)
end

Public Instance Methods

about() click to toggle source
# File lib/bridgetown-plugin-nano/command.rb, line 45
def about
  determine_folder_name
  system("cd #{folder_name} && bundle exec rails about")
end
console() click to toggle source
# File lib/bridgetown-plugin-nano/command.rb, line 87
def console
  determine_folder_name
  system("cd #{folder_name} && bundle exec rails console")
end
database(type_prefix) click to toggle source
# File lib/bridgetown-plugin-nano/command.rb, line 52
def database(type_prefix)
  # NOTE: self.database_prefix is accessed by the YAML template
  dbtype, @database_prefix = type_prefix.split(":")

  determine_folder_name

  case dbtype
  when "postgresql"
    setup_postgresql
  else
    raise "The #{dbtype} database type is not supported"
  end

  finish_database_setup # DatabaseHelpers
end
email() click to toggle source
# File lib/bridgetown-plugin-nano/command.rb, line 69
def email
  determine_folder_name
  configure_action_mailer
end
exec(*args) click to toggle source
# File lib/bridgetown-plugin-nano/command.rb, line 81
def exec(*args)
  determine_folder_name
  system("cd #{folder_name} && bundle exec rails #{args.join(" ")}")
end
generate(*args) click to toggle source
# File lib/bridgetown-plugin-nano/command.rb, line 93
def generate(*args)
  determine_folder_name
  system("cd #{folder_name} && bundle exec rails generate #{args.join(" ")}")
end
jobs() click to toggle source
# File lib/bridgetown-plugin-nano/command.rb, line 75
def jobs
  determine_folder_name
  configure_active_job
end
new(folder_name = "backend") click to toggle source
# File lib/bridgetown-plugin-nano/command.rb, line 33
def new(folder_name = "backend")
  @folder_name = folder_name
  self.destination_root = File.expand_path(folder_name)

  say_status :nano, %(Setting up Nano in "#{folder_name}")
  directory "new_app", ".", exclude_pattern: %r!DS_Store$!

  self.destination_root = File.expand_path(".")
  configure_new_nano_app # GeneralHelpers
end

Private Instance Methods

determine_folder_name() click to toggle source
# File lib/bridgetown-plugin-nano/command.rb, line 100
def determine_folder_name
  rackfile = File.read("config.ru")
  matches = %r!require_relative "\./(.*?)/config/application"!.match(rackfile)
  if matches
    @folder_name = matches[1]
  else
    raise "Nano backend folder could not be determined. Is there an" \
          "appropriate require_relative statement in your config.ru file?"
  end
end