librarian-puppet-maestrodev 0.9.7.5 → 0.9.8.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +3 -3
- data/bin/librarian-puppet +0 -2
- data/lib/librarian/puppet.rb +10 -1
- data/lib/librarian/puppet/extension.rb +68 -11
- data/lib/librarian/puppet/requirement.rb +39 -0
- data/lib/librarian/puppet/source.rb +1 -0
- data/lib/librarian/puppet/source/forge.rb +8 -1
- data/lib/librarian/puppet/source/git.rb +2 -0
- data/lib/librarian/puppet/source/githubtarball.rb +16 -1
- data/lib/librarian/puppet/version.rb +1 -1
- metadata +33 -112
- data/vendor/librarian/CHANGELOG.md +0 -185
- data/vendor/librarian/Gemfile +0 -6
- data/vendor/librarian/MIT-LICENSE +0 -20
- data/vendor/librarian/README.md +0 -403
- data/vendor/librarian/Rakefile +0 -34
- data/vendor/librarian/bin/librarian-chef +0 -7
- data/vendor/librarian/bin/librarian-mock +0 -7
- data/vendor/librarian/config/cucumber.yaml +0 -1
- data/vendor/librarian/features/chef/cli/init.feature +0 -11
- data/vendor/librarian/features/chef/cli/install.feature +0 -64
- data/vendor/librarian/features/chef/cli/show.feature +0 -77
- data/vendor/librarian/features/chef/cli/version.feature +0 -11
- data/vendor/librarian/features/support/env.rb +0 -9
- data/vendor/librarian/lib/librarian.rb +0 -19
- data/vendor/librarian/lib/librarian/action.rb +0 -5
- data/vendor/librarian/lib/librarian/action/base.rb +0 -24
- data/vendor/librarian/lib/librarian/action/clean.rb +0 -44
- data/vendor/librarian/lib/librarian/action/ensure.rb +0 -24
- data/vendor/librarian/lib/librarian/action/install.rb +0 -99
- data/vendor/librarian/lib/librarian/action/resolve.rb +0 -81
- data/vendor/librarian/lib/librarian/action/update.rb +0 -78
- data/vendor/librarian/lib/librarian/chef.rb +0 -1
- data/vendor/librarian/lib/librarian/chef/cli.rb +0 -48
- data/vendor/librarian/lib/librarian/chef/dsl.rb +0 -15
- data/vendor/librarian/lib/librarian/chef/environment.rb +0 -27
- data/vendor/librarian/lib/librarian/chef/extension.rb +0 -9
- data/vendor/librarian/lib/librarian/chef/integration/knife.rb +0 -42
- data/vendor/librarian/lib/librarian/chef/manifest_reader.rb +0 -59
- data/vendor/librarian/lib/librarian/chef/source.rb +0 -3
- data/vendor/librarian/lib/librarian/chef/source/git.rb +0 -25
- data/vendor/librarian/lib/librarian/chef/source/local.rb +0 -69
- data/vendor/librarian/lib/librarian/chef/source/path.rb +0 -12
- data/vendor/librarian/lib/librarian/chef/source/site.rb +0 -446
- data/vendor/librarian/lib/librarian/chef/templates/Cheffile +0 -15
- data/vendor/librarian/lib/librarian/cli.rb +0 -205
- data/vendor/librarian/lib/librarian/cli/manifest_presenter.rb +0 -79
- data/vendor/librarian/lib/librarian/config.rb +0 -7
- data/vendor/librarian/lib/librarian/config/database.rb +0 -205
- data/vendor/librarian/lib/librarian/config/file_source.rb +0 -47
- data/vendor/librarian/lib/librarian/config/hash_source.rb +0 -33
- data/vendor/librarian/lib/librarian/config/source.rb +0 -149
- data/vendor/librarian/lib/librarian/dependency.rb +0 -91
- data/vendor/librarian/lib/librarian/dsl.rb +0 -108
- data/vendor/librarian/lib/librarian/dsl/receiver.rb +0 -48
- data/vendor/librarian/lib/librarian/dsl/target.rb +0 -172
- data/vendor/librarian/lib/librarian/environment.rb +0 -134
- data/vendor/librarian/lib/librarian/error.rb +0 -4
- data/vendor/librarian/lib/librarian/helpers.rb +0 -13
- data/vendor/librarian/lib/librarian/lockfile.rb +0 -29
- data/vendor/librarian/lib/librarian/lockfile/compiler.rb +0 -66
- data/vendor/librarian/lib/librarian/lockfile/parser.rb +0 -100
- data/vendor/librarian/lib/librarian/logger.rb +0 -46
- data/vendor/librarian/lib/librarian/manifest.rb +0 -132
- data/vendor/librarian/lib/librarian/manifest_set.rb +0 -154
- data/vendor/librarian/lib/librarian/mock.rb +0 -1
- data/vendor/librarian/lib/librarian/mock/cli.rb +0 -19
- data/vendor/librarian/lib/librarian/mock/dsl.rb +0 -15
- data/vendor/librarian/lib/librarian/mock/environment.rb +0 -24
- data/vendor/librarian/lib/librarian/mock/extension.rb +0 -9
- data/vendor/librarian/lib/librarian/mock/source.rb +0 -1
- data/vendor/librarian/lib/librarian/mock/source/mock.rb +0 -97
- data/vendor/librarian/lib/librarian/mock/source/mock/registry.rb +0 -83
- data/vendor/librarian/lib/librarian/resolution.rb +0 -44
- data/vendor/librarian/lib/librarian/resolver.rb +0 -78
- data/vendor/librarian/lib/librarian/resolver/implementation.rb +0 -118
- data/vendor/librarian/lib/librarian/source.rb +0 -2
- data/vendor/librarian/lib/librarian/source/git.rb +0 -150
- data/vendor/librarian/lib/librarian/source/git/repository.rb +0 -217
- data/vendor/librarian/lib/librarian/source/local.rb +0 -61
- data/vendor/librarian/lib/librarian/source/path.rb +0 -74
- data/vendor/librarian/lib/librarian/spec.rb +0 -13
- data/vendor/librarian/lib/librarian/spec_change_set.rb +0 -173
- data/vendor/librarian/lib/librarian/specfile.rb +0 -18
- data/vendor/librarian/lib/librarian/support/abstract_method.rb +0 -21
- data/vendor/librarian/lib/librarian/ui.rb +0 -64
- data/vendor/librarian/lib/librarian/version.rb +0 -3
- data/vendor/librarian/librarian.gemspec +0 -34
- data/vendor/librarian/spec/functional/chef/source/git_spec.rb +0 -432
- data/vendor/librarian/spec/functional/chef/source/site_spec.rb +0 -215
- data/vendor/librarian/spec/functional/source/git/repository_spec.rb +0 -149
- data/vendor/librarian/spec/unit/action/base_spec.rb +0 -18
- data/vendor/librarian/spec/unit/action/clean_spec.rb +0 -102
- data/vendor/librarian/spec/unit/action/ensure_spec.rb +0 -37
- data/vendor/librarian/spec/unit/action/install_spec.rb +0 -111
- data/vendor/librarian/spec/unit/config/database_spec.rb +0 -319
- data/vendor/librarian/spec/unit/dependency_spec.rb +0 -36
- data/vendor/librarian/spec/unit/dsl_spec.rb +0 -194
- data/vendor/librarian/spec/unit/environment_spec.rb +0 -9
- data/vendor/librarian/spec/unit/lockfile/parser_spec.rb +0 -162
- data/vendor/librarian/spec/unit/lockfile_spec.rb +0 -65
- data/vendor/librarian/spec/unit/manifest_set_spec.rb +0 -202
- data/vendor/librarian/spec/unit/manifest_spec.rb +0 -36
- data/vendor/librarian/spec/unit/mock/source/mock_spec.rb +0 -22
- data/vendor/librarian/spec/unit/resolver_spec.rb +0 -192
- data/vendor/librarian/spec/unit/source/git_spec.rb +0 -29
- data/vendor/librarian/spec/unit/spec_change_set_spec.rb +0 -169
@@ -1,172 +0,0 @@
|
|
1
|
-
require 'librarian/spec'
|
2
|
-
|
3
|
-
module Librarian
|
4
|
-
class Dsl
|
5
|
-
class Target
|
6
|
-
|
7
|
-
class SourceShortcutDefinitionReceiver
|
8
|
-
def initialize(target)
|
9
|
-
singleton_class = class << self; self end
|
10
|
-
singleton_class.class_eval do
|
11
|
-
define_method(:source) do |options|
|
12
|
-
target.source_from_options(options)
|
13
|
-
end
|
14
|
-
target.source_types.each do |source_type|
|
15
|
-
name = source_type[0]
|
16
|
-
define_method(name) do |*args|
|
17
|
-
args.push({}) unless Hash === args.last
|
18
|
-
target.source_from_params(name, *args)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
SCOPABLES = [:sources]
|
26
|
-
|
27
|
-
attr_accessor :dsl
|
28
|
-
private :dsl=
|
29
|
-
|
30
|
-
attr_reader :dependency_name, :dependency_type
|
31
|
-
attr_reader :source_types, :source_types_map, :source_types_reverse_map, :source_type_names, :source_shortcuts
|
32
|
-
attr_reader :dependencies, :source_cache, *SCOPABLES
|
33
|
-
|
34
|
-
def initialize(dsl)
|
35
|
-
self.dsl = dsl
|
36
|
-
@dependency_name = dsl.dependency_name
|
37
|
-
@dependency_type = dsl.dependency_type
|
38
|
-
@source_types = dsl.source_types
|
39
|
-
@source_types_map = Hash[source_types]
|
40
|
-
@source_types_reverse_map = Hash[source_types.map{|pair| a, b = pair ; [b, a]}]
|
41
|
-
@source_type_names = source_types.map{|t| t[0]}
|
42
|
-
@source_cache = {}
|
43
|
-
@source_shortcuts = {}
|
44
|
-
@dependencies = []
|
45
|
-
SCOPABLES.each do |scopable|
|
46
|
-
instance_variable_set(:"@#{scopable}", [])
|
47
|
-
end
|
48
|
-
dsl.source_shortcuts.each do |name, param|
|
49
|
-
define_source_shortcut(name, param)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def to_spec
|
54
|
-
Spec.new(@sources.first, @dependencies)
|
55
|
-
end
|
56
|
-
|
57
|
-
def dependency(name, *args)
|
58
|
-
options = args.last.is_a?(Hash) ? args.pop : {}
|
59
|
-
source = source_from_options(options) || @sources.last
|
60
|
-
unless source
|
61
|
-
raise Error, "#{dependency_name} #{name} is specified without a source!"
|
62
|
-
end
|
63
|
-
dep = dependency_type.new(name, args, source)
|
64
|
-
@dependencies << dep
|
65
|
-
end
|
66
|
-
|
67
|
-
def source(name, param = nil, options = nil, &block)
|
68
|
-
if !(Hash === name) && [Array, Hash, Proc].any?{|c| c === param} && !options && !block
|
69
|
-
define_source_shortcut(name, param)
|
70
|
-
elsif !(Hash === name) && !param && !options
|
71
|
-
source = source_shortcuts[name]
|
72
|
-
scope_or_directive(block) do
|
73
|
-
@sources = @sources.dup << source
|
74
|
-
end
|
75
|
-
else
|
76
|
-
name, param, options = *normalize_source_options(name, param, options || {})
|
77
|
-
source = source_from_params(name, param, options)
|
78
|
-
scope_or_directive(block) do
|
79
|
-
@sources = @sources.dup << source
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
def precache_sources(sources)
|
85
|
-
sources.each do |source|
|
86
|
-
key = [source_types_reverse_map[source.class], *source.to_spec_args]
|
87
|
-
source_cache[key] = source
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
def scope
|
92
|
-
currents = { }
|
93
|
-
SCOPABLES.each do |scopable|
|
94
|
-
currents[scopable] = instance_variable_get(:"@#{scopable}").dup
|
95
|
-
end
|
96
|
-
yield
|
97
|
-
ensure
|
98
|
-
SCOPABLES.reverse.each do |scopable|
|
99
|
-
instance_variable_set(:"@#{scopable}", currents[scopable])
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
def scope_or_directive(scoped_block = nil)
|
104
|
-
unless scoped_block
|
105
|
-
yield
|
106
|
-
else
|
107
|
-
scope do
|
108
|
-
yield
|
109
|
-
scoped_block.call
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
def normalize_source_options(name, param, options)
|
115
|
-
if name.is_a?(Hash)
|
116
|
-
extract_source_parts(name)
|
117
|
-
else
|
118
|
-
[name, param, options]
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
def extract_source_parts(options)
|
123
|
-
if name = source_type_names.find{|name| options.key?(name)}
|
124
|
-
options = options.dup
|
125
|
-
param = options.delete(name)
|
126
|
-
[name, param, options]
|
127
|
-
else
|
128
|
-
nil
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
def source_from_options(options)
|
133
|
-
if options[:source]
|
134
|
-
source_shortcuts[options[:source]]
|
135
|
-
elsif source_parts = extract_source_parts(options)
|
136
|
-
source_from_params(*source_parts)
|
137
|
-
else
|
138
|
-
nil
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
def source_from_params(name, param, options)
|
143
|
-
source_cache[[name, param, options]] ||= begin
|
144
|
-
type = source_types_map[name]
|
145
|
-
type.from_spec_args(environment, param, options)
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
def source_from_source_shortcut_definition(definition)
|
150
|
-
case definition
|
151
|
-
when Array
|
152
|
-
source_from_params(*definition)
|
153
|
-
when Hash
|
154
|
-
source_from_options(definition)
|
155
|
-
when Proc
|
156
|
-
receiver = SourceShortcutDefinitionReceiver.new(self)
|
157
|
-
receiver.instance_eval(&definition)
|
158
|
-
end
|
159
|
-
end
|
160
|
-
|
161
|
-
def define_source_shortcut(name, definition)
|
162
|
-
source = source_from_source_shortcut_definition(definition)
|
163
|
-
source_shortcuts[name] = source
|
164
|
-
end
|
165
|
-
|
166
|
-
def environment
|
167
|
-
dsl.environment
|
168
|
-
end
|
169
|
-
|
170
|
-
end
|
171
|
-
end
|
172
|
-
end
|
@@ -1,134 +0,0 @@
|
|
1
|
-
require "pathname"
|
2
|
-
|
3
|
-
require "librarian/support/abstract_method"
|
4
|
-
|
5
|
-
require "librarian/error"
|
6
|
-
require "librarian/config"
|
7
|
-
require "librarian/lockfile"
|
8
|
-
require "librarian/logger"
|
9
|
-
require "librarian/specfile"
|
10
|
-
require "librarian/resolver"
|
11
|
-
require "librarian/dsl"
|
12
|
-
require "librarian/source"
|
13
|
-
|
14
|
-
module Librarian
|
15
|
-
class Environment
|
16
|
-
|
17
|
-
include Support::AbstractMethod
|
18
|
-
|
19
|
-
attr_accessor :ui
|
20
|
-
|
21
|
-
abstract_method :specfile_name, :dsl_class, :install_path
|
22
|
-
|
23
|
-
def initialize(options = { })
|
24
|
-
@pwd = options.fetch(:pwd) { Dir.pwd }
|
25
|
-
@env = options.fetch(:env) { ENV.to_hash }
|
26
|
-
@home = options.fetch(:home) { File.expand_path("~") }
|
27
|
-
@project_path = options[:project_path]
|
28
|
-
@specfile_name = options[:specfile_name]
|
29
|
-
end
|
30
|
-
|
31
|
-
def logger
|
32
|
-
@logger ||= Logger.new(self)
|
33
|
-
end
|
34
|
-
|
35
|
-
def config_db
|
36
|
-
@config_db ||= begin
|
37
|
-
Config::Database.new(adapter_name,
|
38
|
-
:pwd => @pwd,
|
39
|
-
:env => @env,
|
40
|
-
:home => @home,
|
41
|
-
:project_path => @project_path,
|
42
|
-
:specfile_name => default_specfile_name
|
43
|
-
)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
def default_specfile_name
|
48
|
-
@default_specfile_name ||= begin
|
49
|
-
capped = adapter_name.capitalize
|
50
|
-
"#{capped}file"
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def project_path
|
55
|
-
config_db.project_path
|
56
|
-
end
|
57
|
-
|
58
|
-
def specfile_name
|
59
|
-
config_db.specfile_name
|
60
|
-
end
|
61
|
-
|
62
|
-
def specfile_path
|
63
|
-
config_db.specfile_path
|
64
|
-
end
|
65
|
-
|
66
|
-
def specfile
|
67
|
-
Specfile.new(self, specfile_path)
|
68
|
-
end
|
69
|
-
|
70
|
-
def adapter_name
|
71
|
-
nil
|
72
|
-
end
|
73
|
-
|
74
|
-
def lockfile_name
|
75
|
-
config_db.lockfile_name
|
76
|
-
end
|
77
|
-
|
78
|
-
def lockfile_path
|
79
|
-
config_db.lockfile_path
|
80
|
-
end
|
81
|
-
|
82
|
-
def lockfile
|
83
|
-
Lockfile.new(self, lockfile_path)
|
84
|
-
end
|
85
|
-
|
86
|
-
def ephemeral_lockfile
|
87
|
-
Lockfile.new(self, nil)
|
88
|
-
end
|
89
|
-
|
90
|
-
def resolver
|
91
|
-
Resolver.new(self)
|
92
|
-
end
|
93
|
-
|
94
|
-
def cache_path
|
95
|
-
project_path.join("tmp/librarian/cache")
|
96
|
-
end
|
97
|
-
|
98
|
-
def scratch_path
|
99
|
-
project_path.join("tmp/librarian/scratch")
|
100
|
-
end
|
101
|
-
|
102
|
-
def project_relative_path_to(path)
|
103
|
-
Pathname.new(path).relative_path_from(project_path)
|
104
|
-
end
|
105
|
-
|
106
|
-
def spec
|
107
|
-
specfile.read
|
108
|
-
end
|
109
|
-
|
110
|
-
def lock
|
111
|
-
lockfile.read
|
112
|
-
end
|
113
|
-
|
114
|
-
def dsl(*args, &block)
|
115
|
-
dsl_class.run(self, *args, &block)
|
116
|
-
end
|
117
|
-
|
118
|
-
def dsl_class
|
119
|
-
self.class.name.split("::")[0 ... -1].inject(Object, &:const_get)::Dsl
|
120
|
-
end
|
121
|
-
|
122
|
-
def config_keys
|
123
|
-
%[
|
124
|
-
]
|
125
|
-
end
|
126
|
-
|
127
|
-
private
|
128
|
-
|
129
|
-
def environment
|
130
|
-
self
|
131
|
-
end
|
132
|
-
|
133
|
-
end
|
134
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
module Librarian
|
2
|
-
module Helpers
|
3
|
-
extend self
|
4
|
-
|
5
|
-
# [active_support/core_ext/string/strip]
|
6
|
-
def strip_heredoc(string)
|
7
|
-
indent = string.scan(/^[ \t]*(?=\S)/).min
|
8
|
-
indent = indent.respond_to?(:size) ? indent.size : 0
|
9
|
-
string.gsub(/^[ \t]{#{indent}}/, '')
|
10
|
-
end
|
11
|
-
|
12
|
-
end
|
13
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
require 'librarian/lockfile/compiler'
|
2
|
-
require 'librarian/lockfile/parser'
|
3
|
-
|
4
|
-
module Librarian
|
5
|
-
class Lockfile
|
6
|
-
|
7
|
-
attr_accessor :environment
|
8
|
-
private :environment=
|
9
|
-
attr_reader :path
|
10
|
-
|
11
|
-
def initialize(environment, path)
|
12
|
-
self.environment = environment
|
13
|
-
@path = path
|
14
|
-
end
|
15
|
-
|
16
|
-
def save(resolution)
|
17
|
-
Compiler.new(environment).compile(resolution)
|
18
|
-
end
|
19
|
-
|
20
|
-
def load(string)
|
21
|
-
Parser.new(environment).parse(string)
|
22
|
-
end
|
23
|
-
|
24
|
-
def read
|
25
|
-
load(path.read)
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
29
|
-
end
|
@@ -1,66 +0,0 @@
|
|
1
|
-
module Librarian
|
2
|
-
class Lockfile
|
3
|
-
class Compiler
|
4
|
-
|
5
|
-
attr_accessor :environment
|
6
|
-
private :environment=
|
7
|
-
|
8
|
-
def initialize(environment)
|
9
|
-
self.environment = environment
|
10
|
-
end
|
11
|
-
|
12
|
-
def compile(resolution)
|
13
|
-
out = StringIO.new
|
14
|
-
save_sources(out, resolution.manifests)
|
15
|
-
save_dependencies(out, resolution.dependencies)
|
16
|
-
out.string
|
17
|
-
end
|
18
|
-
|
19
|
-
private
|
20
|
-
|
21
|
-
def save_sources(out, manifests)
|
22
|
-
dsl_class.source_types.map{|t| t[1]}.each do |type|
|
23
|
-
type_manifests = manifests.select{|m| type === m.source}
|
24
|
-
sources = type_manifests.map{|m| m.source}.uniq.sort_by{|s| s.to_s}
|
25
|
-
sources.each do |source|
|
26
|
-
source_manifests = type_manifests.select{|m| source == m.source}
|
27
|
-
save_source(out, source, source_manifests)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def save_source(out, source, manifests)
|
33
|
-
out.puts "#{source.class.lock_name}"
|
34
|
-
options = source.to_lock_options
|
35
|
-
remote = options.delete(:remote)
|
36
|
-
out.puts " remote: #{remote}"
|
37
|
-
options.to_a.sort_by{|a| a[0].to_s}.each do |o|
|
38
|
-
out.puts " #{o[0]}: #{o[1]}"
|
39
|
-
end
|
40
|
-
out.puts " specs:"
|
41
|
-
manifests.sort_by{|a| a.name}.each do |manifest|
|
42
|
-
out.puts " #{manifest.name} (#{manifest.version})"
|
43
|
-
manifest.dependencies.sort_by{|a| a.name}.each do |dependency|
|
44
|
-
out.puts " #{dependency.name} (#{dependency.requirement})"
|
45
|
-
end
|
46
|
-
end
|
47
|
-
out.puts ""
|
48
|
-
end
|
49
|
-
|
50
|
-
def save_dependencies(out, dependencies)
|
51
|
-
out.puts "DEPENDENCIES"
|
52
|
-
dependencies.sort_by{|a| a.name}.each do |d|
|
53
|
-
res = "#{d.name}"
|
54
|
-
res << " (#{d.requirement})" if d.requirement
|
55
|
-
out.puts " #{res}"
|
56
|
-
end
|
57
|
-
out.puts ""
|
58
|
-
end
|
59
|
-
|
60
|
-
def dsl_class
|
61
|
-
environment.dsl_class
|
62
|
-
end
|
63
|
-
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
@@ -1,100 +0,0 @@
|
|
1
|
-
require 'librarian/manifest'
|
2
|
-
require 'librarian/dependency'
|
3
|
-
require 'librarian/manifest_set'
|
4
|
-
|
5
|
-
module Librarian
|
6
|
-
class Lockfile
|
7
|
-
class Parser
|
8
|
-
|
9
|
-
class ManifestPlaceholder
|
10
|
-
attr_reader :source, :name, :version, :dependencies
|
11
|
-
def initialize(source, name, version, dependencies)
|
12
|
-
@source, @name, @version, @dependencies = source, name, version, dependencies
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
attr_accessor :environment
|
17
|
-
private :environment=
|
18
|
-
|
19
|
-
def initialize(environment)
|
20
|
-
self.environment = environment
|
21
|
-
end
|
22
|
-
|
23
|
-
def parse(string)
|
24
|
-
string = string.dup
|
25
|
-
source_type_names_map = Hash[dsl_class.source_types.map{|t| [t[1].lock_name, t[1]]}]
|
26
|
-
source_type_names = dsl_class.source_types.map{|t| t[1].lock_name}
|
27
|
-
lines = string.split(/(\r|\n|\r\n)+/).select{|l| l =~ /\S/}
|
28
|
-
sources = []
|
29
|
-
while source_type_names.include?(lines.first)
|
30
|
-
source = {}
|
31
|
-
source_type_name = lines.shift
|
32
|
-
source[:type] = source_type_names_map[source_type_name]
|
33
|
-
options = {}
|
34
|
-
while lines.first =~ /^ {2}([\w-]+):\s+(.+)$/
|
35
|
-
lines.shift
|
36
|
-
options[$1.to_sym] = $2
|
37
|
-
end
|
38
|
-
source[:options] = options
|
39
|
-
lines.shift # specs
|
40
|
-
manifests = {}
|
41
|
-
while lines.first =~ /^ {4}([\w-]+) \((.*)\)$/
|
42
|
-
lines.shift
|
43
|
-
name = $1
|
44
|
-
manifests[name] = {:version => $2, :dependencies => {}}
|
45
|
-
while lines.first =~ /^ {6}([\w-]+) \((.*)\)$/
|
46
|
-
lines.shift
|
47
|
-
manifests[name][:dependencies][$1] = $2.split(/,\s*/)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
source[:manifests] = manifests
|
51
|
-
sources << source
|
52
|
-
end
|
53
|
-
manifests = compile(sources)
|
54
|
-
manifests_index = Hash[manifests.map{|m| [m.name, m]}]
|
55
|
-
raise StandardError, "Expected DEPENDENCIES topic!" unless lines.shift == "DEPENDENCIES"
|
56
|
-
dependencies = []
|
57
|
-
while lines.first =~ /^ {2}([\w-]+)(?: \((.*)\))?$/
|
58
|
-
lines.shift
|
59
|
-
name, requirement = $1, $2.split(/,\s*/)
|
60
|
-
dependencies << Dependency.new(name, requirement, manifests_index[name].source)
|
61
|
-
end
|
62
|
-
Resolution.new(dependencies, manifests)
|
63
|
-
end
|
64
|
-
|
65
|
-
private
|
66
|
-
|
67
|
-
def compile(sources_ast)
|
68
|
-
manifests = {}
|
69
|
-
sources_ast.each do |source_ast|
|
70
|
-
source_type = source_ast[:type]
|
71
|
-
source = source_type.from_lock_options(environment, source_ast[:options])
|
72
|
-
source_ast[:manifests].each do |manifest_name, manifest_ast|
|
73
|
-
manifests[manifest_name] = ManifestPlaceholder.new(
|
74
|
-
source,
|
75
|
-
manifest_name,
|
76
|
-
manifest_ast[:version],
|
77
|
-
manifest_ast[:dependencies].map{|k, v| Dependency.new(k, v, nil)}
|
78
|
-
)
|
79
|
-
end
|
80
|
-
end
|
81
|
-
manifests = manifests.map do |name, manifest|
|
82
|
-
dependencies = manifest.dependencies.map do |d|
|
83
|
-
Dependency.new(d.name, d.requirement, manifests[d.name].source)
|
84
|
-
end
|
85
|
-
manifest.source.manifest(
|
86
|
-
manifest.name,
|
87
|
-
manifest.version,
|
88
|
-
dependencies
|
89
|
-
)
|
90
|
-
end
|
91
|
-
ManifestSet.sort(manifests)
|
92
|
-
end
|
93
|
-
|
94
|
-
def dsl_class
|
95
|
-
environment.dsl_class
|
96
|
-
end
|
97
|
-
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|