yui_rest_client 0.5.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 (49) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/publish.yml +33 -0
  3. data/.github/workflows/test.yml +26 -0
  4. data/.gitignore +15 -0
  5. data/.rspec +3 -0
  6. data/.rubocop.yml +41 -0
  7. data/Gemfile +8 -0
  8. data/LICENSE.txt +21 -0
  9. data/README.md +216 -0
  10. data/Rakefile +20 -0
  11. data/bin/console +15 -0
  12. data/bin/setup +8 -0
  13. data/lib/yui_rest_client.rb +42 -0
  14. data/lib/yui_rest_client/actions.rb +12 -0
  15. data/lib/yui_rest_client/app.rb +230 -0
  16. data/lib/yui_rest_client/error.rb +13 -0
  17. data/lib/yui_rest_client/filter_extractor.rb +28 -0
  18. data/lib/yui_rest_client/http/http_client.rb +36 -0
  19. data/lib/yui_rest_client/http/response.rb +21 -0
  20. data/lib/yui_rest_client/http/version_controller.rb +26 -0
  21. data/lib/yui_rest_client/http/widget_controller.rb +54 -0
  22. data/lib/yui_rest_client/local_process.rb +73 -0
  23. data/lib/yui_rest_client/logger.rb +32 -0
  24. data/lib/yui_rest_client/timer.rb +20 -0
  25. data/lib/yui_rest_client/version.rb +6 -0
  26. data/lib/yui_rest_client/wait.rb +21 -0
  27. data/lib/yui_rest_client/waitable.rb +39 -0
  28. data/lib/yui_rest_client/widgets.rb +30 -0
  29. data/lib/yui_rest_client/widgets/bargraph.rb +62 -0
  30. data/lib/yui_rest_client/widgets/base.rb +114 -0
  31. data/lib/yui_rest_client/widgets/button.rb +33 -0
  32. data/lib/yui_rest_client/widgets/checkbox.rb +53 -0
  33. data/lib/yui_rest_client/widgets/combobox.rb +95 -0
  34. data/lib/yui_rest_client/widgets/datefield.rb +47 -0
  35. data/lib/yui_rest_client/widgets/label.rb +41 -0
  36. data/lib/yui_rest_client/widgets/menubutton.rb +48 -0
  37. data/lib/yui_rest_client/widgets/multilinebox.rb +84 -0
  38. data/lib/yui_rest_client/widgets/numberbox.rb +76 -0
  39. data/lib/yui_rest_client/widgets/progressbar.rb +45 -0
  40. data/lib/yui_rest_client/widgets/radiobutton.rb +35 -0
  41. data/lib/yui_rest_client/widgets/richtext.rb +36 -0
  42. data/lib/yui_rest_client/widgets/selectionbox.rb +87 -0
  43. data/lib/yui_rest_client/widgets/tab.rb +81 -0
  44. data/lib/yui_rest_client/widgets/table.rb +154 -0
  45. data/lib/yui_rest_client/widgets/textbox.rb +94 -0
  46. data/lib/yui_rest_client/widgets/timefield.rb +45 -0
  47. data/lib/yui_rest_client/widgets/tree.rb +149 -0
  48. data/yui_rest_client.gemspec +38 -0
  49. metadata +222 -0
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ module YuiRestClient
4
+ module Widgets
5
+ # Class representing a date field in the UI, namely YDateField.
6
+ class Datefield < Widgets::Base
7
+ # Sends action to set the value of date field. Accepts Date, Time or DateTime
8
+ # object and sets value in ISO 8601 format YYYY-MM-DD.
9
+ # @param date [Date] date to be set in date field
10
+ # @return [Datefield] in case action is successful
11
+ # @raise YuiRestClientError if parameter is not Date, DateTime or Time
12
+ # @example Set date in date field with id 'test' to current date
13
+ # app.datefield(id: 'date').set(Time.now)
14
+ # @example Set date in date field with id 'test' to 2002-12-29
15
+ # app.datefield(id: 'date').set(DateTime.new(2002,12,29))
16
+ # @example Set date in date field with id 'test' to 2021-02-03
17
+ # app.datefield(id: 'date').set(Date.new(2001,2,3))
18
+ def set(date)
19
+ unless [Date, DateTime, Time].any? { |c| date.is_a? c }
20
+ raise Error::YuiRestClientError, 'Parameter is not Date, Time or DateTime'
21
+ end
22
+
23
+ action(action: Actions::ENTER_TEXT, value: date.strftime('%F'))
24
+ self
25
+ end
26
+
27
+ # Returns text that is currently set for datefield.
28
+ # Gets value from 'value' parameter in JSON representation of YDateField.
29
+ # @return [String] value
30
+ # @example Get value from datefield with id "date"
31
+ # {
32
+ # "class" : "YDateField",
33
+ # "debug_label" : "Date:",
34
+ # "hstretch" : true,
35
+ # "id" : "date",
36
+ # "label" : "&Date:",
37
+ # "notify" : true,
38
+ # "value" : "1989-11-09"
39
+ # }
40
+ # @example
41
+ # app.datefield(id: 'date').value # '1989-11-09'
42
+ def value
43
+ property(:value)
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ module YuiRestClient
4
+ module Widgets
5
+ # Class representing a Label UI. It can be YLabel, YLabel_Heading
6
+ class Label < Widgets::Base
7
+ # Returns if label is a heading being represented in bold in the UI
8
+ # Gets value from 'is_heading' parameter in JSON representation of YLabel_Heading.
9
+ # @return [Boolean] true if it is a heading, false otherwise.
10
+ # @example Check label with 'label' "Product name"
11
+ # {
12
+ # "class": "YLabel_Heading",
13
+ # "debug_label": "Product name ...",
14
+ # "is_heading": true,
15
+ # "label": "Product name",
16
+ # "text": "Product name"
17
+ # }
18
+ # @example
19
+ # app.label(label: 'Product name').heading? # true
20
+ def heading?
21
+ heading_prop = property(:is_heading)
22
+ !heading_prop.nil? && heading_prop == true
23
+ end
24
+
25
+ # Returns text value for the label.
26
+ # @return [String] value
27
+ # @example Get text value for YLabel, YLabelHeading
28
+ # {
29
+ # "class": "YLabel",
30
+ # "debug_label": "short message",
31
+ # "label": "test label",
32
+ # "text": "text label"
33
+ # }
34
+ # @example
35
+ # text = app.label(label: 'test label').text # "text label"
36
+ def text
37
+ property(:text)
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ module YuiRestClient
4
+ module Widgets
5
+ # Class representing a menubutton in UI. It can be YMenuButton.
6
+ class Menubutton < Widgets::Base
7
+ # Sends action to click on one of the items of the menubutton in UI.
8
+ # @param item [String] value to select from items.
9
+ # @example Click button with label 'test_button' for menubutton with id 'test_id'.
10
+ # @example
11
+ # app.menubutton(id: 'test_id').click('test_button')
12
+ def click(item)
13
+ action(action: Actions::PRESS, value: item)
14
+ end
15
+
16
+ # Returns the list of items available to select from widget.
17
+ # @return [Array<String>] array of strings.
18
+ # @example Get items from widget with id "test_id"
19
+ # {
20
+ # "class": "YMenuButton",
21
+ # "debug_label": "test",
22
+ # "icon_base_path": "",
23
+ # "id": "test_id",
24
+ # "items": [
25
+ # {
26
+ # "label": "button1"
27
+ # },
28
+ # {
29
+ # "label": "button2"
30
+ # },
31
+ # {
32
+ # "label": "button3"
33
+ # }
34
+ # ],
35
+ # "items_count": 3,
36
+ # "label": "button group"
37
+ # }
38
+ # @example
39
+ # app.menubutton(id: 'test').items
40
+ # # button1
41
+ # # button2
42
+ # # button3
43
+ def items
44
+ property(:items).map { |x| x[:label] }
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,84 @@
1
+ # frozen_string_literal: true
2
+
3
+ module YuiRestClient
4
+ module Widgets
5
+ # Class representing a multilinebox in the UI. It can be YMultiLineEdit.
6
+ class Multilinebox < Widgets::Base
7
+ # Returns maximum string length to set in the multilinebox
8
+ # @return [Integer] maximum number of character to set in the multilinebox
9
+ # @example Check maximum string length in multilinebox with id 'TEST_ID'
10
+ # }
11
+ # "class" : "YMultiLineEdit",
12
+ # "debug_label" : "test_label",
13
+ # "default_visible_lines" : 3,
14
+ # "hstretch" : true,
15
+ # "hweight" : 1,
16
+ # "id" : "\"TEST_ID\"",
17
+ # "input_max_length" : -1,
18
+ # "label" : "test_label",
19
+ # "value" : "",
20
+ # "vstretch" : true
21
+ # }
22
+ # @example
23
+ # app.multilinebox(id: '"TEST_ID"').max_length
24
+ # # -1
25
+ def max_length
26
+ property(:input_max_length)
27
+ end
28
+
29
+ # Returns the default visible number of lines for the multilinebox
30
+ # @return [Integer] default number of visible lines for the multilinebox
31
+ # @example Check the default visible number of line for multilinebox with id 'TEST_ID'
32
+ # }
33
+ # "class" : "YMultiLineEdit",
34
+ # "debug_label" : "test_label",
35
+ # "default_visible_lines" : 3,
36
+ # "hstretch" : true,
37
+ # "hweight" : 1,
38
+ # "id" : "\"TEST_ID\"",
39
+ # "input_max_length" : -1,
40
+ # "label" : "test_label",
41
+ # "value" : "",
42
+ # "vstretch" : true
43
+ # }
44
+ # @example
45
+ # app.multilinebox(id: '"TEST_ID"').visible_lines
46
+ # # 3
47
+ def visible_lines
48
+ property(:default_visible_lines)
49
+ end
50
+
51
+ # Sends action to set the value of multilinebox.
52
+ # @param value [String] text to be set in multilinebox
53
+ # @return [Multilinebox] in case action is successful
54
+ # @example Set text in multilinebox with id 'TEST_ID' to 'text'
55
+ # app.multilinebox(id: '"TEST_ID"').set("text\ntext in new line")
56
+ def set(value)
57
+ action(action: Actions::ENTER_TEXT, value: value)
58
+ self
59
+ end
60
+
61
+ # Returns text that is currently set for multilinebox.
62
+ # Gets value from 'value' parameter in JSON representation of YMultiLineEdit.
63
+ # @return [String] text set as value in the multilinebox.
64
+ # @example Get value from multilinebox with id "address"
65
+ # }
66
+ # "class" : "YMultiLineEdit",
67
+ # "debug_label" : "test_label",
68
+ # "default_visible_lines" : 3,
69
+ # "hstretch" : true,
70
+ # "hweight" : 1,
71
+ # "id" : "\"TEST_ID\"",
72
+ # "input_max_length" : -1,
73
+ # "label" : "test_label",
74
+ # "value" : "This is a \nmultiline\ntext",
75
+ # "vstretch" : true
76
+ # }
77
+ # @example
78
+ # app.multilinebox(id: '"TEST_ID"').value # This is a \nmultiline\ntext
79
+ def value
80
+ property(:value)
81
+ end
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,76 @@
1
+ # frozen_string_literal: true
2
+
3
+ module YuiRestClient
4
+ module Widgets
5
+ # Class representing a numberbox in the UI. It can be YIntField.
6
+ class Numberbox < Widgets::Base
7
+ # Returns minimum value to set in the numberbox
8
+ # @return [Integer] with minimum value
9
+ # @example Get minimum value to set numberbox with id 'test'
10
+ # {
11
+ # "class": "YIntField",
12
+ # "debug_label": "label_test",
13
+ # "hstretch": true,
14
+ # "id": "test",
15
+ # "label": "label_test",
16
+ # "max_value": 65535,
17
+ # "min_value": 0,
18
+ # "value": 3260
19
+ # }
20
+ # @example
21
+ # app.numberbox(id: 'test').min_value
22
+ def min_value
23
+ property(:min_value)
24
+ end
25
+
26
+ # Returns maximum value to set in the numberbox
27
+ # @return [Integer] with maximum value
28
+ # @example Get maximum value to set numberbox with id 'test'
29
+ # {
30
+ # "class": "YIntField",
31
+ # "debug_label": "label_test",
32
+ # "hstretch": true,
33
+ # "id": "test",
34
+ # "label": "label_test",
35
+ # "max_value": 65535,
36
+ # "min_value": 0,
37
+ # "value": 3260
38
+ # }
39
+ # @example
40
+ # app.numberbox(id: 'test').max_value
41
+ def max_value
42
+ property(:max_value)
43
+ end
44
+
45
+ # Sends action to set the value of numberbox.
46
+ # @param value [Integer] to be set in numberbox
47
+ # @return [Numberbox] in case action is successful
48
+ # @example Set text in numberbox with id 'test' to 123
49
+ # app.numberbox(id: 'test').set(123)
50
+ def set(value)
51
+ action(action: Actions::ENTER_TEXT, value: value)
52
+ self
53
+ end
54
+
55
+ # Returns number that is currently set for numberbox.
56
+ # Gets value from 'value' parameter in JSON representation of YIntField.
57
+ # @return [Integer] value
58
+ # @example Get value from numberbox with id "test"
59
+ # {
60
+ # "class": "YIntField",
61
+ # "debug_label": "label_test",
62
+ # "hstretch": true,
63
+ # "id": "test",
64
+ # "label": "label_test",
65
+ # "max_value": 65535,
66
+ # "min_value": 0,
67
+ # "value": 3260
68
+ # }
69
+ # @example
70
+ # app.numberbox(id: 'address').value # 3260
71
+ def value
72
+ property(:value)
73
+ end
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ module YuiRestClient
4
+ module Widgets
5
+ # Class representing a Progressbar in UI. It can be YProgressBar.
6
+ class Progressbar < Widgets::Base
7
+ # Returns the current value of progressbar.
8
+ # Gets value from 'value' parameter in JSON representation of YProgressBar.
9
+ # @return [Integer] current value of progressbar.
10
+ # @example Get progressbar value, with id 'initProg'
11
+ # {
12
+ # "class" : "YProgressBar",
13
+ # "hstretch" : true,
14
+ # "id" : "initProg",
15
+ # "label" : "Disk",
16
+ # "max_value" : 1000,
17
+ # "value" : 666
18
+ # }
19
+ # app.progressbar(id: 'initProg').value
20
+ # # 663
21
+ def value
22
+ property(:value)
23
+ end
24
+
25
+ # Returns the max value of progressbar.
26
+ # Gets value from 'max_value' parameter in JSON representation of YProgressBar.
27
+ # @return [Integer] max value of the progressbar.
28
+ # @example Get progressbar max_value, with id 'initProg'
29
+ # {
30
+ # "class" : "YProgressBar",
31
+ # "hstretch" : true,
32
+ # "id" : "initProg",
33
+ # "label" : "Disk",
34
+ # "max_value" : 1000,
35
+ # "value" : 666
36
+ # }
37
+ # @example
38
+ # app.progressbar(id: 'initProg').max_value
39
+ # # 1000
40
+ def max_value
41
+ property(:max_value)
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module YuiRestClient
4
+ module Widgets
5
+ # Class representing a RadioButton in the UI. It can be YRadioButton.
6
+ class Radiobutton < Widgets::Base
7
+ # Sends action to select the radiobutton in UI.
8
+ # @return [Radiobutton] in case action is successful
9
+ # @example Select radiobutton with id 'test'
10
+ # app.radiobutton(id: 'test').select
11
+ def select
12
+ action(action: Actions::SELECT)
13
+ self
14
+ end
15
+
16
+ # Returns the state of radiobutton (selected or not).
17
+ # Gets value from 'value' parameter in JSON representation of YRadioButton.
18
+ # @return [Boolean] true if the radiobutton is selected, false otherwise.
19
+ # @example Get state for radiobutton with id "manual"
20
+ # {
21
+ # "class": "YRadioButton",
22
+ # "debug_label": "Manually",
23
+ # "id": "manual",
24
+ # "label": "&Manually",
25
+ # "notify": true,
26
+ # "value": false
27
+ # }
28
+ # @example
29
+ # app.radiobutton(id: 'manual').selected? # false
30
+ def selected?
31
+ property(:value)
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module YuiRestClient
4
+ module Widgets
5
+ # Class representing a richtext in the UI. It can be YRichText.
6
+ class Richtext < Widgets::Base
7
+ # Sends action to click a link inside a richtext control in the UI.
8
+ # @param value [String] href
9
+ # @return [Richtext] in case action is successful
10
+ # @example Click link with value 'test'
11
+ # items.click_link('test')
12
+ def click_link(value)
13
+ action(action: Actions::PRESS, value: value)
14
+ self
15
+ end
16
+
17
+ # Returns text value for the richtext.
18
+ # @return [String] value
19
+ # @example Get text value for YRichText
20
+ # {
21
+ # "class": "YRichText",
22
+ # "enabled": false,
23
+ # "hstretch": true,
24
+ # "id": "test",
25
+ # "text": "<small>Select something here</small>",
26
+ # "vstretch": true,
27
+ # "vweight": 25
28
+ # }
29
+ # @example
30
+ # text = app.richtext(id: 'test').text # "<small>Select something here</small>"
31
+ def text
32
+ property(:text)
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,87 @@
1
+ # frozen_string_literal: true
2
+
3
+ module YuiRestClient
4
+ module Widgets
5
+ # Class representing a selectionbox in the UI. It can be YSelectionBox.
6
+ class Selectionbox < Widgets::Base
7
+ # Returns the list of items available to select from selection box.
8
+ # @return [Array] array of String objects.
9
+ # @example Get items from selection box with id "test_id"
10
+ # {
11
+ # "class" : "YSelectionBox",
12
+ # "debug_label" : "selection box title",
13
+ # "hstretch" : true,
14
+ # "icon_base_path" : "",
15
+ # "id" : "test_id",
16
+ # "items" :
17
+ # [
18
+ # {
19
+ # "label" : "selection 1",
20
+ # "selected" : true
21
+ # },
22
+ # {
23
+ # "label" : "selection 2"
24
+ # },
25
+ # {
26
+ # "label" : "selection 3"
27
+ # }
28
+ # ],
29
+ # "items_count" : 3,
30
+ # "label" : "&selection box title",
31
+ # "vstretch" : true
32
+ # }
33
+ #
34
+ # @example
35
+ # app.selectionbox(id: 'test_id').items
36
+ # # selection 1
37
+ # # selection 2
38
+ # # selection 3
39
+ def items
40
+ property(:items).map { |x| x[:label] }
41
+ end
42
+
43
+ # Sends action to click the selection in UI.
44
+ # @param item [String] value to select from items.
45
+ # @return [Selectionbox] in case action is successful
46
+ # @example Click selection with id 'test_id'
47
+ # app.selectionbox(id: 'test_id').select('item_id')
48
+ def select(item)
49
+ action(action: Actions::SELECT, value: item)
50
+ self
51
+ end
52
+
53
+ # Returns selected item in selection box.
54
+ # @example Get selected item in selection box with id "test_id"
55
+ # {
56
+ # "class" : "YSelectionBox",
57
+ # "debug_label" : "selection box title",
58
+ # "hstretch" : true,
59
+ # "icon_base_path" : "",
60
+ # "id" : "test_id",
61
+ # "items" :
62
+ # [
63
+ # {
64
+ # "label" : "selection 1",
65
+ # "selected" : true
66
+ # },
67
+ # {
68
+ # "label" : "selection 2"
69
+ # },
70
+ # {
71
+ # "label" : "selection 3"
72
+ # }
73
+ # ],
74
+ # "items_count" : 3,
75
+ # "label" : "&selection box title",
76
+ # "vstretch" : true
77
+ # }
78
+ #
79
+ # @example
80
+ # app.selectionbox(id: 'test_id').selected_item
81
+ # # selection 1
82
+ def selected_item
83
+ property(:items).select { |x| x[:selected] }.first[:label]
84
+ end
85
+ end
86
+ end
87
+ end