abide_dev_utils 0.12.2 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,108 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'puppet-strings'
4
+ require 'puppet-strings/yard'
5
+
6
+ module AbideDevUtils
7
+ # Puppet Strings reference object
8
+ class PuppetStrings
9
+ attr_reader :search_patterns
10
+
11
+ def initialize(search_patterns: nil, opts: {})
12
+ check_yardoc_dir
13
+ @search_patterns = search_patterns || ::PuppetStrings::DEFAULT_SEARCH_PATTERNS
14
+ @debug = opts[:debug]
15
+ @quiet = opts[:quiet]
16
+ PuppetStrings::Yard.setup!
17
+ YARD::CLI::Yardoc.run(*yard_args(@search_patterns, debug: @debug, quiet: @quiet))
18
+ end
19
+
20
+ def debug?
21
+ !!@debug
22
+ end
23
+
24
+ def quiet?
25
+ !!@quiet
26
+ end
27
+
28
+ def find_resource(resource_name)
29
+ to_h.each do |_, resources|
30
+ res = resources.find { |r| r[:name] == resource_name.to_sym }
31
+ return res if res
32
+ end
33
+ end
34
+
35
+ def puppet_classes
36
+ @puppet_classes ||= all_to_h YARD::Registry.all(:puppet_class)
37
+ end
38
+
39
+ def data_types
40
+ @data_types ||= all_to_h YARD::Registry.all(:puppet_data_types)
41
+ end
42
+
43
+ def data_type_aliases
44
+ @data_type_aliases ||= all_to_h YARD::Registry.all(:puppet_data_type_alias)
45
+ end
46
+
47
+ def defined_types
48
+ @defined_types ||= all_to_h YARD::Registry.all(:puppet_defined_type)
49
+ end
50
+
51
+ def resource_types
52
+ @resource_types ||= all_to_h YARD::Registry.all(:puppet_type)
53
+ end
54
+
55
+ def providers
56
+ @providers ||= all_to_h YARD::Registry.all(:puppet_provider)
57
+ end
58
+
59
+ def puppet_functions
60
+ @puppet_functions ||= all_to_h YARD::Registry.all(:puppet_function)
61
+ end
62
+
63
+ def puppet_tasks
64
+ @puppet_tasks ||= all_to_h YARD::Registry.all(:puppet_task)
65
+ end
66
+
67
+ def puppet_plans
68
+ @puppet_plans ||= all_to_h YARD::Registry.all(:puppet_plan)
69
+ end
70
+
71
+ def to_h
72
+ {
73
+ puppet_classes: puppet_classes,
74
+ data_types: data_types,
75
+ data_type_aliases: data_type_aliases,
76
+ defined_types: defined_types,
77
+ resource_types: resource_types,
78
+ providers: providers,
79
+ puppet_functions: puppet_functions,
80
+ puppet_tasks: puppet_tasks,
81
+ puppet_plans: puppet_plans,
82
+ }
83
+ end
84
+
85
+ private
86
+
87
+ def check_yardoc_dir
88
+ yardoc_dir = File.expand_path('./.yardoc')
89
+ return unless Dir.exist?(yardoc_dir) && !File.writable?(yardoc_dir)
90
+
91
+ raise "yardoc directory permissions error. Ensure #{yardoc_dir} is writable by current user."
92
+ end
93
+
94
+ def all_to_h(objects)
95
+ objects.sort_by(&:name).map(&:to_hash)
96
+ end
97
+
98
+ def yard_args(patterns, debug: false, quiet: false)
99
+ args = ['doc', '--no-progress', '-n']
100
+ args << '--debug' if debug && !quiet
101
+ args << '--backtrace' if debug && !quiet
102
+ args << '-q' if quiet
103
+ args << '--no-stats' if quiet
104
+ args += patterns
105
+ args
106
+ end
107
+ end
108
+ end
@@ -27,6 +27,14 @@ module AbideDevUtils
27
27
  raise AbideDevUtils::Errors::PathNotDirectoryError, path unless File.directory?(path)
