glib-web 0.5.9 → 0.5.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8cb6ba9cc8312e05a50ed1179f7690b3dd985410
4
- data.tar.gz: b896cd852f0f42fa7e5a198ff6d3a49f5fca037e
3
+ metadata.gz: 9c409da37352d6e9066f4b7895d76c3cba5e81f2
4
+ data.tar.gz: 7116d6e9e13cc00d98811010acb550749acdcbba
5
5
  SHA512:
6
- metadata.gz: b151098400b68a0eea5271b0d513be08a527fb091668d25769375215d6975d2c71f10268d2303125c156fdba610cf8d6a965b6ec8eb9d3c18a61c32f5fc528f6
7
- data.tar.gz: 030e32c03a9d1b4ad9b4141406d367b60de018b6ce7738eab0080ef5327a9b2958b363d84a182663bcaae9df4fa4b8b66554af4cbcc61a738cebc1d7511be292
6
+ metadata.gz: 5ce3e630395c565eb252a653db28eb026388100082105109d4f2a380f19bab6d0465bd5d04ff65ff0da4c729c4273a08d800c2e8db614678767349ef279a8422
7
+ data.tar.gz: cb22a75b02ed382066e4d6060026600093cd543032c0d9c0679f64628750068a8ffa3dca4070995907040db5871b75ae171a4a5172ec445aa4e762357bd73235
@@ -31,8 +31,8 @@ module Glib::Json::Ui
31
31
  @__json_ui_activated
32
32
  end
33
33
 
34
- def json_ui_lifecycle_prop(name)
35
- if (hash = json_transformation_start).is_a?(Hash)
34
+ def json_ui_page_lifecycle_prop(name)
35
+ if (hash = json_transformation_start).is_a?(Hash) && hash['body'] # A valid page
36
36
  hash[name] ||= { 'action' => 'runMultiple', 'childActions' => [] }
37
37
  hash[name]['childActions']
38
38
  end
@@ -5,35 +5,33 @@ next_page = {
5
5
  autoload: 'asNeeded'
6
6
  }
7
7
 
8
+ page = json_ui_page json
8
9
  column_indexes = (1..3)
10
+
9
11
  if params[:section_only].present?
10
12
  json.nextPage next_page if page_index < 3
11
- json_ui_page json do |page|
12
- json.sections do
13
- json.child! do
14
- render 'json_ui/garage/tables/autoload_section', page: page, page_index: page_index, column_indexes: column_indexes
15
- end
13
+ json.sections do
14
+ json.child! do
15
+ render 'json_ui/garage/tables/autoload_section', page: page, page_index: page_index, column_indexes: column_indexes
16
16
  end
17
17
  end
18
18
  else
19
19
  json.title 'Tables'
20
20
 
21
- json_ui_page json do |page|
22
- render "#{@path_prefix}/nav_menu", json: json, page: page
21
+ render "#{@path_prefix}/nav_menu", json: json, page: page
23
22
 
24
- page.table nextPage: next_page, firstSection: ->(section) do
25
- section.header cellViews: ->(header) do
26
- column_indexes.each do |i|
27
- header.label text: "Heading#{i}"
28
- end
23
+ page.table nextPage: next_page, firstSection: ->(section) do
24
+ section.header cellViews: ->(header) do
25
+ column_indexes.each do |i|
26
+ header.label text: "Heading#{i}"
29
27
  end
30
-
31
- render "#{@path_prefix}/tables/autoload_section", page: page, page_index: page_index, column_indexes: column_indexes
32
- end, onScrollToBottom: ->(action) do
33
- action.snackbars_alert message: 'Scrolled to Bottom'
34
- end, onScrollToTop: ->(action) do
35
- action.snackbars_alert message: 'Scrolled to Top'
36
28
  end
29
+
30
+ render "#{@path_prefix}/tables/autoload_section", page: page, page_index: page_index, column_indexes: column_indexes
31
+ end, onScrollToBottom: ->(action) do
32
+ action.snackbars_alert message: 'Scrolled to Bottom'
33
+ end, onScrollToTop: ->(action) do
34
+ action.snackbars_alert message: 'Scrolled to Top'
37
35
  end
38
36
 
39
37
  end
@@ -8,3 +8,4 @@ require_relative './json_crawler/action_crawlers/windows_open'
8
8
  require_relative './json_crawler/action_crawlers/action_http'
9
9
  require_relative './json_crawler/action_crawlers/forms_submit'
10
10
  require_relative './json_crawler/action_crawlers/menu'
11
+ require_relative './json_crawler/action_crawlers/run_multiple'
@@ -14,7 +14,10 @@ module Glib
14
14
  click view
15
15
  end
16
16
  end
17
- end
18
17
 
18
+ def perform(action)
19
+ @http.router.process_action(@http, action)
20
+ end
21
+ end
19
22
  end
20
23
  end
@@ -4,11 +4,8 @@ module Glib
4
4
  def initialize(method, http, args, controller)
5
5
  @http = http
6
6
  json = @http.send(method, args['url'], controller, args.fetch('formData', {}))
7
-
8
- unless json.nil?
9
- click(json)
10
- end
7
+ perform(json['onResponse'])
11
8
  end
12
9
  end
13
10
  end
14
- end
11
+ end
@@ -41,7 +41,7 @@ module Glib
41
41
  end
42
42
 
43
43
  json = @http.patch url, action, params
44
- click(json)
44
+ perform(json['onResponse'])
45
45
  end
46
46
  end
47
47
  end
