Module: Appraisal::Utils
- Defined in:
- lib/appraisal/utils.rb
Overview
Contains methods for various operations
Class Method Summary collapse
- .bundler_version ⇒ Object
- .format_arguments(arguments) ⇒ Object
- .format_hash_value(key, value) ⇒ Object
- .format_string(object, enclosing_object = false) ⇒ Object
- .join_parts(parts) ⇒ Object
- .prefix_path(path) ⇒ Object
- .support_parallel_installation? ⇒ Boolean
Class Method Details
.bundler_version ⇒ Object
57 58 59 |
# File 'lib/appraisal/utils.rb', line 57 def self.bundler_version Gem::Specification.detect { |spec| spec.name == "bundler" }.version.to_s end |
.format_arguments(arguments) ⇒ Object
38 39 40 41 42 |
# File 'lib/appraisal/utils.rb', line 38 def self.format_arguments(arguments) unless arguments.empty? arguments.map { |object| format_string(object, false) }.join(", ") end end |
.format_hash_value(key, value) ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/appraisal/utils.rb', line 27 def self.format_hash_value(key, value) key = format_string(key, true) value = format_string(value, true) if key.start_with?(":") "#{key.sub(/^:/, "")}: #{value}" else "#{key} => #{value}" end end |
.format_string(object, enclosing_object = false) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/appraisal/utils.rb', line 10 def self.format_string(object, enclosing_object = false) case object when Hash items = object.map do |key, value| format_hash_value(key, value) end if enclosing_object "{ #{items.join(', ')} }" else items.join(", ") end else object.inspect end end |
.join_parts(parts) ⇒ Object
44 45 46 |
# File 'lib/appraisal/utils.rb', line 44 def self.join_parts(parts) parts.reject(&:nil?).reject(&:empty?).join("\n\n").strip end |
.prefix_path(path) ⇒ Object
48 49 50 51 52 53 54 55 |
# File 'lib/appraisal/utils.rb', line 48 def self.prefix_path(path) if path !~ /^(?:\/|\S:)/ && path !~ /^\S+:\/\// && path !~ /^\S+@\S+:/ cleaned_path = path.gsub(/(^|\/)\.(?:\/|$)/, "\\1") File.join("..", cleaned_path) else path end end |
.support_parallel_installation? ⇒ Boolean
6 7 8 |
# File 'lib/appraisal/utils.rb', line 6 def self.support_parallel_installation? Gem::Version.create(Bundler::VERSION) >= Gem::Version.create("1.4.0.pre.1") end |