librarian-puppet 0.0.1.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. data/.gitignore +1 -0
  2. data/LICENSE +20 -0
  3. data/README.md +0 -0
  4. data/bin/librarian-puppet +9 -0
  5. data/lib/librarian/puppet.rb +7 -0
  6. data/lib/librarian/puppet/cli.rb +30 -0
  7. data/lib/librarian/puppet/dsl.rb +14 -0
  8. data/lib/librarian/puppet/environment.rb +18 -0
  9. data/lib/librarian/puppet/extension.rb +9 -0
  10. data/lib/librarian/puppet/source.rb +2 -0
  11. data/lib/librarian/puppet/source/git.rb +12 -0
  12. data/lib/librarian/puppet/source/local.rb +46 -0
  13. data/lib/librarian/puppet/source/path.rb +12 -0
  14. data/lib/librarian/puppet/templates/Puppetfile +6 -0
  15. data/librarian-puppet.gemspec +126 -0
  16. data/vendor/librarian/.rspec +1 -0
  17. data/vendor/librarian/.travis.yml +6 -0
  18. data/vendor/librarian/CHANGELOG.md +168 -0
  19. data/vendor/librarian/Gemfile +4 -0
  20. data/vendor/librarian/MIT-LICENSE +20 -0
  21. data/vendor/librarian/README.md +318 -0
  22. data/vendor/librarian/Rakefile +34 -0
  23. data/vendor/librarian/bin/librarian-chef +7 -0
  24. data/vendor/librarian/bin/librarian-mock +7 -0
  25. data/vendor/librarian/config/cucumber.yaml +1 -0
  26. data/vendor/librarian/features/chef/cli/init.feature +10 -0
  27. data/vendor/librarian/features/chef/cli/install.feature +64 -0
  28. data/vendor/librarian/features/chef/cli/show.feature +65 -0
  29. data/vendor/librarian/features/chef/cli/version.feature +11 -0
  30. data/vendor/librarian/features/support/env.rb +9 -0
  31. data/vendor/librarian/lib/librarian.rb +19 -0
  32. data/vendor/librarian/lib/librarian/action.rb +5 -0
  33. data/vendor/librarian/lib/librarian/action/base.rb +22 -0
  34. data/vendor/librarian/lib/librarian/action/clean.rb +44 -0
  35. data/vendor/librarian/lib/librarian/action/ensure.rb +24 -0
  36. data/vendor/librarian/lib/librarian/action/install.rb +95 -0
  37. data/vendor/librarian/lib/librarian/action/resolve.rb +81 -0
  38. data/vendor/librarian/lib/librarian/action/update.rb +78 -0
  39. data/vendor/librarian/lib/librarian/chef.rb +1 -0
  40. data/vendor/librarian/lib/librarian/chef/cli.rb +27 -0
  41. data/vendor/librarian/lib/librarian/chef/dsl.rb +15 -0
  42. data/vendor/librarian/lib/librarian/chef/environment.rb +19 -0
  43. data/vendor/librarian/lib/librarian/chef/extension.rb +9 -0
  44. data/vendor/librarian/lib/librarian/chef/integration/knife.rb +42 -0
  45. data/vendor/librarian/lib/librarian/chef/manifest_reader.rb +47 -0
  46. data/vendor/librarian/lib/librarian/chef/source.rb +3 -0
  47. data/vendor/librarian/lib/librarian/chef/source/git.rb +12 -0
  48. data/vendor/librarian/lib/librarian/chef/source/local.rb +63 -0
  49. data/vendor/librarian/lib/librarian/chef/source/path.rb +12 -0
  50. data/vendor/librarian/lib/librarian/chef/source/site.rb +434 -0
  51. data/vendor/librarian/lib/librarian/chef/templates/Cheffile +15 -0
  52. data/vendor/librarian/lib/librarian/cli.rb +175 -0
  53. data/vendor/librarian/lib/librarian/cli/manifest_presenter.rb +79 -0
  54. data/vendor/librarian/lib/librarian/dependency.rb +95 -0
  55. data/vendor/librarian/lib/librarian/dsl.rb +105 -0
  56. data/vendor/librarian/lib/librarian/dsl/receiver.rb +48 -0
  57. data/vendor/librarian/lib/librarian/dsl/target.rb +176 -0
  58. data/vendor/librarian/lib/librarian/environment.rb +129 -0
  59. data/vendor/librarian/lib/librarian/error.rb +4 -0
  60. data/vendor/librarian/lib/librarian/helpers.rb +13 -0
  61. data/vendor/librarian/lib/librarian/helpers/debug.rb +35 -0
  62. data/vendor/librarian/lib/librarian/lockfile.rb +33 -0
  63. data/vendor/librarian/lib/librarian/lockfile/compiler.rb +70 -0
  64. data/vendor/librarian/lib/librarian/lockfile/parser.rb +104 -0
  65. data/vendor/librarian/lib/librarian/manifest.rb +140 -0
  66. data/vendor/librarian/lib/librarian/manifest_set.rb +153 -0
  67. data/vendor/librarian/lib/librarian/mock.rb +1 -0
  68. data/vendor/librarian/lib/librarian/mock/cli.rb +19 -0
  69. data/vendor/librarian/lib/librarian/mock/dsl.rb +15 -0
  70. data/vendor/librarian/lib/librarian/mock/environment.rb +24 -0
  71. data/vendor/librarian/lib/librarian/mock/extension.rb +9 -0
  72. data/vendor/librarian/lib/librarian/mock/source.rb +1 -0
  73. data/vendor/librarian/lib/librarian/mock/source/mock.rb +97 -0
  74. data/vendor/librarian/lib/librarian/mock/source/mock/registry.rb +83 -0
  75. data/vendor/librarian/lib/librarian/resolution.rb +44 -0
  76. data/vendor/librarian/lib/librarian/resolver.rb +73 -0
  77. data/vendor/librarian/lib/librarian/resolver/implementation.rb +122 -0
  78. data/vendor/librarian/lib/librarian/source.rb +2 -0
  79. data/vendor/librarian/lib/librarian/source/git.rb +150 -0
  80. data/vendor/librarian/lib/librarian/source/git/repository.rb +213 -0
  81. data/vendor/librarian/lib/librarian/source/local.rb +51 -0
  82. data/vendor/librarian/lib/librarian/source/path.rb +74 -0
  83. data/vendor/librarian/lib/librarian/spec.rb +13 -0
  84. data/vendor/librarian/lib/librarian/spec_change_set.rb +170 -0
  85. data/vendor/librarian/lib/librarian/specfile.rb +22 -0
  86. data/vendor/librarian/lib/librarian/support/abstract_method.rb +21 -0
  87. data/vendor/librarian/lib/librarian/ui.rb +64 -0
  88. data/vendor/librarian/lib/librarian/version.rb +3 -0
  89. data/vendor/librarian/librarian.gemspec +33 -0
  90. data/vendor/librarian/spec/functional/chef/source/git_spec.rb +432 -0
  91. data/vendor/librarian/spec/functional/chef/source/site_spec.rb +215 -0
  92. data/vendor/librarian/spec/unit/action/base_spec.rb +18 -0
  93. data/vendor/librarian/spec/unit/action/clean_spec.rb +102 -0
  94. data/vendor/librarian/spec/unit/action/ensure_spec.rb +37 -0
  95. data/vendor/librarian/spec/unit/action/install_spec.rb +111 -0
  96. data/vendor/librarian/spec/unit/dependency_spec.rb +30 -0
  97. data/vendor/librarian/spec/unit/dsl_spec.rb +194 -0
  98. data/vendor/librarian/spec/unit/environment_spec.rb +9 -0
  99. data/vendor/librarian/spec/unit/lockfile/parser_spec.rb +162 -0
  100. data/vendor/librarian/spec/unit/lockfile_spec.rb +65 -0
  101. data/vendor/librarian/spec/unit/manifest_set_spec.rb +202 -0
  102. data/vendor/librarian/spec/unit/manifest_spec.rb +30 -0
  103. data/vendor/librarian/spec/unit/mock/source/mock_spec.rb +22 -0
  104. data/vendor/librarian/spec/unit/resolver_spec.rb +192 -0
  105. data/vendor/librarian/spec/unit/source/git_spec.rb +29 -0
  106. data/vendor/librarian/spec/unit/spec_change_set_spec.rb +169 -0
  107. metadata +163 -0
