libyui_client 0.4.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.
Files changed (48) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +15 -0
  3. data/.rspec +3 -0
  4. data/.rubocop.yml +41 -0
  5. data/.travis.yml +11 -0
  6. data/Gemfile +8 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +210 -0
  9. data/Rakefile +20 -0
  10. data/bin/console +15 -0
  11. data/bin/setup +8 -0
  12. data/lib/libyui_client.rb +42 -0
  13. data/lib/libyui_client/actions.rb +12 -0
  14. data/lib/libyui_client/app.rb +230 -0
  15. data/lib/libyui_client/error.rb +13 -0
  16. data/lib/libyui_client/filter_extractor.rb +28 -0
  17. data/lib/libyui_client/http/http_client.rb +36 -0
  18. data/lib/libyui_client/http/response.rb +21 -0
  19. data/lib/libyui_client/http/version_controller.rb +26 -0
  20. data/lib/libyui_client/http/widget_controller.rb +54 -0
  21. data/lib/libyui_client/local_process.rb +73 -0
  22. data/lib/libyui_client/logger.rb +32 -0
  23. data/lib/libyui_client/timer.rb +20 -0
  24. data/lib/libyui_client/version.rb +6 -0
  25. data/lib/libyui_client/wait.rb +21 -0
  26. data/lib/libyui_client/waitable.rb +39 -0
  27. data/lib/libyui_client/widgets.rb +30 -0
  28. data/lib/libyui_client/widgets/bargraph.rb +62 -0
  29. data/lib/libyui_client/widgets/base.rb +114 -0
  30. data/lib/libyui_client/widgets/button.rb +33 -0
  31. data/lib/libyui_client/widgets/checkbox.rb +53 -0
  32. data/lib/libyui_client/widgets/combobox.rb +95 -0
  33. data/lib/libyui_client/widgets/datefield.rb +47 -0
  34. data/lib/libyui_client/widgets/label.rb +41 -0
  35. data/lib/libyui_client/widgets/menubutton.rb +48 -0
  36. data/lib/libyui_client/widgets/multilinebox.rb +84 -0
  37. data/lib/libyui_client/widgets/numberbox.rb +76 -0
  38. data/lib/libyui_client/widgets/progressbar.rb +45 -0
  39. data/lib/libyui_client/widgets/radiobutton.rb +35 -0
  40. data/lib/libyui_client/widgets/richtext.rb +36 -0
  41. data/lib/libyui_client/widgets/selectionbox.rb +87 -0
  42. data/lib/libyui_client/widgets/tab.rb +81 -0
  43. data/lib/libyui_client/widgets/table.rb +154 -0
  44. data/lib/libyui_client/widgets/textbox.rb +94 -0
  45. data/lib/libyui_client/widgets/timefield.rb +45 -0
  46. data/lib/libyui_client/widgets/tree.rb +149 -0
  47. data/libyui_client.gemspec +44 -0
  48. metadata +135 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 53f5f7b922bad1e4f7dbc3d9cd05ac392dc45ffc64c422ad6edab4bcc5c86b64
