Module: FogExtensions::Fogdocker::Images

Extended by:
ActiveSupport::Concern
Defined in:
app/models/concerns/fog_extensions/fogdocker/images.rb

Instance Method Summary collapse

Instance Method Details

#downcase_hash_keys(hash, k = []) ⇒ Object



13
14
15
16
17
18
# File 'app/models/concerns/fog_extensions/fogdocker/images.rb', line 13

def downcase_hash_keys(hash, k = [])
  if hash.is_a?(Hash)
    return hash.reduce({}) { |a, e| a.merge! downcase_hash_keys(e[-1], k + [e[0]]) }
  end
  { k.join('_').gsub(/([a-z])([A-Z])/, '\1_\2').downcase => hash }
end

#image_search(query = {}) ⇒ Object



7
8
9
10
11
# File 'app/models/concerns/fog_extensions/fogdocker/images.rb', line 7

def image_search(query = {})
  Docker::Util.parse_json(Docker.connection.get('/images/search', query)).map do |image|
    downcase_hash_keys(image)
  end
end