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,94 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LibyuiClient
4
+ module Widgets
5
+ # Class representing a textbox in the UI. It can be YInputField.
6
+ class Textbox < Widgets::Base
7
+ # Returns maximum string length to set in the textbox
8
+ # @return [Integer] maximum number of character to set in the textbox
9
+ # @example Check maximum string length in textbox with id 'test'
10
+ # {
11
+ # "class": "YInputField",
12
+ # "debug_label": "label_test",
13
+ # "hstretch": true,
14
+ # "id": "test",
15
+ # "input_max_length": 256,
16
+ # "label": "label_test",
17
+ # "password_mode": false,
18
+ # "valid_chars": "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.",
19
+ # "value": ""
20
+ # }
21
+ # @example
22
+ # app.textbox(id: 'test').max_length
23
+ def max_length
24
+ property(:input_max_length)
25
+ end
26
+
27
+ # Sends action to set the value of textbox.
28
+ # @param value [String] text to be set in textbox
29
+ # @return [Textbox] in case action is successful
30
+ # @example Set text in textbox with id 'test' to 'my value'
31
+ # app.textbox(id: 'test').set('my value')
32
+ def set(value)
33
+ action(action: Actions::ENTER_TEXT, value: value)
34
+ self
35
+ end
36
+
37
+ # Check if textbox has password mode
38
+ # @return [Boolean] true if has password mode, otherwise false
39
+ # @example Check password mode in textbox with id 'test'
40
+ # {
41
+ # "class": "YInputField",
42
+ # "debug_label": "label_test",
43
+ # "hstretch": true,
44
+ # "id": "test",
45
+ # "label": "label_test",
46
+ # "password_mode": false,
47
+ # "value": ""
48
+ # }
49
+ # @example
50
+ # app.textbox(id: 'test').password?
51
+ def password?
52
+ property(:password_mode)
53
+ end
54
+
55
+ # Returns valid chars to set in the textbox
56
+ # @return [String] containing all valid chars
57
+ # @example Check password mode in textbox with id 'test'
58
+ # {
59
+ # "class": "YInputField",
60
+ # "debug_label": "label_test",
61
+ # "hstretch": true,
62
+ # "id": "test",
63
+ # "label": "label_test",
64
+ # "password_mode": false,
65
+ # "valid_chars": "0123456789",
66
+ # "value": ""
67
+ # }
68
+ # @example
69
+ # app.textbox(id: 'test').valid_chars
70
+ def valid_chars
71
+ property(:valid_chars)
72
+ end
73
+
74
+ # Returns text that is currently set for textbox.
75
+ # Gets value from 'value' parameter in JSON representation of YInputField.
76
+ # @return [String] value
77
+ # @example Get value from textbox with id "address"
78
+ # {
79
+ # "class": "YInputField",
80
+ # "debug_label": "Address",
81
+ # "hstretch": true,
82
+ # "id": "address",
83
+ # "label": "A&ddress",
84
+ # "password_mode": false,
85
+ # "value": "Test Address"
86
+ # }
87
+ # @example
88
+ # app.textbox(id: 'address').value # Test Address
89
+ def value
90
+ property(:value)
91
+ end
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LibyuiClient
4
+ module Widgets
5
+ # Class representing a DateField in the UI, namely YTimeField.
6
+ class Timefield < Widgets::Base
7
+ # Sends action to set the value of time field. Accepts Time or DateTime
8
+ # object and sets value in ISO 8601 format HH:MM:SS.
9
+ # @param time [Time] time to be set in the time field
10
+ # @return [Timefield] in case action is successful
11
+ # @raise LibyuiClientError if parameter is not DateTime or Time
12
+ # @example Set current time in the time field with id 'test' using Time
13
+ # app.timefield(id: 'time').set(Time.now)
14
+ # @example Set custom time in the field with id 'test' to 04:05:06
15
+ # app.timefield(id: 'time').set(DateTime.new(2001,2,3,4,5,6))
16
+ def set(time)
17
+ unless [DateTime, Time].any? { |c| time.is_a? c }
18
+ raise Error::LibyuiClientError, 'Parameter is not Date, Time or DateTime'
19
+ end
20
+
21
+ action(action: Actions::ENTER_TEXT, value: time.strftime('%T'))
22
+ self
23
+ end
24
+
25
+ # Returns text that is currently set for timefield.
26
+ # Gets value from 'value' parameter in JSON representation of YTimeField.
27
+ # @return [String] value
28
+ # @example Get value from timefield with id "time"
29
+ # {
30
+ # "class" : "YTimeField",
31
+ # "debug_label" : "Time:",
32
+ # "hstretch" : true,
33
+ # "id" : "time",
34
+ # "label" : "&Time:",
35
+ # "notify" : true,
36
+ # "value" : "20:15:00"
37
+ # }
38
+ # @example
39
+ # app.timefield(id: 'time').value # '20:15:00'
40
+ def value
41
+ property(:value)
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,149 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LibyuiClient
4
+ module Widgets
5
+ # Class representing a tree in UI. It can be YTree.
6
+ class Tree < Widgets::Base
7
+ # Returns the list of items available to select from tree. Each item
8
+ # is represented by its path from root node to leaf in the tree,
9
+ # in other words, a list of nodes separated by special simbol '|'
10
+ # @return [Array<String>] array of strings
11
+ # @example Get items from tree with id "test_id"
12
+ # {
13
+ # "class": "YTree",
14
+ # "debug_label": "node_0",
15
+ # "hstretch": true,
16
+ # "hweight": 30,
17
+ # "icon_base_path": "",
18
+ # "id": "test_id",
19
+ # "items": [
20
+ # {
21
+ # "children": [
22
+ # {
23
+ # "icon_name": "icon",
24
+ # "label": "node1_1"
25
+ # },
26
+ # {
27
+ # "children": [
28
+ # {
29
+ # "label": "node1_2_1"
30
+ # },
31
+ # {
32
+ # "label": "node1_2_2",
33
+ # "selected": true
34
+ # }
35
+ # ],
36
+ # "icon_name": "icon",
37
+ # "label": "node1_2"
38
+ # }
39
+ # ],
40
+ # "icon_name": "icon",
41
+ # "label": "node1",
42
+ # },
43
+ # {
44
+ # "icon_name": "icon",
45
+ # "label": "node2"
46
+ # }
47
+ # ],
48
+ # "items_count": 2,
49
+ # "label": "node_0",
50
+ # "notify": true,
51
+ # "vstretch": true
52
+ # }
53
+ # @example
54
+ # app.tree(id: 'test_id').items
55
+ # # node1
56
+ # # node1|node1_1
57
+ # # node1|node1_2
58
+ # # node1|node1_2|node1_2_1
59
+ # # node1|node1_2|node1_2_2
60
+ # # node2
61
+ def items
62
+ get_nodes(property(:items))
63
+ end
64
+
65
+ # Sends action to select an item from the tree in UI.
66
+ # @param item [String] value to select from items.
67
+ # @example Select tree node 'test_node' from tree with id 'test_id'
68
+ # app.tree(id: 'test_id').select('test_node')
69
+ def select(item)
70
+ action(action: Actions::SELECT, value: item)
71
+ self
72
+ end
73
+
74
+ # Returns the item currently selected/highlighted in the tree. Item
75
+ # is represented by its path from root node to leaf in the tree,
76
+ # in other words, a list of nodes separated by special simbol '|'
77
+ # @return [String] item selected/highlighted in the tree
78
+ # @example Get selected item from tree with id "test_id"
79
+ # {
80
+ # "class": "YTree",
81
+ # "debug_label": "node_0",
82
+ # "hstretch": true,
83
+ # "hweight": 30,
84
+ # "icon_base_path": "",
85
+ # "id": "test_id",
86
+ # "items": [
87
+ # {
88
+ # "children": [
89
+ # {
90
+ # "icon_name": "icon",
91
+ # "label": "node1_1"
92
+ # },
93
+ # {
94
+ # "children": [
95
+ # {
96
+ # "label": "node_1_2_1"
97
+ # },
98
+ # {
99
+ # "label": "node_1_2_2",
100
+ # "selected": true
101
+ # }
102
+ # ],
103
+ # "icon_name": "icon",
104
+ # "label": "node1_2"
105
+ # }
106
+ # ],
107
+ # "icon_name": "icon",
108
+ # "label": "node1",
109
+ # },
110
+ # {
111
+ # "icon_name": "icon",
112
+ # "label": "node2"
113
+ # }
114
+ # ],
115
+ # "items_count": 2,
116
+ # "label": "node_0",
117
+ # "notify": true,
118
+ # "vstretch": true
119
+ # }
120
+ # @example
121
+ # app.tree(id: 'test_id').selected_item
122
+ # # node1|node1_2|node1_2_2
123
+ def selected_item
124
+ get_selected_node(property(:items))
125
+ end
126
+
127
+ private
128
+
129
+ def get_nodes(items, root = '')
130
+ items.map do |x|
131
+ current = root.empty? ? x[:label] : root + '|' + x[:label]
132
+ x.key?(:children) ? [current, get_nodes(x[:children], current)] : current
133
+ end.flatten
134
+ end
135
+
136
+ def get_selected_node(items, root = '')
137
+ selected = ''
138
+ items.each do |x|
139
+ current = root.empty? ? x[:label] : root + '|' + x[:label]
140
+ return current if x[:selected]
141
+
142
+ selected = get_selected_node(x[:children], current) if x.key?(:children)
143
+ break unless selected.empty?
144
+ end
145
+ selected
146
+ end
147
+ end
148
+ end
149
+ end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'libyui_client/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'libyui_client'
9
+ spec.version = LibyuiClient::VERSION
10
+ spec.required_ruby_version = '>= 2.5.0'
11
+ spec.authors = ['Joaquin Rivera', 'Ioannis Bonatakis', 'Oleksandr Orlov', 'Rodion Iafarov', 'Sofia Syrianidou']
12
+ spec.email = ['qa-sle-yast@suse.de']
13
+
14
+ spec.summary = 'Client for libyui applications.'
15
+ spec.description = 'Client to operate controls for libyui applications.'
16
+ spec.homepage = "https://github.com/qa-sle-yast/libyui_client"
17
+ spec.license = 'MIT'
18
+
19
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
20
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
21
+ if spec.respond_to?(:metadata)
22
+ # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
23
+ #
24
+ # spec.metadata["homepage_uri"] = spec.homepage
25
+ # spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
26
+ # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
27
+ else
28
+ raise 'RubyGems 2.0 or newer is required to protect against ' \
29
+ 'public gem pushes.'
30
+ end
31
+
32
+ # Specify which files should be added to the gem when it is released.
33
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
34
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
35
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
36
+ end
37
+ spec.bindir = 'exe'
38
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
39
+ spec.require_paths = ['lib']
40
+
41
+ spec.add_development_dependency 'bundler', '~> 2.1.4'
42
+ spec.add_development_dependency 'rake', '~> 13.0.1'
43
+ spec.add_development_dependency 'rspec', '~> 3.9.0'
44
+ end
metadata ADDED
@@ -0,0 +1,135 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: libyui_client
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.0
5
+ platform: ruby
6
+ authors:
7
+ - Joaquin Rivera
8
+ - Ioannis Bonatakis
9
+ - Oleksandr Orlov
10
+ - Rodion Iafarov
11
+ - Sofia Syrianidou
12
+ autorequire:
13
+ bindir: exe
14
+ cert_chain: []
15
+ date: 2020-09-01 00:00:00.000000000 Z
16
+ dependencies:
17
+ - !ruby/object:Gem::Dependency
18
+ name: bundler
19
+ requirement: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - "~>"
22
+ - !ruby/object:Gem::Version
23
+ version: 2.1.4
24
+ type: :development
25
+ prerelease: false
26
+ version_requirements: !ruby/object:Gem::Requirement
27
+ requirements:
28
+ - - "~>"
29
+ - !ruby/object:Gem::Version
30
+ version: 2.1.4
31
+ - !ruby/object:Gem::Dependency
32
+ name: rake
33
+ requirement: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - "~>"
36
+ - !ruby/object:Gem::Version
37
+ version: 13.0.1
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - "~>"
43
+ - !ruby/object:Gem::Version
44
+ version: 13.0.1
45
+ - !ruby/object:Gem::Dependency
46
+ name: rspec
47
+ requirement: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - "~>"
50
+ - !ruby/object:Gem::Version
51
+ version: 3.9.0
52
+ type: :development
53
+ prerelease: false
54
+ version_requirements: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - "~>"
57
+ - !ruby/object:Gem::Version
58
+ version: 3.9.0
59
+ description: Client to operate controls for libyui applications.
60
+ email:
61
+ - qa-sle-yast@suse.de
62
+ executables: []
63
+ extensions: []
64
+ extra_rdoc_files: []
65
+ files:
66
+ - ".gitignore"
67
+ - ".rspec"
68
+ - ".rubocop.yml"
69
+ - ".travis.yml"
70
+ - Gemfile
71
+ - LICENSE.txt
72
+ - README.md
73
+ - Rakefile
74
+ - bin/console
75
+ - bin/setup
76
+ - lib/libyui_client.rb
77
+ - lib/libyui_client/actions.rb
78
+ - lib/libyui_client/app.rb
79
+ - lib/libyui_client/error.rb
80
+ - lib/libyui_client/filter_extractor.rb
81
+ - lib/libyui_client/http/http_client.rb
82
+ - lib/libyui_client/http/response.rb
83
+ - lib/libyui_client/http/version_controller.rb
84
+ - lib/libyui_client/http/widget_controller.rb
85
+ - lib/libyui_client/local_process.rb
86
+ - lib/libyui_client/logger.rb
87
+ - lib/libyui_client/timer.rb
88
+ - lib/libyui_client/version.rb
89
+ - lib/libyui_client/wait.rb
90
+ - lib/libyui_client/waitable.rb
91
+ - lib/libyui_client/widgets.rb
92
+ - lib/libyui_client/widgets/bargraph.rb
93
+ - lib/libyui_client/widgets/base.rb
94
+ - lib/libyui_client/widgets/button.rb
95
+ - lib/libyui_client/widgets/checkbox.rb
96
+ - lib/libyui_client/widgets/combobox.rb
97
+ - lib/libyui_client/widgets/datefield.rb
98
+ - lib/libyui_client/widgets/label.rb
99
+ - lib/libyui_client/widgets/menubutton.rb
100
+ - lib/libyui_client/widgets/multilinebox.rb
101
+ - lib/libyui_client/widgets/numberbox.rb
102
+ - lib/libyui_client/widgets/progressbar.rb
103
+ - lib/libyui_client/widgets/radiobutton.rb
104
+ - lib/libyui_client/widgets/richtext.rb
105
+ - lib/libyui_client/widgets/selectionbox.rb
106
+ - lib/libyui_client/widgets/tab.rb
107
+ - lib/libyui_client/widgets/table.rb
108
+ - lib/libyui_client/widgets/textbox.rb
109
+ - lib/libyui_client/widgets/timefield.rb
110
+ - lib/libyui_client/widgets/tree.rb
111
+ - libyui_client.gemspec
112
+ homepage: https://github.com/qa-sle-yast/libyui_client
113
+ licenses:
114
+ - MIT
115
+ metadata: {}
116
+ post_install_message:
117
+ rdoc_options: []
118
+ require_paths:
119
+ - lib
120
+ required_ruby_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: 2.5.0
125
+ required_rubygems_version: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - ">="
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ requirements: []
131
+ rubygems_version: 3.1.2
132
+ signing_key:
133
+ specification_version: 4
134
+ summary: Client for libyui applications.
135
+ test_files: []