glib-web 0.4.59 → 0.4.60

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: 43d8906b4ef965875d75a600b81d440ad34b32bb
4
- data.tar.gz: 40d4203cecc000335fb49303f7f41c569213d56d
3
+ metadata.gz: 7e115e3000243622421f51568643954470a02eb1
4
+ data.tar.gz: cf697c88ba64ac3ce3731fbdb49a69f993d87f9e
5
5
  SHA512:
6
- metadata.gz: 7f8d68129838007a4844863e5120e78f8006d33c9b7bd275c2afe61e186942503d56d9aff8d377405d2e08d3a4f3602dd1cce0dea2ffaa08b46dc1e81bc37ae2
7
- data.tar.gz: a9c1d10c6e926951e31a2a62c0f212d179effaabeb26f7f965f2967659b783b50cc0a5ad91738ab35a8e0e6d5c07b31420b3f462813dd1530eb5445cef379d44
6
+ metadata.gz: 738eaed2dd23bb59903ed80a1e1c05cc06d95928a9e68ae8a24ee6137739d5d181fb40076aa1d60a3a766546d987da50271076f499d28a67ab7d2437b1f620d0
7
+ data.tar.gz: 98be8ec4b19300946473005aa238bec89e1c02b0146ea0ecafb29b2dd32faf5719112562db95055813f8804da2cf893622182a10d9057ec67bde33ee8db8c54a
@@ -189,23 +189,13 @@ module Glib
189
189
  end
190
190
 
191
191
  json.set!(propName) do
192
- if name
193
- data[:material] ||= {}
194
- data[:material][:name] = name
195
- end
192
+ data[:material] ||= {}
193
+ data[:material][:name] = name if name
196
194
 
197
- if (material = data[:material])
198
- json.material do
199
- json.name material[:name]
200
- json.size material[:size] if material[:size]
201
- end
202
- end
203
-
204
- if (fa = data[:fa])
205
- json.fa do
206
- json.name fa[:name]
207
- json.size fa[:size] if fa[:size]
208
- end
195
+ material = data[:material]
196
+ json.material do
197
+ json.name material[:name]
198
+ json.size material[:size] if material[:size]
209
199
  end
210
200
 
211
201
  if (custom = data[:custom])
@@ -80,7 +80,6 @@ module Glib
80
80
  end
81
81
 
82
82
  class Markdown < AbstractText
83
- bool :previewVideo
84
83
  end
85
84
 
86
85
  class Label < AbstractText
@@ -5,7 +5,7 @@ json_ui_page json do |page|
5
5
 
6
6
  page.scroll padding: glib_json_padding_body, childViews: ->(scroll) do
7
7
  scroll.spacer height: 20
8
- scroll.h2 text: 'Markdown'
8
+ scroll.h2 text: 'Paragraph'
9
9
  scroll.spacer height: 6
10
10
  scroll.markdown text:
11
11
  '# h1 Heading' + "\n" +
@@ -25,17 +25,6 @@ json_ui_page json do |page|
25
25
  "\n" +
26
26
  '_This is italic text_' + "\n" +
27
27
  "\n" +
28
- '~~Strikethrough~~' + "\n" +
29
- "\n" +
30
- 'https://www.google.com' + "\n"
31
-
32
- scroll.spacer height: 20
33
- scroll.h2 text: 'Markdown with preview'
34
- scroll.spacer height: 6
35
- scroll.markdown text: 'Here is the video: https://www.youtube.com/watch?v=947op8yKJRY', previewVideo: true
36
-
37
- scroll.spacer height: 10
38
- scroll.markdown text: 'Some videos: https://youtu.be/ATnpEOo3GJA, https://www.youtube.com/watch?v=947op8yKJRY', previewVideo: true
39
-
28
+ '~~Strikethrough~~' + "\n"
40
29
  end
41
30
  end
@@ -1,12 +1,16 @@
1
1
  module Glib
2
2
  module JsonCrawler
3
3
  class ActionCrawler
4
+ def initialize(http)
5
+ @http = http
6
+ end
7
+
4
8
  def click object
5
- JsonCrawler::Router.step(@http, object)
9
+ @http.router.step(@http, object)
6
10
  end
7
11
 
8
12
  def crawl views
