Class: Klaro::Client::Story
- Defined in:
- lib/klaro/client/resource/story.rb
Instance Method Summary collapse
- #download_and_relocate_attachments(root_path, target_folder, client) ⇒ Object
- #download_and_relocate_images(root_path, target_folder, client) ⇒ Object
Instance Method Details
#download_and_relocate_attachments(root_path, target_folder, client) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/klaro/client/resource/story.rb', line 5 def (root_path, target_folder, client) as = self..map do || url = ["url"] url += "?n=" + URI.encode_www_form_component(["filename"]) unless url =~ /\?n=/ path = handle_image(url, root_path, target_folder, client) .merge("url" => path) end self.class.new(self.to_h.merge( attachments: as )) rescue => ex puts ex. puts ex.backtrace.join("\n") raise end |
#download_and_relocate_images(root_path, target_folder, client) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/klaro/client/resource/story.rb', line 21 def download_and_relocate_images(root_path, target_folder, client) spec = self.specification.gsub(%r{!\[([^\]]*)\]\(([^\)]*)\)}) do m = Regexp.last_match label, url = m[1], m[2] image_relative_path = handle_image(url, root_path, target_folder, client) "" end self.class.new(self.to_h.merge( specification: spec )) end |