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,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#^syntax detection
|
3
|
+
|
4
|
+
site 'http://community.opscode.com/api/v1'
|
5
|
+
|
6
|
+
# cookbook 'chef-client'
|
7
|
+
|
8
|
+
# cookbook 'apache2', '>= 1.0.0'
|
9
|
+
|
10
|
+
# cookbook 'rvm',
|
11
|
+
# :git => 'https://github.com/fnichol/chef-rvm'
|
12
|
+
|
13
|
+
# cookbook 'postgresql',
|
14
|
+
# :git => 'https://github.com/findsyou/cookbooks',
|
15
|
+
# :ref => 'postgresql-improvements'
|
@@ -0,0 +1,205 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'thor/actions'
|
3
|
+
|
4
|
+
require 'librarian'
|
5
|
+
require 'librarian/error'
|
6
|
+
require 'librarian/action'
|
7
|
+
require "librarian/ui"
|
8
|
+
|
9
|
+
module Librarian
|
10
|
+
class Cli < Thor
|
11
|
+
|
12
|
+
autoload :ManifestPresenter, "librarian/cli/manifest_presenter"
|
13
|
+
|
14
|
+
include Thor::Actions
|
15
|
+
|
16
|
+
module Particularity
|
17
|
+
def root_module
|
18
|
+
nil
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
include Particularity
|
23
|
+
extend Particularity
|
24
|
+
|
25
|
+
class << self
|
26
|
+
def bin!
|
27
|
+
begin
|
28
|
+
environment = root_module.environment
|
29
|
+
start
|
30
|
+
rescue Librarian::Error => e
|
31
|
+
environment.ui.error e.message
|
32
|
+
environment.ui.debug e.backtrace.join("\n")
|
33
|
+
exit (e.respond_to?(:status_code) ? e.status_code : 1)
|
34
|
+
rescue Interrupt => e
|
35
|
+
environment.ui.error "\nQuitting..."
|
36
|
+
exit 1
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def initialize(*)
|
42
|
+
super
|
43
|
+
the_shell = (options["no-color"] ? Thor::Shell::Basic.new : shell)
|
44
|
+
environment.ui = UI::Shell.new(the_shell)
|
45
|
+
environment.ui.be_quiet! if options["quiet"]
|
46
|
+
environment.ui.debug! if options["verbose"]
|
47
|
+
environment.ui.debug_line_numbers! if options["verbose"] && options["line-numbers"]
|
48
|
+
|
49
|
+
write_debug_header
|
50
|
+
end
|
51
|
+
|
52
|
+
desc "version", "Displays the version."
|
53
|
+
def version
|
54
|
+
say "librarian-#{root_module.version}"
|
55
|
+
end
|
56
|
+
|
57
|
+
desc "config", "Show or edit the config."
|
58
|
+
option "verbose", :type => :boolean, :default => false
|
59
|
+
option "line-numbers", :type => :boolean, :default => false
|
60
|
+
option "global", :type => :boolean, :default => false
|
61
|
+
option "local", :type => :boolean, :default => false
|
62
|
+
option "delete", :type => :boolean, :default => false
|
63
|
+
def config(key = nil, value = nil)
|
64
|
+
if key
|
65
|
+
raise Error, "cannot set both value and delete" if value && options["delete"]
|
66
|
+
if options["delete"]
|
67
|
+
raise Error, "must set either global or local" unless options["global"] ^ options["local"]
|
68
|
+
scope = options["global"] ? :global : options["local"] ? :local : nil
|
69
|
+
environment.config_db[key, scope] = nil
|
70
|
+
elsif value
|
71
|
+
raise Error, "must set either global or local" unless options["global"] ^ options["local"]
|
72
|
+
scope = options["global"] ? :global : options["local"] ? :local : nil
|
73
|
+
environment.config_db[key, scope] = value
|
74
|
+
else
|
75
|
+
raise Error, "cannot set both global and local" if options["global"] && options["local"]
|
76
|
+
scope = options["global"] ? :global : options["local"] ? :local : nil
|
77
|
+
if value = environment.config_db[key, scope]
|
78
|
+
prefix = scope ? "#{key} (#{scope})" : key
|
79
|
+
say "#{prefix}: #{value}"
|
80
|
+
end
|
81
|
+
end
|
82
|
+
else
|
83
|
+
environment.config_db.keys.each do |key|
|
84
|
+
say "#{key}: #{environment.config_db[key]}"
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
desc "clean", "Cleans out the cache and install paths."
|
90
|
+
option "verbose", :type => :boolean, :default => false
|
91
|
+
option "line-numbers", :type => :boolean, :default => false
|
92
|
+
def clean
|
93
|
+
ensure!
|
94
|
+
clean!
|
95
|
+
end
|
96
|
+
|
97
|
+
desc "update", "Updates and installs the dependencies you specify."
|
98
|
+
option "verbose", :type => :boolean, :default => false
|
99
|
+
option "line-numbers", :type => :boolean, :default => false
|
100
|
+
def update(*names)
|
101
|
+
ensure!
|
102
|
+
if names.empty?
|
103
|
+
resolve!(:force => true)
|
104
|
+
else
|
105
|
+
update!(:names => names)
|
106
|
+
end
|
107
|
+
install!
|
108
|
+
end
|
109
|
+
|
110
|
+
desc "outdated", "Lists outdated dependencies."
|
111
|
+
option "verbose", :type => :boolean, :default => false
|
112
|
+
option "line-numbers", :type => :boolean, :default => false
|
113
|
+
def outdated
|
114
|
+
ensure!
|
115
|
+
resolution = environment.lock
|
116
|
+
resolution.manifests.sort_by(&:name).each do |manifest|
|
117
|
+
source = manifest.source
|
118
|
+
source_manifest = source.manifests(manifest.name).first
|
119
|
+
next if manifest.version == source_manifest.version
|
120
|
+
say "#{manifest.name} (#{manifest.version} -> #{source_manifest.version})"
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
desc "show", "Shows dependencies"
|
125
|
+
option "verbose", :type => :boolean, :default => false
|
126
|
+
option "line-numbers", :type => :boolean, :default => false
|
127
|
+
option "detailed", :type => :boolean
|
128
|
+
def show(*names)
|
129
|
+
ensure!
|
130
|
+
if environment.lockfile_path.file?
|
131
|
+
manifest_presenter.present(names, :detailed => options["detailed"])
|
132
|
+
else
|
133
|
+
raise Error, "Be sure to install first!"
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
desc "init", "Initializes the current directory."
|
138
|
+
def init
|
139
|
+
puts "Nothing to do."
|
140
|
+
end
|
141
|
+
|
142
|
+
private
|
143
|
+
|
144
|
+
def environment
|
145
|
+
root_module.environment
|
146
|
+
end
|
147
|
+
|
148
|
+
def ensure!(options = { })
|
149
|
+
Action::Ensure.new(environment, options).run
|
150
|
+
end
|
151
|
+
|
152
|
+
def clean!(options = { })
|
153
|
+
Action::Clean.new(environment, options).run
|
154
|
+
end
|
155
|
+
|
156
|
+
def install!(options = { })
|
157
|
+
Action::Install.new(environment, options).run
|
158
|
+
end
|
159
|
+
|
160
|
+
def resolve!(options = { })
|
161
|
+
Action::Resolve.new(environment, options).run
|
162
|
+
end
|
163
|
+
|
164
|
+
def update!(options = { })
|
165
|
+
Action::Update.new(environment, options).run
|
166
|
+
end
|
167
|
+
|
168
|
+
def manifest_presenter
|
169
|
+
ManifestPresenter.new(self, environment.lock.manifests)
|
170
|
+
end
|
171
|
+
|
172
|
+
def write_debug_header
|
173
|
+
debug { "Ruby Version: #{RUBY_VERSION}" }
|
174
|
+
debug { "Ruby Platform: #{RUBY_PLATFORM}" }
|
175
|
+
debug { "Rubinius Version: #{Rubinius::VERSION}" } if defined?(Rubinius)
|
176
|
+
debug { "JRuby Version: #{JRUBY_VERSION}" } if defined?(JRUBY_VERSION)
|
177
|
+
debug { "Rubygems Version: #{Gem::VERSION}" }
|
178
|
+
debug { "Librarian Version: #{VERSION}" }
|
179
|
+
debug { "Librarian Adapter: #{environment.adapter_name}"}
|
180
|
+
debug { "Project: #{environment.project_path}" }
|
181
|
+
debug { "Specfile: #{relative_path_to(environment.specfile_path)}" }
|
182
|
+
debug { "Lockfile: #{relative_path_to(environment.lockfile_path)}" }
|
183
|
+
debug { "Git: #{Source::Git::Repository.bin}" }
|
184
|
+
debug { "Git Version: #{Source::Git::Repository.new(environment, environment.project_path).version(:silent => true)}" }
|
185
|
+
debug { "Git Environment Variables:" }
|
186
|
+
git_env = ENV.to_a.select{|(k, v)| k =~ /\AGIT/}.sort_by{|(k, v)| k}
|
187
|
+
if git_env.empty?
|
188
|
+
debug { " (empty)" }
|
189
|
+
else
|
190
|
+
git_env.each do |(k, v)|
|
191
|
+
debug { " #{k}=#{v}"}
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
def debug(*args, &block)
|
197
|
+
environment.logger.debug(*args, &block)
|
198
|
+
end
|
199
|
+
|
200
|
+
def relative_path_to(path)
|
201
|
+
environment.logger.relative_path_to(path)
|
202
|
+
end
|
203
|
+
|
204
|
+
end
|
205
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
module Librarian
|
2
|
+
class Cli
|
3
|
+
class ManifestPresenter
|
4
|
+
|
5
|
+
attr_accessor :cli, :manifests
|
6
|
+
private :cli=, :manifests=
|
7
|
+
|
8
|
+
def initialize(cli, manifests)
|
9
|
+
self.cli = cli or raise ArgumentError, "cli required"
|
10
|
+
self.manifests = manifests or raise ArgumentError, "manifests required"
|
11
|
+
self.manifests_index = Hash[manifests.map{|m| [m.name, m]}]
|
12
|
+
|
13
|
+
self.scope_level = 0
|
14
|
+
end
|
15
|
+
|
16
|
+
def present(names = [], options = { })
|
17
|
+
full = options[:detailed]
|
18
|
+
full = !names.empty? if full.nil?
|
19
|
+
|
20
|
+
if names.empty?
|
21
|
+
names = manifests.map(&:name).sort if names.empty?
|
22
|
+
else
|
23
|
+
missing_names = names.reject{|name| manifest(name)}
|
24
|
+
unless missing_names.empty?
|
25
|
+
raise Error, "not found: #{missing_names.map(&:inspect).join(', ')}"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
names.each do |name|
|
30
|
+
manifest = manifest(name)
|
31
|
+
present_one(manifest, :detailed => full)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def present_one(manifest, options = { })
|
36
|
+
full = options[:detailed]
|
37
|
+
|
38
|
+
say "#{manifest.name} (#{manifest.version})" do
|
39
|
+
if full
|
40
|
+
say "source: #{manifest.source}"
|
41
|
+
unless manifest.dependencies.empty?
|
42
|
+
say "dependencies:" do
|
43
|
+
manifest.dependencies.sort_by(&:name).each do |dependency|
|
44
|
+
say "#{dependency.name} (#{dependency.requirement})"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
attr_accessor :scope_level, :manifests_index
|
55
|
+
|
56
|
+
def manifest(name)
|
57
|
+
manifests_index[name]
|
58
|
+
end
|
59
|
+
|
60
|
+
def say(string)
|
61
|
+
cli.say " " * scope_level << string
|
62
|
+
if block_given?
|
63
|
+
scope do
|
64
|
+
yield
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def scope
|
70
|
+
original_scope_level = scope_level
|
71
|
+
self.scope_level = scope_level + 1
|
72
|
+
yield
|
73
|
+
ensure
|
74
|
+
self.scope_level = original_scope_level
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,205 @@
|
|
1
|
+
require "pathname"
|
2
|
+
|
3
|
+
require "librarian/config/file_source"
|
4
|
+
require "librarian/config/hash_source"
|
5
|
+
|
6
|
+
module Librarian
|
7
|
+
module Config
|
8
|
+
class Database
|
9
|
+
|
10
|
+
class << self
|
11
|
+
def library
|
12
|
+
name.split("::").first.downcase
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
attr_accessor :adapter_name
|
17
|
+
private :adapter_name=
|
18
|
+
|
19
|
+
attr_accessor :root, :assigned_specfile_name
|
20
|
+
private :root=, :assigned_specfile_name=
|
21
|
+
|
22
|
+
attr_accessor :underlying_env, :underlying_pwd, :underlying_home
|
23
|
+
private :underlying_env=, :underlying_pwd=, :underlying_home=
|
24
|
+
|
25
|
+
def initialize(adapter_name, options = { })
|
26
|
+
self.adapter_name = adapter_name or raise ArgumentError, "must provide adapter_name"
|
27
|
+
|
28
|
+
options[:project_path] || options[:pwd] or raise ArgumentError, "must provide project_path or pwd"
|
29
|
+
|
30
|
+
self.root = options[:project_path] && Pathname(options[:project_path])
|
31
|
+
self.assigned_specfile_name = options[:specfile_name]
|
32
|
+
self.underlying_env = options[:env] or raise ArgumentError, "must provide env"
|
33
|
+
self.underlying_pwd = options[:pwd] && Pathname(options[:pwd])
|
34
|
+
self.underlying_home = options[:home] && Pathname(options[:home])
|
35
|
+
end
|
36
|
+
|
37
|
+
def global
|
38
|
+
memo(__method__) { new_file_source(global_config_path) }
|
39
|
+
end
|
40
|
+
|
41
|
+
def env
|
42
|
+
memo(__method__) { HashSource.new(adapter_name, :name => "environment", :raw => env_source_data) }
|
43
|
+
end
|
44
|
+
|
45
|
+
def local
|
46
|
+
memo(__method__) { new_file_source(local_config_path) }
|
47
|
+
end
|
48
|
+
|
49
|
+
def [](key, scope = nil)
|
50
|
+
case scope
|
51
|
+
when "local", :local then local[key]
|
52
|
+
when "env", :env then env[key]
|
53
|
+
when "global", :global then global[key]
|
54
|
+
when nil then local[key] || env[key] || global[key]
|
55
|
+
else raise Error, "bad scope"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def []=(key, scope, value)
|
60
|
+
case scope
|
61
|
+
when "local", :local then local[key] = value
|
62
|
+
when "global", :global then global[key] = value
|
63
|
+
else raise Error, "bad scope"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def keys
|
68
|
+
[local, env, global].inject([]){|a, e| a.concat(e.keys) ; a}.sort.uniq
|
69
|
+
end
|
70
|
+
|
71
|
+
def project_path
|
72
|
+
root || specfile_path.dirname
|
73
|
+
end
|
74
|
+
|
75
|
+
def specfile_path
|
76
|
+
if root
|
77
|
+
root + (assigned_specfile_name || default_specfile_name)
|
78
|
+
else
|
79
|
+
env_specfile_path || default_specfile_path
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def specfile_name
|
84
|
+
specfile_path.basename.to_s
|
85
|
+
end
|
86
|
+
|
87
|
+
def lockfile_path
|
88
|
+
project_path + lockfile_name
|
89
|
+
end
|
90
|
+
|
91
|
+
def lockfile_name
|
92
|
+
"#{specfile_name}.lock"
|
93
|
+
end
|
94
|
+
|
95
|
+
private
|
96
|
+
|
97
|
+
def new_file_source(config_path)
|
98
|
+
return unless config_path
|
99
|
+
|
100
|
+
FileSource.new(adapter_name,
|
101
|
+
:config_path => config_path,
|
102
|
+
:forbidden_keys => [config_key, specfile_key]
|
103
|
+
)
|
104
|
+
end
|
105
|
+
|
106
|
+
def global_config_path
|
107
|
+
env_global_config_path || default_global_config_path
|
108
|
+
end
|
109
|
+
|
110
|
+
def env_global_config_path
|
111
|
+
memo(__method__) { env[config_key] }
|
112
|
+
end
|
113
|
+
|
114
|
+
def default_global_config_path
|
115
|
+
underlying_home && underlying_home + config_name
|
116
|
+
end
|
117
|
+
|
118
|
+
def local_config_path
|
119
|
+
root_local_config_path || env_local_config_path || default_local_config_path
|
120
|
+
end
|
121
|
+
|
122
|
+
def root_local_config_path
|
123
|
+
root && root + config_name
|
124
|
+
end
|
125
|
+
|
126
|
+
def env_specfile_path
|
127
|
+
memo(__method__) do
|
128
|
+
path = env[specfile_key]
|
129
|
+
path && Pathname(path)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
def default_specfile_path
|
134
|
+
default_project_root_path + (assigned_specfile_name || default_specfile_name)
|
135
|
+
end
|
136
|
+
|
137
|
+
def env_local_config_path
|
138
|
+
return unless env_specfile_path
|
139
|
+
|
140
|
+
env_specfile_path.dirname + config_name
|
141
|
+
end
|
142
|
+
|
143
|
+
def default_local_config_path
|
144
|
+
default_project_root_path + config_name
|
145
|
+
end
|
146
|
+
|
147
|
+
def default_project_root_path
|
148
|
+
if root
|
149
|
+
root
|
150
|
+
else
|
151
|
+
path = underlying_pwd
|
152
|
+
path = path.dirname until project_root_path?(path) || path.dirname == path
|
153
|
+
project_root_path?(path) ? path : underlying_pwd
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
def project_root_path?(path)
|
158
|
+
File.file?(path + default_specfile_name)
|
159
|
+
end
|
160
|
+
|
161
|
+
def config_key
|
162
|
+
"config"
|
163
|
+
end
|
164
|
+
|
165
|
+
def specfile_key
|
166
|
+
"#{adapter_name}file"
|
167
|
+
end
|
168
|
+
|
169
|
+
def default_specfile_name
|
170
|
+
"#{adapter_name.capitalize}file"
|
171
|
+
end
|
172
|
+
|
173
|
+
def library
|
174
|
+
self.class.library
|
175
|
+
end
|
176
|
+
|
177
|
+
def config_name_prefix
|
178
|
+
".#{library}"
|
179
|
+
end
|
180
|
+
|
181
|
+
def config_name
|
182
|
+
File.join(*[config_name_prefix, adapter_name, "config"])
|
183
|
+
end
|
184
|
+
|
185
|
+
def raw_key_prefix
|
186
|
+
"#{library.upcase}_#{adapter_name.upcase}_"
|
187
|
+
end
|
188
|
+
|
189
|
+
def env_source_data
|
190
|
+
prefix = raw_key_prefix
|
191
|
+
|
192
|
+
data = underlying_env.dup
|
193
|
+
data.reject!{|k, _| !k.start_with?(prefix) || k.size <= prefix.size}
|
194
|
+
data
|
195
|
+
end
|
196
|
+
|
197
|
+
def memo(key)
|
198
|
+
key = "@#{key}"
|
199
|
+
instance_variable_set(key, yield) unless instance_variable_defined?(key)
|
200
|
+
instance_variable_get(key)
|
201
|
+
end
|
202
|
+
|
203
|
+
end
|
204
|
+
end
|
205
|
+
end
|