Top Level Namespace

Includes:
Dropsite

Defined Under Namespace

Modules: Dropsite Classes: ImageThumbnails, SimpleIndex

Constant Summary collapse

PLUGINS_DIR =
File.join(File.dirname(__FILE__), 'plugins')

Constants included from Dropsite

Dropsite::VERSION

Instance Method Summary collapse

Instance Method Details

#dropbox_dirObject

Attempts to find the Dropbox directory (not the Public directory, the Dropbox base directory) on this box. Returns nil if an existing directory could not be found.



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/dropsite/globals.rb', line 5

def dropbox_dir
  return ENV['DROPBOX_HOME'] if ENV['DROPBOX_HOME']

  path = case RUBY_PLATFORM
  when /darwin/, /linux/, /freebsd/
    File.join(home_dir, 'Dropbox')
  when /win32/, /mingw/
    File.join(home_dir, 'My Documents', 'My Dropbox')
  end

  File.exist?(path) ? path : nil
end

#dropsite_config_dirObject

Find the configuration directory for Dropsite. The folder .dropsite is looked for from most “local” to the Public folder outward. First in the Public folder, then the Dropsite directory itself (recommended place) and then the user’s home directory.



22
23
24
25
26
27
28
29
# File 'lib/dropsite/globals.rb', line 22

def dropsite_config_dir
  config_dir_name = '.dropsite'
  [
    File.join(dropbox_dir, 'Public', config_dir_name),
    File.join(dropbox_dir, config_dir_name),
    File.join(home_dir, config_dir_name)
  ].find {|dir| File.exist? dir}
end

#home_dirObject

Platform-specific home directory



32
33
34
35
36
37
38
39
40
41
# File 'lib/dropsite/globals.rb', line 32

def home_dir
  home = ENV['HOME']
  home = ENV['USERPROFILE'] if not home
  if !home && (ENV['HOMEDRIVE'] && ENV['HOMEPATH'])
    home = File.join(ENV['HOMEDRIVE'], ENV['HOMEPATH'])
  end
  home = File.expand_path('~') if not home
  home = 'C:/' if !home && RUBY_PLATFORM =~ /mswin|mingw/
  home
end

#underscorize(camel_cased_word) ⇒ Object

Convert a camel-cased string into a lowercase, underscore separated string



44
45
46
47
48
49
# File 'lib/dropsite/globals.rb', line 44

def underscorize(camel_cased_word)
  camel_cased_word.to_s.gsub(/::/, '/').
  gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
  gsub(/([a-z\d])([A-Z])/,'\1_\2').
  tr("-", "_").downcase
end