Class: Rosette::Core::ExtractorConfig
- Inherits:
-
Object
- Object
- Rosette::Core::ExtractorConfig
- Defined in:
- lib/rosette/core/extractor/extractor_config.rb
Overview
Configuration for an extractor.
Instance Attribute Summary collapse
-
#encoding ⇒ String, Encoding
readonly
The encoding to expect the contents of source files to be in.
-
#extractor ⇒ Extractor
readonly
The extractor instance that will be used to extract phrases.
-
#extractor_id ⇒ Object
readonly
Returns the value of attribute extractor_id.
-
#root ⇒ PathMatcherFactory::Node
readonly
The root of the conditions tree.
Instance Method Summary collapse
-
#initialize(extractor_id, extractor_class) ⇒ ExtractorConfig
constructor
Creates a new extractor configuration.
-
#matches?(path) ⇒ Boolean
Determines if the given path matches all the conditions in the conditions tree.
-
#set_conditions {|root| ... } ⇒ self
Creates and yields a node that represents the root of a conditions tree.
-
#set_encoding(new_encoding) ⇒ self
Sets the encoding to expect the contents of source files to be in.
Constructor Details
#initialize(extractor_id, extractor_class) ⇒ ExtractorConfig
Creates a new extractor configuration.
34 35 36 37 38 39 |
# File 'lib/rosette/core/extractor/extractor_config.rb', line 34 def initialize(extractor_id, extractor_class) @extractor_id = extractor_id @extractor = extractor_class.new(self) @root = PathMatcherFactory.create_root @encoding = Rosette::Core::DEFAULT_ENCODING end |
Instance Attribute Details
#encoding ⇒ String, Encoding (readonly)
Returns the encoding to expect the contents of source files to be in.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/rosette/core/extractor/extractor_config.rb', line 27 class ExtractorConfig attr_reader :extractor_id, :extractor, :encoding, :root # Creates a new extractor configuration. # # @param [String] extractor_id The extractor id of +extractor_class+. # @param [Class] extractor_class The extractor to use. def initialize(extractor_id, extractor_class) @extractor_id = extractor_id @extractor = extractor_class.new(self) @root = PathMatcherFactory.create_root @encoding = Rosette::Core::DEFAULT_ENCODING end # Sets the encoding to expect the contents of source files to be in. # # @param [String, Encoding] new_encoding the encoding to use. # @return [self] def set_encoding(new_encoding) @encoding = new_encoding self end # Determines if the given path matches all the conditions in the # conditions tree. # # @param [String] path The path to match. # @return [Boolean] true if the path matches, false otherwise. def matches?(path) root.matches?(path) end # Creates and yields a node that represents the root of a conditions # tree. Callers should use the yielded root to build up a set of # conditions that will be used to match paths in the repository. # Matching paths will be processed by the extractor (i.e. their # translatable phrases will be identified and stored). # # @return [self] # @yield [root] the root of the conditions tree # @yieldparam root [PathMatcherFactory::Node] def set_conditions @root = yield PathMatcherFactory.create_root self end end |
#extractor ⇒ Extractor (readonly)
Returns the extractor instance that will be used to extract phrases.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/rosette/core/extractor/extractor_config.rb', line 27 class ExtractorConfig attr_reader :extractor_id, :extractor, :encoding, :root # Creates a new extractor configuration. # # @param [String] extractor_id The extractor id of +extractor_class+. # @param [Class] extractor_class The extractor to use. def initialize(extractor_id, extractor_class) @extractor_id = extractor_id @extractor = extractor_class.new(self) @root = PathMatcherFactory.create_root @encoding = Rosette::Core::DEFAULT_ENCODING end # Sets the encoding to expect the contents of source files to be in. # # @param [String, Encoding] new_encoding the encoding to use. # @return [self] def set_encoding(new_encoding) @encoding = new_encoding self end # Determines if the given path matches all the conditions in the # conditions tree. # # @param [String] path The path to match. # @return [Boolean] true if the path matches, false otherwise. def matches?(path) root.matches?(path) end # Creates and yields a node that represents the root of a conditions # tree. Callers should use the yielded root to build up a set of # conditions that will be used to match paths in the repository. # Matching paths will be processed by the extractor (i.e. their # translatable phrases will be identified and stored). # # @return [self] # @yield [root] the root of the conditions tree # @yieldparam root [PathMatcherFactory::Node] def set_conditions @root = yield PathMatcherFactory.create_root self end end |
#extractor_id ⇒ Object (readonly)
Returns the value of attribute extractor_id.
28 29 30 |
# File 'lib/rosette/core/extractor/extractor_config.rb', line 28 def extractor_id @extractor_id end |
#root ⇒ PathMatcherFactory::Node (readonly)
Returns the root of the conditions tree. Only files that are matched by the conditions in this tree will have their phrases extracted.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/rosette/core/extractor/extractor_config.rb', line 27 class ExtractorConfig attr_reader :extractor_id, :extractor, :encoding, :root # Creates a new extractor configuration. # # @param [String] extractor_id The extractor id of +extractor_class+. # @param [Class] extractor_class The extractor to use. def initialize(extractor_id, extractor_class) @extractor_id = extractor_id @extractor = extractor_class.new(self) @root = PathMatcherFactory.create_root @encoding = Rosette::Core::DEFAULT_ENCODING end # Sets the encoding to expect the contents of source files to be in. # # @param [String, Encoding] new_encoding the encoding to use. # @return [self] def set_encoding(new_encoding) @encoding = new_encoding self end # Determines if the given path matches all the conditions in the # conditions tree. # # @param [String] path The path to match. # @return [Boolean] true if the path matches, false otherwise. def matches?(path) root.matches?(path) end # Creates and yields a node that represents the root of a conditions # tree. Callers should use the yielded root to build up a set of # conditions that will be used to match paths in the repository. # Matching paths will be processed by the extractor (i.e. their # translatable phrases will be identified and stored). # # @return [self] # @yield [root] the root of the conditions tree # @yieldparam root [PathMatcherFactory::Node] def set_conditions @root = yield PathMatcherFactory.create_root self end end |
Instance Method Details
#matches?(path) ⇒ Boolean
Determines if the given path matches all the conditions in the conditions tree.
55 56 57 |
# File 'lib/rosette/core/extractor/extractor_config.rb', line 55 def matches?(path) root.matches?(path) end |
#set_conditions {|root| ... } ⇒ self
Creates and yields a node that represents the root of a conditions tree. Callers should use the yielded root to build up a set of conditions that will be used to match paths in the repository. Matching paths will be processed by the extractor (i.e. their translatable phrases will be identified and stored).
68 69 70 71 |
# File 'lib/rosette/core/extractor/extractor_config.rb', line 68 def set_conditions @root = yield PathMatcherFactory.create_root self end |
#set_encoding(new_encoding) ⇒ self
Sets the encoding to expect the contents of source files to be in.
45 46 47 48 |
# File 'lib/rosette/core/extractor/extractor_config.rb', line 45 def set_encoding(new_encoding) @encoding = new_encoding self end |