Class: Oxidized::Source::JSONFile
- Defined in:
- lib/oxidized/source/jsonfile.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize ⇒ JSONFile
constructor
A new instance of JSONFile.
- #load ⇒ Object
- #setup ⇒ Object
Methods inherited from Source
#map_group, #map_model, #node_var_interpolate
Constructor Details
Instance Method Details
#load ⇒ Object
28 29 30 31 32 33 |
# File 'lib/oxidized/source/jsonfile.rb', line 28 def load(*) data = JSON.parse(open_file.read) data = string_navigate_object(data, @cfg.hosts_location) if @cfg.hosts_location? transform_json(data) end |
#setup ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/oxidized/source/jsonfile.rb', line 10 def setup if @cfg.empty? Oxidized.asetus.user.source.jsonfile.file = File.join(Oxidized::Config::ROOT, 'router.json') Oxidized.asetus.user.source.jsonfile.map.name = "name" Oxidized.asetus.user.source.jsonfile.map.model = "model" Oxidized.asetus.user.source.jsonfile.gpg = false Oxidized.asetus.save :user raise NoConfig, "No source json config, edit #{Oxidized::Config.configfile}" end require 'gpgme' if @cfg.gpg? # map.name is mandatory return if @cfg.map.has_key?('name') raise InvalidConfig, "map/name is a mandatory source attribute, edit #{Oxidized::Config.configfile}" end |