@@ -9,6 +9,8 @@ module Glib
9
9
  crawl left_drawer['header']&.[]('childViews')
10
10
  crawl left_drawer['rows']
11
11
  end
12
+
13
+ perform(json['onLoad'])
12
14
  end
13
15
  end
14
16
  end
@@ -0,0 +1,13 @@
1
+ module Glib
2
+ module JsonCrawler
3
+ class RunMultiple < ActionCrawler
4
+ def initialize(http, args, action)
5
+ @http = http
6
+
7
+ args['childActions']&.each do |button|
8
+ perform(button)
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -3,6 +3,7 @@ module Glib
3
3
  class WindowsOpen < ActionCrawler
4
4
  def initialize(http, args, action)
5
5
  @http = http
6
+
6
7
  if (url = args['url'])
7
8
  json = @http.get(url, action, args.except('url'))
8
9
 
@@ -20,6 +21,8 @@ module Glib
20
21
  click button
21
22
  end
22
23
  end
24
+
25
+ perform(json['onLoad'])
23
26
  end
24
27
  end
25
28
  end
@@ -19,6 +19,7 @@ module Glib
19
19
  end
20
20
 
21
21
  def step(http, args)
22
+ # TODO: Refactor
22
23
  case args['view']
23
24
  when 'fields/submit-v1', 'fields/submit'
24
25
  @depth += 1
@@ -29,40 +30,45 @@ module Glib
29
30
  end
30
31
 
31
32
  if args.is_a?(Hash) && args['rel'] != 'nofollow'
32
- if (onClick = (args.fetch('onClick', nil) || args.fetch('onResponse', nil)))
33
- action = onClick['action']
34
- params = onClick
33
+ if (onClick = (args.fetch('onClick', nil)))
34
+ process_action(http, onClick)
35
35
  end
36
+ end
37
+ end
36
38
 
37
- if action.present?
38
- @depth += 1
39
- case action
40
- when 'initiate_navigation'
41
- @read_only_actions.add([action, params['url']])
42
- JsonCrawler::NavInitiate.new(http, params, action)
43
- when 'windows/open-v1', 'dialogs/open-v1', 'windows/reload-v1', 'windows/open', 'dialogs/open', 'windows/reload'
39
+ def process_action(http, spec)
40
+ action = spec['action']
41
+ params = spec
42
+
43
+ if action.present?
44
+ @depth += 1
45
+ case action
46
+ when 'initiate_navigation'
47
+ @read_only_actions.add([action, params['url']])
48
+ JsonCrawler::NavInitiate.new(http, params, action)
49
+ when 'runMultiple-v1', 'runMultiple'
50
+ JsonCrawler::RunMultiple.new(http, params, action)
51
+ when 'windows/open-v1', 'dialogs/open-v1', 'windows/reload-v1', 'windows/open', 'dialogs/open', 'windows/reload'
52
+ @read_only_actions.add([action, params['url']])
53
+ JsonCrawler::WindowsOpen.new(http, params, action)
54
+ when 'sheets/select-v1', 'sheets/select'
55
+ JsonCrawler::Menu.new(http, params, action)
56
+ when 'http/post-v1', 'http/post'
57
+ JsonCrawler::ActionHttp.new(:post, http, params, action)
58
+ when 'forms/submit-v1', 'forms/submit'
59
+ forms = @visitor.forms
60
+ # raise 'Submit action needs to be inside a form' if forms.size < 1
61
+ JsonCrawler::FormsSubmit.new(http, forms.last)
62
+ else
63
+ unless [
64
+ 'http/delete-v1', 'dialogs/oauth-v1', 'windows/openWeb-v1',
65
+ 'http/delete', 'dialogs/oauth', 'windows/openWeb'
66
+ ].include?(action)
44
67
  @read_only_actions.add([action, params['url']])
45
- JsonCrawler::WindowsOpen.new(http, params, action)
46
- when 'sheets/select-v1', 'sheets/select'
47
- JsonCrawler::Menu.new(http, params, action)
48
- when 'http/post-v1', 'http/post'
49
- JsonCrawler::ActionHttp.new(:post, http, params, action)
50
- when 'forms/submit-v1', 'forms/submit'
51
- forms = @visitor.forms
52
- # raise 'Submit action needs to be inside a form' if forms.size < 1
53
- JsonCrawler::FormsSubmit.new(http, forms.last)
54
- else
55
- unless [
56
- 'http/delete-v1', 'dialogs/oauth-v1', 'windows/openWeb-v1',
57
- 'http/delete', 'dialogs/oauth', 'windows/openWeb'
58
- ].include?(action)
59
- @read_only_actions.add([action, params['url']])
60
- end
61
- self.log action, params['url']
62
68
  end
63
- @depth -= 1
64
- # child
69
+ self.log action, params['url']
65
70
  end
71
+ @depth -= 1
66
72
  end
67
73
  end
68
74
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glib-web
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.9
4
+ version: 0.5.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''
@@ -214,6 +214,7 @@ files:
214
214
  - lib/glib/json_crawler/action_crawlers/forms_submit.rb
215
215
  - lib/glib/json_crawler/action_crawlers/menu.rb
216
216
  - lib/glib/json_crawler/action_crawlers/nav_initiate.rb
217
+ - lib/glib/json_crawler/action_crawlers/run_multiple.rb
217
218
  - lib/glib/json_crawler/action_crawlers/windows_open.rb
218
219
  - lib/glib/json_crawler/coverage.rb
219
220
  - lib/glib/json_crawler/http.rb