librarian-puppet-lmco 0.9.8.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +5 -0
  3. data/LICENSE +20 -0
  4. data/README.md +187 -0
  5. data/bin/librarian-puppet +9 -0
  6. data/lib/librarian/puppet.rb +22 -0
  7. data/lib/librarian/puppet/cli.rb +85 -0
  8. data/lib/librarian/puppet/dsl.rb +16 -0
  9. data/lib/librarian/puppet/environment.rb +54 -0
  10. data/lib/librarian/puppet/extension.rb +47 -0
  11. data/lib/librarian/puppet/lockfile/parser.rb +53 -0
  12. data/lib/librarian/puppet/source.rb +4 -0
  13. data/lib/librarian/puppet/source/forge.rb +348 -0
  14. data/lib/librarian/puppet/source/git.rb +121 -0
  15. data/lib/librarian/puppet/source/githubtarball.rb +249 -0
  16. data/lib/librarian/puppet/source/local.rb +57 -0
  17. data/lib/librarian/puppet/source/path.rb +12 -0
  18. data/lib/librarian/puppet/templates/Puppetfile +10 -0
  19. data/lib/librarian/puppet/version.rb +5 -0
  20. data/vendor/librarian/CHANGELOG.md +224 -0
  21. data/vendor/librarian/Gemfile +6 -0
  22. data/vendor/librarian/MIT-LICENSE +20 -0
  23. data/vendor/librarian/README.md +401 -0
  24. data/vendor/librarian/Rakefile +34 -0
  25. data/vendor/librarian/bin/librarian-chef +7 -0
  26. data/vendor/librarian/bin/librarian-mock +7 -0
  27. data/vendor/librarian/config/cucumber.yaml +1 -0
  28. data/vendor/librarian/features/chef/cli/init.feature +11 -0
  29. data/vendor/librarian/features/chef/cli/install.feature +64 -0
  30. data/vendor/librarian/features/chef/cli/show.feature +77 -0
  31. data/vendor/librarian/features/chef/cli/version.feature +11 -0
  32. data/vendor/librarian/features/support/env.rb +9 -0
  33. data/vendor/librarian/lib/librarian.rb +11 -0
  34. data/vendor/librarian/lib/librarian/action.rb +5 -0
  35. data/vendor/librarian/lib/librarian/action/base.rb +24 -0
  36. data/vendor/librarian/lib/librarian/action/clean.rb +44 -0
  37. data/vendor/librarian/lib/librarian/action/ensure.rb +24 -0
  38. data/vendor/librarian/lib/librarian/action/install.rb +95 -0
  39. data/vendor/librarian/lib/librarian/action/persist_resolution_mixin.rb +51 -0
  40. data/vendor/librarian/lib/librarian/action/resolve.rb +46 -0
  41. data/vendor/librarian/lib/librarian/action/update.rb +44 -0
  42. data/vendor/librarian/lib/librarian/chef.rb +1 -0
  43. data/vendor/librarian/lib/librarian/chef/cli.rb +47 -0
  44. data/vendor/librarian/lib/librarian/chef/dsl.rb +16 -0
  45. data/vendor/librarian/lib/librarian/chef/environment.rb +27 -0
  46. data/vendor/librarian/lib/librarian/chef/extension.rb +9 -0
  47. data/vendor/librarian/lib/librarian/chef/integration/knife.rb +46 -0
  48. data/vendor/librarian/lib/librarian/chef/manifest_reader.rb +59 -0
  49. data/vendor/librarian/lib/librarian/chef/source.rb +4 -0
  50. data/vendor/librarian/lib/librarian/chef/source/git.rb +25 -0
  51. data/vendor/librarian/lib/librarian/chef/source/github.rb +27 -0
  52. data/vendor/librarian/lib/librarian/chef/source/local.rb +69 -0
  53. data/vendor/librarian/lib/librarian/chef/source/path.rb +12 -0
  54. data/vendor/librarian/lib/librarian/chef/source/site.rb +442 -0
  55. data/vendor/librarian/lib/librarian/chef/templates/Cheffile +15 -0
  56. data/vendor/librarian/lib/librarian/cli.rb +223 -0
  57. data/vendor/librarian/lib/librarian/cli/manifest_presenter.rb +93 -0
  58. data/vendor/librarian/lib/librarian/config.rb +7 -0
  59. data/vendor/librarian/lib/librarian/config/database.rb +205 -0
  60. data/vendor/librarian/lib/librarian/config/file_source.rb +47 -0
  61. data/vendor/librarian/lib/librarian/config/hash_source.rb +33 -0
  62. data/vendor/librarian/lib/librarian/config/source.rb +149 -0
  63. data/vendor/librarian/lib/librarian/dependency.rb +147 -0
  64. data/vendor/librarian/lib/librarian/dsl.rb +108 -0
  65. data/vendor/librarian/lib/librarian/dsl/receiver.rb +46 -0
  66. data/vendor/librarian/lib/librarian/dsl/target.rb +171 -0
  67. data/vendor/librarian/lib/librarian/environment.rb +182 -0
  68. data/vendor/librarian/lib/librarian/error.rb +4 -0
  69. data/vendor/librarian/lib/librarian/helpers.rb +13 -0
  70. data/vendor/librarian/lib/librarian/linter/source_linter.rb +55 -0
  71. data/vendor/librarian/lib/librarian/lockfile.rb +29 -0
  72. data/vendor/librarian/lib/librarian/lockfile/compiler.rb +66 -0
  73. data/vendor/librarian/lib/librarian/lockfile/parser.rb +123 -0
  74. data/vendor/librarian/lib/librarian/logger.rb +46 -0
  75. data/vendor/librarian/lib/librarian/manifest.rb +140 -0
  76. data/vendor/librarian/lib/librarian/manifest_set.rb +151 -0
  77. data/vendor/librarian/lib/librarian/mock.rb +1 -0
  78. data/vendor/librarian/lib/librarian/mock/cli.rb +19 -0
  79. data/vendor/librarian/lib/librarian/mock/dsl.rb +15 -0
  80. data/vendor/librarian/lib/librarian/mock/environment.rb +24 -0
  81. data/vendor/librarian/lib/librarian/mock/extension.rb +9 -0
  82. data/vendor/librarian/lib/librarian/mock/source.rb +1 -0
  83. data/vendor/librarian/lib/librarian/mock/source/mock.rb +80 -0
  84. data/vendor/librarian/lib/librarian/mock/source/mock/registry.rb +83 -0
  85. data/vendor/librarian/lib/librarian/resolution.rb +46 -0
  86. data/vendor/librarian/lib/librarian/resolver.rb +81 -0
  87. data/vendor/librarian/lib/librarian/resolver/implementation.rb +223 -0
  88. data/vendor/librarian/lib/librarian/source.rb +2 -0
  89. data/vendor/librarian/lib/librarian/source/basic_api.rb +45 -0
  90. data/vendor/librarian/lib/librarian/source/git.rb +134 -0
  91. data/vendor/librarian/lib/librarian/source/git/repository.rb +217 -0
  92. data/vendor/librarian/lib/librarian/source/local.rb +54 -0
  93. data/vendor/librarian/lib/librarian/source/path.rb +56 -0
  94. data/vendor/librarian/lib/librarian/spec.rb +13 -0
  95. data/vendor/librarian/lib/librarian/spec_change_set.rb +173 -0
  96. data/vendor/librarian/lib/librarian/specfile.rb +17 -0
  97. data/vendor/librarian/lib/librarian/support/abstract_method.rb +21 -0
  98. data/vendor/librarian/lib/librarian/ui.rb +64 -0
  99. data/vendor/librarian/lib/librarian/version.rb +3 -0
  100. data/vendor/librarian/librarian.gemspec +35 -0
  101. data/vendor/librarian/spec/functional/chef/cli_spec.rb +194 -0
  102. data/vendor/librarian/spec/functional/chef/source/git_spec.rb +432 -0
  103. data/vendor/librarian/spec/functional/chef/source/site_spec.rb +266 -0
  104. data/vendor/librarian/spec/functional/source/git/repository_spec.rb +150 -0
  105. data/vendor/librarian/spec/integration/chef/source/git_spec.rb +441 -0
  106. data/vendor/librarian/spec/integration/chef/source/site_spec.rb +217 -0
  107. data/vendor/librarian/spec/support/cli_macro.rb +114 -0
  108. data/vendor/librarian/spec/support/method_patch_macro.rb +30 -0
  109. data/vendor/librarian/spec/support/with_env_macro.rb +20 -0
  110. data/vendor/librarian/spec/unit/action/base_spec.rb +18 -0
  111. data/vendor/librarian/spec/unit/action/clean_spec.rb +102 -0
  112. data/vendor/librarian/spec/unit/action/ensure_spec.rb +37 -0
  113. data/vendor/librarian/spec/unit/action/install_spec.rb +111 -0
  114. data/vendor/librarian/spec/unit/config/database_spec.rb +327 -0
  115. data/vendor/librarian/spec/unit/dependency_spec.rb +212 -0
  116. data/vendor/librarian/spec/unit/dsl_spec.rb +173 -0
  117. data/vendor/librarian/spec/unit/environment_spec.rb +173 -0
  118. data/vendor/librarian/spec/unit/lockfile/parser_spec.rb +162 -0
  119. data/vendor/librarian/spec/unit/lockfile_spec.rb +65 -0
  120. data/vendor/librarian/spec/unit/manifest_set_spec.rb +202 -0
  121. data/vendor/librarian/spec/unit/manifest_spec.rb +36 -0
  122. data/vendor/librarian/spec/unit/mock/source/mock_spec.rb +22 -0
  123. data/vendor/librarian/spec/unit/resolver_spec.rb +233 -0
  124. data/vendor/librarian/spec/unit/source/git_spec.rb +29 -0
  125. data/vendor/librarian/spec/unit/spec_change_set_spec.rb +169 -0
  126. metadata +220 -0
