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

yast / yast-ntp-client / 3618557524

pending completion
3618557524

Pull #173

github

Unknown Committer
Unknown Commit Message
Pull Request #173: WIP: Updated ntp sources handling

166 of 166 new or added lines in 5 files covered. (100.0%)

931 of 1445 relevant lines covered (64.43%)

20.52 hits per line

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

80.49
/src/lib/y2ntp_client/widgets/sources_table.rb
1
# Copyright (c) [2019] SUSE LLC
2
#
3
# All Rights Reserved.
4
#
5
# This program is free software; you can redistribute it and/or modify it
6
# under the terms of version 2 of the GNU General Public License as published
7
# by the Free Software Foundation.
8
#
9
# This program is distributed in the hope that it will be useful, but WITHOUT
10
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
12
# more details.
13
#
14
# You should have received a copy of the GNU General Public License along
15
# with this program; if not, contact SUSE LLC.
16
#
17
# To contact SUSE LLC about this file by physical or electronic mail, you may
18
# find current contact information at www.suse.com.
19

20
require "cwm/table"
1✔
21
require "cwm/widget"
1✔
22

23
module Y2NtpClient
1✔
24
  module Widgets
1✔
25
    # Table displaying list of defined NTP sources. It displays its type and address.
26
    class SourcesTable < CWM::Table
1✔
27
      attr_reader :sources
1✔
28
      attr_accessor :items
1✔
29

30
      SOURCES = {
31
        pool:   "Pool".freeze,
1✔
32
        server: "Server".freeze
33
      }.freeze
34

35
      # @param sources [Hash<String, Symbol>] hash of ntp sources address (ip or url)
36
      #                                       and type (pool or server)
37
      def initialize(sources = {})
1✔
38
        textdomain "ntp-client"
26✔
39

40
        # TODO: validation of the input
41
        @sources = sources
26✔
42
      end
43

44
      def header
1✔
45
        [
46
          _("Type"),
×
47
          _("Address")
48
        ]
49
      end
50

51
      def sources=(sources)
1✔
52
        @sources = sources
4✔
53
        # <id, source-type, source-address>
54
        change_items(items = @sources.map { |a, t| [a, SOURCES[t], a] })
5✔
55

56
        @sources
4✔
57
      end
58

59
      # Adds one item into table's content
60
      #
61
      # @param item [Array] a table item in array format (<id, column1 value, column2 value, ...)
62
      def add_item(item)
1✔
63
        change_items(items << item)
×
64
      end
65

66
      # Removes one item from table's content
67
      #
68
      # @param id [any] id of table's item to remove
69
      def remove_item(id)
1✔
70
        updated_items = items.delete_if { |i| i[0] == id }
×
71
        change_items(updated_items)
×
72
      end
73
    end
74

75
    # A button for adding an item into @see SourcesTable
76
    class SourcesAdd < CWM::PushButton
1✔
77
      def initialize
1✔
78
        textdomain "ntp-client"
26✔
79
      end
80

81
      def label
1✔
82
        _("Add")
×
83
      end
84

85
      def handle
1✔
86
        nil
87
      end
88
    end
89

90
    # A button for removing an item from @see SourcesTable
91
    class SourcesRemove < CWM::PushButton
1✔
92
      def initialize
1✔
93
        textdomain "ntp-client"
26✔
94
      end
95

96
      def label
1✔
97
        _("Remove")
×
98
      end
99

100
      def handle
1✔
101
        nil
102
      end
103
    end
104

105
    # A ComboBox containing varius supported types of NTP Sources
106
    class SourcesType < CWM::ComboBox
1✔
107
      def initialize
1✔
108
        textdomain "ntp-client"
26✔
109
      end
110

111
      def label
1✔
112
        _("Source Type")
×
113
      end
114

115
      def items
1✔
116
        [
117
          [:pool, _("Pool")],
×
118
          [:server, _("Server")]
119
        ]
120
      end
121
    end
122
  end
123
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