Module: Dropsite
- Defined in:
- lib/dropsite.rb,
lib/dropsite/site.rb,
lib/dropsite/site_dir.rb,
lib/dropsite/site_file.rb,
lib/dropsite/site_item.rb,
lib/dropsite/application.rb,
lib/dropsite/dir_renderer.rb,
lib/dropsite/render_helper.rb
Defined Under Namespace
Modules: RenderHelper Classes: Application, ConfigFile, DirRenderer, Site, SiteDir, SiteFile, SiteItem
Constant Summary collapse
- VERSION =
'0.3.2'
Instance Method Summary collapse
-
#dropbox_dir ⇒ Object
Attempts to find the Dropbox directory (not the Public directory, the Dropbox base directory) on this box.
-
#dropsite_config_dir ⇒ Object
Find the configuration directory for Dropsite.
-
#home_dir ⇒ Object
Platform-specific home directory.
Instance Method Details
#dropbox_dir ⇒ Object
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.
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/dropsite.rb', line 6 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_dir ⇒ Object
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.
23 24 25 26 27 28 29 30 |
# File 'lib/dropsite.rb', line 23 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_dir ⇒ Object
Platform-specific home directory
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/dropsite.rb', line 33 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.('~') if not home home = 'C:/' if !home && RUBY_PLATFORM =~ /mswin|mingw/ home end |