Module: Card::Set::Abstract::Attachment::Paths
- Extended by:
- Card::Set
- Defined in:
- tmpsets/set/mod019-carrierwave/abstract/attachment/paths.rb
Overview
Set: Abstract (Attachment, Paths)
Constant Summary collapse
- MOD_FILE_DIR =
"file".freeze
Class Method Summary collapse
Instance Method Summary collapse
-
#coded_dir(new_mod = nil) ⇒ Object
place for files of mod file cards.
-
#file_dir ⇒ Object
used in the indentifier.
- #file_id ⇒ Object
- #files_base_dir ⇒ Object
- #files_base_dir_configuration_error ⇒ Object
- #mod_dir(new_mod = nil) ⇒ Object
- #public? ⇒ Boolean
- #retrieve_dir ⇒ Object
- #store_dir ⇒ Object
-
#upload_dir ⇒ Object
place for files of regular file cards.
Methods included from I18nScope
Methods included from Loader
#clean_empty_module_from_hash, #clean_empty_modules, #extended, #process_base_modules, #register_set
Methods included from Helpers
#abstract_set?, #all_set?, #num_set_parts, #shortname, #underscore
Methods included from Card::Set::AdvancedApi
#attachment, #ensure_set, #stage_method
Methods included from Format
#before, #format, layout_method_name, #view, view_method_name, view_setting_method_name, wrapper_method_name
Methods included from Inheritance
#include_set, #include_set_formats
Methods included from Basket
#abstract_basket, #add_to_basket, #basket, #unshift_basket
Methods included from Trait
#card_accessor, #card_reader, #card_writer, #require_field
Methods included from Event::Api
Class Method Details
.source_location ⇒ Object
7 |
# File 'tmpsets/set/mod019-carrierwave/abstract/attachment/paths.rb', line 7 def self.source_location; "/Users/ethan/dev/decko/gem/card/mod/carrierwave/set/abstract/attachment/paths.rb"; end |
Instance Method Details
#coded_dir(new_mod = nil) ⇒ Object
place for files of mod file cards
24 25 26 27 28 |
# File 'tmpsets/set/mod019-carrierwave/abstract/attachment/paths.rb', line 24 def coded_dir new_mod=nil dir = File.join mod_dir(new_mod), MOD_FILE_DIR, codename.to_s FileUtils.mkdir_p(dir) unless File.directory?(dir) dir end |
#file_dir ⇒ Object
used in the indentifier
49 50 51 52 53 54 55 56 57 |
# File 'tmpsets/set/mod019-carrierwave/abstract/attachment/paths.rb', line 49 def file_dir if coded? ":#{codename}" elsif cloud? "(#{bucket})/#{file_id}" else "~#{file_id}" end end |
#file_id ⇒ Object
63 64 65 |
# File 'tmpsets/set/mod019-carrierwave/abstract/attachment/paths.rb', line 63 def file_id id? ? id : upload_cache_card.id end |
#files_base_dir ⇒ Object
38 39 40 41 |
# File 'tmpsets/set/mod019-carrierwave/abstract/attachment/paths.rb', line 38 def files_base_dir dir = bucket ? bucket_config[:subdirectory] : Card.paths["files"].existent.first dir || files_base_dir_configuration_error end |
#files_base_dir_configuration_error ⇒ Object
43 44 45 46 |
# File 'tmpsets/set/mod019-carrierwave/abstract/attachment/paths.rb', line 43 def files_base_dir_configuration_error raise StandardError, "missing directory for file cache (default is `files` in deck root)" end |
#mod_dir(new_mod = nil) ⇒ Object
30 31 32 33 34 35 36 |
# File 'tmpsets/set/mod019-carrierwave/abstract/attachment/paths.rb', line 30 def mod_dir new_mod=nil mod_name = new_mod || mod dir = Mod.dirs.path(mod_name) || (mod_name.to_sym == :test && "test") raise Error, "can't find mod \"#{mod_name}\"" unless dir dir end |
#public? ⇒ Boolean
59 60 61 |
# File 'tmpsets/set/mod019-carrierwave/abstract/attachment/paths.rb', line 59 def public? who_can(:read).include? Card::AnyoneID end |
#retrieve_dir ⇒ Object
14 15 16 |
# File 'tmpsets/set/mod019-carrierwave/abstract/attachment/paths.rb', line 14 def retrieve_dir coded? ? coded_dir : upload_dir end |
#store_dir ⇒ Object
10 11 12 |
# File 'tmpsets/set/mod019-carrierwave/abstract/attachment/paths.rb', line 10 def store_dir will_become_coded? ? coded_dir(@new_mod) : upload_dir end |
#upload_dir ⇒ Object
place for files of regular file cards
19 20 21 |
# File 'tmpsets/set/mod019-carrierwave/abstract/attachment/paths.rb', line 19 def upload_dir id ? "#{files_base_dir}/#{id}" : tmp_upload_dir end |