Class: Dependency

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(map) ⇒ Dependency

Returns a new instance of Dependency.



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

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

  @include = File.absolute_path(map[:include])
  @lib = File.absolute_path(map[:lib])
  @scope = map[:scope] || :compile
end

Instance Attribute Details

#includeObject (readonly)

Returns the value of attribute include.



2
3
4
# File 'lib/simple-make/dependency.rb', line 2

def include
  @include
end

#scopeObject (readonly)

Returns the value of attribute scope.



2
3
4
# File 'lib/simple-make/dependency.rb', line 2

def scope
  @scope
end

Instance Method Details

#lib_nameObject



11
12
13
14
15
16
17
18
19
# File 'lib/simple-make/dependency.rb', line 11

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



21
22
23
24
25
26
27
# File 'lib/simple-make/dependency.rb', line 21

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