frogger 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +15 -14
- data/VERSION +1 -1
- data/features/enhanced_logger.feature +15 -0
- data/features/step_definitions/enhanced_logging_steps.rb +56 -0
- data/features/support/env.rb +2 -0
- data/frogger.gemspec +8 -4
- data/lib/frogger/cucumber.rb +50 -0
- metadata +26 -22
data/README.rdoc
CHANGED
@@ -1,25 +1,22 @@
|
|
1
1
|
= frogger
|
2
|
-
'Hop
|
2
|
+
'Hop across the logs'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
Navigating 'noise' in your log files can feel like when you are crossing a busy road while attempting to avoid the cars.
|
4
|
+
Navigating your log files can feel like you are crossing a busy road while attempting to avoid the cars.
|
7
5
|
Frogger makes your log files more fun by adding some 8 bit colour and a some nice formatting.
|
8
6
|
|
9
7
|
== Why?
|
8
|
+
I created frogger after squinting at the log tail so many times and feeling like a complete idiot as I searched for a needle in a haystack.
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
Ignore the traffic and just get across the logs.
|
14
|
-
Forget how fast the traffic is, frogger just helps you get across the logs.
|
10
|
+
I thought surely this can be more fun.
|
15
11
|
|
16
|
-
|
17
|
-
|
18
|
-
I created frogger after squinting at the log tail so many times and feeling like a complete idiot as I searched for my needle in a haystack.
|
12
|
+
Other log enhancing gems are all about tracking performance and other such tasks.
|
13
|
+
Frogger is not about speed, it's about getting through the logs with the least amount of pain.
|
19
14
|
|
20
|
-
|
15
|
+
== What it does
|
21
16
|
|
22
|
-
Initially I've added a few tricks for working with cucumber log files
|
17
|
+
Initially I've added a few tricks for working with cucumber log files.
|
18
|
+
Run a cucumber feature and tail your log file
|
19
|
+
The scenario name and step names will annotate your log file in glorious 8 bit colour
|
23
20
|
|
24
21
|
== How
|
25
22
|
|
@@ -37,8 +34,12 @@ Windows users:
|
|
37
34
|
== Usage
|
38
35
|
Just tail your log files like you usually do.
|
39
36
|
Eg.
|
37
|
+
|
40
38
|
$ tail -f /log/test.log
|
41
39
|
|
40
|
+
Then run your cucumber tests
|
41
|
+
$ bundle exec cucumber
|
42
|
+
|
42
43
|
And be amazed as your log files become just a little more fun.
|
43
44
|
Disclaimer: Increased fun may vary from developer to developer.
|
44
45
|
|
@@ -56,7 +57,7 @@ Windows users:
|
|
56
57
|
|
57
58
|
== Compatibility
|
58
59
|
|
59
|
-
|
60
|
+
No known issues
|
60
61
|
|
61
62
|
== Contributing to frogger
|
62
63
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
0.1.1
|
@@ -0,0 +1,15 @@
|
|
1
|
+
Feature: A developer is ecstatic to discover informative step based logging in their rails log
|
2
|
+
As a developer
|
3
|
+
In order to derive joy and happiness when checking my cucumber logs
|
4
|
+
I want to see rainbows and unicorns when my log files run
|
5
|
+
|
6
|
+
Scenario: Step information is written to the rails log
|
7
|
+
Given a cucumber feature is executing against my rails application
|
8
|
+
When I examine the rails log
|
9
|
+
And I do some crazy Inception like test on myself
|
10
|
+
Then I see the following log entries:
|
11
|
+
| Message | Colour |
|
12
|
+
| STEP INFORMATION IS WRITTEN TO THE RAILS LOG | black_on_green |
|
13
|
+
| Given a cucumber feature is executing against my rails application | black_on_yellow |
|
14
|
+
| When I examine the rails log | black_on_yellow |
|
15
|
+
| And I do some crazy Inception like test on myself | black_on_yellow |
|
@@ -0,0 +1,56 @@
|
|
1
|
+
class String
|
2
|
+
def black_on_green
|
3
|
+
[self, :black_on_green]
|
4
|
+
end
|
5
|
+
|
6
|
+
def black_on_blue
|
7
|
+
[self, :black_on_blue]
|
8
|
+
end
|
9
|
+
|
10
|
+
def black_on_yellow
|
11
|
+
[self, :black_on_yellow]
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class FakeLogger
|
16
|
+
attr_reader :logs
|
17
|
+
|
18
|
+
def initialize
|
19
|
+
@logs = []
|
20
|
+
end
|
21
|
+
|
22
|
+
def reset
|
23
|
+
@logs = []
|
24
|
+
end
|
25
|
+
|
26
|
+
def debug message
|
27
|
+
@logs << message
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
module Rails
|
32
|
+
def self.logger
|
33
|
+
@logger ||= FakeLogger.new
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
Given /^a cucumber feature is executing against my rails application$/ do
|
38
|
+
#Rails.logger.reset
|
39
|
+
end
|
40
|
+
|
41
|
+
When /^I examine the rails log$/ do
|
42
|
+
end
|
43
|
+
|
44
|
+
When /^I do some crazy Inception like test on myself$/ do
|
45
|
+
end
|
46
|
+
|
47
|
+
Then /^I see the following log entries:$/ do |ast|
|
48
|
+
completed_lines = ast.hashes[0..-2]
|
49
|
+
completed_lines.each do |expected_line|
|
50
|
+
message, colour = expected_line['Message'], expected_line['Colour'].to_sym
|
51
|
+
|
52
|
+
raise "Did not find expected log entry #{string}" unless Rails.logger.logs.any? do |log|
|
53
|
+
log.first.chomp.strip == message && log[1] == colour
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/frogger.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{frogger}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Richie Khoo"]
|
12
|
-
s.date = %q{2011-06-
|
12
|
+
s.date = %q{2011-06-15}
|
13
13
|
s.description = %q{Navigating noise in your log files can be like trying to cross a busy road and avoid the cars. Frogger makes your log files more fun by adding some good ol' 8 bit color and a bit of formatting.}
|
14
14
|
s.email = %q{evolve2k@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -24,14 +24,18 @@ Gem::Specification.new do |s|
|
|
24
24
|
"README.rdoc",
|
25
25
|
"Rakefile",
|
26
26
|
"VERSION",
|
27
|
+
"features/enhanced_logger.feature",
|
28
|
+
"features/step_definitions/enhanced_logging_steps.rb",
|
29
|
+
"features/support/env.rb",
|
27
30
|
"frogger.gemspec",
|
28
31
|
"lib/frogger.rb",
|
32
|
+
"lib/frogger/cucumber.rb",
|
29
33
|
"spec/spec_helper.rb"
|
30
34
|
]
|
31
35
|
s.homepage = %q{http://github.com/evolve2k/frogger}
|
32
36
|
s.licenses = ["MIT"]
|
33
37
|
s.require_paths = ["lib"]
|
34
|
-
s.rubygems_version = %q{1.
|
38
|
+
s.rubygems_version = %q{1.7.2}
|
35
39
|
s.summary = %q{Frogger makes logs easier to navigate.}
|
36
40
|
s.test_files = [
|
37
41
|
"spec/spec_helper.rb"
|
@@ -42,7 +46,7 @@ Gem::Specification.new do |s|
|
|
42
46
|
|
43
47
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
44
48
|
s.add_runtime_dependency(%q<colored>, [">= 1.2"])
|
45
|
-
s.
|
49
|
+
s.add_runtime_dependency(%q<cucumber>, [">= 0"])
|
46
50
|
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
47
51
|
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
48
52
|
s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
|
@@ -0,0 +1,50 @@
|
|
1
|
+
Cucumber::Ast::Background.send(:attr_reader, :raw_steps)
|
2
|
+
Cucumber::Ast::Feature.send(:attr_reader, :background)
|
3
|
+
|
4
|
+
Before do |scenario|
|
5
|
+
scenario_background = scenario.feature.send(:background)
|
6
|
+
@frogger_steps = if scenario_background
|
7
|
+
scenario_background.send(:raw_steps) + scenario.raw_steps
|
8
|
+
else
|
9
|
+
scenario.raw_steps
|
10
|
+
end
|
11
|
+
|
12
|
+
@max_length = scenario.name.length
|
13
|
+
@frogger_steps.each { |step|
|
14
|
+
step_length = "#{step.keyword} #{step.name}".length
|
15
|
+
@max_length = step_length if step_length > @max_length
|
16
|
+
}
|
17
|
+
@max_length + 6
|
18
|
+
|
19
|
+
padding = @max_length - 2 - scenario.name.length
|
20
|
+
Rails.logger.debug("\n\n #{scenario.name.upcase}#{ ' ' * padding } ".black_on_green)
|
21
|
+
# Rails.logger.debug("\n\n ".black_on_green + ' ' + scenario.name + ' ' + ' '.black_on_green)
|
22
|
+
|
23
|
+
@step_index = 0
|
24
|
+
print_step(@frogger_steps[@step_index])
|
25
|
+
end
|
26
|
+
|
27
|
+
AfterStep do |scenario|
|
28
|
+
@step_index += 1
|
29
|
+
print_step(@frogger_steps[@step_index]) if @frogger_steps[@step_index]
|
30
|
+
end
|
31
|
+
|
32
|
+
def print_step(step)
|
33
|
+
step_to_s = "#{step.keyword}#{step.name}"
|
34
|
+
padding = @max_length - 4 - step_to_s.length
|
35
|
+
padding = 0 if padding < 0
|
36
|
+
if step.background?
|
37
|
+
Rails.logger.debug("\n #{ step_to_s }#{ ' ' * padding } ".black_on_blue) unless step == nil
|
38
|
+
else
|
39
|
+
Rails.logger.debug("\n #{ step_to_s }#{ ' ' * padding } ".black_on_yellow) unless step == nil
|
40
|
+
# Rails.logger.debug("\n ".black_on_yellow + ' ' + step_to_s + ' ' + " ".black_on_yellow)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
# module ActiveRecord
|
45
|
+
# class LogSubscriber < ActiveSupport::LogSubscriber
|
46
|
+
# def sql(event)
|
47
|
+
# puts event.payload[:name].gsub(/(.*) Load/, "\\1").inspect
|
48
|
+
# end
|
49
|
+
# end
|
50
|
+
# end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: frogger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Richie Khoo
|
@@ -15,11 +15,10 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-06-
|
18
|
+
date: 2011-06-15 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
|
-
|
22
|
-
prerelease: false
|
21
|
+
type: :runtime
|
23
22
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
23
|
none: false
|
25
24
|
requirements:
|
@@ -30,11 +29,11 @@ dependencies:
|
|
30
29
|
- 1
|
31
30
|
- 2
|
32
31
|
version: "1.2"
|
33
|
-
type: :runtime
|
34
32
|
version_requirements: *id001
|
35
|
-
|
36
|
-
name: cucumber
|
33
|
+
name: colored
|
37
34
|
prerelease: false
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
type: :runtime
|
38
37
|
requirement: &id002 !ruby/object:Gem::Requirement
|
39
38
|
none: false
|
40
39
|
requirements:
|
@@ -44,11 +43,11 @@ dependencies:
|
|
44
43
|
segments:
|
45
44
|
- 0
|
46
45
|
version: "0"
|
47
|
-
type: :development
|
48
46
|
version_requirements: *id002
|
49
|
-
|
50
|
-
name: shoulda
|
47
|
+
name: cucumber
|
51
48
|
prerelease: false
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
type: :development
|
52
51
|
requirement: &id003 !ruby/object:Gem::Requirement
|
53
52
|
none: false
|
54
53
|
requirements:
|
@@ -58,11 +57,11 @@ dependencies:
|
|
58
57
|
segments:
|
59
58
|
- 0
|
60
59
|
version: "0"
|
61
|
-
type: :development
|
62
60
|
version_requirements: *id003
|
63
|
-
|
64
|
-
name: bundler
|
61
|
+
name: shoulda
|
65
62
|
prerelease: false
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
type: :development
|
66
65
|
requirement: &id004 !ruby/object:Gem::Requirement
|
67
66
|
none: false
|
68
67
|
requirements:
|
@@ -74,11 +73,11 @@ dependencies:
|
|
74
73
|
- 0
|
75
74
|
- 0
|
76
75
|
version: 1.0.0
|
77
|
-
type: :development
|
78
76
|
version_requirements: *id004
|
79
|
-
|
80
|
-
name: jeweler
|
77
|
+
name: bundler
|
81
78
|
prerelease: false
|
79
|
+
- !ruby/object:Gem::Dependency
|
80
|
+
type: :development
|
82
81
|
requirement: &id005 !ruby/object:Gem::Requirement
|
83
82
|
none: false
|
84
83
|
requirements:
|
@@ -90,11 +89,11 @@ dependencies:
|
|
90
89
|
- 5
|
91
90
|
- 2
|
92
91
|
version: 1.5.2
|
93
|
-
type: :development
|
94
92
|
version_requirements: *id005
|
95
|
-
|
96
|
-
name: rcov
|
93
|
+
name: jeweler
|
97
94
|
prerelease: false
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
type: :development
|
98
97
|
requirement: &id006 !ruby/object:Gem::Requirement
|
99
98
|
none: false
|
100
99
|
requirements:
|
@@ -104,8 +103,9 @@ dependencies:
|
|
104
103
|
segments:
|
105
104
|
- 0
|
106
105
|
version: "0"
|
107
|
-
type: :development
|
108
106
|
version_requirements: *id006
|
107
|
+
name: rcov
|
108
|
+
prerelease: false
|
109
109
|
description: Navigating noise in your log files can be like trying to cross a busy road and avoid the cars. Frogger makes your log files more fun by adding some good ol' 8 bit color and a bit of formatting.
|
110
110
|
email: evolve2k@gmail.com
|
111
111
|
executables: []
|
@@ -123,8 +123,12 @@ files:
|
|
123
123
|
- README.rdoc
|
124
124
|
- Rakefile
|
125
125
|
- VERSION
|
126
|
+
- features/enhanced_logger.feature
|
127
|
+
- features/step_definitions/enhanced_logging_steps.rb
|
128
|
+
- features/support/env.rb
|
126
129
|
- frogger.gemspec
|
127
130
|
- lib/frogger.rb
|
131
|
+
- lib/frogger/cucumber.rb
|
128
132
|
- spec/spec_helper.rb
|
129
133
|
homepage: http://github.com/evolve2k/frogger
|
130
134
|
licenses:
|