]> git.openstreetmap.org Git - chef.git/blob - cookbooks/hardware/libraries/sensors.rb
Revert "Switch web site to use MapQuest Nominatim for search"
[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           if label = attributes[:label]
12             resuls << "label #{sensor} \"#{label}\""
13           end
14
15           if compute = attributes[:compute]
16             resuls << "compute #{sensor} #{compute}"
17           end
18
19           attribute_names.each do |name|
20             if value = attributes[name]
21               results << "set #{sensor}_#{name} #{value}"
22             end
23           end
24         end
25       end
26
27       results.map { |r| "  #{r}\n" }.join("")
28     end
29   end
30 end