Class: FileDefinition

Inherits:
Object
  • Object
show all
Defined in:
lib/file_definition.rb

Constant Summary collapse

@@extensions_to_include_in_target =
["c", "m", "sh"]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ FileDefinition

Returns a new instance of FileDefinition.



17
18
19
20
21
22
# File 'lib/file_definition.rb', line 17

def initialize(options)
  @input_path = options[:input_path]
  @group_path = options[:group_path]
  @output_path = options[:output_path]
  @include_in_target = options[:include_in_target]
end

Instance Attribute Details

#group_pathObject

Returns the value of attribute group_path.



2
3
4
# File 'lib/file_definition.rb', line 2

def group_path
  @group_path
end

#include_in_targetObject

Returns the value of attribute include_in_target.



2
3
4
# File 'lib/file_definition.rb', line 2

def include_in_target
  @include_in_target
end

#input_pathObject

Returns the value of attribute input_path.



2
3
4
# File 'lib/file_definition.rb', line 2

def input_path
  @input_path
end

#output_pathObject

Returns the value of attribute output_path.



2
3
4
# File 'lib/file_definition.rb', line 2

def output_path
  @output_path
end

Class Method Details

.build(project_root, file_path) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/file_definition.rb', line 6

def self.build(project_root, file_path)
  relative_file_path = file_path.gsub("#{File.expand_path(project_root)}/", "")
  include_in_target = @@extensions_to_include_in_target.any? {|ext| relative_file_path.end_with?(ext)}
   FileDefinition.new({
    :input_path => relative_file_path,
    :group_path => File.dirname(relative_file_path),
    :output_path => relative_file_path,
    :include_in_target => include_in_target
  })
end

Instance Method Details

#include_in_target?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/file_definition.rb', line 24

def include_in_target?
  @include_in_target
end