Parent

Included Modules

GetText::Tools::Task

Attributes

domain[RW]

It is a required parameter.

@return [String] Text domain

enable_description[W]

@return [Bool] @see enable_description? For details.

enable_po[W]

@return [Bool] @see enable_po? For details.

files[RW]

It is a required parameter.

@return [Array<String>] Files that have messages.

locales[RW]

It is a required parameter.

@return [Array<String>] Supported locales. It is filled from

{#po_base_directory} by default.
mo_base_directory[RW]

@return [String] Base directory that has generated MOs. MOs

are generated into
`#{mo_base_directory}/#{locale}/LC_MESSAGES/#{domain}.mo`.
msgcat_options[RW]

@return [Array<String>] Command line options for filtering PO. @see GetText::Tools::MsgCat @see `rmsgcat --help` @since 3.1.3

msginit_options[RW]

@return [Array<String>] Command line options for creating PO from POT. @see GetText::Tools::MsgInit @see `rmsginit --help`

msgmerge_options[RW]

@return [Array<String>] Command line options for merging PO with the

latest POT.

@see GetText::Tools::MsgMerge @see `rmsgmerge --help`

namespace_prefix[RW]

It is useful when you have multiple domains. You can define tasks for each domains by using different namespace prefix.

It is `nil` by default. It means that tasks are defined at top level.

TODO: example

@return [String] Namespace prefix for tasks defined by this class.

package_name[RW]

@return [String, nil] Package name for messages.

package_version[RW]

@return [String, nil] Package version for messages.

po_base_directory[RW]
pot_creator[RW]

It is used to custom how to create POT file. The object must have `call` method. The method must accept one argument. The argument

is a `Pathname` object that represents POT file path.

@example

GetText::Tools::Task.define do |task|
  task.pot_creator = lambda do |pot_file_path|
    pot_file_path.open("w") do |pot_file|
      pot_file << <<-POT
msgid "Hello"
msgstr ""
      POT
    end
  end
end

@return [Proc]

spec[R]

@return [Gem::Specification, nil] Package information associated

with the task.
xgettext_options[RW]

@return [Array<String>] Command line options for extracting messages

from sources.

@see GetText::Tools::XGetText @see `rxgettext --help`

Public Class Methods

define() click to toggle source

Define gettext related Rake tasks. Normally, use this method to define tasks because this method is a convenient API.

See accessor APIs how to configure this task.

See {define} for what task is defined.

@example Recommended usage

require "gettext/tools/task"
# Recommended usage
GetText::Tools::Task.define do |task|
  task.spec = spec
  # ...
end
# Low level API
task = GetText::Tools::Task.new
task.spec = spec
# ...
task.define

@yield [task] Gives the newely created task to the block. @yieldparam [GetText::Tools::Task] task The task that should be

configured.

@see define @return [void]

# File lib/gettext/tools/task.rb, line 73
def define
  task = new
  yield(task)
  task.define
end
new(spec=nil) click to toggle source

@param [Gem::Specification, nil] spec Package information associated

with the task. Some information are extracted from the spec.

@see spec= What information are extracted from the spec.

# File lib/gettext/tools/task.rb, line 175
def initialize(spec=nil)
  initialize_variables
  self.spec = spec
  if spec
    yield(self) if block_given?
    warn("Use #{self.class.name}.define instead of #{self.class.name}.new(spec).")
    define
  end
end

Public Instance Methods

define() click to toggle source

Define tasks from configured parameters.

TODO: List defined Rake tasks.

# File lib/gettext/tools/task.rb, line 208
def define
  ensure_variables
  validate

  define_file_tasks
  if namespace_prefix
    namespace_recursive namespace_prefix do
      define_named_tasks
    end
  else
    define_named_tasks
  end
end
enable_description?() click to toggle source

If it is true, each task has description. Otherwise, all tasks doesn't have description.

@return [Bool] @since 3.0.1

# File lib/gettext/tools/task.rb, line 227
def enable_description?
  @enable_description
end
enable_po?() click to toggle source

If it is true, PO related tasks are defined. Otherwise, they are not defined.

This parameter is useful to manage PO written by hand.

@return [Bool] @since 3.0.1

# File lib/gettext/tools/task.rb, line 238
def enable_po?
  @enable_po
end
spec=(spec) click to toggle source

Sets package infromation by Gem::Specification. Here is a list for information extracted from the spec:

* {#package_name}
* {#package_version}
* {#domain}
* {#files}

@param [Gem::Specification] spec package information for the

i18n application.
# File lib/gettext/tools/task.rb, line 195
def spec=(spec)
  @spec = spec
  return if @spec.nil?

  @package_name = spec.name
  @package_version = spec.version.to_s
  @domain ||= spec.name
  @files += target_files
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.