benchmark_to_js 0.2.0 → 0.3.0

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
- SHA1:
3
- metadata.gz: 8b341053fc099c0d918520b916f88513ca8e0e62
4
- data.tar.gz: 8e282f9a88caa39d22fb0ea772e15a0e1f4cb227
2
+ SHA256:
3
+ metadata.gz: 60f42bd58f4d1e532c6c0e7b87ffc3a931e91aa739865eea38388c4b6dad2867
4
+ data.tar.gz: 31c28663e2ac46e4840750597d489e5859964eb7a50e60f0d9a397bdb010d746
5
5
  SHA512:
6
- metadata.gz: 09792bcdad9795450fca1f7491bc79288ef6f138186daba87576c6df14146b8b567ea706bfbc87b76d5f780ce309ba9c714ab162859ea95ecedf64ef521443fa
7
- data.tar.gz: 6a54c86e03e5249fb40db4969577f6ff2bcf2e76314559f053046fa45a4097118ed68c75df51fa4504bf18c01eeb6e6f67e7d2ecf71b6a926a2ea57066ddb6c2
6
+ metadata.gz: fe94c190cf04917471708dfa91024ee96725888b308c384cca0ce44896fa4fc9f121ec832de95a5b69166de0edc36127ad4c21fb10575bc4d6209709f42258bc
7
+ data.tar.gz: 8184ba6081a513f80dfa52d39fe10267a540e6339c15bd1c8b7202d17d96dfd4bcf34175e126163ec90261ee03acb1f14bc9c277fd5cb7c4b2b2fa7803a5f07c
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
+ *.gem
1
2
  /.bundle/
2
3
  /.yardoc
3
4
  /Gemfile.lock
data/README.md CHANGED
@@ -34,6 +34,11 @@ BenchmarkToJs.configure do |config|
34
34
  # minimum milliseconds before time is highlighted in respective colour
35
35
  config.red_threshold = 1000 # default 500
36
36
  config.orange_threshold = 200 # default 100
37
+
38
+ # options that will be passed to `javascript_tag`
39
+ # takes anything that responds to `call`
40
+ # first argument will be the context in which you called `benchmark_to_js` (most likely your view), so any instance methods available there are available here
41
+ config.tag_options = lambda {|ctx| {nonce: ctx.content_security_policy_script_nonce} }
37
42
  end
38
43
  ```
39
44
 
@@ -1,12 +1,13 @@
1
1
  module BenchmarkToJs
2
2
  class Configuration
3
- attr_accessor :run_in_environments, :pretty, :orange_threshold, :red_threshold
3
+ attr_accessor :run_in_environments, :pretty, :orange_threshold, :red_threshold, :tag_options
4
4
 
5
5
  def initialize
6
6
  self.run_in_environments = [:development]
7
7
  self.pretty = true
8
8
  self.orange_threshold = 100
9
9
  self.red_threshold = 500
10
+ self.tag_options = nil
10
11
  end
11
12
 
12
13
  def run?
@@ -1,3 +1,3 @@
1
1
  module BenchmarkToJs
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -19,7 +19,8 @@ module BenchmarkToJs
19
19
  %Q("'#{escape_javascript(name)}' ran in #{time.round(5)}ms")
20
20
  end
21
21
 
22
- ret + javascript_tag(%Q(console.log(#{message})))
22
+ options = BenchmarkToJs.configuration.tag_options.respond_to?(:call) ? BenchmarkToJs.configuration.tag_options.call(self) : nil
23
+ ret + javascript_tag(%Q(console.log(#{message})), options)
23
24
  else
24
25
  capture(&block)
25
26
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: benchmark_to_js
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dave Allie
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-03-30 00:00:00.000000000 Z
11
+ date: 2018-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -81,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
81
81
  version: '0'
82
82
  requirements: []
83
83
  rubyforge_project:
84
- rubygems_version: 2.4.5.1
84
+ rubygems_version: 2.7.7
85
85
  signing_key:
86
86
  specification_version: 4
87
87
  summary: Benchmarks content in views and logs times to JS console.