Sha256: 2ba7dbef0490608365f053b6078e4270bc792db2a423632f5484d694ee72941e

Contents?: true

Size: 857 Bytes

Versions: 11

Compression:

Stored size: 857 Bytes

Contents

require 'controlrepo'

class Controlrepo
  class Node
    @@all = []


    attr_accessor :name
    attr_accessor :beaker_node
    attr_accessor :fact_set

    def initialize(name)
      @name = name
      @beaker_node = nil

      # If we can't find the factset it will fail, so just catch that error and ignore it
      begin
        @fact_set = Controlrepo.facts[(Controlrepo.facts_files.index{|facts_file| File.basename(facts_file,'.json') == name})]
      rescue TypeError
        @fact_set = nil
      end
      @@all << self

    end

    def self.find(node_name)
      @@all.each do |node|
        if node_name.is_a?(Controlrepo::Node)
          if node = node_name
            return node
          end
        elsif node.name == node_name
          return node
        end
      end
      nil
    end

    def self.all
      @@all
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
controlrepo-2.0.10 lib/controlrepo/node.rb
controlrepo-2.0.8 lib/controlrepo/node.rb
controlrepo-2.0.7 lib/controlrepo/node.rb
controlrepo-2.0.6 lib/controlrepo/node.rb
controlrepo-2.0.5 lib/controlrepo/node.rb
controlrepo-2.0.3 lib/controlrepo/node.rb
controlrepo-2.0.2 lib/controlrepo/node.rb
controlrepo-2.0.1 lib/controlrepo/node.rb
controlrepo-2.0.0 lib/controlrepo/node.rb
controlrepo-1.1.0 lib/controlrepo/node.rb
controlrepo-1.0.0 lib/controlrepo/node.rb