class TemplateHydrator

Attributes

args[R]
project_name[R]

Public Class Methods

new(args, project_name) click to toggle source
# File lib/cli/template_hydrator.rb, line 7
def initialize(args, project_name)
  @args = args
  @project_name = project_name
end

Public Instance Methods

brew_dependencies() click to toggle source
# File lib/cli/template_hydrator.rb, line 24
def brew_dependencies
  args.string("homebrew")&.split(" ") || []
end
feature_enabled?(feature) click to toggle source
# File lib/cli/template_hydrator.rb, line 46
def feature_enabled?(feature)
  features.include?(feature)
end
features() click to toggle source
# File lib/cli/template_hydrator.rb, line 32
def features
  @features ||= [
    (Rubiclifier::Feature::BACKGROUND if args.boolean("background")),
    (Rubiclifier::Feature::DATABASE if (args.boolean("database") || include_settings?)),
    (Rubiclifier::Feature::IDLE_DETECTION if args.boolean("idle-detection")),
    (Rubiclifier::Feature::NOTIFICATIONS if args.boolean("notifications")),
    (Rubiclifier::Feature::SERVER if args.boolean("server")),
  ].compact
end
hydrate(template_string) click to toggle source
# File lib/cli/template_hydrator.rb, line 12
def hydrate(template_string)
  ERB.new(template_string, nil, "-").result(binding)
end
include_settings?() click to toggle source
# File lib/cli/template_hydrator.rb, line 20
def include_settings?
  args.boolean("settings")
end
needs_setup?() click to toggle source
# File lib/cli/template_hydrator.rb, line 42
def needs_setup?
  !features.empty? || uses_brew?
end
project_name_camel_case() click to toggle source
# File lib/cli/template_hydrator.rb, line 16
def project_name_camel_case
  @pnsc ||= project_name.split("_").collect(&:capitalize).join
end
uses_brew?() click to toggle source
# File lib/cli/template_hydrator.rb, line 28
def uses_brew?
  !brew_dependencies.empty?
end