Class: AbideDevUtils::Ppt::Strings

Inherits:
Object
  • Object
show all
Defined in:
lib/abide_dev_utils/ppt/strings.rb

Overview

Puppet Strings reference object

Constant Summary collapse

REGISTRY_TYPES =
%i[
  root
  module
  class
  puppet_class
  puppet_data_type
  puppet_data_type_alias
  puppet_defined_type
  puppet_type
  puppet_provider
  puppet_function
  puppet_task
  puppet_plan
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(search_patterns: nil, **opts) ⇒ Strings

Returns a new instance of Strings.



27
28
29
30
31
32
33
34
# File 'lib/abide_dev_utils/ppt/strings.rb', line 27

def initialize(search_patterns: nil, **opts)
  check_yardoc_dir
  @search_patterns = search_patterns || PuppetStrings::DEFAULT_SEARCH_PATTERNS
  @debug = opts[:debug]
  @quiet = opts[:quiet]
  PuppetStrings::Yard.setup!
  YARD::CLI::Yardoc.run(*yard_args(@search_patterns, debug: @debug, quiet: @quiet))
end

Instance Attribute Details

#search_patternsObject (readonly)

Returns the value of attribute search_patterns.



25
26
27
# File 'lib/abide_dev_utils/ppt/strings.rb', line 25

def search_patterns
  @search_patterns
end

Instance Method Details

#data_type_aliases(hashed: false) ⇒ Object Also known as: puppet_data_type_alias



64
65
66
# File 'lib/abide_dev_utils/ppt/strings.rb', line 64

def data_type_aliases(hashed: false)
  reg_type(:puppet_data_type_alias, hashed: hashed)
end

#data_types(hashed: false) ⇒ Object Also known as: puppet_data_type



59
60
61
# File 'lib/abide_dev_utils/ppt/strings.rb', line 59

def data_types(hashed: false)
  reg_type(:puppet_data_types, hashed: hashed)
end

#debug?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/abide_dev_utils/ppt/strings.rb', line 36

def debug?
  !!@debug
end

#defined_types(hashed: false) ⇒ Object Also known as: puppet_defined_type



69
70
71
# File 'lib/abide_dev_utils/ppt/strings.rb', line 69

def defined_types(hashed: false)
  reg_type(:puppet_defined_type, hashed: hashed)
end

#find_resource(resource_name) ⇒ Object



48
49
50
51
52
53
# File 'lib/abide_dev_utils/ppt/strings.rb', line 48

def find_resource(resource_name)
  to_h.each do |_, resources|
    res = resources.find { |r| r[:name] == resource_name.to_sym }
    return res if res
  end
end

#providers(hashed: false) ⇒ Object Also known as: puppet_provider



79
80
81
# File 'lib/abide_dev_utils/ppt/strings.rb', line 79

def providers(hashed: false)
  reg_type(:puppet_provider, hashed: hashed)
end

#puppet_classes(hashed: false) ⇒ Object



55
56
57
# File 'lib/abide_dev_utils/ppt/strings.rb', line 55

def puppet_classes(hashed: false)
  reg_type(:puppet_class, hashed: hashed)
end

#puppet_functions(hashed: false) ⇒ Object Also known as: puppet_function



84
85
86
# File 'lib/abide_dev_utils/ppt/strings.rb', line 84

def puppet_functions(hashed: false)
  reg_type(:puppet_function, hashed: hashed)
end

#puppet_plans(hashed: false) ⇒ Object Also known as: puppet_plan



94
95
96
# File 'lib/abide_dev_utils/ppt/strings.rb', line 94

def puppet_plans(hashed: false)
  reg_type(:puppet_plan, hashed: hashed)
end

#puppet_tasks(hashed: false) ⇒ Object Also known as: puppet_task



89
90
91
# File 'lib/abide_dev_utils/ppt/strings.rb', line 89

def puppet_tasks(hashed: false)
  reg_type(:puppet_task, hashed: hashed)
end

#quiet?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/abide_dev_utils/ppt/strings.rb', line 40

def quiet?
  !!@quiet
end

#registryObject



44
45
46
# File 'lib/abide_dev_utils/ppt/strings.rb', line 44

def registry
  @registry ||= YARD::Registry.all(*REGISTRY_TYPES).map { |i| YardObjectWrapper.new(i) }
end

#resource_types(hashed: false) ⇒ Object Also known as: puppet_type



74
75
76
# File 'lib/abide_dev_utils/ppt/strings.rb', line 74

def resource_types(hashed: false)
  reg_type(:puppet_type, hashed: hashed)
end

#to_hObject



99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/abide_dev_utils/ppt/strings.rb', line 99

def to_h
  {
    puppet_classes: puppet_classes,
    data_types: data_types,
    data_type_aliases: data_type_aliases,
    defined_types: defined_types,
    resource_types: resource_types,
    providers: providers,
    puppet_functions: puppet_functions,
    puppet_tasks: puppet_tasks,
    puppet_plans: puppet_plans,
  }
end