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

Constants included from Helpers

Helpers::SET_PATTERN_TEST_REGEXP

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Card::Set

reset_modules

Methods included from I18nScope

#mod_name, #scope

Methods included from Loader

#clean_empty_module_from_hash, #clean_empty_modules, #extended, #process_base_modules, #register_set

Methods included from Helpers

#method_missing, #num_set_parts, #pattern_code, #respond_to_missing?, #set_name_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

#event

Class Method Details

.source_locationObject



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_dirObject

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_idObject



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_dirObject



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_errorObject

Raises:

  • (StandardError)


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

Raises:



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

Returns:

  • (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_dirObject



14
15
16
# File 'tmpsets/set/mod019-carrierwave/abstract/attachment/paths.rb', line 14

def retrieve_dir
  coded? ? coded_dir : upload_dir
end

#store_dirObject



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_dirObject

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