flatfoot 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +11 -1
- data/Rakefile +8 -0
- data/flatfoot.gemspec +4 -0
- data/lib/flatfoot/version.rb +1 -1
- data/lib/flatfoot.rb +20 -15
- data/test/test_helper.rb +17 -0
- data/test/unit/flatfoot_test.rb +65 -0
- metadata +73 -5
data/README.md
CHANGED
@@ -42,9 +42,15 @@ After making changes deploying or just to clear out the Redis size you can clear
|
|
42
42
|
|
43
43
|
FLATFOOT.reset_recordings
|
44
44
|
|
45
|
-
If you set the `FLATFOOT` constant in a initializer you can also use the included rake tasks.
|
45
|
+
If you set the `FLATFOOT` constant in a initializer you can also use the included rake tasks. Edit your `Rakefile` and add
|
46
46
|
|
47
|
+
require 'flatfoot/tasks'
|
47
48
|
|
49
|
+
Then you should have tasks to help view the flatfoot data
|
50
|
+
|
51
|
+
rake flatfoot:reset # reset tracked views
|
52
|
+
rake flatfoot:unused # report unused views
|
53
|
+
rake flatfoot:used # report used views
|
48
54
|
|
49
55
|
## Contributing
|
50
56
|
|
@@ -53,3 +59,7 @@ If you set the `FLATFOOT` constant in a initializer you can also use the include
|
|
53
59
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
54
60
|
4. Push to the branch (`git push origin my-new-feature`)
|
55
61
|
5. Create new Pull Request
|
62
|
+
|
63
|
+
## MIT LICENSE
|
64
|
+
|
65
|
+
view the LICENSE.txt for details
|
data/Rakefile
CHANGED
data/flatfoot.gemspec
CHANGED
@@ -20,4 +20,8 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.3"
|
22
22
|
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "mocha", "~> 0.14.0"
|
24
|
+
spec.add_development_dependency "shoulda"
|
25
|
+
spec.add_development_dependency "rack"
|
26
|
+
spec.add_development_dependency "simplecov"
|
23
27
|
end
|
data/lib/flatfoot/version.rb
CHANGED
data/lib/flatfoot.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "flatfoot/version"
|
2
|
+
require 'timeout'
|
2
3
|
|
3
4
|
module Flatfoot
|
4
5
|
|
@@ -13,23 +14,27 @@ module Flatfoot
|
|
13
14
|
end
|
14
15
|
|
15
16
|
def track_views(name, start, finish, id, payload)
|
16
|
-
|
17
|
-
|
18
|
-
logged_views
|
19
|
-
|
17
|
+
begin
|
18
|
+
if file = payload[:identifier]
|
19
|
+
unless logged_views.include?(file)
|
20
|
+
logged_views << file
|
21
|
+
store.sadd(tracker_key, file)
|
22
|
+
end
|
20
23
|
end
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
24
|
+
###
|
25
|
+
# Annoyingly while you get full path for templates
|
26
|
+
# notifications only pass part of the path for layouts dropping any format info
|
27
|
+
# such as .html.erb or .js.erb
|
28
|
+
# http://edgeguides.rubyonrails.org/active_support_instrumentation.html#render_partial-action_view
|
29
|
+
###
|
30
|
+
if layout_file = payload[:layout]
|
31
|
+
unless logged_views.include?(layout_file)
|
32
|
+
logged_views << layout_file
|
33
|
+
store.sadd(tracker_key, layout_file)
|
34
|
+
end
|
32
35
|
end
|
36
|
+
rescue Errno::EAGAIN, Timeout::Error
|
37
|
+
#we don't want to raise errors if flatfoot can't reach redis. This is a nice to have not a bring the system down
|
33
38
|
end
|
34
39
|
end
|
35
40
|
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
require 'test/unit'
|
3
|
+
require 'shoulda'
|
4
|
+
require 'mocha/setup'
|
5
|
+
require 'ostruct'
|
6
|
+
|
7
|
+
SimpleCov.start do
|
8
|
+
add_filter 'specs/ruby/1.9.1/gems/'
|
9
|
+
add_filter '/test/'
|
10
|
+
add_filter '/config/'
|
11
|
+
end
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
15
|
+
Mocha::Configuration.prevent(:stubbing_non_existent_method)
|
16
|
+
|
17
|
+
require 'flatfoot'
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require File.expand_path('../test_helper', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
class ReporterTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
should "init correctly" do
|
6
|
+
tracker = Flatfoot::Tracker.new("store", {:roots => 'dir'})
|
7
|
+
assert_equal 'dir', tracker.roots.first
|
8
|
+
assert_equal 'store', tracker.store
|
9
|
+
assert_equal [], tracker.logged_views
|
10
|
+
end
|
11
|
+
|
12
|
+
should "track partials" do
|
13
|
+
store = fake_store
|
14
|
+
store.expects(:sadd).with('render_tracker', 'file')
|
15
|
+
tracker = Flatfoot::Tracker.new(store, {:roots => 'dir'})
|
16
|
+
tracker.track_views('name', 'start', 'finish', 'id', {:identifier => 'file'})
|
17
|
+
assert_equal ['file'], tracker.logged_views
|
18
|
+
end
|
19
|
+
|
20
|
+
should "track layouts" do
|
21
|
+
store = fake_store
|
22
|
+
store.expects(:sadd).with('render_tracker', 'layout')
|
23
|
+
tracker = Flatfoot::Tracker.new(store, {:roots => 'dir'})
|
24
|
+
tracker.track_views('name', 'start', 'finish', 'id', {:layout => 'layout'})
|
25
|
+
assert_equal ['layout'], tracker.logged_views
|
26
|
+
end
|
27
|
+
|
28
|
+
should "report used partials" do
|
29
|
+
store = fake_store
|
30
|
+
tracker = Flatfoot::Tracker.new(store, {:roots => 'dir'})
|
31
|
+
tracker.track_views('name', 'start', 'finish', 'id', {:identifier => 'file'})
|
32
|
+
assert_equal ['file'], tracker.used_views
|
33
|
+
end
|
34
|
+
|
35
|
+
should "report unused partials" do
|
36
|
+
store = fake_store
|
37
|
+
Dir.expects(:glob).returns(['file', 'not_used'])
|
38
|
+
tracker = Flatfoot::Tracker.new(store, {:roots => 'dir'})
|
39
|
+
tracker.track_views('name', 'start', 'finish', 'id', {:identifier => 'file'})
|
40
|
+
assert_equal ['not_used'], tracker.unused_views
|
41
|
+
end
|
42
|
+
|
43
|
+
should "reset store" do
|
44
|
+
store = fake_store
|
45
|
+
store.expects(:del).with('render_tracker')
|
46
|
+
tracker = Flatfoot::Tracker.new(store, {:roots => 'dir'})
|
47
|
+
tracker.track_views('name', 'start', 'finish', 'id', {:identifier => 'file'})
|
48
|
+
tracker.reset_recordings
|
49
|
+
end
|
50
|
+
|
51
|
+
protected
|
52
|
+
|
53
|
+
def fake_store
|
54
|
+
store = OpenStruct.new(:del => true)
|
55
|
+
store.data = []
|
56
|
+
def store.sadd(key, val)
|
57
|
+
data << val
|
58
|
+
end
|
59
|
+
def store.smembers(key)
|
60
|
+
data
|
61
|
+
end
|
62
|
+
store
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flatfoot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-05-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -43,6 +43,70 @@ dependencies:
|
|
43
43
|
- - ! '>='
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: mocha
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 0.14.0
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.14.0
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: shoulda
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: rack
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: simplecov
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
46
110
|
description: Discover dead view files in your app. Track view layer render usage
|
47
111
|
email:
|
48
112
|
- dan.mayer@livingsocial.com
|
@@ -59,6 +123,8 @@ files:
|
|
59
123
|
- lib/flatfoot.rb
|
60
124
|
- lib/flatfoot/tasks.rb
|
61
125
|
- lib/flatfoot/version.rb
|
126
|
+
- test/test_helper.rb
|
127
|
+
- test/unit/flatfoot_test.rb
|
62
128
|
homepage: ''
|
63
129
|
licenses:
|
64
130
|
- MIT
|
@@ -74,7 +140,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
74
140
|
version: '0'
|
75
141
|
segments:
|
76
142
|
- 0
|
77
|
-
hash:
|
143
|
+
hash: -445969606613763391
|
78
144
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
145
|
none: false
|
80
146
|
requirements:
|
@@ -83,11 +149,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
149
|
version: '0'
|
84
150
|
segments:
|
85
151
|
- 0
|
86
|
-
hash:
|
152
|
+
hash: -445969606613763391
|
87
153
|
requirements: []
|
88
154
|
rubyforge_project:
|
89
155
|
rubygems_version: 1.8.23
|
90
156
|
signing_key:
|
91
157
|
specification_version: 3
|
92
158
|
summary: Discover dead view files in your app. Track view layer render usage
|
93
|
-
test_files:
|
159
|
+
test_files:
|
160
|
+
- test/test_helper.rb
|
161
|
+
- test/unit/flatfoot_test.rb
|