class Zapnito::Cli::Models::Theme

Attributes

files[R]
revision[R]
tenant_slug[R]

Public Class Methods

new(path) click to toggle source
# File lib/zapnito/cli/models/theme.rb, line 7
def initialize(path)
  @path = with_trailing_slash(path)

  @tenant_slug = File.basename(path)
  @revision = build_revision(@path)
  @files = build_files(@path)
end

Public Instance Methods

absolute_path_for(file) click to toggle source
# File lib/zapnito/cli/models/theme.rb, line 15
def absolute_path_for(file)
  File.join(@path, file)
end
mime_type_for(file) click to toggle source
# File lib/zapnito/cli/models/theme.rb, line 19
def mime_type_for(file)
  Utils.mime_type_for(file)
end

Private Instance Methods

build_files(theme_path) click to toggle source
# File lib/zapnito/cli/models/theme.rb, line 29
def build_files(theme_path)
  absolute_paths = Dir[File.join(theme_path, '**', '*')]
  absolute_file_paths = absolute_paths.reject { |path| FileTest.directory?(path) }
  absolute_file_paths.map { |path| path.gsub(theme_path, "") }
end
build_revision(theme_path) click to toggle source
# File lib/zapnito/cli/models/theme.rb, line 35
def build_revision(theme_path)
  Utils.checksum_directory(theme_path)
end
with_trailing_slash(text) click to toggle source
# File lib/zapnito/cli/models/theme.rb, line 25
def with_trailing_slash(text)
  text.gsub(/([^\/]{1,1})$/, '\1/')
end