File: local.rb

package info (click to toggle)
ruby-librarian 1.1.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 624 kB
  • sloc: ruby: 6,109; makefile: 11
file content (54 lines) | stat: -rw-r--r-- 1,242 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
require 'librarian/support/abstract_method'

module Librarian
  module Source
    # Requires that the including source class have methods:
    #   #path
    #   #environment
    module Local

      include Support::AbstractMethod

      abstract_method :path, :fetch_version, :fetch_dependencies

      def manifests(name)
        manifest = Manifest.new(self, name)
        [manifest].compact
      end

      def manifest_search_paths(name)
        @manifest_search_paths ||= { }
        @manifest_search_paths[name] ||= begin
          cache!
          paths = [filesystem_path, filesystem_path.join(name)]
          paths.select{|s| s.exist?}
        end
      end

      def found_path(name)
        @_found_paths ||= { }
        @_found_paths[name] ||= begin
          paths = manifest_search_paths(name)
          paths.find{|p| manifest?(name, p)}
        end
      end

    private

      abstract_method :manifest? # (name, path) -> boolean

      def info(*args, &block)
        environment.logger.info(*args, &block)
      end

      def debug(*args, &block)
        environment.logger.debug(*args, &block)
      end

      def relative_path_to(path)
        environment.logger.relative_path_to(path)
      end

    end
  end
end