]> git.openstreetmap.org Git - chef.git/blob - cookbooks/hardware/libraries/sensors.rb
imagery: update backend method
[chef.git] / cookbooks / hardware / libraries / sensors.rb
1 class Chef
2   class Sensors
3     def self.attributes(sensors, attribute_names)
4       sensors ||= {}
5       results = []
6
7       sensors.sort.each do |sensor, attributes|
8         if attributes[:ignore]
9           results << "ignore #{sensor}"
10         else
11           results << "label #{sensor} \"#{attributes[:label]}\"" if attributes[:label]
12           results << "compute #{sensor} #{attributes[:compute]}" if attributes[:compute]
13
14           attribute_names.each do |name|
15             results << "set #{sensor}_#{name} #{attributes[name]}" if attributes[name]
16           end
17         end
18       end
19
20       results.map { |r| "  #{r}\n" }.join("")
21     end
22   end
23 end