librarian-puppet-maestrodev 0.9.7
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/LICENSE +20 -0
- data/README.md +187 -0
- data/bin/librarian-puppet +9 -0
- data/lib/librarian/puppet.rb +13 -0
- data/lib/librarian/puppet/cli.rb +85 -0
- data/lib/librarian/puppet/dsl.rb +16 -0
- data/lib/librarian/puppet/environment.rb +54 -0
- data/lib/librarian/puppet/extension.rb +41 -0
- data/lib/librarian/puppet/lockfile/parser.rb +53 -0
- data/lib/librarian/puppet/source.rb +4 -0
- data/lib/librarian/puppet/source/forge.rb +279 -0
- data/lib/librarian/puppet/source/git.rb +114 -0
- data/lib/librarian/puppet/source/githubtarball.rb +234 -0
- data/lib/librarian/puppet/source/local.rb +57 -0
- data/lib/librarian/puppet/source/path.rb +12 -0
- data/lib/librarian/puppet/templates/Puppetfile +10 -0
- data/lib/librarian/puppet/version.rb +5 -0
- data/vendor/librarian/CHANGELOG.md +185 -0
- data/vendor/librarian/Gemfile +6 -0
- data/vendor/librarian/MIT-LICENSE +20 -0
- data/vendor/librarian/README.md +403 -0
- data/vendor/librarian/Rakefile +34 -0
- data/vendor/librarian/bin/librarian-chef +7 -0
- data/vendor/librarian/bin/librarian-mock +7 -0
- data/vendor/librarian/config/cucumber.yaml +1 -0
- data/vendor/librarian/features/chef/cli/init.feature +11 -0
- data/vendor/librarian/features/chef/cli/install.feature +64 -0
- data/vendor/librarian/features/chef/cli/show.feature +77 -0
- data/vendor/librarian/features/chef/cli/version.feature +11 -0
- data/vendor/librarian/features/support/env.rb +9 -0
- data/vendor/librarian/lib/librarian.rb +19 -0
- data/vendor/librarian/lib/librarian/action.rb +5 -0
- data/vendor/librarian/lib/librarian/action/base.rb +24 -0
- data/vendor/librarian/lib/librarian/action/clean.rb +44 -0
- data/vendor/librarian/lib/librarian/action/ensure.rb +24 -0
- data/vendor/librarian/lib/librarian/action/install.rb +99 -0
- data/vendor/librarian/lib/librarian/action/resolve.rb +81 -0
- data/vendor/librarian/lib/librarian/action/update.rb +78 -0
- data/vendor/librarian/lib/librarian/chef.rb +1 -0
- data/vendor/librarian/lib/librarian/chef/cli.rb +48 -0
- data/vendor/librarian/lib/librarian/chef/dsl.rb +15 -0
- data/vendor/librarian/lib/librarian/chef/environment.rb +27 -0
- data/vendor/librarian/lib/librarian/chef/extension.rb +9 -0
- data/vendor/librarian/lib/librarian/chef/integration/knife.rb +42 -0
- data/vendor/librarian/lib/librarian/chef/manifest_reader.rb +59 -0
- data/vendor/librarian/lib/librarian/chef/source.rb +3 -0
- data/vendor/librarian/lib/librarian/chef/source/git.rb +25 -0
- data/vendor/librarian/lib/librarian/chef/source/local.rb +69 -0
- data/vendor/librarian/lib/librarian/chef/source/path.rb +12 -0
- data/vendor/librarian/lib/librarian/chef/source/site.rb +446 -0
- data/vendor/librarian/lib/librarian/chef/templates/Cheffile +15 -0
- data/vendor/librarian/lib/librarian/cli.rb +205 -0
- data/vendor/librarian/lib/librarian/cli/manifest_presenter.rb +79 -0
- data/vendor/librarian/lib/librarian/config.rb +7 -0
- data/vendor/librarian/lib/librarian/config/database.rb +205 -0
- data/vendor/librarian/lib/librarian/config/file_source.rb +47 -0
- data/vendor/librarian/lib/librarian/config/hash_source.rb +33 -0
- data/vendor/librarian/lib/librarian/config/source.rb +149 -0
- data/vendor/librarian/lib/librarian/dependency.rb +91 -0
- data/vendor/librarian/lib/librarian/dsl.rb +108 -0
- data/vendor/librarian/lib/librarian/dsl/receiver.rb +48 -0
- data/vendor/librarian/lib/librarian/dsl/target.rb +172 -0
- data/vendor/librarian/lib/librarian/environment.rb +134 -0
- data/vendor/librarian/lib/librarian/error.rb +4 -0
- data/vendor/librarian/lib/librarian/helpers.rb +13 -0
- data/vendor/librarian/lib/librarian/lockfile.rb +29 -0
- data/vendor/librarian/lib/librarian/lockfile/compiler.rb +66 -0
- data/vendor/librarian/lib/librarian/lockfile/parser.rb +100 -0
- data/vendor/librarian/lib/librarian/logger.rb +46 -0
- data/vendor/librarian/lib/librarian/manifest.rb +132 -0
- data/vendor/librarian/lib/librarian/manifest_set.rb +153 -0
- data/vendor/librarian/lib/librarian/mock.rb +1 -0
- data/vendor/librarian/lib/librarian/mock/cli.rb +19 -0
- data/vendor/librarian/lib/librarian/mock/dsl.rb +15 -0
- data/vendor/librarian/lib/librarian/mock/environment.rb +24 -0
- data/vendor/librarian/lib/librarian/mock/extension.rb +9 -0
- data/vendor/librarian/lib/librarian/mock/source.rb +1 -0
- data/vendor/librarian/lib/librarian/mock/source/mock.rb +97 -0
- data/vendor/librarian/lib/librarian/mock/source/mock/registry.rb +83 -0
- data/vendor/librarian/lib/librarian/resolution.rb +44 -0
- data/vendor/librarian/lib/librarian/resolver.rb +78 -0
- data/vendor/librarian/lib/librarian/resolver/implementation.rb +118 -0
- data/vendor/librarian/lib/librarian/source.rb +2 -0
- data/vendor/librarian/lib/librarian/source/git.rb +150 -0
- data/vendor/librarian/lib/librarian/source/git/repository.rb +217 -0
- data/vendor/librarian/lib/librarian/source/local.rb +61 -0
- data/vendor/librarian/lib/librarian/source/path.rb +74 -0
- data/vendor/librarian/lib/librarian/spec.rb +13 -0
- data/vendor/librarian/lib/librarian/spec_change_set.rb +173 -0
- data/vendor/librarian/lib/librarian/specfile.rb +18 -0
- data/vendor/librarian/lib/librarian/support/abstract_method.rb +21 -0
- data/vendor/librarian/lib/librarian/ui.rb +64 -0
- data/vendor/librarian/lib/librarian/version.rb +3 -0
- data/vendor/librarian/librarian.gemspec +34 -0
- data/vendor/librarian/spec/functional/chef/source/git_spec.rb +432 -0
- data/vendor/librarian/spec/functional/chef/source/site_spec.rb +215 -0
- data/vendor/librarian/spec/functional/source/git/repository_spec.rb +149 -0
- data/vendor/librarian/spec/unit/action/base_spec.rb +18 -0
- data/vendor/librarian/spec/unit/action/clean_spec.rb +102 -0
- data/vendor/librarian/spec/unit/action/ensure_spec.rb +37 -0
- data/vendor/librarian/spec/unit/action/install_spec.rb +111 -0
- data/vendor/librarian/spec/unit/config/database_spec.rb +319 -0
- data/vendor/librarian/spec/unit/dependency_spec.rb +36 -0
- data/vendor/librarian/spec/unit/dsl_spec.rb +194 -0
- data/vendor/librarian/spec/unit/environment_spec.rb +9 -0
- data/vendor/librarian/spec/unit/lockfile/parser_spec.rb +162 -0
- data/vendor/librarian/spec/unit/lockfile_spec.rb +65 -0
- data/vendor/librarian/spec/unit/manifest_set_spec.rb +202 -0
- data/vendor/librarian/spec/unit/manifest_spec.rb +36 -0
- data/vendor/librarian/spec/unit/mock/source/mock_spec.rb +22 -0
- data/vendor/librarian/spec/unit/resolver_spec.rb +192 -0
- data/vendor/librarian/spec/unit/source/git_spec.rb +29 -0
- data/vendor/librarian/spec/unit/spec_change_set_spec.rb +169 -0
- metadata +227 -0
@@ -0,0 +1,47 @@
|
|
1
|
+
require "yaml"
|
2
|
+
|
3
|
+
require "librarian/config/source"
|
4
|
+
|
5
|
+
module Librarian
|
6
|
+
module Config
|
7
|
+
class FileSource < Source
|
8
|
+
|
9
|
+
attr_accessor :config_path
|
10
|
+
private :config_path=
|
11
|
+
|
12
|
+
def initialize(adapter_name, options = { })
|
13
|
+
super
|
14
|
+
|
15
|
+
self.config_path = options.delete(:config_path) or raise ArgumentError, "must provide config_path"
|
16
|
+
end
|
17
|
+
|
18
|
+
def to_s
|
19
|
+
config_path
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def load
|
25
|
+
return { } unless File.file?(config_path)
|
26
|
+
|
27
|
+
raw = YAML.load_file(config_path)
|
28
|
+
return { } unless Hash === raw
|
29
|
+
|
30
|
+
translate_raw_to_config(raw)
|
31
|
+
end
|
32
|
+
|
33
|
+
def save(config)
|
34
|
+
raw = translate_config_to_raw(config)
|
35
|
+
|
36
|
+
if config.empty?
|
37
|
+
File.delete(config_path) if File.file?(config_path)
|
38
|
+
else
|
39
|
+
config_dir = File.dirname(config_path)
|
40
|
+
FileUtils.mkpath(config_dir) unless File.directory?(config_dir)
|
41
|
+
File.open(config_path, "wb"){|f| YAML.dump(raw, f)}
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require "librarian/source"
|
2
|
+
|
3
|
+
module Librarian
|
4
|
+
module Config
|
5
|
+
class HashSource < Source
|
6
|
+
|
7
|
+
attr_accessor :name, :raw
|
8
|
+
private :name=, :raw=
|
9
|
+
|
10
|
+
def initialize(adapter_name, options = { })
|
11
|
+
super
|
12
|
+
|
13
|
+
self.name = options.delete(:name) or raise ArgumentError, "must provide name"
|
14
|
+
self.raw = options.delete(:raw) or raise ArgumentError, "must provide raw"
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_s
|
18
|
+
name
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def load
|
24
|
+
translate_raw_to_config(raw)
|
25
|
+
end
|
26
|
+
|
27
|
+
def save(config)
|
28
|
+
raise Error, "nonsense!"
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,149 @@
|
|
1
|
+
require "librarian/error"
|
2
|
+
|
3
|
+
module Librarian
|
4
|
+
module Config
|
5
|
+
class Source
|
6
|
+
|
7
|
+
RAW_KEY_SUFFIX_VALIDITY_PATTERN =
|
8
|
+
/\A[A-Z0-9_]+\z/
|
9
|
+
CONFIG_KEY_VALIDITY_PATTERN =
|
10
|
+
/\A[a-z][a-z0-9\-]+(?:\.[a-z0-9\-]+)*\z/
|
11
|
+
|
12
|
+
class << self
|
13
|
+
def raw_key_suffix_validity_pattern
|
14
|
+
RAW_KEY_SUFFIX_VALIDITY_PATTERN
|
15
|
+
end
|
16
|
+
def config_key_validity_pattern
|
17
|
+
CONFIG_KEY_VALIDITY_PATTERN
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
attr_accessor :adapter_name
|
22
|
+
private :adapter_name=
|
23
|
+
|
24
|
+
def initialize(adapter_name, options = { })
|
25
|
+
self.adapter_name = adapter_name
|
26
|
+
|
27
|
+
self.forbidden_keys = options.delete(:forbidden_keys) || []
|
28
|
+
end
|
29
|
+
|
30
|
+
def [](key)
|
31
|
+
load!
|
32
|
+
|
33
|
+
data[key]
|
34
|
+
end
|
35
|
+
|
36
|
+
def []=(key, value)
|
37
|
+
key_permitted?(key) or raise Error, "key not permitted: #{key.inspect}"
|
38
|
+
value_permitted?(key, value) or raise Error, "value for key #{key.inspect} not permitted: #{value.inspect}"
|
39
|
+
|
40
|
+
load!
|
41
|
+
if value.nil?
|
42
|
+
data.delete(key)
|
43
|
+
else
|
44
|
+
data[key] = value
|
45
|
+
end
|
46
|
+
save(data)
|
47
|
+
end
|
48
|
+
|
49
|
+
def keys
|
50
|
+
load!
|
51
|
+
|
52
|
+
data.keys
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
attr_accessor :data, :forbidden_keys
|
58
|
+
|
59
|
+
def load!
|
60
|
+
self.data = load unless data
|
61
|
+
end
|
62
|
+
|
63
|
+
def key_permitted?(key)
|
64
|
+
String === key &&
|
65
|
+
config_key_validity_pattern === key &&
|
66
|
+
!forbidden_keys.any?{|k| k === key}
|
67
|
+
end
|
68
|
+
|
69
|
+
def value_permitted?(key, value)
|
70
|
+
return true if value.nil?
|
71
|
+
|
72
|
+
String === value
|
73
|
+
end
|
74
|
+
|
75
|
+
def raw_key_valid?(key)
|
76
|
+
return false unless key.start_with?(raw_key_prefix)
|
77
|
+
|
78
|
+
suffix = key[raw_key_prefix.size..-1]
|
79
|
+
raw_key_suffix_validity_pattern =~ suffix
|
80
|
+
end
|
81
|
+
|
82
|
+
def raw_key_suffix_validity_pattern
|
83
|
+
self.class.raw_key_suffix_validity_pattern
|
84
|
+
end
|
85
|
+
|
86
|
+
def config_key_valid?(key)
|
87
|
+
config_key_validity_pattern === key
|
88
|
+
end
|
89
|
+
|
90
|
+
def config_key_validity_pattern
|
91
|
+
self.class.config_key_validity_pattern
|
92
|
+
end
|
93
|
+
|
94
|
+
def raw_key_prefix
|
95
|
+
@key_prefix ||= "LIBRARIAN_#{adapter_name.upcase}_"
|
96
|
+
end
|
97
|
+
|
98
|
+
def assert_raw_keys_valid!(raw)
|
99
|
+
bad_keys = raw.keys.reject{|k| raw_key_valid?(k)}
|
100
|
+
unless bad_keys.empty?
|
101
|
+
config_path_s = config_path.to_s.inspect
|
102
|
+
bad_keys_s = bad_keys.map(&:inspect).join(", ")
|
103
|
+
raise Error, "config #{to_s} has bad keys: #{bad_keys_s}"
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def assert_config_keys_valid!(config)
|
108
|
+
bad_keys = config.keys.reject{|k| config_key_valid?(k)}
|
109
|
+
unless bad_keys.empty?
|
110
|
+
bad_keys_s = bad_keys.map(&:inspect).join(", ")
|
111
|
+
raise Error, "config has bad keys: #{bad_keys_s}"
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
def assert_values_valid!(data)
|
116
|
+
bad_data = data.reject{|k, v| String === v}
|
117
|
+
bad_keys = bad_data.keys
|
118
|
+
|
119
|
+
unless bad_keys.empty?
|
120
|
+
bad_keys_s = bad_keys.map(&:inspect).join(", ")
|
121
|
+
raise Error, "config has bad values for keys: #{bad_keys_s}"
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
def translate_raw_to_config(raw)
|
126
|
+
assert_raw_keys_valid!(raw)
|
127
|
+
assert_values_valid!(raw)
|
128
|
+
|
129
|
+
Hash[raw.map do |key, value|
|
130
|
+
key = key[raw_key_prefix.size .. -1]
|
131
|
+
key = key.downcase.gsub(/__/, ".").gsub(/_/, "-")
|
132
|
+
[key, value]
|
133
|
+
end]
|
134
|
+
end
|
135
|
+
|
136
|
+
def translate_config_to_raw(config)
|
137
|
+
assert_config_keys_valid!(config)
|
138
|
+
assert_values_valid!(config)
|
139
|
+
|
140
|
+
Hash[config.map do |key, value|
|
141
|
+
key = key.gsub(/\./, "__").gsub(/\-/, "_").upcase
|
142
|
+
key = "#{raw_key_prefix}#{key}"
|
143
|
+
[key, value]
|
144
|
+
end]
|
145
|
+
end
|
146
|
+
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
|
3
|
+
module Librarian
|
4
|
+
class Dependency
|
5
|
+
|
6
|
+
class Requirement
|
7
|
+
def initialize(*args)
|
8
|
+
args = initialize_normalize_args(args)
|
9
|
+
|
10
|
+
self.backing = Gem::Requirement.create(*args)
|
11
|
+
end
|
12
|
+
|
13
|
+
def to_gem_requirement
|
14
|
+
backing
|
15
|
+
end
|
16
|
+
|
17
|
+
def satisfied_by?(version)
|
18
|
+
to_gem_requirement.satisfied_by?(version.to_gem_version)
|
19
|
+
end
|
20
|
+
|
21
|
+
def ==(other)
|
22
|
+
to_gem_requirement == other.to_gem_requirement
|
23
|
+
end
|
24
|
+
|
25
|
+
def to_s
|
26
|
+
to_gem_requirement.to_s
|
27
|
+
end
|
28
|
+
|
29
|
+
protected
|
30
|
+
|
31
|
+
attr_accessor :backing
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def initialize_normalize_args(args)
|
36
|
+
args.map do |arg|
|
37
|
+
arg = arg.backing if self.class === arg
|
38
|
+
arg
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
attr_accessor :name, :requirement, :source
|
44
|
+
private :name=, :requirement=, :source=
|
45
|
+
|
46
|
+
def initialize(name, requirement, source)
|
47
|
+
assert_name_valid! name
|
48
|
+
|
49
|
+
self.name = name
|
50
|
+
self.requirement = Requirement.new(requirement)
|
51
|
+
self.source = source
|
52
|
+
|
53
|
+
@manifests = nil
|
54
|
+
end
|
55
|
+
|
56
|
+
def manifests
|
57
|
+
@manifests ||= cache_manifests!
|
58
|
+
end
|
59
|
+
|
60
|
+
def cache_manifests!
|
61
|
+
source.manifests(name)
|
62
|
+
end
|
63
|
+
|
64
|
+
def satisfied_by?(manifest)
|
65
|
+
manifest.satisfies?(self)
|
66
|
+
end
|
67
|
+
|
68
|
+
def to_s
|
69
|
+
"#{name} (#{requirement}) <#{source}>"
|
70
|
+
end
|
71
|
+
|
72
|
+
def ==(other)
|
73
|
+
!other.nil? &&
|
74
|
+
self.class == other.class &&
|
75
|
+
self.name == other.name &&
|
76
|
+
self.requirement == other.requirement &&
|
77
|
+
self.source == other.source
|
78
|
+
end
|
79
|
+
|
80
|
+
private
|
81
|
+
|
82
|
+
def environment
|
83
|
+
source.environment
|
84
|
+
end
|
85
|
+
|
86
|
+
def assert_name_valid!(name)
|
87
|
+
raise ArgumentError, "name (#{name.inspect}) must be sensible" unless name =~ /\A\S(?:.*\S)?\z/
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
require 'librarian/dependency'
|
2
|
+
require 'librarian/dsl/receiver'
|
3
|
+
require 'librarian/dsl/target'
|
4
|
+
|
5
|
+
module Librarian
|
6
|
+
class Dsl
|
7
|
+
|
8
|
+
class Error < Exception
|
9
|
+
end
|
10
|
+
|
11
|
+
attr_accessor :environment
|
12
|
+
private :environment=
|
13
|
+
|
14
|
+
class << self
|
15
|
+
|
16
|
+
def run(environment, specfile = nil, precache_sources = [], &block)
|
17
|
+
new(environment).run(specfile, precache_sources, &block)
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def dependency(name)
|
23
|
+
dependency_name = name
|
24
|
+
dependency_type = Dependency
|
25
|
+
singleton_class = class << self; self end
|
26
|
+
singleton_class.instance_eval do
|
27
|
+
define_method(:dependency_name) { dependency_name }
|
28
|
+
define_method(:dependency_type) { dependency_type }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
define_method(:source_types) { [] }
|
33
|
+
|
34
|
+
def source(options)
|
35
|
+
name = options.keys.first
|
36
|
+
type = options[name]
|
37
|
+
types = source_types
|
38
|
+
types << [name, type]
|
39
|
+
singleton_class = class << self; self end
|
40
|
+
singleton_class.instance_eval do
|
41
|
+
define_method(:source_types) { types }
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
define_method(:source_shortcuts) { {} }
|
46
|
+
|
47
|
+
def shortcut(name, options)
|
48
|
+
instances = source_shortcuts
|
49
|
+
instances[name] = options
|
50
|
+
singleton_class = class << self; self end
|
51
|
+
singleton_class.instance_eval do
|
52
|
+
define_method(:source_shortcuts) { instances }
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def delegate_to_class(*names)
|
57
|
+
names.each do |name|
|
58
|
+
define_method(name) { self.class.send(name) }
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
delegate_to_class :dependency_name, :dependency_type, :source_types, :source_shortcuts
|
65
|
+
|
66
|
+
def initialize(environment)
|
67
|
+
self.environment = environment
|
68
|
+
end
|
69
|
+
|
70
|
+
def run(specfile = nil, sources = [])
|
71
|
+
Target.new(self).tap do |target|
|
72
|
+
target.precache_sources(sources)
|
73
|
+
debug_named_source_cache("Pre-Cached Sources", target)
|
74
|
+
|
75
|
+
receiver = Receiver.new(target)
|
76
|
+
if block_given?
|
77
|
+
receiver.run(&Proc.new)
|
78
|
+
else
|
79
|
+
case specfile
|
80
|
+
when Specfile, String, Proc
|
81
|
+
receiver.run(specfile)
|
82
|
+
else
|
83
|
+
raise ArgumentError, "specfile must be a #{Specfile}, #{String}, or #{Proc} if no block is given (it was #{specfile.inspect})"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
debug_named_source_cache("Post-Cached Sources", target)
|
88
|
+
end.to_spec
|
89
|
+
end
|
90
|
+
|
91
|
+
def debug_named_source_cache(name, target)
|
92
|
+
source_cache = target.source_cache
|
93
|
+
debug { "#{name}:" }
|
94
|
+
source_cache.each do |key, value|
|
95
|
+
type = key[0]
|
96
|
+
attributes = key[1...key.size]
|
97
|
+
debug { " #{key.inspect}" }
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
private
|
102
|
+
|
103
|
+
def debug(*args, &block)
|
104
|
+
environment.logger.debug(*args, &block)
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'librarian/specfile'
|
2
|
+
|
3
|
+
module Librarian
|
4
|
+
class Dsl
|
5
|
+
class Receiver
|
6
|
+
|
7
|
+
def initialize(target)
|
8
|
+
singleton_class = class << self; self end
|
9
|
+
singleton_class.class_eval do
|
10
|
+
define_method(target.dependency_name) do |*args, &block|
|
11
|
+
target.dependency(*args, &block)
|
12
|
+
end
|
13
|
+
define_method(:source) do |*args, &block|
|
14
|
+
target.source(*args, &block)
|
15
|
+
end
|
16
|
+
target.source_types.each do |source_type|
|
17
|
+
name = source_type[0]
|
18
|
+
define_method(name) do |*args, &block|
|
19
|
+
target.source(name, *args, &block)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def run(specfile = nil)
|
26
|
+
if block_given?
|
27
|
+
instance_eval(&Proc.new)
|
28
|
+
else
|
29
|
+
case specfile
|
30
|
+
when Specfile
|
31
|
+
eval(specfile.path.read, instance_binding, specfile.path.to_s, 1)
|
32
|
+
when String
|
33
|
+
eval(specfile, instance_binding)
|
34
|
+
when Proc
|
35
|
+
instance_eval(&specfile)
|
36
|
+
else
|
37
|
+
raise ArgumentError, "specfile must be a #{Specfile}, #{String}, or #{Proc} if no block is given (it was #{specfile.inspect})"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def instance_binding
|
43
|
+
binding
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|