Sha256: 13b6c37f5205b699cd0274c11eb8a180f36fb99673d9281ca5fe2253c330b844

Contents?: true

Size: 922 Bytes

Versions: 3

Compression:

Stored size: 922 Bytes

Contents

require 'wordmove/wordpress_directory/path'

class WordpressDirectory
  attr_accessor :type, :options

  def initialize(type, options)
    @type = type
    @options = options
  end

  DEFAULT_PATHS = {
    Path::WP_CONTENT => 'wp-content',
    Path::WP_CONFIG  => 'wp-config.php',
    Path::PLUGINS    => 'wp-content/plugins',
    Path::THEMES     => 'wp-content/themes',
    Path::UPLOADS    => 'wp-content/uploads',
    Path::LANGUAGES  => 'wp-content/languages'
  }.freeze

  def self.default_path_for(sym)
    DEFAULT_PATHS[sym]
  end

  def path(*args)
    File.join(options[:wordpress_path], relative_path(*args))
  end

  def url(*args)
    File.join(options[:vhost], relative_path(*args))
  end

  def relative_path(*args)
    path = if options[:paths] && options[:paths][type]
             options[:paths][type]
           else
             DEFAULT_PATHS[type]
           end
    File.join(path, *args)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
wordmove-1.4.0.pre10 lib/wordmove/wordpress_directory.rb
wordmove-1.4.0.pre9 lib/wordmove/wordpress_directory.rb
wordmove-1.4.0.pre8 lib/wordmove/wordpress_directory.rb