9
- JsonCrawler::Router::crawl_multiple views, ->(view) do
13
+ @http.router.crawl_multiple views, ->(view) do
10
14
  click view
11
15
  end
12
16
  end
@@ -1,28 +1,30 @@
1
1
  module Glib
2
2
  module JsonCrawler
3
3
  class FormsSubmit < ActionCrawler
4
- def initialize http, params, action, form
4
+ def initialize(http, params, action, form)
5
+ super(http)
6
+
5
7
  @http = http
6
8
 
7
9
  case form['method']
8
10
  when 'patch', 'put'
9
11
  submit_update(form, action)
10
12
  else
11
- JsonCrawler::Router.log action, params['url']
13
+ http.router.log action, params['url']
12
14
  end
13
15
  end
14
-
16
+
15
17
  def submit_update(view, action)
16
18
  url = view['url']
17
19
  fields = []
18
20
  params = {}
19
- JsonCrawler::Router.crawl_multiple view['childViews'], ->(child) do
21
+ @http.router.crawl_multiple view['childViews'], ->(child) do
20
22
  if child['view'].start_with?('fields/')
21
23
  fields << child
22
24
  params[child['name']] = child['value']
23
25
  end
24
26
  end
25
-
27
+
26
28
  json = @http.patch url, action, params
27
29
  click(json)
28
30
  end
@@ -1,7 +1,9 @@
1
1
  module Glib
2
2
  module JsonCrawler
3
3
  class NavInitiate < ActionCrawler
4
- def initialize http, args, controller
4
+ def initialize(http, args, controller)
5
+ super(http)
6
+
5
7
  @http = http
6
8
  if (json = @http.get args['url'], controller) && (left_drawer = json['leftDrawer'])
7
9
  crawl left_drawer['header']&.[]('childViews')
@@ -2,7 +2,7 @@
2
2
  module Glib
3
3
  module JsonCrawler
4
4
  class Http
5
- attr_accessor :history, :response_times, :user
5
+ attr_accessor :history, :response_times, :user, :router
6
6
 
7
7
  URI_REGEXP = /\A#{URI::regexp}\z/
8
8
 
@@ -13,11 +13,12 @@ module Glib
13
13
  403, ## FORBIDDEN Should be used for logged-in but not allowed to access
14
14
  ].flatten
15
15
 
16
- def initialize(context, user)
16
+ def initialize(context, user, router)
17
17
  @context = context
18
18
  @history = []
19
19
  @response_times = []
20
20
  @user = user
21
+ @router = router
21
22
  end
22
23
 
23
24
  def get(url, controller)
@@ -40,6 +41,10 @@ module Glib
40
41
  fetch(:delete, url, controller, {})
41
42
  end
42
43
 
44
+ # def log(controller, url, response)
45
+ # @router.log(controller, url, response)
46
+ # end
47
+
43
48
  def controller
44
49
  @context.integration_session.controller
45
50
  end
@@ -77,7 +82,7 @@ module Glib
77
82
  raise
78
83
  end
79
84
  response = @context.response
80
- JsonCrawler::Router.log(controller, url, response)
85
+ @router.log(controller, url, response)
81
86
 
82
87
  if (code = response.code.to_i) == 302
83
88
  redirect_uri = URI(response.headers['Location'])
