harness-actionview 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: cfc777bff2a74a278ec2b665414544cbf3004ffc
4
+ data.tar.gz: 3e3e6476edfa7a69cc39774fd0cb0a9510e5056d
5
+ SHA512:
6
+ metadata.gz: 89b2264c56391e1411f8975520a456a3fa86b28665bfa9a95b455a3b189d38b73bf173ad498525486304f9346dfe8a18b2f37004c1420a80e655e6bc4cbd9faf
7
+ data.tar.gz: 46c49d38aa56d90c1283600105f474aa990bd1ffaf90b5fa9198ae1807b78de3d6f45a2bb4e5b34e128214d8f03e59011e4aac6f1a344b31c2bab5781016778a
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in harness-varnish.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 ahawkins
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,33 @@
1
+ # Harness::Actionview
2
+
3
+ Forwards template rendering times to harness.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'harness-actionview'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install harness-actionview
18
+
19
+ ## Usage
20
+
21
+ All you need to do is require the file:
22
+
23
+ ```ruby
24
+ require 'harness-actionview'
25
+ ```
26
+
27
+ ## Contributing
28
+
29
+ 1. Fork it
30
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
31
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
32
+ 4. Push to the branch (`git push origin my-new-feature`)
33
+ 5. Create new Pull Request
@@ -0,0 +1,9 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rake/testtask'
4
+ Rake::TestTask.new(:test) do |test|
5
+ test.libs << 'test'
6
+ test.pattern = 'test/**/*_test.rb'
7
+ end
8
+
9
+ task :default => :test
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'harness/action_view/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "harness-actionview"
8
+ spec.version = Harness::ActionView::VERSION
9
+ spec.authors = ["ahawkins"]
10
+ spec.email = ["adam@hawkins.io"]
11
+ spec.description = %q{Log ActionView's internal performance metrics with Harness}
12
+ spec.summary = %q{}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "harness"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.3"
24
+ spec.add_development_dependency "rake"
25
+ end
@@ -0,0 +1 @@
1
+ require 'harness/action_view'
@@ -0,0 +1,18 @@
1
+ require 'harness'
2
+
3
+ events = %w(render_template render_partial)
4
+
5
+ events.each do |name|
6
+ ActiveSupport::Notifications.subscribe "#{name}.action_view" do |*args|
7
+ event = ActiveSupport::Notifications::Event.new(*args)
8
+ identifier = event.payload.fetch :identifier
9
+
10
+ path = identifier.gsub /^.+app\/views\//, ''
11
+ paths = path.gsub('/', '.').split('.')
12
+ paths.pop
13
+
14
+ template = paths.join '.'
15
+
16
+ Harness.timing "action_view.#{name}.#{template}", event.duration
17
+ end
18
+ end
@@ -0,0 +1,5 @@
1
+ module Harness
2
+ module ActionView
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,32 @@
1
+ require_relative 'test_helper'
2
+
3
+ class ActionViewIntegration < MiniTest::Unit::TestCase
4
+ def test_logs_render_template
5
+ instrument "render_template", identifier: '/foo/bar/app/views/foo/bar/baz.html.erb'
6
+
7
+ assert_timer "action_view.render_template.foo.bar.baz.html"
8
+ end
9
+
10
+ def test_logs_render_partial
11
+ instrument "render_partial", identifier: '/foo/bar/app/views/foo/bar/baz.html.erb'
12
+
13
+ assert_timer "action_view.render_partial.foo.bar.baz.html"
14
+ end
15
+
16
+ def test_skips_internal_partial_events
17
+ instrument "!render_partial"
18
+
19
+ assert_empty timers
20
+ end
21
+
22
+ def test_skips_internal_template_events
23
+ instrument "!render_template"
24
+
25
+ assert_empty timers
26
+ end
27
+
28
+ private
29
+ def instrument(event, data = { }, &block)
30
+ super "#{event}.action_view", data, &block
31
+ end
32
+ end
@@ -0,0 +1,63 @@
1
+ require 'bundler/setup'
2
+ require 'harness/action_view'
3
+ require 'minitest/unit'
4
+ require 'minitest/autorun'
5
+
6
+ class MiniTest::Unit::TestCase
7
+ def setup
8
+ Harness.config.collector = Harness::FakeCollector.new
9
+ Harness.config.queue = Harness::SyncQueue.new
10
+ end
11
+
12
+ def assert_timer(name)
13
+ refute_empty timers
14
+ timer = timers.find { |t| t.name == name }
15
+ assert timer, "Timer #{name} not logged!"
16
+ end
17
+
18
+ def assert_increment(name)
19
+ refute_empty increments
20
+ increment = increments.find { |i| i.name == name }
21
+ assert increment, "Increment #{name} not logged!"
22
+ end
23
+
24
+ def assert_decrement(name)
25
+ refute_empty decrements
26
+ decrement = decrements.find { |i| i.name == name }
27
+ assert decrement, "decrement #{name} not logged!"
28
+ end
29
+
30
+ def assert_gauge(name)
31
+ refute_empty gauges
32
+ gauge = gauges.find { |g| g.name == name }
33
+ assert gauge, "gauge #{name} not logged!"
34
+ end
35
+
36
+ def instrument(name, data = {}, &block)
37
+ ActiveSupport::Notifications.instrument name, data, &block
38
+ end
39
+
40
+ def collector
41
+ Harness.config.collector
42
+ end
43
+
44
+ def timers
45
+ collector.timers
46
+ end
47
+
48
+ def increments
49
+ collector.increments
50
+ end
51
+
52
+ def decrements
53
+ collector.decrements
54
+ end
55
+
56
+ def counters
57
+ collector.counters
58
+ end
59
+
60
+ def gauges
61
+ collector.gauges
62
+ end
63
+ end
metadata ADDED
@@ -0,0 +1,99 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: harness-actionview
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - ahawkins
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-11-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: harness
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Log ActionView's internal performance metrics with Harness
56
+ email:
57
+ - adam@hawkins.io
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - .gitignore
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - harness-actionview.gemspec
68
+ - lib/harness-actionview.rb
69
+ - lib/harness/action_view.rb
70
+ - lib/harness/action_view/version.rb
71
+ - test/action_view_test.rb
72
+ - test/test_helper.rb
73
+ homepage: ''
74
+ licenses:
75
+ - MIT
76
+ metadata: {}
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements: []
92
+ rubyforge_project:
93
+ rubygems_version: 2.0.3
94
+ signing_key:
95
+ specification_version: 4
96
+ summary: ''
97
+ test_files:
98
+ - test/action_view_test.rb
99
+ - test/test_helper.rb