Class: Docks::Builder
- Inherits:
-
Object
- Object
- Docks::Builder
- Defined in:
- lib/docks/build.rb
Defined Under Namespace
Classes: Config
Class Method Summary collapse
- .add_assets(assets, options) ⇒ Object
- .build ⇒ Object
- .options ⇒ Object
- .parse(options = {}) ⇒ Object
- .setup(options) ⇒ Object
Class Method Details
.add_assets(assets, options) ⇒ Object
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/docks/build.rb', line 129 def self.add_assets(assets, ) root = /#{Regexp.escape(.fetch(:root, "").to_s)}\/?/ copy_to = case [:type] when :styles then Docks.config.root + ASSETS_DIR + Docks.config.asset_folders.styles when :scripts then Docks.config.root + ASSETS_DIR + Docks.config.asset_folders.scripts when :templates then Docks.config.templates end [assets].flatten.each do |asset| asset = Pathname.new(asset) destination_file = copy_to + asset.to_s.sub(root, "") relative_path = destination_file.relative_path_from(Docks.config.root) exists = destination_file.exist? next if exists && FileUtils.identical?(asset, destination_file) destination_dir = destination_file.dirname FileUtils.mkdir_p(destination_dir) FileUtils.cp(asset, destination_dir) Messenger.file(relative_path, exists ? :updated : :created) end end |
.build ⇒ Object
96 97 98 99 100 101 102 103 104 |
# File 'lib/docks/build.rb', line 96 def self.build prepare_destination Messenger.file_header("Assets:") copy_theme_assets Messenger.file_header("Pages:") rendered_patterns = render_pattern_library remove_unused_directories(rendered_patterns) end |
.options ⇒ Object
127 |
# File 'lib/docks/build.rb', line 127 def self.; @options end |
.parse(options = {}) ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/docks/build.rb', line 81 def self.parse( = {}) cache = Cache.new cache.clear if .fetch(:clear_cache, false) Grouper.group(Docks.config.sources).each do |identifier, group| if Cache.cached?(group) cache.no_update(identifier) else cache << Parser.parse(group) end end cache.dump end |
.setup(options) ⇒ Object
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/docks/build.rb', line 106 def self.setup() @options = = OpenStruct.new() @assets_dir = File.join(Dir.pwd, Docks::ASSETS_DIR) FileUtils.mkdir_p(@assets_dir) if .theme theme = Themes.for(.theme) theme.configure(Docks.config) if theme && theme.respond_to?(:configure) end if Dir[CONFIG_FILE].empty? setup_config end Docks.configure Docks.config.root = Pathname.pwd return unless Docks.config.theme && Docks.config.theme.respond_to?(:setup) Docks.config.theme.setup(self) end |