@@ -1,63 +1,84 @@
1
- module Glib
2
- module JsonCrawler
3
- class Router
4
- def self.log(action, url, response = nil)
5
- @@logger.puts ' ' * @@depth + [
6
- action,
7
- response.present? ? response.code : nil,
8
- url
9
- ].compact.join(' :: ')
10
- end
11
-
12
- def self.set_up(logger)
13
- @@depth = -1
14
- @@logger = logger
15
- @@visitor = Glib::Json::Traversal::Visitor.new
16
- end
17
-
18
- def self.step(http, args)
19
- if controller = http.controller
20
- Glib::JsonCrawler::Coverage.coverage_files.add(http.controller.class.instance_method(http.action_name).source_location.first)
21
- end
22
-
23
- if args.is_a?(Hash) && args['rel'] != 'nofollow'
24
- if (onClick = (args.fetch('onClick', nil) || args.fetch('onResponse', nil)))
25
- action = onClick['action']
26
- params = onClick
27
- end
28
-
29
- if action.present?
30
- @@depth += 1
31
- child = case action
32
- when 'initiate_navigation'
33
- JsonCrawler::NavInitiate.new(http, params, action)
34
- when 'windows/open-v1', 'dialogs/open-v1', 'windows/reload-v1'
35
- JsonCrawler::WindowsOpen.new(http, params, action)
36
- # when 'http/delete-v1'
37
- # JsonCrawler::ActionHttp.new(:delete, http, params, action)
38
- when 'http/post-v1'
39
- JsonCrawler::ActionHttp.new(:post, http, params, action)
40
- when 'forms/submit-v1'
41
- forms = @@visitor.forms
42
- raise 'Submit action needs to be inside a form' if forms.size < 1
43
- JsonCrawler::FormsSubmit.new(http, params, action, forms.last)
44
- else
45
- self.log action, params['url']
46
- end
47
- @@depth -= 1
48
- child
49
- end
50
- end
51
- end
52
-
53
- def self.tear_down
54
- @@logger.close
55
- end
56
-
57
- def self.crawl_multiple(views, block)
58
- @@visitor.traverse_multiple views, block
59
- end
60
-
61
- end
62
- end
63
- end
1
+
2
+ module Glib
3
+ module JsonCrawler
4
+ class Router
5
+ # @@crawler_actions = Set.new
6
+ # @@store_action = false
7
+
8
+ # def self.crawler_actions
9
+ # @@crawler_actions
10
+ # end
11
+
12
+ def log(action, url, response = nil)
13
+ @logger.puts ' ' * @depth + [
14
+ action,
15
+ response.present? ? response.code : nil,
16
+ url
17
+ ].compact.join(' :: ')
18
+ end
19
+
20
+ def initialize(logger, store_action)
21
+ # @@depth = -1
22
+ # @@logger = logger
23
+ # @@visitor = Glib::Json::Traversal::Visitor.new
24
+ # @@store_action = store_action
25
+
26
+ @depth = -1
27
+ @logger = logger
28
+ @visitor = Glib::Json::Traversal::Visitor.new
29
+ @store_action = store_action
30
+ end
31
+
32
+ def step(http, args)
33
+ if (controller = http.controller)
34
+ Glib::JsonCrawler::Coverage.coverage_files.add(http.controller.class.instance_method(http.action_name).source_location.first)
35
+ end
36
+
37
+ if args.is_a?(Hash) && args['rel'] != 'nofollow'
38
+ if (onClick = (args.fetch('onClick', nil) || args.fetch('onResponse', nil)))
39
+ action = onClick['action']
40
+ params = onClick
41
+ end
42
+
43
+ if action.present?
44
+ @depth += 1
45
+ child = case action
46
+ when 'initiate_navigation'
47
+ # @@crawler_actions.add([action, params['url']]) if @@store_action
48
+ JsonCrawler::NavInitiate.new(http, params, action)
49
+ when 'windows/open-v1', 'dialogs/open-v1', 'windows/reload-v1'
50
+ unless action == 'dialogs/open-v1'
51
+ # @@crawler_actions.add([action, params['url']]) if @@store_action
52
+ end
53
+ JsonCrawler::WindowsOpen.new(http, params, action)
54
+ # when 'http/delete-v1'
55
+ # JsonCrawler::ActionHttp.new(:delete, http, params, action)
56
+ when 'http/post-v1'
57
+ JsonCrawler::ActionHttp.new(:post, http, params, action)
58
+ when 'forms/submit-v1'
59
+ forms = @visitor.forms
60
+ raise 'Submit action needs to be inside a form' if forms.size < 1
61
+ JsonCrawler::FormsSubmit.new(http, params, action, forms.last)
62
+ else
63
+ unless ['http/delete-v1', 'dialogs/oauth-v1', 'windows/openWeb-v1'].include?(action)
64
+ # @@crawler_actions.add([action, params['url']]) if @@store_action
65
+ end
66
+ self.log action, params['url']
67
+ end
68
+ @depth -= 1
69
+ child
70
+ end
71
+ end
72
+ end
73
+
74
+ def tear_down
75
+ @logger.close
76
+ end
77
+
78
+ def crawl_multiple(views, block)
79
+ @visitor.traverse_multiple views, block
80
+ end
81
+
82
+ end
83
+ end
84
+ end
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.4.59
4
+ version: 0.4.60
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''