@@ -0,0 +1,9 @@
1
+ require 'librarian/mock/environment'
2
+
3
+ module Librarian
4
+ module Mock
5
+ extend self
6
+ extend Librarian
7
+
8
+ end
9
+ end
@@ -0,0 +1 @@
1
+ require 'librarian/mock/source/mock'
@@ -0,0 +1,97 @@
1
+ require 'librarian/manifest'
2
+ require 'librarian/mock/source/mock/registry'
3
+
4
+ module Librarian
5
+ module Mock
6
+ module Source
7
+ class Mock
8
+
9
+ class << self
10
+
11
+ LOCK_NAME = 'MOCK'
12
+
13
+ def lock_name
14
+ LOCK_NAME
15
+ end
16
+
17
+ def from_lock_options(environment, options)
18
+ new(environment, options[:remote], options.reject{|k, v| k == :remote})
19
+ end
20
+
21
+ def from_spec_args(environment, name, options)
22
+ recognized_options = []
23
+ unrecognized_options = options.keys - recognized_options
24
+ unrecognized_options.empty? or raise Error, "unrecognized options: #{unrecognized_options.join(", ")}"
25
+
26
+ new(environment, name, options)
27
+ end
28
+
29
+ end
30
+
31
+ attr_accessor :environment
32
+ private :environment=
33
+ attr_reader :name
34
+
35
+ def initialize(environment, name, options)
36
+ self.environment = environment
37
+ @name = name
38
+ end
39
+
40
+ def to_s
41
+ name
42
+ end
43
+
44
+ def ==(other)
45
+ other &&
46
+ self.class == other.class &&
47
+ self.name == other.name
48
+ end
49
+
50
+ def to_spec_args
51
+ [name, {}]
52
+ end
53
+
54
+ def to_lock_options
55
+ {:remote => name}
56
+ end
57
+
58
+ def registry
59
+ environment.registry[name]
60
+ end
61
+
62
+ def manifest(name, version, dependencies)
63
+ manifest = Manifest.new(self, name)
64
+ manifest.version = version
65
+ manifest.dependencies = dependencies
66
+ manifest
67
+ end
68
+
69
+ def manifests(name)
70
+ if d = registry[name]
71
+ d.map{|v| manifest(name, v[:version], v[:dependencies])}
72
+ else
73
+ nil
74
+ end
75
+ end
76
+
77
+ def install!(manifest)
78
+ end
79
+
80
+ def to_s
81
+ name
82
+ end
83
+
84
+ def fetch_version(name, extra)
85
+ extra
86
+ end
87
+
88
+ def fetch_dependencies(name, version, extra)
89
+ d = registry[name]
90
+ m = d.find{|v| v[:version] == version.to_s}
91
+ m[:dependencies]
92
+ end
93
+
94
+ end
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,83 @@
1
+ module Librarian
2
+ module Mock
3
+ module Source
4
+ class Mock
5
+ class Registry
6
+
7
+ module Dsl
8
+
9
+ class Top
10
+ def initialize(sources)
11
+ @sources = sources
12
+ end
13
+ def source(name, &block)
14
+ @sources[name] ||= {}
15
+ Source.new(@sources[name]).instance_eval(&block) if block
16
+ end
17
+ end
18
+
19
+ class Source
20
+ def initialize(source)
21
+ @source = source
22
+ end
23
+ def spec(name, version = nil, &block)
24
+ @source[name] ||= []
25
+ unless version
26
+ Spec.new(@source[name]).instance_eval(&block) if block
27
+ else
28
+ Spec.new(@source[name]).version(version, &block)
29
+ end
30
+ @source[name] = @source[name].sort_by{|a| Manifest::Version.new(a[:version])}.reverse
31
+ end
32
+ end
33
+
34
+ class Spec
35
+ def initialize(spec)
36
+ @spec = spec
37
+ end
38
+ def version(name, &block)
39
+ @spec << { :version => name, :dependencies => {} }
40
+ Version.new(@spec.last[:dependencies]).instance_eval(&block) if block
41
+ end
42
+ end
43
+
44
+ class Version
45
+ def initialize(version)
46
+ @version = version
47
+ end
48
+ def dependency(name, *requirement)
49
+ @version[name] = requirement
50
+ end
51
+ end
52
+
53
+ class << self
54
+ def run!(sources, &block)
55
+ Top.new(sources).instance_eval(&block) if block
56
+ end
57
+ end
58
+
59
+ end
60
+
61
+ def initialize
62
+ clear!
63
+ end
64
+ def clear!
65
+ self.sources = { }
66
+ end
67
+ def merge!(options = nil, &block)
68
+ clear! if options && options[:clear]
69
+ Dsl.run!(sources, &block) if block
70
+ end
71
+ def [](name)
72
+ sources[name] ||= {}
73
+ end
74
+
75
+ private
76
+
77
+ attr_accessor :sources
78
+
79
+ end
80
+ end
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,44 @@
1
+ module Librarian
2
+ #
3
+ # Represents the output of the resolution process. Captures the declared
4
+ # dependencies plus the full set of resolved manifests. The sources are
5
+ # already known by the dependencies and by the resolved manifests, so they do
6
+ # not need to be captured explicitly.
7
+ #
8
+ # This representation may be produced by the resolver, may be serialized into
9
+ # a lockfile, and may be deserialized from a lockfile. It is expected that the
10
+ # lockfile is a direct representation in text of this representation, so that
11
+ # the serialization-deserialization process is just the identity function.
12
+ #
13
+ class Resolution
14
+ attr_reader :dependencies, :manifests, :manifests_index
15
+
16
+ def initialize(dependencies, manifests)
17
+ @dependencies, @manifests = dependencies, manifests
18
+ @manifests_index = build_manifests_index(manifests)
19
+ end
20
+
21
+ def correct?
22
+ manifests && manifests_consistent_with_dependencies? && manifests_internally_consistent?
23
+ end
24
+
25
+ def sources
26
+ manifests.map{|m| m.source}.uniq
27
+ end
28
+
29
+ private
30
+
31
+ def build_manifests_index(manifests)
32
+ Hash[manifests.map{|m| [m.name, m]}] if manifests
33
+ end
34
+
35
+ def manifests_consistent_with_dependencies?
36
+ ManifestSet.new(manifests).in_compliance_with?(dependencies)
37
+ end
38
+
39
+ def manifests_internally_consistent?
40
+ ManifestSet.new(manifests).consistent?
41
+ end
42
+
43
+ end
44
+ end
@@ -0,0 +1,73 @@
1
+ require 'librarian/resolver/implementation'
2
+ require 'librarian/manifest_set'
3
+ require 'librarian/resolution'
4
+
5
+ module Librarian
6
+ class Resolver
7
+ include Helpers::Debug
8
+
9
+ attr_accessor :environment
10
+ private :environment=
11
+
12
+ def initialize(environment)
13
+ self.environment = environment
14
+ end
15
+
16
+ def resolve(spec, partial_manifests = [])
17
+ implementation = Implementation.new(self, spec)
18
+ partial_manifests_index = Hash[partial_manifests.map{|m| [m.name, m]}]
19
+ manifests = implementation.resolve(spec.dependencies, partial_manifests_index)
20
+ enforce_consistency!(spec.dependencies, manifests) if manifests
21
+ manifests = sort(manifests) if manifests
22
+ Resolution.new(spec.dependencies, manifests)
23
+ end
24
+
25
+ def enforce_consistency!(dependencies, manifests)
26
+ return if dependencies.all?{|d|
27
+ m = manifests[d.name]
28
+ m && d.satisfied_by?(m)
29
+ } && ManifestSet.new(manifests).consistent?
30
+
31
+ debug { "Resolver Malfunctioned!" }
32
+ errors = []
33
+ dependencies.sort_by(&:name).each do |d|
34
+ m = manifests[d.name]
35
+ if !m
36
+ errors << ["Depends on #{d}", "Missing!"]
37
+ elsif !d.satisfied_by?(m)
38
+ errors << ["Depends on #{d}", "Found: #{m}"]
39
+ end
40
+ end
41
+ unless errors.empty?
42
+ errors.each do |a, b|
43
+ debug { " #{a}" }
44
+ debug { " #{b}" }
45
+ end
46
+ end
47
+ manifests.values.sort_by(&:name).each do |manifest|
48
+ errors = []
49
+ manifest.dependencies.sort_by(&:name).each do |d|
50
+ m = manifests[d.name]
51
+ if !m
52
+ errors << ["Depends on: #{d}", "Missing!"]
53
+ elsif !d.satisfied_by?(m)
54
+ errors << ["Depends on: #{d}", "Found: #{m}"]
55
+ end
56
+ end
57
+ unless errors.empty?
58
+ debug { " #{manifest}" }
59
+ errors.each do |a, b|
60
+ debug { " #{a}" }
61
+ debug { " #{b}" }
62
+ end
63
+ end
64
+ end
65
+ raise Error, "Resolver Malfunctioned!"
66
+ end
67
+
68
+ def sort(manifests)
69
+ ManifestSet.sort(manifests)
70
+ end
71
+
72
+ end
73
+ end
@@ -0,0 +1,122 @@
1
+ require 'librarian/helpers/debug'
2
+
3
+ require 'librarian/dependency'
4
+
5
+ module Librarian
6
+ class Resolver
7
+ class Implementation
8
+
9
+ include Helpers::Debug
10
+
11
+ attr_reader :resolver, :source, :dependency_source_map
12
+
13
+ def initialize(resolver, spec)
14
+ @resolver = resolver
15
+ @source = spec.source
16
+ @dependency_source_map = Hash[spec.dependencies.map{|d| [d.name, d.source]}]
17
+ @level = 0
18
+ end
19
+
20
+ def resolve(dependencies, manifests = {})
21
+ dependencies += manifests.values.map { |m|
22
+ m.dependencies.map { |d| sourced_dependency_for(d) }
23
+ }.flatten(1)
24
+ resolution = recursive_resolve([], manifests, dependencies)
25
+ resolution ? resolution[1] : nil
26
+ end
27
+
28
+ def sourced_dependency_for(dependency)
29
+ return dependency if dependency.source
30
+
31
+ s = dependency_source_map[dependency.name] || source
32
+ Dependency.new(dependency.name, dependency.requirement, s)
33
+ end
34
+
35
+ def recursive_resolve(dependencies, manifests, queue)
36
+ if dependencies.empty?
37
+ queue.each do |dependency|
38
+ debug { "Scheduling #{dependency}" }
39
+ end
40
+ end
41
+ failure = false
42
+ until failure || queue.empty?
43
+ dependency = queue.shift
44
+ dependencies << dependency
45
+ debug { "Resolving #{dependency}" }
46
+ scope do
47
+ if manifests.key?(dependency.name)
48
+ unless dependency.satisfied_by?(manifests[dependency.name])
49
+ debug { "Conflicts with #{manifests[dependency.name]}" }
50
+ failure = true
51
+ else
52
+ debug { "Accords with all prior constraints" }
53
+ # nothing left to do
54
+ end
55
+ else
56
+ debug { "No known prior constraints" }
57
+ resolution = nil
58
+ related_dependencies = dependencies.select{|d| d.name == dependency.name}
59
+ unless dependency.manifests && dependency.manifests.first
60
+ debug { "No known manifests" }
61
+ else
62
+ debug { "Checking manifests" }
63
+ scope do
64
+ dependency.manifests.each do |manifest|
65
+ break if resolution
66
+
67
+ debug { "Checking #{manifest}" }
68
+ scope do
69
+ if related_dependencies.all?{|d| d.satisfied_by?(manifest)}
70
+ m = manifests.merge(dependency.name => manifest)
71
+ a = manifest.dependencies.map { |d| sourced_dependency_for(d) }
72
+ a.each do |d|
73
+ debug { "Scheduling #{d}" }
74
+ end
75
+ q = queue + a
76
+ resolution = recursive_resolve(dependencies.dup, m, q)
77
+ end
78
+ if resolution
79
+ debug { "Resolved #{dependency} at #{manifest}" }
80
+ else
81
+ debug { "Backtracking from #{manifest}" }
82
+ end
83
+ end
84
+ end
85
+ end
86
+ if resolution
87
+ debug { "Resolved #{dependency}" }
88
+ else
89
+ debug { "Failed to resolve #{dependency}" }
90
+ end
91
+ end
92
+ unless resolution
93
+ failure = true
94
+ else
95
+ dependencies, manifests, queue = *resolution
96
+ end
97
+ end
98
+ end
99
+ end
100
+ failure ? nil : [dependencies, manifests, queue]
101
+ end
102
+
103
+ private
104
+
105
+ def scope
106
+ @level += 1
107
+ yield
108
+ ensure
109
+ @level -= 1
110
+ end
111
+
112
+ def debug
113
+ super { ' ' * @level + yield }
114
+ end
115
+
116
+ def environment
117
+ resolver.environment
118
+ end
119
+
120
+ end
121
+ end
122
+ end
@@ -0,0 +1,2 @@
1
+ require 'librarian/source/git'
2
+ require 'librarian/source/path'
@@ -0,0 +1,150 @@
1
+ require 'fileutils'
2
+ require 'pathname'
3
+ require 'digest'
4
+
5
+ require 'librarian/source/git/repository'
6
+ require 'librarian/source/local'
7
+
8
+ module Librarian
9
+ module Source
10
+ class Git
11
+
12
+ include Local
13
+
14
+ class << self
15
+
16
+ LOCK_NAME = 'GIT'
17
+
18
+ def lock_name
19
+ LOCK_NAME
20
+ end
21
+
22
+ def from_lock_options(environment, options)
23
+ new(environment, options[:remote], options.reject{|k, v| k == :remote})
24
+ end
25
+
26
+ def from_spec_args(environment, uri, options)
27
+ recognized_options = [:ref, :path]
28
+ unrecognized_options = options.keys - recognized_options
29
+ unrecognized_options.empty? or raise Error, "unrecognized options: #{unrecognized_options.join(", ")}"
30
+
31
+ new(environment, uri, options)
32
+ end
33
+
34
+ end
35
+
36
+ DEFAULTS = {
37
+ :ref => 'master'
38
+ }
39
+
40
+ attr_accessor :environment
41
+ private :environment=
42
+
43
+ attr_accessor :uri, :ref, :sha, :path
44
+ private :uri=, :ref=, :sha=, :path=
45
+
46
+ def initialize(environment, uri, options)
47
+ self.environment = environment
48
+ self.uri = uri
49
+ self.ref = options[:ref] || DEFAULTS[:ref]
50
+ self.sha = options[:sha]
51
+ self.path = options[:path]
52
+
53
+ @repository = nil
54
+ @repository_cache_path = nil
55
+ end
56
+
57
+ def to_s
58
+ path ? "#{uri}##{ref}(#{path})" : "#{uri}##{ref}"
59
+ end
60
+
61
+ def ==(other)
62
+ other &&
63
+ self.class == other.class &&
64
+ self.uri == other.uri &&
65
+ self.ref == other.ref &&
66
+ self.path == other.path &&
67
+ (self.sha.nil? || other.sha.nil? || self.sha == other.sha)
68
+ end
69
+
70
+ def to_spec_args
71
+ options = {}
72
+ options.merge!(:ref => ref) if ref != DEFAULTS[:ref]
73
+ options.merge!(:path => path) if path
74
+ [uri, options]
75
+ end
76
+
77
+ def to_lock_options
78
+ options = {:remote => uri, :ref => ref, :sha => sha}
79
+ options.merge!(:path => path) if path
80
+ options
81
+ end
82
+
83
+ def pinned?
84
+ !!sha
85
+ end
86
+
87
+ def unpin!
88
+ @sha = nil
89
+ end
90
+
91
+ def cache!
92
+ repository_cached? and return or repository_cached!
93
+
94
+ unless repository.git?
95
+ repository.path.rmtree if repository.path.exist?
96
+ repository.path.mkpath
97
+ repository.clone!(uri)
98
+ end
99
+ repository.reset_hard!
100
+ repository.clean!
101
+ unless repository.checked_out?(sha)
102
+ remote = repository.default_remote
103
+ repository.fetch!(remote)
104
+ repository.fetch!(remote, :tags => true)
105
+
106
+ self.sha = repository.hash_from(remote, ref) unless sha
107
+ repository.checkout!(sha) unless repository.checked_out?(sha)
108
+
109
+ raise Error, "failed to checkout #{sha}" unless repository.checked_out?(sha)
110
+ end
111
+ end
112
+
113
+ private
114
+
115
+ attr_accessor :repository_cached
116
+ alias repository_cached? repository_cached
117
+
118
+ def repository_cached!
119
+ self.repository_cached = true
120
+ end
121
+
122
+ def repository_cache_path
123
+ @repository_cache_path ||= begin
124
+ environment.cache_path.join("source/git/#{cache_key}")
125
+ end
126
+ end
127
+
128
+ def repository
129
+ @repository ||= begin
130
+ Repository.new(environment, repository_cache_path)
131
+ end
132
+ end
133
+
134
+ def filesystem_path
135
+ @filesystem_path ||= path ? repository.path.join(path) : repository.path
136
+ end
137
+
138
+ def cache_key
139
+ @cache_key ||= begin
140
+ uri_part = uri
141
+ path_part = "/#{path}" if path
142
+ ref_part = "##{ref}"
143
+ key_source = [uri_part, path_part, ref_part].join
144
+ Digest::MD5.hexdigest(key_source)
145
+ end
146
+ end
147
+
148
+ end
149
+ end
150
+ end