stackprof-webnav 1.0.2 → 1.0.3

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
  SHA256:
3
- metadata.gz: 1552e5fc93e065620a447d3a7c32e23da16590ee857cfd2e13a5856fcc0972ad
4
- data.tar.gz: 7514d5a49e0544494ee8fcf924ba6d3f9f2bccfb7cee2021c1b588b8cc6b4af5
3
+ metadata.gz: 1b4dd46c0ac72aaee58af286f92444820d29a4e06152981a41c6667c4183aa19
4
+ data.tar.gz: 74b43d464b781f3f42ef815e21beaab77c7eb9e46b47f2b3233a69519b9aee1e
5
5
  SHA512:
6
- metadata.gz: 9573405eb7fd02e23b6bf72d9f1065b6a6b6c584cf83c17e07388fa4722c79bfc9fa1e4c5bc8e48d0850ae8d33fd69456f67b6a82c9a5178f9dbb3b4a52b5a6e
7
- data.tar.gz: 74c6a96b5e19164f8b2ee61803f59f1af867a4b5ccf3155156000e939e9607517468cecedd62671468bd9a81ab2ef9fe2159f11d5b532a2c1b245bbc98f8b889
6
+ metadata.gz: b4dbb9e1bd18dbedfcee77cced956d2a205094ffb6721c100a8f5bf592fc1a008d91647bcd113eb1ed7d8d89c38e908407c32932b58f764f93ce5503de0104f1
7
+ data.tar.gz: 21e1289ab6b4170da780cdaefb1d4c8cdf0a63b79f887ed9e5f2330f6f1f733e8fb9bc39ed0820c60ce2518fe6c371ba70a2004f60de8ad0ee8a81b88627f1c8
@@ -19,7 +19,9 @@ jobs:
19
19
  runs-on: ubuntu-latest
20
20
  strategy:
21
21
  matrix:
22
- ruby-version: ['2.7']
22
+ ruby-version:
23
+ - '2.7'
24
+ - '3.0'
23
25
 
24
26
  steps:
25
27
  - uses: actions/checkout@v2
data/Gemfile.lock CHANGED
@@ -1,18 +1,18 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- stackprof-webnav (1.0.2)
4
+ stackprof-webnav (1.0.3)
5
5
  better_errors (~> 1.1.0)
6
6
  haml (~> 5.1.2)
7
7
  ruby-graphviz (~> 1.2.4)
8
- sinatra (~> 2.0.7)
9
- sinatra-contrib (~> 2.0.5)
8
+ sinatra (~> 2.1.0)
9
+ sinatra-contrib (~> 2.1.0)
10
10
  stackprof (>= 0.2.13)
11
+ webrick (~> 1.7.0)
11
12
 
12
13
  GEM
13
14
  remote: https://rubygems.org/
14
15
  specs:
15
- backports (3.21.0)
16
16
  better_errors (1.1.0)
17
17
  coderay (>= 1.0.0)
18
18
  erubis (>= 2.6.6)
@@ -29,8 +29,8 @@ GEM
29
29
  pry (0.12.2)
30
30
  coderay (~> 1.1.0)
31
31
  method_source (~> 0.9.0)
32
- rack (2.0.8)
33
- rack-protection (2.0.8.1)
32
+ rack (2.2.3)
33
+ rack-protection (2.1.0)
34
34
  rack
35
35
  rack-test (1.1.0)
36
36
  rack (>= 1.0, < 3)
@@ -51,22 +51,22 @@ GEM
51
51
  rspec-support (3.9.0)
52
52
  ruby-graphviz (1.2.5)
53
53
  rexml
54
- ruby2_keywords (0.0.4)
55
- sinatra (2.0.8.1)
54
+ ruby2_keywords (0.0.5)
55
+ sinatra (2.1.0)
56
56
  mustermann (~> 1.0)
57
- rack (~> 2.0)
58
- rack-protection (= 2.0.8.1)
57
+ rack (~> 2.2)
58
+ rack-protection (= 2.1.0)
59
59
  tilt (~> 2.0)
60
- sinatra-contrib (2.0.8.1)
61
- backports (>= 2.8.2)
60
+ sinatra-contrib (2.1.0)
62
61
  multi_json
63
62
  mustermann (~> 1.0)
64
- rack-protection (= 2.0.8.1)
65
- sinatra (= 2.0.8.1)
63
+ rack-protection (= 2.1.0)
64
+ sinatra (= 2.1.0)
66
65
  tilt (~> 2.0)
67
66
  stackprof (0.2.17)
68
67
  temple (0.8.2)
69
68
  tilt (2.0.10)
69
+ webrick (1.7.0)
70
70
 
71
71
  PLATFORMS
