Class: Cbt::SrcFile
- Inherits:
-
Object
- Object
- Cbt::SrcFile
- Defined in:
- lib/cbt/component.rb
Overview
handle file platform versinn and copy
Instance Attribute Summary collapse
-
#component_name ⇒ Object
Returns the value of attribute component_name.
Instance Method Summary collapse
-
#initialize(component_name, basename, ext = nil) ⇒ SrcFile
constructor
A new instance of SrcFile.
-
#path(dir = [], platform = 'debug') ⇒ Object
search up for the source file for the current file object with @name as the basename.
-
#target(workspace_dir) ⇒ Object
file copy to under workspace.
Constructor Details
#initialize(component_name, basename, ext = nil) ⇒ SrcFile
Returns a new instance of SrcFile.
6 7 8 9 10 11 12 13 |
# File 'lib/cbt/component.rb', line 6 def initialize component_name, basename, ext=nil unless ext if /^(?<basename_>.+?)\.(?<ext_>\w+)$/ =~ basename basename, ext = basename_, ext_ end end @component_name, @basename, @ext = component_name, basename, ext end |
Instance Attribute Details
#component_name ⇒ Object
Returns the value of attribute component_name.
5 6 7 |
# File 'lib/cbt/component.rb', line 5 def component_name @component_name end |
Instance Method Details
#path(dir = [], platform = 'debug') ⇒ Object
search up for the source file for the current file object with @name as the basename
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/cbt/component.rb', line 17 def path dir = [], platform = 'debug' # search up for each dir in row dir.each do |d| [".#{platform}.", "."].each do |filename| file_path = File.join(d, @basename + filename + @ext) # end search and return the file first found in the given directories # return File.expand_path(file_path) if File.exists? file_path return file_path if File.exists? file_path end end nil end |
#target(workspace_dir) ⇒ Object
file copy to under workspace
31 32 33 |
# File 'lib/cbt/component.rb', line 31 def target workspace_dir File.join(workspace_dir, @basename + '.' + @ext) end |