Sha256: cbdca087c11ddde76c2d5cd707df6e94a2045bbbdb78e2a1b934db6f32441ff9

Contents?: true

Size: 942 Bytes

Versions: 1

Compression:

Stored size: 942 Bytes

Contents

class Dependency
  attr_reader :include, :scope
  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

  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

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

  private
  def wrong_format_msg(map)
    "#{map.inspect} is not a map, please present dependencies in format {include: <include_path>, lib: <lib_file_name>}"
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
simple-make-0.0.1 lib/simple-make/dependency.rb