72
72
  ruby
@@ -6,6 +6,12 @@ pre code {
6
6
  color: black;
7
7
  }
8
8
 
9
+ input.filter {
10
+ max-width: 68%;
11
+ margin: 0 0 0 1rem;
12
+ display: inline;
13
+ }
14
+
9
15
  #graph > a {
10
16
  position: absolute;
11
17
  }
@@ -0,0 +1,78 @@
1
+ /*
2
+ * string_score.js: Quicksilver-like string scoring algorithm.
3
+ *
4
+ * Copyright (C) 2009-2011 Joshaven Potter <yourtech@gmail.com>
5
+ * Copyright (C) 2010-2011 Yesudeep Mangalapilly <yesudeep@gmail.com>
6
+ * MIT license: http://www.opensource.org/licenses/mit-license.php
7
+ *
8
+ * This is a javascript port of the above mentionned, with a tiny change:
9
+ * it avoids string monkey patch.
10
+ */
11
+ ;(function(global) {
12
+ global.stringScore = (string, abbreviation) => {
13
+ // Perfect match if the spring equals the abbreviation
14
+ if (string == abbreviation) return 1.0
15
+
16
+ // Initializing variables.
17
+ let string_length = string.length
18
+ let abbreviation_length = abbreviation.length
19
+ let total_character_score = 0
20
+
21
+ // Awarded only if the string and the abbreviation have a common prefix.
22
+ let should_award_common_prefix_bonus = 0
23
+
24
+ // # Sum character scores
25
+
26
+ // Add up scores for each character in the abbreviation.
27
+ for (let i = 0, c = abbreviation[i]; i < abbreviation_length; c = abbreviation[++i]) {
28
+ // Find the index of current character (case-insensitive) in remaining part of string.
29
+ let index_c_lowercase = string.indexOf(c.toLowerCase())
30
+ let index_c_uppercase = string.indexOf(c.toUpperCase())
31
+ let min_index = Math.min(index_c_lowercase, index_c_uppercase)
32
+ let index_in_string = min_index > -1 ? min_index : Math.max(index_c_lowercase, index_c_uppercase)
33
+
34
+ // # Identical Strings
35
+ // Bail out if current character is not found (case-insensitive) in remaining part of string.
36
+ if (index_in_string == -1) return 0
37
+
38
+ // Set base score for current character.
39
+ let character_score = 0.1
40
+
41
+
42
+ // # Case-match bonus
43
+ // If the current abbreviation character has the same case
44
+ // as that of the character in the string, we add a bonus.
45
+ if (string[index_in_string] == c) character_score += 0.1
46
+
47
+ // # Consecutive character match and common prefix bonuses
48
+ // Increase the score when each consecutive character of
49
+ // the abbreviation matches the first character of the
50
+ // remaining string.
51
+ if (index_in_string == 0) {
52
+ character_score += 0.8
53
+ // String and abbreviation have common prefix, so award bonus.
54
+ if (i == 0) should_award_common_prefix_bonus = 1
55
+ }
56
+
57
+ // # Acronym bonus
58
+ // Typing the first character of an acronym is as
59
+ // though you preceded it with two perfect character
60
+ // matches.
61
+ if (string.charAt(index_in_string - 1) == ' ') // TODO: better accro
62
+ character_score += 0.8 // * Math.min(index_in_string, 5) # Cap bonus at 0.4 * 5
63
+
64
+ // Left trim the matched part of the string
65
+ // (forces sequential matching).
66
+ string = string.substring(index_in_string + 1, string_length)
67
+
68
+ // Add to total character score.
69
+ total_character_score += character_score
70
+ }
71
+
72
+ let abbreviation_score = total_character_score / abbreviation_length
73
+
74
+ let final_score = ((abbreviation_score * (abbreviation_length / string_length)) + abbreviation_score) / 2
75
+ if (should_award_common_prefix_bonus && final_score + 0.1 < 1) final_score += 0.1
76
+ return final_score
77
+ }
78
+ })(window)
@@ -0,0 +1,29 @@
1
+ ;(function() {
2
+ const table = document.getElementsByTagName('table')[0]
3
+ const input = document.getElementsByClassName('filter')[0]
4
+ const rows = {}
5
+ const filterKeys = Array.from(document.querySelectorAll('tr[data-filter-key]')).map(el => {
6
+ key = el.dataset.filterKey
7
+ rows[key] = el
8
+ return key
9
+ })
10
+ const scores = {}
11
+ const computeScores = () => {
12
+ const searchString = input.value
13
+ filterKeys.forEach(filterKey => scores[filterKey] = stringScore(filterKey, searchString))
14
+ }
15
+
16
+ const redrawTable = (sorted) => {
17
+ const newBody = document.createElement('tbody')
18
+ sorted.forEach(key => newBody.appendChild(rows[key]))
19
+ table.removeChild(table.getElementsByTagName('tbody')[0])
20
+ table.appendChild(newBody)
21
+ }
22
+
23
+ input.addEventListener('input', () => {
24
+ computeScores()
25
+ redrawTable(
26
+ filterKeys.filter(k => scores[k] !== 0).sort((a, b) => scores[b] - scores[a])
27
+ )
28
+ })
29
+ })()
@@ -3,7 +3,6 @@ require 'haml'
3
3
  require 'stackprof'
