• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pulibrary / tigerdata-app / d7ce1bf9-25b8-4b3e-b9dd-43f9a26f2d96

17 Oct 2025 05:51PM UTC coverage: 91.054%. Remained the same
d7ce1bf9-25b8-4b3e-b9dd-43f9a26f2d96

Pull #2055

circleci

jrgriffiniii
- Ensuring that `parallelism` is set to 4
- Separating `system` RSpec spec suites in the CI build
- Using an `inconsistent` RSpec tag to mark inconsistently failing tests
- Ensuring that CI does not run for `inconsistent` tests
Pull Request #2055: Ensuring that `parallelism` is set to 4 for CircleCI and separates `system` and inconsistently-failing tests into separate CI jobs

2738 of 3007 relevant lines covered (91.05%)

380.37 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/app/services/xml_element_builder.rb
1
# frozen_string_literal: true
2
class XmlElementBuilder < XmlNodeBuilder
4✔
3
  attr_reader :presenter, :name, :attributes, :content
4✔
4
  alias entry content
4✔
5
  delegate :blank?, to: :content
4✔
6

7
  # @return [Nokogiri::XML::Element] the XML element node
8
  def element
4✔
9
    @element ||= begin
4,681✔
10
                   created = @document.create_element(name)
1,583✔
11
                   @document.root = created
1,583✔
12
                   created
1,583✔
13
                 end
14
  end
15

16
  # @return [Nokogiri::XML::Element] the XML element node
17
  def build_attributes
4✔
18
    attributes.each do |key, attr_entry|
1,630✔
19
      value = attr_entry
3,154✔
20
      if attr_entry.is_a?(Hash) && attr_entry.key?(:object_method)
3,154✔
21
        allow_empty_attr = attr_entry.fetch(:allow_empty, true)
547✔
22

23
        message = attr_entry[:object_method]
547✔
24
        method_args = attr_entry[:args] || []
547✔
25
        method_args = @default_method_args + method_args
547✔
26
        value = presenter.send(message, *method_args)
547✔
27

28
        raise ArgumentError, "Value for #{key} cannot be nil" if value.nil? && !allow_empty_attr
543✔
29
      end
30

31
      element[key] = value unless value.nil?
3,107✔
32
    end
33

34
    element
1,583✔
35
  end
36

37
  # @return [String] the content for the XML element
38
  def build_content!
4✔
39
    allow_empty_content = entry.fetch(:allow_empty, true)
997✔
40

41
    message = entry[:object_method]
997✔
42
    method_args = entry[:args] || []
997✔
43
    method_args = @default_method_args + method_args
997✔
44
    @content = presenter.send(message, *method_args)
997✔
45

46
    raise ArgumentError, "Content for #{name} cannot be nil" if content.nil? && !allow_empty_content
997✔
47
    content
954✔
48
  end
49

50
  # rubocop:disable Metrics/AbcSize
51
  # rubocop:disable Metrics/CyclomaticComplexity
52
  # rubocop:disable Metrics/MethodLength
53
  # rubocop:disable Metrics/PerceivedComplexity
54
  #
55
  # @return [Nokogiri::XML::Element]
56
  def build
4✔
57
    if entry.is_a?(Hash) && entry.key?(:object_method)
1,673✔
58
      build_content!
997✔
59
    end
60

61
    built = build_attributes
1,630✔
62
    built.content = content
1,583✔
63

64
    built
1,583✔
65
  rescue ArgumentError => arg_error
66
    Rails.logger.warn("Error building XML project metadata: #{arg_error.message}")
90✔
67
    nil
90✔
68
  end
69
  # rubocop:enable Metrics/PerceivedComplexity
70
  # rubocop:enable Metrics/MethodLength
71
  # rubocop:enable Metrics/CyclomaticComplexity
72
  # rubocop:enable Metrics/AbcSize
73

74
  # @return [Nokogiri::XML::Element] the XML element node
75
  def node
4✔
76
    @node ||= build
3,210✔
77
  end
78

79
  def add_child(child)
4✔
80
    return if child.nil?
1,627✔
81

82
    # @see https://nokogiri.org/rdoc/Nokogiri/XML/Node.html#method-i-clone
83
    level = 1
1,537✔
84
    cloned = child.clone(level, document)
1,537✔
85
    node.add_child(cloned)
1,537✔
86

87
    cloned
1,537✔
88
  end
89

90
  # @param [ProjectXmlPresenter] presenter
91
  # @param [String] name
92
  # @param [Hash] attributes
93
  # @param [String] content
94
  # @param [Integer] index the index for the element (when there are multiple sibling nodes)
95
  # @param [Hash] options
96
  def initialize(presenter:, name:, attributes: {}, content: nil, index: nil, **options)
4✔
97
    super(**options)
1,673✔
98

99
    @presenter = presenter
1,673✔
100
    @name = name
1,673✔
101

102
    @attributes = attributes
1,673✔
103
    @content = content
1,673✔
104

105
    @index = index
1,673✔
106

107
    @default_method_args = []
1,673✔
108
    @default_method_args << @index unless @index.nil?
1,673✔
109
  end
110
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc