Class: Dependency

Inherits:
Object
  • Object
show all
Includes:
PathHelper
Defined in:
lib/simple-make/dependency.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from PathHelper

#get_path

Constructor Details

#initialize(map, path_mode = :absolute) ⇒ Dependency

Returns a new instance of Dependency.



7
8
9
10
11
12
13
# File 'lib/simple-make/dependency.rb', line 7

def initialize map, path_mode = :absolute
  raise wrong_format_msg(map) if !(map.is_a? Hash) or map[:include].nil? or map[:lib].nil?

  @include = get_path(path_mode, map[:include])
  @lib = get_path(path_mode, map[:lib])
  @scope = map[:scope] || :compile
end

Instance Attribute Details

#includeObject (readonly)

Returns the value of attribute include.



5
6
7
# File 'lib/simple-make/dependency.rb', line 5

def include
  @include
end

#scopeObject (readonly)

Returns the value of attribute scope.



5
6
7
# File 'lib/simple-make/dependency.rb', line 5

def scope
  @scope
end

Instance Method Details

#lib_nameObject



15
16
17
18
19
20
21
22
23
# File 'lib/simple-make/dependency.rb', line 15

def lib_name
  if @lib_name.nil?
    matches = @lib.match /.*\/lib([^\/]*)\.a/
    raise "lib name format is wrong, it should be [libxxx.a]" if matches.nil?
    @lib_name = matches[1]
    raise "lib name format is wrong, it should be [libxxx.a], and the xxx should not be empty" if @lib_name.empty?
  end
  @lib_name
end

#lib_pathObject



25
26
27
28
29
30
31
# File 'lib/simple-make/dependency.rb', line 25

def lib_path
  if @lib_path.nil?
    matches = @lib.match /(.*\/)[^\/]*/
    @lib_path = matches[1]
  end
  @lib_path
end