Sha256: a4ec003fe54f7837c49723c1cb84b55799c9ed4b846a5ab2f90343dbfff0ddc0

Contents?: true

Size: 1.2 KB

Versions: 22

Compression:

Stored size: 1.2 KB

Contents

module Lono::Template::Strategy::Dsl::Builder::Helpers
  module FileHelper
    extend Memoist

    def content(path)
      render_file(Lono.config.content_path, path)
    end

    def user_data(path)
      render_file(Lono.config.user_data_path, path)
    end

    def user_data_script
      unless @user_data_script
        return <<~EOL
          # @user_data_script variable not set. IE: @user_data_script = "configs/#{@blueprint}/user_data/boostrap.sh"
          # Also, make sure that "configs/#{@blueprint}/user_data/boostrap.sh" path you're using exists.
        EOL
      end

      if File.exist?(@user_data_script)
        render_path(@user_data_script)
      else
        message = "WARN: #{@user_data_script} not found"
        puts message.color(:yellow)
        "# #{message}"
      end
    end

    def render_file(folder, path)
      path = "#{folder}/#{path}"
      if File.exist?(path)
        render_path(path)
      else
        message = "WARNING: path #{path} not found"
        puts message.color(:yellow)
        puts "Called from:"
        puts caller[2]
        message
      end
    end
    memoize :render_file

    def render_path(path)
      RenderMePretty.result(path, context: self)
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
lono-7.5.2 lib/lono/template/strategy/dsl/builder/helpers/file_helper.rb
lono-7.5.1 lib/lono/template/strategy/dsl/builder/helpers/file_helper.rb
lono-7.5.0 lib/lono/template/strategy/dsl/builder/helpers/file_helper.rb
lono-7.4.11 lib/lono/template/strategy/dsl/builder/helpers/file_helper.rb
lono-7.4.10 lib/lono/template/strategy/dsl/builder/helpers/file_helper.rb
lono-7.4.9 lib/lono/template/strategy/dsl/builder/helpers/file_helper.rb
lono-7.4.8 lib/lono/template/strategy/dsl/builder/helpers/file_helper.rb
lono-7.4.7 lib/lono/template/strategy/dsl/builder/helpers/file_helper.rb
lono-7.4.6 lib/lono/template/strategy/dsl/builder/helpers/file_helper.rb
lono-7.4.5 lib/lono/template/strategy/dsl/builder/helpers/file_helper.rb
lono-7.4.4 lib/lono/template/strategy/dsl/builder/helpers/file_helper.rb
lono-7.4.3 lib/lono/template/strategy/dsl/builder/helpers/file_helper.rb
lono-7.4.2 lib/lono/template/strategy/dsl/builder/helpers/file_helper.rb
lono-7.4.1 lib/lono/template/strategy/dsl/builder/helpers/file_helper.rb
lono-7.4.0 lib/lono/template/strategy/dsl/builder/helpers/file_helper.rb
lono-7.3.2 lib/lono/template/strategy/dsl/builder/helpers/file_helper.rb
lono-7.3.1 lib/lono/template/strategy/dsl/builder/helpers/file_helper.rb
lono-7.3.0 lib/lono/template/strategy/dsl/builder/helpers/file_helper.rb
lono-7.2.3 lib/lono/template/strategy/dsl/builder/helpers/file_helper.rb
lono-7.2.2 lib/lono/template/strategy/dsl/builder/helpers/file_helper.rb