28
28
  end
29
29
 
30
+ def self.populated_string?(thing)
31
+ return false if thing.nil?
32
+ return false unless thing.instance_of?(String)
33
+ return false if thing.empty?
34
+
35
+ true
36
+ end
37
+
30
38
  def self.populated_string(thing)
31
39
  raise AbideDevUtils::Errors::NotPopulatedStringError, 'Object is nil' if thing.nil?
32
40
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AbideDevUtils
4
- VERSION = "0.12.2"
4
+ VERSION = "0.14.0"
5
5
  end
@@ -456,7 +456,7 @@ module AbideDevUtils
456
456
 
457
457
  def new_implementation_groups(element)
458
458
  igroup = find_element.at_xpath(element, 'implementation_groups')
459
- return if igroup.nil? || igroup.empty?
459
+ return if igroup.nil? || igroup.attributes.empty?
460
460
 
461
461
  add_child(ShortText, igroup['ig1']) if igroup['ig1']
462
462
  add_child(ShortText, igroup['ig2']) if igroup['ig2']
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: abide_dev_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.2
4
+ version: 0.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - abide-team
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-10-17 00:00:00.000000000 Z
11
+ date: 2023-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '6.23'
55
+ - !ruby/object:Gem::Dependency
56
+ name: puppet-strings
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '2.7'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '2.7'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: jira-ruby
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -142,14 +156,14 @@ dependencies:
142
156
  requirements:
143
157
  - - ">="
144
158
  - !ruby/object:Gem::Version
145
- version: '1.18'
159
+ version: '1.21'
146
160
  type: :runtime
147
161
  prerelease: false
148
162
  version_requirements: !ruby/object:Gem::Requirement
149
163
  requirements:
150
164
  - - ">="
151
165
  - !ruby/object:Gem::Version
152
- version: '1.18'
166
+ version: '1.21'
153
167
  - !ruby/object:Gem::Dependency
154
168
  name: bundler
155
169
  requirement: !ruby/object:Gem::Requirement
@@ -341,6 +355,7 @@ executables:
341
355
  extensions: []
342
356
  extra_rdoc_files: []
343
357
  files:
358
+ - ".github/workflows/mend_ruby.yaml"
344
359
  - ".gitignore"
345
360
  - ".rspec"
346
361
  - ".rubocop.yml"
@@ -374,6 +389,11 @@ files:
374
389
  - lib/abide_dev_utils/cem/mapping/mapper.rb
375
390
  - lib/abide_dev_utils/cem/validate.rb
376
391
  - lib/abide_dev_utils/cem/validate/resource_data.rb
392
+ - lib/abide_dev_utils/cem/validate/strings.rb
393
+ - lib/abide_dev_utils/cem/validate/strings/base_validator.rb
394
+ - lib/abide_dev_utils/cem/validate/strings/puppet_class_validator.rb
395
+ - lib/abide_dev_utils/cem/validate/strings/puppet_defined_type_validator.rb
396
+ - lib/abide_dev_utils/cem/validate/strings/validation_finding.rb
377
397
  - lib/abide_dev_utils/cli.rb
378
398
  - lib/abide_dev_utils/cli/abstract.rb
379
399
  - lib/abide_dev_utils/cli/cem.rb
@@ -420,7 +440,9 @@ files:
420
440
  - lib/abide_dev_utils/ppt/new_obj.rb
421
441
  - lib/abide_dev_utils/ppt/puppet_module.rb
422
442
  - lib/abide_dev_utils/ppt/score_module.rb
443
+ - lib/abide_dev_utils/ppt/strings.rb
423
444
  - lib/abide_dev_utils/prompt.rb
445
+ - lib/abide_dev_utils/puppet_strings.rb
424
446
  - lib/abide_dev_utils/resources/generic_spec.erb
425
447
  - lib/abide_dev_utils/validate.rb
426
448
  - lib/abide_dev_utils/version.rb