Module: ShopifyCLI::Utilities
- Defined in:
- lib/shopify_cli/utilities.rb
Class Method Summary collapse
- .deep_merge(first, second) ⇒ Object
- .directory(pattern, curr) ⇒ Object
- .version_dropping_pre_and_build(version) ⇒ Object
Class Method Details
.deep_merge(first, second) ⇒ Object
16 17 18 19 |
# File 'lib/shopify_cli/utilities.rb', line 16 def self.deep_merge(first, second) merger = proc { |_key, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2 } first.merge(second, &merger) end |
.directory(pattern, curr) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/shopify_cli/utilities.rb', line 7 def self.directory(pattern, curr) loop do return nil if curr == "/" || /^[A-Z]:\/$/.match?(curr) file = File.join(curr, pattern) return curr if File.exist?(file) curr = File.dirname(curr) end end |
.version_dropping_pre_and_build(version) ⇒ Object
3 4 5 |
# File 'lib/shopify_cli/utilities.rb', line 3 def self.version_dropping_pre_and_build(version) Semantic::Version.new("#{version.major}.#{version.minor}.#{version.patch}") end |