Class: Inventory::Extension
- Inherits:
-
Object
- Object
- Inventory::Extension
- Defined in:
- lib/inventory-1.0/extension.rb
Overview
An extension represents a sub-directory under the “ext” directory in the project. Such a directory contains source files, usually written in C, that interface with the underlying Ruby implementation, and possibly other low-level systems, that aren’t otherwise available to Ruby code.
For an inventory, an extension is a set of files that should be included in the project and can contain multiple extensions. [Inventory-Rake](disu.se/software/inventory-rake-1.0/) uses information found in these extensions to compile them for use from Ruby code.
Instance Attribute Summary collapse
-
#name ⇒ String
readonly
The receiver’s #name.
Instance Method Summary collapse
-
#additional_files ⇒ Array<String>
The complete paths to any additional files.
-
#depend ⇒ String
The path into the project that contains the “depend” file for the extension, the default being ‘#directory/depend`.
-
#directory ⇒ String
The sub-directory into the project that contains the extension, the default being ‘ext/#name`.
-
#extconf ⇒ String
The path into the project that contains the “extconf.rb” file for the extension, the default being ‘#directory/extconf.rb`.
-
#files ⇒ Array<String>
All files included in the package, that is [#extconf, #depend] + #source_files + #additional_files.
-
#initialize(name) {|?| ... } ⇒ Extension
constructor
Creates an extension named NAME.
- #inspect ⇒ Object
-
#source_files ⇒ Array<String>
The complete paths of #sources inside the package.
-
#sources ⇒ Array<String>
The source files that make up the extension, the default being empty.
-
#to_a ⇒ Array<String>
Whatever #files returns.
-
#to_s ⇒ String
The receiver’s #name.
Constructor Details
#initialize(name) {|?| ... } ⇒ Extension
Creates an extension named NAME. A block may be given that’ll be #instance_exec’d in the extension being created so that various methods may be overridden to suit the extension being created.
19 20 21 22 |
# File 'lib/inventory-1.0/extension.rb', line 19 def initialize(name) @name = name instance_exec(&Proc.new) if block_given? end |
Instance Attribute Details
#name ⇒ String (readonly)
Returns The receiver’s #name.
81 82 83 |
# File 'lib/inventory-1.0/extension.rb', line 81 def name @name end |
Instance Method Details
#additional_files ⇒ Array<String>
Returns The complete paths to any additional files.
56 57 58 |
# File 'lib/inventory-1.0/extension.rb', line 56 def additional_files [] end |
#depend ⇒ String
This file is usually created by hand by invoking ‘gcc -MM *.c > depend`
Returns The path into the project that contains the “depend” file for the extension, the default being ‘#directory/depend`.
40 41 42 |
# File 'lib/inventory-1.0/extension.rb', line 40 def depend '%s/depend' % directory end |
#directory ⇒ String
Returns The sub-directory into the project that contains the extension, the default being ‘ext/#name`.
26 27 28 |
# File 'lib/inventory-1.0/extension.rb', line 26 def directory 'ext/%s' % name end |
#extconf ⇒ String
Returns The path into the project that contains the “extconf.rb” file for the extension, the default being ‘#directory/extconf.rb`.
32 33 34 |
# File 'lib/inventory-1.0/extension.rb', line 32 def extconf '%s/extconf.rb' % directory end |
#files ⇒ Array<String>
Returns All files included in the package, that is
62 63 64 |
# File 'lib/inventory-1.0/extension.rb', line 62 def files [extconf, depend] + source_files + additional_files end |
#inspect ⇒ Object
76 77 78 |
# File 'lib/inventory-1.0/extension.rb', line 76 def inspect '#<%s: %s %s>' % [self.class, name, directory] end |
#source_files ⇒ Array<String>
Returns The complete paths of #sources inside the package.
51 52 53 |
# File 'lib/inventory-1.0/extension.rb', line 51 def source_files sources.map{ |e| '%s/%s' % [directory, e] } end |
#sources ⇒ Array<String>
Returns The source files that make up the extension, the default being empty.
46 47 48 |
# File 'lib/inventory-1.0/extension.rb', line 46 def sources [] end |
#to_a ⇒ Array<String>
Returns Whatever #files returns.
67 68 69 |
# File 'lib/inventory-1.0/extension.rb', line 67 def to_a files end |
#to_s ⇒ String
Returns The receiver’s #name.
72 73 74 |
# File 'lib/inventory-1.0/extension.rb', line 72 def to_s name end |