Class: Sprout::FileTarget
- Inherits:
-
Object
- Object
- Sprout::FileTarget
- Defined in:
- lib/sprout/file_target.rb
Overview
This is a class that is generally used by the Sprout::Specification::add_file_target method.
File targets are files that are embedded into (or referred to by) a RubyGem in such a way that Sprouts can use them as a library or executable.
A given FileTarget may be configured to work on a specific platform, or it may be universal.
Direct Known Subclasses
Instance Attribute Summary (collapse)
-
- (Object) executables
readonly
Returns the value of attribute executables.
-
- (Object) libraries
readonly
Returns the value of attribute libraries.
-
- (Object) load_path
Returns the value of attribute load_path.
-
- (Object) pkg_name
Returns the value of attribute pkg_name.
-
- (Object) pkg_version
Returns the value of attribute pkg_version.
-
- (Object) platform
Returns the value of attribute platform.
Instance Method Summary (collapse)
-
- (Object) add_executable(name, path)
Add an executable to the RubyGem package.
-
- (Sprout::Library) add_library(name, path)
Add a library to the package.
-
- (Object) expand_local_path(path)
This is a template method that is overridden by RemoteFileTarget.
-
- (FileTarget) initialize {|_self| ... }
constructor
A new instance of FileTarget.
-
- (Object) resolve
This is a template method that will be called so that RemoteFileTarget subclasses and load the appropriate files at the appropriate time.
- - (Object) to_s
- - (Object) validate
Constructor Details
- (FileTarget) initialize {|_self| ... }
A new instance of FileTarget
22 23 24 25 26 27 28 |
# File 'lib/sprout/file_target.rb', line 22 def initialize @executables = [] @libraries = [] @load_path = '.' @platform = :universal yield self if block_given? end |
Instance Attribute Details
- (Object) executables (readonly)
Returns the value of attribute executables
19 20 21 |
# File 'lib/sprout/file_target.rb', line 19 def executables @executables end |
- (Object) libraries (readonly)
Returns the value of attribute libraries
20 21 22 |
# File 'lib/sprout/file_target.rb', line 20 def libraries @libraries end |
- (Object) load_path
Returns the value of attribute load_path
14 15 16 |
# File 'lib/sprout/file_target.rb', line 14 def load_path @load_path end |
- (Object) pkg_name
Returns the value of attribute pkg_name
15 16 17 |
# File 'lib/sprout/file_target.rb', line 15 def pkg_name @pkg_name end |
- (Object) pkg_version
Returns the value of attribute pkg_version
16 17 18 |
# File 'lib/sprout/file_target.rb', line 16 def pkg_version @pkg_version end |
- (Object) platform
Returns the value of attribute platform
17 18 19 |
# File 'lib/sprout/file_target.rb', line 17 def platform @platform end |
Instance Method Details
- (Object) add_executable(name, path)
Add an executable to the RubyGem package.
with this name.
64 65 66 67 |
# File 'lib/sprout/file_target.rb', line 64 def add_executable name, path path = path executables << OpenStruct.new( :name => name, :path => path, :file_target => self ) end |
- (Sprout::Library) add_library(name, path)
Add a library to the package.
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/sprout/file_target.rb', line 46 def add_library name, path if path.is_a?(Array) path = path.collect { |p| (p) } else path = path end library = Sprout::Library.new( :name => name, :path => path, :file_target => self ) libraries << library library end |
- (Object) expand_local_path(path)
This is a template method that is overridden by RemoteFileTarget.
81 82 83 |
# File 'lib/sprout/file_target.rb', line 81 def path File.join load_path, path end |
- (Object) resolve
This is a template method that will be called so that RemoteFileTarget subclasses and load the appropriate files at the appropriate time. Admittedly kind of smelly, other ideas welcome...
35 36 |
# File 'lib/sprout/file_target.rb', line 35 def resolve end |
- (Object) to_s
69 70 71 |
# File 'lib/sprout/file_target.rb', line 69 def to_s "[FileTarget pkg_name=#{pkg_name} pkg_version=#{pkg_version} platform=#{platform}]" end |
- (Object) validate
73 74 75 76 |
# File 'lib/sprout/file_target.rb', line 73 def validate raise Sprout::Errors::UsageError.new "FileTarget.pkg_name is required" if pkg_name.nil? raise Sprout::Errors::UsageError.new "FileTarget.pkg_version is required" if pkg_version.nil? end |