@@ -0,0 +1,223 @@
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
+ extend Particularity
23
+
24
+ class << self
25
+ def bin!
26
+ status = with_environment { returning_status { start } }
27
+ exit status
28
+ end
29
+
30
+ def returning_status
31
+ yield
32
+ 0
33
+ rescue Librarian::Error => e
34
+ environment.ui.error e.message
35
+ environment.ui.debug e.backtrace.join("\n")
36
+ e.respond_to?(:status_code) && e.status_code || 1
37
+ rescue Interrupt => e
38
+ environment.ui.error "\nQuitting..."
39
+ 1
40
+ end
41
+
42
+ attr_accessor :environment
43
+
44
+ def with_environment
45
+ environment = root_module.environment_class.new
46
+ self.environment, orig_environment = environment, self.environment
47
+ yield(environment)
48
+ ensure
49
+ self.environment = orig_environment
50
+ end
51
+ end
52
+
53
+ def initialize(*)
54
+ super
55
+ the_shell = (options["no-color"] ? Thor::Shell::Basic.new : shell)
56
+ environment.ui = UI::Shell.new(the_shell)
57
+ environment.ui.be_quiet! if options["quiet"]
58
+ environment.ui.debug! if options["verbose"]
59
+ environment.ui.debug_line_numbers! if options["verbose"] && options["line-numbers"]
60
+
61
+ write_debug_header
62
+ end
63
+
64
+ desc "version", "Displays the version."
65
+ def version
66
+ say "librarian-#{environment.version}"
67
+ end
68
+
69
+ desc "config", "Show or edit the config."
70
+ option "verbose", :type => :boolean, :default => false
71
+ option "line-numbers", :type => :boolean, :default => false
72
+ option "global", :type => :boolean, :default => false
73
+ option "local", :type => :boolean, :default => false
74
+ option "delete", :type => :boolean, :default => false
75
+ def config(key = nil, value = nil)
76
+ if key
77
+ raise Error, "cannot set both value and delete" if value && options["delete"]
78
+ if options["delete"]
79
+ scope = config_scope(true)
80
+ environment.config_db[key, scope] = nil
81
+ elsif value
82
+ scope = config_scope(true)
83
+ environment.config_db[key, scope] = value
84
+ else
85
+ scope = config_scope(false)
86
+ if value = environment.config_db[key, scope]
87
+ prefix = scope ? "#{key} (#{scope})" : key
88
+ say "#{prefix}: #{value}"
89
+ end
90
+ end
91
+ else
92
+ environment.config_db.keys.each do |key|
93
+ say "#{key}: #{environment.config_db[key]}"
94
+ end
95
+ end
96
+ end
97
+
98
+ desc "clean", "Cleans out the cache and install paths."
99
+ option "verbose", :type => :boolean, :default => false
100
+ option "line-numbers", :type => :boolean, :default => false
101
+ def clean
102
+ ensure!
103
+ clean!
104
+ end
105
+
106
+ desc "update", "Updates and installs the dependencies you specify."
107
+ option "verbose", :type => :boolean, :default => false
108
+ option "line-numbers", :type => :boolean, :default => false
109
+ def update(*names)
110
+ ensure!
111
+ if names.empty?
112
+ resolve!(:force => true)
113
+ else
114
+ update!(:names => names)
115
+ end
116
+ install!
117
+ end
118
+
119
+ desc "outdated", "Lists outdated dependencies."
120
+ option "verbose", :type => :boolean, :default => false
121
+ option "line-numbers", :type => :boolean, :default => false
122
+ def outdated
123
+ ensure!
124
+ resolution = environment.lock
125
+ manifests = resolution.manifests.sort_by(&:name)
126
+ manifests.select(&:outdated?).each do |manifest|
127
+ say "#{manifest.name} (#{manifest.version} -> #{manifest.latest.version})"
128
+ end
129
+ end
130
+
131
+ desc "show", "Shows dependencies"
132
+ option "verbose", :type => :boolean, :default => false
133
+ option "line-numbers", :type => :boolean, :default => false
134
+ option "detailed", :type => :boolean
135
+ def show(*names)
136
+ ensure!
137
+ if environment.lockfile_path.file?
138
+ manifest_presenter.present(names, :detailed => options["detailed"])
139
+ else
140
+ raise Error, "Be sure to install first!"
141
+ end
142
+ end
143
+
144
+ desc "init", "Initializes the current directory."
145
+ def init
146
+ puts "Nothing to do."
147
+ end
148
+
149
+ private
150
+
151
+ def environment
152
+ self.class.environment
153
+ end
154
+
155
+ def ensure!(options = { })
156
+ Action::Ensure.new(environment, options).run
157
+ end
158
+
159
+ def clean!(options = { })
160
+ Action::Clean.new(environment, options).run
161
+ end
162
+
163
+ def install!(options = { })
164
+ Action::Install.new(environment, options).run
165
+ end
166
+
167
+ def resolve!(options = { })
168
+ Action::Resolve.new(environment, options).run
169
+ end
170
+
171
+ def update!(options = { })
172
+ Action::Update.new(environment, options).run
173
+ end
174
+
175
+ def manifest_presenter
176
+ ManifestPresenter.new(self, environment.lock.manifests)
177
+ end
178
+
179
+ def write_debug_header
180
+ debug { "Ruby Version: #{RUBY_VERSION}" }
181
+ debug { "Ruby Platform: #{RUBY_PLATFORM}" }
182
+ debug { "Rubinius Version: #{Rubinius::VERSION}" } if defined?(Rubinius)
183
+ debug { "JRuby Version: #{JRUBY_VERSION}" } if defined?(JRUBY_VERSION)
184
+ debug { "Rubygems Version: #{Gem::VERSION}" }
185
+ debug { "Librarian Version: #{VERSION}" }
186
+ debug { "Librarian Adapter: #{environment.adapter_name}"}
187
+ debug { "Project: #{environment.project_path}" }
188
+ debug { "Specfile: #{relative_path_to(environment.specfile_path)}" }
189
+ debug { "Lockfile: #{relative_path_to(environment.lockfile_path)}" }
190
+ debug { "Git: #{Source::Git::Repository.bin}" }
191
+ debug { "Git Version: #{Source::Git::Repository.new(environment, environment.project_path).version(:silent => true)}" }
192
+ debug { "Git Environment Variables:" }
193
+ git_env = ENV.to_a.select{|(k, v)| k =~ /\AGIT/}.sort_by{|(k, v)| k}
194
+ if git_env.empty?
195
+ debug { " (empty)" }
196
+ else
197
+ git_env.each do |(k, v)|
198
+ debug { " #{k}=#{v}"}
199
+ end
200
+ end
201
+ end
202
+
203
+ def debug(*args, &block)
204
+ environment.logger.debug(*args, &block)
205
+ end
206
+
207
+ def relative_path_to(path)
208
+ environment.logger.relative_path_to(path)
209
+ end
210
+
211
+ def config_scope(exclusive)
212
+ g, l = "global", "local"
213
+ if exclusive
214
+ options[g] ^ options[l] or raise Error, "must set either #{g} or #{l}"
215
+ else
216
+ options[g] && options[l] and raise Error, "cannot set both #{g} and #{l}"
217
+ end
218
+
219
+ options[g] ? :global : options[l] ? :local : nil
220
+ end
221
+
222
+ end
223
+ end
@@ -0,0 +1,93 @@
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
+ names = manifests.map(&:name).sort if names.empty?
21
+ assert_no_manifests_missing!(names)
22
+
23
+ present_each(names, :detailed => full)
24
+ end
25
+
26
+ def present_one(manifest, options = { })
27
+ full = options[:detailed]
28
+
29
+ say "#{manifest.name} (#{manifest.version})" do
30
+ full or next
31
+
32
+ present_one_source(manifest)
33
+ present_one_dependencies(manifest)
34
+ end
35
+ end
36
+
37
+ private
38
+
39
+ def present_each(names, options)
40
+ names.each do |name|
41
+ manifest = manifest(name)
42
+ present_one(manifest, options)
43
+ end
44
+ end
45
+
46
+ def present_one_source(manifest)
47
+ say "source: #{manifest.source}"
48
+ end
49
+
50
+ def present_one_dependencies(manifest)
51
+ manifest.dependencies.empty? and return
52
+
53
+ say "dependencies:" do
54
+ deps = manifest.dependencies.sort_by(&:name)
55
+ deps.each do |dependency|
56
+ say "#{dependency.name} (#{dependency.requirement})"
57
+ end
58
+ end
59
+ end
60
+
61
+ attr_accessor :scope_level, :manifests_index
62
+
63
+ def manifest(name)
64
+ manifests_index[name]
65
+ end
66
+
67
+ def say(string)
68
+ cli.say " " * scope_level << string
69
+ if block_given?
70
+ scope do
71
+ yield
72
+ end
73
+ end
74
+ end
75
+
76
+ def scope
77
+ original_scope_level = scope_level
78
+ self.scope_level = scope_level + 1
79
+ yield
80
+ ensure
81
+ self.scope_level = original_scope_level
82
+ end
83
+
84
+ def assert_no_manifests_missing!(names)
85
+ missing_names = names.reject{|name| manifest(name)}
86
+ unless missing_names.empty?
87
+ raise Error, "not found: #{missing_names.map(&:inspect).join(', ')}"
88
+ end
89
+ end
90
+
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,7 @@
1
+ require "librarian/config/database"
2
+
3
+ module Librarian
4
+ module Config
5
+
6
+ end
7
+ 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