Sha256: e5a1f2fe75caeb23d3f1db15873a08013d5ce395d9f84711812cdf43d25edd35

Contents?: true

Size: 959 Bytes

Versions: 8

Compression:

Stored size: 959 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::MU_PLUGINS => 'wp-content/mu-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

8 entries across 8 versions & 1 rubygems

Version Path
wordmove-5.2.2 lib/wordmove/wordpress_directory.rb
wordmove-5.2.1 lib/wordmove/wordpress_directory.rb
wordmove-5.2.0 lib/wordmove/wordpress_directory.rb
wordmove-5.1.0 lib/wordmove/wordpress_directory.rb
wordmove-5.0.2 lib/wordmove/wordpress_directory.rb
wordmove-5.0.1 lib/wordmove/wordpress_directory.rb
wordmove-5.0.0.dev lib/wordmove/wordpress_directory.rb
wordmove-5.0.0 lib/wordmove/wordpress_directory.rb