4
+ data.tar.gz: 490036bf1243db80b41b77cd37ddf1eca0a4745b422b0290ee8ecf1c5e30bbb8
5
+ SHA512:
6
+ metadata.gz: 46c6f9c9253371caeed56e60c3344a487ae241ed2dc4c8295b67a19c42b5b90c003c497efe01985c53e3cec5095e5a8c6619afe15971597f8225044dee8f9593
7
+ data.tar.gz: 2d7d984776851c6220f98109a7e176970788bec03eb609a2986c15266924486064edff6e5d5450620fccb44774dafb0f23e9ad75db1798013d259e854d34f3de
@@ -0,0 +1,15 @@
1
+ *.gem
2
+ *.rbc
3
+ .rakeTasks
4
+ .rspec_status
5
+ .vendor
6
+ /.bundle/
7
+ /.yardoc
8
+ /_yardoc/
9
+ /coverage/
10
+ /pkg/
11
+ /spec/reports/
12
+ /tmp/
13
+ doc/
14
+ Gemfile.lock
15
+ y2signal.log
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,41 @@
1
+ # Cops documentation: https://rubocop.readthedocs.io/en/stable/
2
+
3
+ AllCops:
4
+ TargetRubyVersion: 2.5
5
+
6
+ Layout/LineLength:
7
+ Max: 120
8
+
9
+ Layout/SpaceAroundMethodCallOperator:
10
+ Enabled: true
11
+
12
+ Lint/RaiseException:
13
+ Enabled: true
14
+
15
+ Lint/StructNewOverride:
16
+ Enabled: true
17
+
18
+ Lint/UriEscapeUnescape:
19
+ Enabled: false
20
+
21
+ Metrics/BlockLength:
22
+ Exclude:
23
+ - "**/*_spec.rb"
24
+
25
+ Style/Documentation:
26
+ Enabled: false
27
+
28
+ Style/ExponentialNotation:
29
+ Enabled: true
30
+
31
+ Style/HashEachMethods:
32
+ Enabled: true
33
+
34
+ Style/HashTransformKeys:
35
+ Enabled: true
36
+
37
+ Style/HashTransformValues:
38
+ Enabled: true
39
+
40
+ Metrics/ModuleLength:
41
+ Max: 500
@@ -0,0 +1,11 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.5
6
+ - 2.6
7
+ before_install:
8
+ - gem install bundler
9
+ script:
10
+ - bundle exec rubocop
11
+ - bundle exec rspec
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in libyui_client.gemspec
6
+ gemspec
7
+ gem 'rubocop'
8
+ gem 'webmock'
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019-2020 SUSE LLC
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,210 @@
1
+ # LibyuiClient
2
+
3
+ Ruby gem to interact with YaST applications via libyui-rest-api.
4
+ See documentation of the [libyui-rest-api project](https://github.com/libyui/libyui-rest-api/)
5
+ for more details about server side implementation.
6
+
7
+ Usage example:
8
+
9
+ ```ruby
10
+ require 'libyui_client'
11
+
12
+ app = LibyuiClient::App.new(host: 'localhost', port: '9999')
13
+ button = app.button(id: 'settime')
14
+ button.click
15
+ ```
16
+
17
+ ## Installing libyui_client
18
+
19
+ As soon as the gem is in development, run the following command from command line:
20
+
21
+ ```
22
+ gem "libyui_client", :git => "git@github.com:jknphy/libyui_client.git"
23
+ ```
24
+
25
+ Now need to require gem in order to use it.
26
+
27
+ ## Initialize the app under control
28
+
29
+ It is assumed the application is running on `localhost:9999`.
30
+ Then the code to initialize the application looks like:
31
+
32
+ ```ruby
33
+ require 'libyui_client'
34
+
35
+ app = LibyuiClient::App.new(host: 'localhost', port: '9999')
36
+ ```
37
+
38
+ ## Supported widgets
39
+
40
+ libyui_client supports different types of widgets.
41
+
42
+ Here are examples of usage:
43
+
44
+ ### Button
45
+ ```ruby
46
+ app.button(id: 'test_id').click # clicks the button with id 'test_id'
47
+ app.button(label: 'test_label').debug_label # get 'debug_label' value with label 'test_label'
48
+ ```
49
+
50
+ ### Bargraph
51
+ ```ruby
52
+ # Get list of labels in the segments:
53
+ app.bargraph(class: YBarGraph).labels
54
+ # Get array of hashes containing label->value pairs denoting each segment:
55
+ app.bargraph(class: YBarGraph).segments
56
+ # Get list of values in the segments:
57
+ app.bargraph(class: YBarGraph).values
58
+ ```
59
+
60
+ ### Checkbox
61
+ ```ruby
62
+ app.checkbox(id: 'test_id').check # checks the checkbox with id 'test_id'
63
+ app.checkbox(label: 'test_label', class: 'YCheckBox').checked? # gets the state of checkbox with label 'test_label'
64
+ app.checkbox(id: 'test_id').toggle # toggles the checkbox with id 'test_id'
65
+ app.checkbox(label: 'test_label', class: 'YCheckBoxFrame').uncheck # unchecks the checkbox with id 'test_id'
66
+ ```
67
+
68
+ ### Combobox
69
+ ```ruby
70
+ app.combobox(id: 'test_id').items # gets all available items for combobox with id 'test_id'
71
+ app.combobox(id: 'test_id').select # selects the checkbox with id 'test_id'
72
+ app.combobox(id: 'test_id').selected_item # gets the selected item in combobox with id 'test_id'
73
+ app.combobox(label: 'cmbx', class: 'YComboBox').set # Sets custom string to the editable checkbox
74
+ ```
75
+
76
+ ### Datefield
77
+ ```ruby
78
+ # Set date field to 2048-08-16
79
+ app.datefield(class: 'YDateField').set(Date.new(2048, 8, 16))
80
+ app.datefield(id: 'date').value # gets value from datefield with id 'date'
81
+ ```
82
+
83
+ ### Label
84
+ ```ruby
85
+ app.label(id: 'test_id').heading? # gets if label has bold font respresentation with id 'test_id'
86
+ app.label(id: 'test_id').text # gets text from label with id 'test_id'
87
+ ```
88
+
89
+ ### Menubutton
90
+ ```ruby
91
+ app.menubutton(id: 'test_id').click('button1') # clicks on 'button1' of menubutton with id 'test_id'
92
+ ```
93
+
94
+ ### Numberbox
95
+ ```ruby
96
+ app.numberbox(id: 'test_id').min_value # gets min value to be set in numberbox with id 'test_id'
97
+ app.numberbox(id: 'test_id').max_value # gets max value to be set in numberbox with id 'test_id'
98
+ app.numberbox(id: 'test_id').set(99) # sets 99 to numberbox with id 'test_id'
99
+ app.numberbox(id: 'test_id').value # gets value from numberbox with id 'test_id'
100
+ ```
101
+
102
+ ### Radiobutton
103
+ ```ruby
104
+ app.radiobutton(id: 'test_id').select # selects the radiobutton with id 'test_id'
105
+ app.radiobutton(id: 'test_id').selected? # gets the state of radiobutton with id 'test_id'
106
+ ```
107
+
108
+ ### Richtext
109
+ ```ruby
110
+ app.richtext(id: 'test_id').click_link('test_link') # clicks on link "test_link" with id 'test_id'
111
+ app.richtext(id: 'test_id').text # gets text from richtext
112
+ ```
113
+
114
+ ### Tab
115
+ ```ruby
116
+ app.tab(id: 'test_id').items # gets items from tab with id 'test_id'
117
+ app.tab(id: 'test_id').select(value: 'item') # selects specific tab with id 'test_id'
118
+ app.tab(id: 'test_id').selected_item # gets selected tab for tab with id 'test_id'
119
+ ```
120
+
121
+ ### Table
122
+ ```ruby
123
+ # checks if there is not rows in table with id 'test_id':
124
+ app.table(id: 'test_id').empty?
125
+ # gets rows in the table with id 'test_id':
126
+ app.table(id: 'test_id').items
127
+ # selects row in table with value test.item.1 and column test.header:
128
+ app.table(id: 'test_id').select( value: 'test.item.1', column: 'test.header' )
129
+ # selects row with number 3, numeration starts from 0 and corresponds to the order
130
+ # in the list returned by method `items`:
131
+ app.table(id: 'test_id').select(row: 3)
132
+ # gets items currently selected in table with id 'test_id':
133
+ app.table(id: 'test_id').seleted_items
134
+
135
+
136
+ ```
137
+ ### Textbox
138
+ ```ruby
139
+ app.textbox(id: 'test_id').max_length
140
+ app.textbox(id: 'test_id').set('Test Text') # sets "Test Text" to textbox with id 'test_id'
141
+ app.textbox(id: 'test_id').password? # checks password mode for textbox with id 'test_id'
142
+ app.textbox(id: 'test_id').valid_chars # checks valid chars for textbox with id 'test_id'
143
+ app.textbox(id: 'test_id').value # gets value from textbox with id 'test_id'
144
+ ```
145
+
146
+ ### TimeField
147
+ ```ruby
148
+ # Set TimeField to current time
149
+ app.timefield(label: 'time', class: 'YTimeField').set(Time.now)
150
+ app.timefield(id: 'time').value # gets value from timefield with id 'time'
151
+ ```
152
+
153
+ ### Tree
154
+ ```ruby
155
+ app.tree(id: 'test_id').items # gets items from tree with id 'test_id'
156
+ app.tree(id: 'test_id').select('node1|node1_2') # selects item in tree with id 'test_id'
157
+ app.tree(id: 'test_id').selected_item # gets currently highlighted item from tree with id 'test_id'
158
+ ```
159
+
160
+ ## Filters
161
+
162
+ libyui_client supports the same filters, as libyui-rest-api provides:
163
+
164
+ * id - widget ID serialized as string, might include special characters like backtick (\`)
165
+ * label - widget label as currently displayed (i.e. translated!)
166
+ * class - widget class
167
+
168
+ Also, regex for the filters is allowed.
169
+
170
+ Example:
171
+ ```ruby
172
+ app.button(id: /.*test/).debug_label
173
+ ```
174
+
175
+ ## Waits
176
+
177
+ ### Default timeout and interval
178
+
179
+ All the actions against widgets in libyui_client are made with default timeout and interval.
180
+ Default timeout is 5 sec, default interval is 0.5 sec.
181
+ That means libyui_client will repeat sending requests to YaST application every 0.5 seconds until 5 seconds
182
+ timeout will be reached. This default wait is needed because widgets may not be loaded immediately while trying to
183
+ interact with them (e.g. when navigating from one screen to another).
184
+
185
+ The default timeout and interval can be changed by the following:
186
+
187
+ ```ruby
188
+ LibyuiClient.timeout = 10
189
+ LibyuiClient.interval = 1
190
+ ```
191
+
192
+ ### Specific waits
193
+
194
+ All the widgets include Waitable module, which contains special methods to allow explicit waiting:
195
+ `wait_until` and `wait_while`.
196
+ These methods can be used when it is needed to wait until some property of the widget will be changed.
197
+
198
+ For example, wait until button will be enabled and click on it:
199
+
200
+ ```ruby
201
+ # with #to_proc syntax:
202
+ app.button(id: 'test_id').wait_until(&:enabled?).click
203
+
204
+ # without #to_proc syntax:
205
+ app.button(id: 'test_id').wait_until{ |button| button.enabled? }.click
206
+ ```
207
+
208
+ ## License
209
+
210
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
9
+
10
+ task :integration do
11
+ RSpec::Core::RakeTask.new(:integration) do |t|
12
+ t.pattern = 'spec/widgets/*_spec.rb'
13
+ end
14
+ end
15
+
16
+ task :unit do
17
+ RSpec::Core::RakeTask.new(:unit) do |t|
18
+ t.pattern = 'spec/unit/**/*_spec.rb'
19
+ end
20
+ end
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'libyui_client'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require 'irb'
15
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'date'
4
+ require 'json'
5
+ require 'net/http'
6
+ require 'uri'
7
+ require 'timeout'
8
+ require 'time'
9
+
10
+ require 'libyui_client/version'
11
+ require 'libyui_client/local_process'
12
+ require 'libyui_client/widgets'
13
+ require 'libyui_client/logger'
14
+ require 'libyui_client/timer'
15
+ require 'libyui_client/wait'
16
+ require 'libyui_client/app'
17
+ require 'libyui_client/http/http_client'
18
+ require 'libyui_client/http/response'
19
+ require 'libyui_client/http/version_controller'
20
+ require 'libyui_client/http/widget_controller'
21
+ require 'libyui_client/error'
22
+ require 'libyui_client/actions'
23
+ require 'libyui_client/filter_extractor'
24
+
25
+ # Client to interact with YAST UI rest api framework for integration testing
26
+ module LibyuiClient
27
+ class << self
28
+ attr_writer :timeout, :interval
29
+
30
+ def timeout
31
+ @timeout ||= 5
32
+ end
33
+
34
+ def interval
35
+ @interval ||= 0.5
36
+ end
37
+ end
38
+
39
+ def self.logger
40
+ @logger ||= LibyuiClient::Logger.new
41
+ end
42
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LibyuiClient
4
+ module Actions
5
+ PRESS = 'press'
6
+ TOGGLE = 'toggle'
7
+ CHECK = 'check'
8
+ UNCHECK = 'uncheck'
9
+ SELECT = 'select'
10
+ ENTER_TEXT = 'enter_text'
11
+ end
12
+ end
@@ -0,0 +1,230 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LibyuiClient
4
+ class App
5
+ # Used to initialize main entry point of LibyuiClient and set host and port
6
+ # for the application under control.
7
+ # @param host [String] host address (e.g. 'localhost', '192.168.0.1')
8
+ # @param port [String] port opened for communication (e.g. '9999')
9
+ def initialize(host:, port:)
10
+ @host = host
11
+ @port = port
12
+ @widget_controller = Http::WidgetController.new(host: host, port: port)
13
+ @version_controller = Http::VersionController.new(host: host, port: port)
14
+ end
15
+
16
+ # Initializes new instance of Bargraph with the filter provided.
17
+ # Does not make request to libyui-rest-api.
18
+ # @param filter [Hash] filter to find a widget
19
+ # @return [Widgets::Bargraph] new instance of Table
20
+ # @example
21
+ # app.bargraph(id: 'id', label: 'label', class: 'YBarGraph')
22
+ def bargraph(filter)
23
+ Widgets::Bargraph.new(@widget_controller, FilterExtractor.new(filter))
24
+ end
25
+
26
+ # Initializes new instance of Button with the filter provided.
27
+ # Does not make request to libyui-rest-api.
28
+ # @param filter [Hash] filter to find a widget
29
+ # @return [Widgets::Button] new instance of Button
30
+ # @example
31
+ # app.button(id: 'id', label: 'label', class: 'YPushButton')
32
+ def button(filter)
33
+ Widgets::Button.new(@widget_controller, FilterExtractor.new(filter))
34
+ end
35
+
36
+ # Initializes new instance of Checkbox with the filter provided.
37
+ # Does not make request to libyui-rest-api.
38
+ # @param filter [Hash] filter to find a widget
39
+ # @return [Widgets::Checkbox] new instance of Checkbox
40
+ # @example
41
+ # app.checkbox(id: 'id', label: 'label', class: 'YCheckBox')
42
+ def checkbox(filter)
43
+ Widgets::Checkbox.new(@widget_controller, FilterExtractor.new(filter))
44
+ end
45
+
46
+ # Initializes new instance of Combobox with the filter provided.
47
+ # Does not make request to libyui-rest-api.
48
+ # @param filter [Hash] filter to find a widget
49
+ # @return [Widgets::Combobox] new instance of Combobox
50
+ # @example
51
+ # app.combobox(id: 'id', label: 'label', class: 'YComboBox')
52
+ def combobox(filter)
53
+ Widgets::Combobox.new(@widget_controller, FilterExtractor.new(filter))
54
+ end
55
+
56
+ # Initializes new instance of Datefield with the filter provided.
57
+ # Does not make request to libyui-rest-api.
58
+ # @param filter [Hash] filter to find a widget
59
+ # @return [Widgets::Datefield] new instance of Datefield
60
+ # @example
61
+ # app.datefield(id: 'id', label: 'label', class: 'YDateField')
62
+ def datefield(filter)
63
+ Widgets::Datefield.new(@widget_controller, FilterExtractor.new(filter))
64
+ end
65
+
66
+ # Initializes new instance of Label with the filter provided.
67
+ # Does not make request to libyui-rest-api.
68
+ # @param filter [Hash] filter to find a widget
69
+ # @return [Widgets::Label] new instance of Label
70
+ # @example
71
+ # app.label(id: 'id', label: 'label', class: 'YLabel')
72
+ def label(filter)
73
+ Widgets::Label.new(@widget_controller, FilterExtractor.new(filter))
74
+ end
75
+
76
+ # Initializes new instance of Menubutton with the filter provided.
77
+ # Does not make request to libyui-rest-api.
78
+ # @param filter [Hash] filter to find a widget
79
+ # @return [Widgets::Menubutton] new instance of Menubutton
80
+ # @example
81
+ # app.menubutton(id: 'id', label: 'label', class: 'YMenuButton')
82
+ def menubutton(filter)
83
+ Widgets::Menubutton.new(@widget_controller, FilterExtractor.new(filter))
84
+ end
85
+
86
+ # Initializes new instance of Multilinebox with the filter provided.
87
+ # Does not make request to libyui-rest-api.
88
+ # @param filter [Hash] filter to find a widget
89
+ # @return [Widgets::Multilinebox] new instance of Multilinebox
90
+ # @example
91
+ # app.multilinebox(id: 'id', label: 'label', class: 'YMultiLineEdit')
92
+ def multilinebox(filter)
93
+ Widgets::Multilinebox.new(@widget_controller, FilterExtractor.new(filter))
94
+ end
95
+
96
+ # Initializes new instance of Numberbox with the filter provided.
97
+ # Does not make request to libyui-rest-api.
98
+ # @param filter [Hash] filter to find a widget
99
+ # @return [Widgets::Numberbox] new instance of Numberbox
100
+ # @example
101
+ # app.numberbox(id: 'id', label: 'label', class: 'YIntField')
102
+ def numberbox(filter)
103
+ Widgets::Numberbox.new(@widget_controller, FilterExtractor.new(filter))
104
+ end
105
+
106
+ # Initializes new instance of Progressbar with the filter provided.
107
+ # Does not make request to libyui-rest-api.
108
+ # @param filter [Hash] filter to find a widget
109
+ # @return [Widgets::Progressbar] new instance of Progressbar
110
+ # @example
111
+ # app.progressbar(id: 'id', label: 'label', class: 'YProgressBar')
112
+ def progressbar(filter)
113
+ Widgets::Progressbar.new(@widget_controller, FilterExtractor.new(filter))
114
+ end
115
+
116
+ # Initializes new instance of Radiobutton with the filter provided.
117
+ # Does not make request to libyui-rest-api.
118
+ # @param filter [Hash] filter to find a widget
119
+ # @return [Widgets::Radiobutton] new instance of Radiobutton
120
+ # @example
121
+ # app.radiobutton(id: 'id', label: 'label', class: 'YRadioButton')
122
+ def radiobutton(filter)
123
+ Widgets::Radiobutton.new(@widget_controller, FilterExtractor.new(filter))
124
+ end
125
+
126
+ # Initializes new instance of Richtext with the filter provided.
127
+ # Does not make request to libyui-rest-api.
128
+ # @param filter [Hash] filter to find a widget
129
+ # @return [Widgets::Richtext] new instance of Richtext
130
+ # @example
131
+ # app.richtext(id: 'id', label: 'label', class: 'YRichText')
132
+ def richtext(filter)
133
+ Widgets::Richtext.new(@widget_controller, FilterExtractor.new(filter))
134
+ end
135
+
136
+ # Initializes new instance of Selectionbox with the filter provided.
137
+ # Does not make request to libyui-rest-api.
138
+ # @param filter [Hash] filter to find a widget
139
+ # @return [Widgets::Selectionbox] new instance of Selectionbox
140
+ # @example
141
+ # app.selectionbox(id: 'id', label: 'label', class: 'YSelectionBox')
142
+ def selectionbox(filter)
143
+ Widgets::Selectionbox.new(@widget_controller, FilterExtractor.new(filter))
144
+ end
145
+
146
+ # Initializes new instance of Tab with the filter provided.
147
+ # Does not make request to libyui-rest-api.
148
+ # @param filter [Hash] filter to find a widget
149
+ # @return [Widgets::Tab] new instance of Tab
150
+ # @example
151
+ # app.tab(id: 'id', label: 'label', class: 'YDumbTab')
152
+ def tab(filter)
153
+ Widgets::Tab.new(@widget_controller, FilterExtractor.new(filter))
154
+ end
155
+
156
+ # Initializes new instance of Table with the filter provided.
157
+ # Does not make request to libyui-rest-api.
158
+ # @param filter [Hash] filter to find a widget
159
+ # @return [Widgets::Table] new instance of Table
160
+ # @example
161
+ # app.table(id: 'id', label: 'label', class: 'YTable')
162
+ def table(filter)
163
+ Widgets::Table.new(@widget_controller, FilterExtractor.new(filter))
164
+ end
165
+
166
+ # Initializes new instance of time field with the filter provided.
167
+ # Does not make request to libyui-rest-api.
168
+ # @param filter [Hash] filter to find a widget
169
+ # @return [Widgets::Timefield] new instance of Table
170
+ # @example
171
+ # app.timefield(id: 'id', label: 'label', class: 'YTimeField')
172
+ def timefield(filter)
173
+ Widgets::Timefield.new(@widget_controller, FilterExtractor.new(filter))
174
+ end
175
+
176
+ # Initializes new instance of Textbox with the filter provided.
177
+ # Does not make request to libyui-rest-api.
178
+ # @param filter [Hash] filter to find a widget
179
+ # @return [Widgets::Textbox] new instance of Textbox
180
+ # @example
181
+ # app.textbox(id: 'id', label: 'label', class: 'YInputField')
182
+ def textbox(filter)
183
+ Widgets::Textbox.new(@widget_controller, FilterExtractor.new(filter))
184
+ end
185
+
186
+ # Initializes new instance of Tree with the filter provided.
187
+ # Does not make request to libyui-rest-api.
188
+ # @param filter [Hash] filter to find a widget
189
+ # @return [Widgets::Tree] new instance of Tree
190
+ # @example
191
+ # app.tree(id: 'id', label: 'label', class: 'YTree')
192
+ def tree(filter)
193
+ Widgets::Tree.new(@widget_controller, FilterExtractor.new(filter))
194
+ end
195
+
196
+ # Initializes new instance of Wizard with the filter provided.
197
+ # Does not make request to libyui-rest-api.
198
+ # @param filter [Hash] filter to find a widget
199
+ # @return [Widgets::Wizard] new instance of Wizard
200
+ # @example
201
+ # app.wizard(id: 'id', label: 'label', class: 'YWizard')
202
+ def wizard(filter)
203
+ Widgets::Wizard.new(@widget_controller, FilterExtractor.new(filter))
204
+ end
205
+
206
+ # Returns client side libyui REST API version
207
+ # @return libyui client REST API version
208
+ def client_api_version
209
+ API_VERSION
210
+ end
211
+
212
+ # Returns server side libyui REST API version
213
+ # @return libyui server REST API version
214
+ def server_api_version
215
+ @version_controller.api_version
216
+ end
217
+
218
+ # Validates if server side REST API is compatible with client inside
219
+ # @return true if version is compatible, false if not or any error while
220
+ # receiving version from the server
221
+ def check_api_version
222
+ LibyuiClient.logger.info("Client API version: #{API_VERSION}")
223
+ server_api_v = server_api_version
224
+ raise Error::LibyuiClientError if server_api_v.nil?
225
+
226
+ LibyuiClient.logger.info("Server API version: #{server_api_v}")
227
+ server_api_v <= client_api_version
228
+ end
229
+ end
230
+ end