Class: YARD::JsonRegistryStore

Inherits:
RegistryStore
  • Object
show all
Defined in:
lib/puppet_x/puppetlabs/strings/yard/json_registry_store.rb

Instance Method Summary collapse

Instance Method Details

#save(merge = true, file = nil) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/puppet_x/puppetlabs/strings/yard/json_registry_store.rb', line 4

def save(merge=true, file=nil)
  super

  @serializer = Serializers::JsonSerializer.new(@file)

  sdb = Registry.single_object_db
  if sdb == true || sdb == nil
    serialize_output_schema(@store)
  else
    values(false).each do |object|
      serialize_output_schema(object)
    end
  end
  true
end

#serialize_output_schema(obj) ⇒ Object

registry.

Parameters:

  • obj (Hash)

    A hash representing the registry or part of the



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/puppet_x/puppetlabs/strings/yard/json_registry_store.rb', line 22

def serialize_output_schema(obj)

    schema = {
      :puppet_functions => [],
      :puppet_providers => [],
      :puppet_classes => [],
      :defined_types => [],
      :puppet_types => [],
    }

    schema[:puppet_functions] += obj.select do |key, val|
      val.type == :method and (val['puppet_4x_function'] or
                               val['puppet_3x_function'])
    end.values

    schema[:puppet_classes] += obj.select do |key, val|
      val.type == :hostclass
    end.values

    schema[:defined_types] += obj.select do |key, val|
      val.type == :definedtype
    end.values

    schema[:puppet_providers] += obj.select do |key, val|
      val.type == :provider
    end.values

    schema[:puppet_types] += obj.select do |key, val|
      val.type == :type
    end.values

    @serializer.serialize(schema.to_json)
end