4
4
  require_relative 'presenter'
5
5
  require_relative 'dump'
6
- require 'pry'
7
6
  require 'sinatra/reloader' if development?
8
7
  require 'ruby-graphviz'
9
8
 
@@ -1,5 +1,5 @@
1
1
  module StackProf
2
2
  module Webnav
3
- VERSION = '1.0.2'
3
+ VERSION = '1.0.3'
4
4
  end
5
5
  end
@@ -25,11 +25,14 @@
25
25
  %th %
26
26
  %th Samples
27
27
  %th %
28
- %th Method
28
+ %th
29
+ Method
30
+ %input.filter{:placeholder => "filter methods", :type => "text"}/
29
31
 
30
32
  %tbody
31
33
  - @frames.each do |frame|
32
- %tr
34
+ - # Filter keys are preprocessed to better match acronyms.
35
+ %tr{"data-filter-key" => frame[:method].gsub(/[A-Z]/, " \\0").gsub(/[\W_]+/, " ").strip}
33
36
  %td= frame[:total]
34
37
  %td= frame[:total_pct]
35
38
  %td= frame[:samples]
@@ -37,3 +40,6 @@
37
40
  %td
38
41
  %a{:href => url_for("/method", name: frame[:method])}
39
42
  &= frame[:method]
43
+
44
+ %script{src: "lib/string_score.js"}
45
+ %script{src: "overview.js"}
@@ -21,12 +21,13 @@ Gem::Specification.new do |spec|
21
21
  spec.bindir = 'bin'
22
22
  spec.executables << 'stackprof-webnav'
23
23
 
24
- spec.add_dependency "sinatra", "~> 2.0.7"
24
+ spec.add_dependency "sinatra", "~> 2.1.0"
25
25
  spec.add_dependency "haml", "~> 5.1.2"
26
26
  spec.add_dependency "stackprof", ">= 0.2.13"
27
27
  spec.add_dependency "better_errors", "~> 1.1.0"
28
28
  spec.add_dependency "ruby-graphviz", "~> 1.2.4"
29
- spec.add_dependency "sinatra-contrib", "~> 2.0.5"
29
+ spec.add_dependency "sinatra-contrib", "~> 2.1.0"
30
+ spec.add_dependency "webrick", "~> 1.7.0"
30
31
  spec.add_development_dependency "bundler", "~> 2.2"
31
32
  spec.add_development_dependency "rake", "~> 10.1"
32
33
  spec.add_development_dependency "rspec", "~> 3.9.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stackprof-webnav
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrei Lisnic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-27 00:00:00.000000000 Z
11
+ date: 2021-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 2.0.7
19
+ version: 2.1.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 2.0.7
26
+ version: 2.1.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: haml
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -86,14 +86,28 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 2.0.5
89
+ version: 2.1.0
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 2.0.5
96
+ version: 2.1.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: webrick
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 1.7.0
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 1.7.0
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: bundler
99
113
  requirement: !ruby/object:Gem::Requirement
@@ -160,7 +174,6 @@ extra_rdoc_files: []
160
174
  files:
161
175
  - ".github/workflows/ruby.yml"
162
176
  - ".gitignore"
163
- - ".travis.yml"
164
177
  - Gemfile
165
178
  - Gemfile.lock
166
179
  - LICENSE.txt
@@ -176,6 +189,8 @@ files:
176
189
  - lib/stackprof-webnav/public/css/foundation.min.css
177
190
  - lib/stackprof-webnav/public/css/normalize.css
178
191
  - lib/stackprof-webnav/public/flamegraph.js
192
+ - lib/stackprof-webnav/public/lib/string_score.js
193
+ - lib/stackprof-webnav/public/overview.js
179
194
  - lib/stackprof-webnav/server.rb
180
195
  - lib/stackprof-webnav/version.rb
181
196
  - lib/stackprof-webnav/views/error.haml
data/.travis.yml DELETED
@@ -1,4 +0,0 @@
1
- language: ruby
2
- script: bundle exec rspec
3
- before_install:
4
- - "sudo apt-get install graphviz"