Class: Giblish::ResourcePaths
- Inherits:
-
Object
- Object
- Giblish::ResourcePaths
- Defined in:
- lib/giblish/resourcepaths.rb
Overview
Provides relevant paths for layout resources based on the given options
Constant Summary collapse
- STYLE_EXTENSIONS =
{ "html5" => ".css", "html" => ".css", "pdf" => ".yml", "web-pdf" => ".css" }
- FONT_REGEX =
/.*\.(ttf)|(TTF)$/- RESOURCE_DST_TOP_BASENAME =
Pathname.new("web_assets")
Instance Attribute Summary collapse
-
#dst_resource_dir_abs ⇒ Object
readonly
the abs path to the top of the destination dir for resources.
-
#dst_style_path_rel ⇒ Object
readonly
the relative path from the dst top dir to the copied style file (if it would be copied).
-
#font_dirs_abs ⇒ Object
readonly
a set with all dirs containing ttf files, paths are relative to resource area top.
-
#src_style_path_abs ⇒ Object
readonly
the absolute path from the top of the resource area to the style file.
-
#src_style_path_rel ⇒ Object
readonly
the relative path from the top of the resource area to the style file.
Instance Method Summary collapse
-
#initialize(cmd_opts) ⇒ ResourcePaths
constructor
A new instance of ResourcePaths.
Constructor Details
#initialize(cmd_opts) ⇒ ResourcePaths
Returns a new instance of ResourcePaths.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/giblish/resourcepaths.rb', line 33 def initialize(cmd_opts) @style_ext = STYLE_EXTENSIONS.fetch(cmd_opts.format, nil) raise OptionParser::InvalidArgument, "Unsupported format: #{cmd_opts.format}" if @style_ext.nil? # Cache all file paths in the resource area r_top = cmd_opts.resource_dir file_tree = PathTree.build_from_fs(r_top) # find and validate paths @dst_resource_dir_abs = cmd_opts.dstdir / RESOURCE_DST_TOP_BASENAME @src_style_path_rel = find_style_file(file_tree, cmd_opts) @src_style_path_abs = r_top / @src_style_path_rel @dst_style_path_rel = RESOURCE_DST_TOP_BASENAME / @src_style_path_rel @font_dirs_abs = find_font_dirs(file_tree) end |
Instance Attribute Details
#dst_resource_dir_abs ⇒ Object (readonly)
the abs path to the top of the destination dir for resources
31 32 33 |
# File 'lib/giblish/resourcepaths.rb', line 31 def dst_resource_dir_abs @dst_resource_dir_abs end |
#dst_style_path_rel ⇒ Object (readonly)
the relative path from the dst top dir to the copied style file (if it would be copied)
28 29 30 |
# File 'lib/giblish/resourcepaths.rb', line 28 def dst_style_path_rel @dst_style_path_rel end |
#font_dirs_abs ⇒ Object (readonly)
a set with all dirs containing ttf files, paths are relative to resource area top
25 26 27 |
# File 'lib/giblish/resourcepaths.rb', line 25 def font_dirs_abs @font_dirs_abs end |
#src_style_path_abs ⇒ Object (readonly)
the absolute path from the top of the resource area to the style file
22 23 24 |
# File 'lib/giblish/resourcepaths.rb', line 22 def src_style_path_abs @src_style_path_abs end |
#src_style_path_rel ⇒ Object (readonly)
the relative path from the top of the resource area to the style file
18 19 20 |
# File 'lib/giblish/resourcepaths.rb', line 18 def src_style_path_rel @src_style_path_rel end |