Sha256: 8c4da392249722a3b4bd7770e3ac805fd6b5d673540b69541e6fb7ef29d427fb

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

class WordpressDirectory < Struct.new(:type, :options)

  module PATH
    WP_CONTENT = :wp_content
    WP_CONFIG  = :wp_config
    PLUGINS    = :plugins
    MU_PLUGINS    = :mu_plugins
    THEMES     = :themes
    UPLOADS    = :uploads
    LANGUAGES  = :languages
  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'
  }

  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

1 entries across 1 versions & 1 rubygems

Version Path
wordmove-1.4.0.pre lib/wordmove/wordpress_directory.rb