Skip to content

Instantly share code, notes, and snippets.

@whiteleaf7
Created August 6, 2016 18:15
Show Gist options
  • Save whiteleaf7/d71d5edb7cb366be5d17d61443b8cf3d to your computer and use it in GitHub Desktop.
Save whiteleaf7/d71d5edb7cb366be5d17d61443b8cf3d to your computer and use it in GitHub Desktop.
send する時にサイト名でフォルダを分けるように
# -*- coding: utf-8 -*-
#
# Copyright 2013 whiteleaf. All rights reserved.
#
module Device::Kobo
PHYSICAL_SUPPORT = true
VOLUME_NAME = "KOBOeReader"
DOCUMENTS_PATH_LIST = ["/"]
EBOOK_FILE_EXT = ".kepub.epub"
NAME = "Kobo"
DISPLAY_NAME = "Kobo"
RELATED_VARIABLES = {
"default.enable_half_indent_bracket" => false,
}
module SendToSiteDirectory
def each(*argv)
hack_copy_to_documents unless __called?
super
end
def __called?
res = @__called
@__called = true
res
end
def hack_copy_to_documents
device = Device.create("kobo")
def device.copy_to_documents(src_file)
use_subdirectory = Inventory.load("local_setting")["download.use-subdirectory"]
site_name = src_file.split("/")[use_subdirectory ? -4 : -3]
instance_eval <<-EOS
def get_documents_path
path = File.join(super, "#{site_name}")
FileUtils.mkdir(path) unless File.directory?(path)
path
end
EOS
super
end
end
end
DOCUMENTS_PATH_LIST.extend SendToSiteDirectory
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment