lib/release_me/adapter.rb in release_me-0.1.3 vs lib/release_me/adapter.rb in release_me-0.1.4

- old
+ new

@@ -10,12 +10,12 @@ def adapter_config(project_path = Dir.pwd) path = project_path || Dir.pwd config = local_config(path) || detect_adapter_config(path) raise 'Cannot find config' if config.nil? adapter = OpenStruct.new(config) - adapter[:version_file] = version_file(adapter, path) - adapter[:current_version] = current_version(adapter, adapter[:version_file]) + adapter.version_file = version_file(path, adapter.version_file_relative_path) + adapter.current_version = current_version(adapter, adapter.version_file) adapter end def adapter_list adapters.keys @@ -29,12 +29,15 @@ data = load_adapter(file) data.fetch('adapter', nil) end end - def version_file(adapter, path) - Dir.glob(File.join(path, adapter.version_file_relative_path)).first + # @param project_path [String] - path to the directory in which you want to check + # @param version_path [String] - path to the version file or glob of version file + # @return [String] path to version file + def version_file(project_path, version_path) + Dir.glob(File.join(project_path, version_path)).first end private # @param [OpenStruct] - adapter config @@ -60,9 +63,10 @@ def detect_adapter_config(path = Dir.pwd) type, config = adapters.find do |_, adapter_config| pattern = File.join(path, adapter_config['detection_pattern']) || '' Dir.glob(pattern).count > 0 end + puts "Adapter type: #{type} detected" config end # @param [String] path to adapter file # @return [Hash] rendered object from YAML