frogger 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,16 +1,10 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- # Add dependencies required to use your gem here.
4
- # Example:
5
- # gem "activesupport", ">= 2.3.5"
6
- gem 'colored', '>= 1.2'
7
- gem "cucumber", ">= 0"
3
+ gem 'colored', '>= 1.2'
4
+ gem 'cucumber', '>= 0.10.5'
8
5
 
9
- # Add dependencies to develop your gem here.
10
- # Include everything needed to run rake, tests, features, etc.
11
6
  group :development, :test do
12
- gem "shoulda", ">= 0"
13
- gem "bundler", "~> 1.0.0"
14
- gem "jeweler", "~> 1.5.2"
15
- gem "rcov", ">= 0"
16
- end
7
+ gem 'bundler', '~> 1.0.0'
8
+ gem 'jeweler', '~> 1.5.2'
9
+ gem 'rspec', '2.6.0'
10
+ end
@@ -19,8 +19,14 @@ GEM
19
19
  rake
20
20
  json (1.5.1)
21
21
  rake (0.9.2)
22
- rcov (0.9.9)
23
- shoulda (2.11.3)
22
+ rspec (2.6.0)
23
+ rspec-core (~> 2.6.0)
24
+ rspec-expectations (~> 2.6.0)
25
+ rspec-mocks (~> 2.6.0)
26
+ rspec-core (2.6.4)
27
+ rspec-expectations (2.6.0)
28
+ diff-lcs (~> 1.1.2)
29
+ rspec-mocks (2.6.0)
24
30
  term-ansicolor (1.0.5)
25
31
 
26
32
  PLATFORMS
@@ -29,7 +35,6 @@ PLATFORMS
29
35
  DEPENDENCIES
30
36
  bundler (~> 1.0.0)
31
37
  colored (>= 1.2)
32
- cucumber
38
+ cucumber (>= 0.10.5)
33
39
  jeweler (~> 1.5.2)
34
- rcov
35
- shoulda
40
+ rspec (= 2.6.0)
@@ -0,0 +1,67 @@
1
+ h1. frogger
2
+
3
+ 'Hop across the logs'
4
+
5
+ Navigating your log files can feel like you are crossing a busy road while attempting to avoid the cars.
6
+ Frogger makes your log files more fun by adding some 8 bit colour and some nice formatting.
7
+
8
+ h2. Why?
9
+
10
+ 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.
11
+
12
+ I thought surely this can be more fun.
13
+
14
+ Other log enhancing gems are all about tracking performance and other such tasks.
15
+ Frogger is not about speed, it's about getting through the logs with the least amount of pain.
16
+
17
+ h2. What it does
18
+
19
+ Run a cucumber feature and tail your log file, the scenario name and step names will be annotated in your log file in glorious 8 bit colour.
20
+
21
+ h2. How
22
+
23
+ Add this to your Gemfile:
24
+
25
+ <pre><code>gem 'frogger'</code></pre>
26
+
27
+ *Windows users:* You will need the Win32 Console Ansi gem. Get it by running this from the command line:
28
+
29
+ <pre><code>gem install win32console</code></pre>
30
+
31
+
32
+ h2. Usage
33
+
34
+ Just tail your log files like you usually do.
35
+
36
+ <pre><code>$ tail -f /log/test.log</code></pre>
37
+
38
+ Then run your cucumber tests
39
+
40
+ <pre><code>$ bundle exec cucumber</code></pre>
41
+
42
+ And be amazed as your log files become just a little more fun. Disclaimer: Increased fun may vary from developer to developer.
43
+
44
+ h2. Who?
45
+
46
+ Richie Khoo is a developer from Melbourne, Australia. Don't be shy, you can follow me on twitter via "@evolve2k":http://twitter.com/evolve2k
47
+
48
+ Special thanks to:
49
+ "Pat Allan":http://twitter.com/pat, "Keith Pitt":http://twitter.com/keithpitt, "Jared Fraser"::http://twitter.com/modsognir, "Thomas Sinclair":http://twitter.com/anathematic, "Mark Ryall":http://twitter.com/markryall, "Nathan Sampimon":http://twitter.com/nathan_scott and everyone else at Australian Rails Camp 9 who helped me with the code and understanding the inner workings of cucumber.
50
+
51
+ h2. Compatibility
52
+
53
+ No known issues
54
+
55
+ h2. Contributing to frogger
56
+
57
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
58
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
59
+ * Fork the project
60
+ * Start a feature/bugfix branch
61
+ * Commit and push until you are happy with your contribution
62
+ * Make sure to add rspec tests for it. This is important so I don't break it in a future version unintentionally.
63
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
64
+
65
+ h2. Copyright
66
+
67
+ Copyright (c) 2011 Richie Khoo. See LICENSE.txt for further details.
data/Rakefile CHANGED
@@ -31,13 +31,6 @@ Rake::TestTask.new(:test) do |test|
31
31
  test.verbose = true
32
32
  end
33
33
 
34
- require 'rcov/rcovtask'
35
- Rcov::RcovTask.new do |test|
36
- test.libs << 'test'
37
- test.pattern = 'test/**/test_*.rb'
38
- test.verbose = true
39
- end
40
-
41
34
  task :default => :test
42
35
 
43
36
  require 'rake/rdoctask'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.2.0
@@ -1,2 +1,3 @@
1
- require 'pp'
2
- require File.expand_path "../../../lib/frogger/cucumber", __FILE__
1
+ $LOAD_PATH.unshift File.dirname(__FILE__) + '/../../lib'
2
+
3
+ require 'frogger'
@@ -5,23 +5,23 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{frogger}
8
- s.version = "0.1.1"
8
+ s.version = "0.2.0"
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-15}
12
+ s.date = %q{2011-06-28}
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 = [
16
16
  "LICENSE.txt",
17
- "README.rdoc"
17
+ "README.textile"
18
18
  ]
19
19
  s.files = [
20
20
  ".document",
21
21
  "Gemfile",
22
22
  "Gemfile.lock",
23
23
  "LICENSE.txt",
24
- "README.rdoc",
24
+ "README.textile",
25
25
  "Rakefile",
26
26
  "VERSION",
27
27
  "features/enhanced_logger.feature",
@@ -30,6 +30,8 @@ Gem::Specification.new do |s|
30
30
  "frogger.gemspec",
31
31
  "lib/frogger.rb",
32
32
  "lib/frogger/cucumber.rb",
33
+ "lib/frogger/frog.rb",
34
+ "spec/frogger/frog_spec.rb",
33
35
  "spec/spec_helper.rb"
34
36
  ]
35
37
  s.homepage = %q{http://github.com/evolve2k/frogger}
@@ -38,6 +40,7 @@ Gem::Specification.new do |s|
38
40
  s.rubygems_version = %q{1.7.2}
39
41
  s.summary = %q{Frogger makes logs easier to navigate.}
40
42
  s.test_files = [
43
+ "spec/frogger/frog_spec.rb",
41
44
  "spec/spec_helper.rb"
42
45
  ]
43
46
 
@@ -46,26 +49,23 @@ Gem::Specification.new do |s|
46
49
 
47
50
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
48
51
  s.add_runtime_dependency(%q<colored>, [">= 1.2"])
49
- s.add_runtime_dependency(%q<cucumber>, [">= 0"])
50
- s.add_development_dependency(%q<shoulda>, [">= 0"])
52
+ s.add_runtime_dependency(%q<cucumber>, [">= 0.10.5"])
51
53
  s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
52
54
  s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
53
- s.add_development_dependency(%q<rcov>, [">= 0"])
55
+ s.add_development_dependency(%q<rspec>, ["= 2.6.0"])
54
56
  else
55
57
  s.add_dependency(%q<colored>, [">= 1.2"])
56
- s.add_dependency(%q<cucumber>, [">= 0"])
57
- s.add_dependency(%q<shoulda>, [">= 0"])
58
+ s.add_dependency(%q<cucumber>, [">= 0.10.5"])
58
59
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
59
60
  s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
60
- s.add_dependency(%q<rcov>, [">= 0"])
61
+ s.add_dependency(%q<rspec>, ["= 2.6.0"])
61
62
  end
62
63
  else
63
64
  s.add_dependency(%q<colored>, [">= 1.2"])
64
- s.add_dependency(%q<cucumber>, [">= 0"])
65
- s.add_dependency(%q<shoulda>, [">= 0"])
65
+ s.add_dependency(%q<cucumber>, [">= 0.10.5"])
66
66
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
67
67
  s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
68
- s.add_dependency(%q<rcov>, [">= 0"])
68
+ s.add_dependency(%q<rspec>, ["= 2.6.0"])
69
69
  end
70
70
  end
71
71
 
@@ -1,2 +1,7 @@
1
+ require 'colored'
2
+
1
3
  module Frogger
2
- end
4
+ end
5
+
6
+ require 'frogger/frog'
7
+ require 'frogger/cucumber' if defined?(Cucumber)
@@ -1,52 +1,9 @@
1
- require 'colored'
2
-
3
- Cucumber::Ast::Background.send(:attr_reader, :raw_steps)
4
- Cucumber::Ast::Feature.send(:attr_reader, :background)
5
-
6
- Before do |scenario|
7
- scenario_background = scenario.feature.send(:background)
8
- @frogger_steps = if scenario_background
9
- scenario_background.send(:raw_steps) + scenario.raw_steps
10
- else
11
- scenario.raw_steps
12
- end
13
-
14
- @max_length = scenario.name.length
15
- @frogger_steps.each { |step|
16
- step_length = "#{step.keyword} #{step.name}".length
17
- @max_length = step_length if step_length > @max_length
18
- }
19
- @max_length + 6
20
-
21
- padding = @max_length - 2 - scenario.name.length
22
- Rails.logger.debug("\n\n #{scenario.name.upcase}#{ ' ' * padding } ".black_on_green)
23
- # Rails.logger.debug("\n\n ".black_on_green + ' ' + scenario.name + ' ' + ' '.black_on_green)
24
-
25
- @step_index = 0
26
- print_step(@frogger_steps[@step_index])
1
+ Before do |scenario|
2
+ @frog = Frogger::Frog.new scenario
3
+ @frog.log_scenario
4
+ @frog.log_step
27
5
  end
28
6
 
29
- AfterStep do |scenario|
30
- @step_index += 1
31
- print_step(@frogger_steps[@step_index]) if @frogger_steps[@step_index]
7
+ AfterStep do
8
+ @frog.log_step
32
9
  end
33
-
34
- def print_step(step)
35
- step_to_s = "#{step.keyword}#{step.name}"
36
- padding = @max_length - 4 - step_to_s.length
37
- padding = 0 if padding < 0
38
- if step.background?
39
- Rails.logger.debug("\n #{ step_to_s }#{ ' ' * padding } ".black_on_blue) unless step == nil
40
- else
41
- Rails.logger.debug("\n #{ step_to_s }#{ ' ' * padding } ".black_on_yellow) unless step == nil
42
- # Rails.logger.debug("\n ".black_on_yellow + ' ' + step_to_s + ' ' + " ".black_on_yellow)
43
- end
44
- end
45
-
46
- # module ActiveRecord
47
- # class LogSubscriber < ActiveSupport::LogSubscriber
48
- # def sql(event)
49
- # puts event.payload[:name].gsub(/(.*) Load/, "\\1").inspect
50
- # end
51
- # end
52
- # end
@@ -0,0 +1,56 @@
1
+ class Frogger::Frog
2
+ attr_reader :scenario, :logger
3
+ attr_accessor :step_index
4
+
5
+ def initialize(scenario, logger = default_logger)
6
+ @scenario = scenario
7
+ @logger = logger
8
+ @step_index = 0
9
+ end
10
+
11
+ def log_scenario
12
+ padding = max_length - 2 - scenario.name.length
13
+ logger.debug(
14
+ "\n\n #{scenario.name.upcase}#{ ' ' * padding } ".black_on_green
15
+ )
16
+ end
17
+
18
+ def log_step
19
+ return if step.nil?
20
+
21
+ step_to_s = "#{step.keyword}#{step.name}"
22
+ padding = [max_length - 4 - step_to_s.length, 0].max
23
+
24
+ logger.debug "\n #{ step_to_s }#{ ' ' * padding } ".black_on_yellow
25
+
26
+ self.step_index += 1
27
+ end
28
+
29
+ private
30
+
31
+ def default_logger
32
+ Rails.logger
33
+ end
34
+
35
+ def steps
36
+ @steps ||= background_steps + scenario.raw_steps
37
+ end
38
+
39
+ def step
40
+ steps[step_index]
41
+ end
42
+
43
+ def background
44
+ @background ||= scenario.feature.instance_variable_get(:@background)
45
+ end
46
+
47
+ def background_steps
48
+ background.nil? ? [] : background.instance_variable_get(:@raw_steps)
49
+ end
50
+
51
+ def max_length
52
+ @max_length ||= steps.inject(scenario.name.length) { |max, step|
53
+ [max, "#{step.keyword} #{step.name}".length].max
54
+ } + 6
55
+ end
56
+ end
@@ -0,0 +1,56 @@
1
+ require 'spec_helper'
2
+
3
+ module Rails
4
+ def self.logger
5
+ :rails_logger
6
+ end
7
+ end
8
+
9
+ describe Frogger::Frog do
10
+ let(:frog) { Frogger::Frog.new(scenario, custom_logger) }
11
+ let(:scenario) { double('Scenario', :raw_steps => [step], :name => 'Foo') }
12
+ let(:custom_logger) { double('Custom Logger', :debug => true) }
13
+ let(:step) { double('Step', :keyword => 'When', :name => ' something happens') }
14
+
15
+ before :each do
16
+ scenario.stub_chain(:feature, :instance_variable_get).and_return(nil)
17
+ end
18
+
19
+ describe '#logger' do
20
+ it "is the logger passed in when initialised" do
21
+ frog = Frogger::Frog.new(scenario, custom_logger)
22
+ frog.logger.should == custom_logger
23
+ end
24
+
25
+ it "defaults to the Rails logger" do
26
+ frog = Frogger::Frog.new(scenario)
27
+ frog.logger.should == Rails.logger
28
+ end
29
+ end
30
+
31
+ describe '#log_scenario' do
32
+ it "prints the scenario name in black on green" do
33
+ custom_logger.should_receive(:debug).with("\n\n FOO ".black_on_green)
34
+ frog.log_scenario
35
+ end
36
+ end
37
+
38
+ describe '#log_step' do
39
+ it "prints the step name in black on yellow" do
40
+ custom_logger.should_receive(:debug).with("\n When something happens ".black_on_yellow)
41
+ frog.log_step
42
+ end
43
+
44
+ it "increments the step index" do
45
+ step_index = frog.step_index
46
+ frog.log_step
47
+ frog.step_index.should == step_index + 1
48
+ end
49
+ end
50
+
51
+ describe '#step_index' do
52
+ it "defaults to 0" do
53
+ frog.step_index.should == 0
54
+ end
55
+ end
56
+ end
@@ -1,3 +1,3 @@
1
1
  $LOAD_PATH << File.join(File.dirname(__FILE__),"..","lib")
2
- require 'spec'
3
- require 'frogger'
2
+ require 'rspec'
3
+ require 'frogger'
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: 31
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 1
9
8
  - 2
10
- version: 0.1.2
9
+ - 0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Richie Khoo
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-06-16 00:00:00 Z
18
+ date: 2011-06-28 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  type: :runtime
@@ -39,30 +39,18 @@ dependencies:
39
39
  requirements:
40
40
  - - ">="
41
41
  - !ruby/object:Gem::Version
42
- hash: 3
42
+ hash: 61
43
43
  segments:
44
44
  - 0
45
- version: "0"
45
+ - 10
46
+ - 5
47
+ version: 0.10.5
46
48
  version_requirements: *id002
47
49
  name: cucumber
48
50
  prerelease: false
49
51
  - !ruby/object:Gem::Dependency
50
52
  type: :development
51
53
  requirement: &id003 !ruby/object:Gem::Requirement
52
- none: false
53
- requirements:
54
- - - ">="
55
- - !ruby/object:Gem::Version
56
- hash: 3
57
- segments:
58
- - 0
59
- version: "0"
60
- version_requirements: *id003
61
- name: shoulda
62
- prerelease: false
63
- - !ruby/object:Gem::Dependency
64
- type: :development
65
- requirement: &id004 !ruby/object:Gem::Requirement
66
54
  none: false
67
55
  requirements:
68
56
  - - ~>
@@ -73,12 +61,12 @@ dependencies:
73
61
  - 0
74
62
  - 0
75
63
  version: 1.0.0
76
- version_requirements: *id004
64
+ version_requirements: *id003
77
65
  name: bundler
78
66
  prerelease: false
79
67
  - !ruby/object:Gem::Dependency
80
68
  type: :development
81
- requirement: &id005 !ruby/object:Gem::Requirement
69
+ requirement: &id004 !ruby/object:Gem::Requirement
82
70
  none: false
83
71
  requirements:
84
72
  - - ~>
@@ -89,22 +77,24 @@ dependencies:
89
77
  - 5
90
78
  - 2
91
79
  version: 1.5.2
92
- version_requirements: *id005
80
+ version_requirements: *id004
93
81
  name: jeweler
94
82
  prerelease: false
95
83
  - !ruby/object:Gem::Dependency
96
84
  type: :development
97
- requirement: &id006 !ruby/object:Gem::Requirement
85
+ requirement: &id005 !ruby/object:Gem::Requirement
98
86
  none: false
99
87
  requirements:
100
- - - ">="
88
+ - - "="
101
89
  - !ruby/object:Gem::Version
102
- hash: 3
90
+ hash: 23
103
91
  segments:
92
+ - 2
93
+ - 6
104
94
  - 0
105
- version: "0"
106
- version_requirements: *id006
107
- name: rcov
95
+ version: 2.6.0
96
+ version_requirements: *id005
97
+ name: rspec
108
98
  prerelease: false
109
99
  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
100
  email: evolve2k@gmail.com
@@ -114,13 +104,13 @@ extensions: []
114
104
 
115
105
  extra_rdoc_files:
116
106
  - LICENSE.txt
117
- - README.rdoc
107
+ - README.textile
118
108
  files:
119
109
  - .document
120
110
  - Gemfile
121
111
  - Gemfile.lock
122
112
  - LICENSE.txt
123
- - README.rdoc
113
+ - README.textile
124
114
  - Rakefile
125
115
  - VERSION
126
116
  - features/enhanced_logger.feature
@@ -129,6 +119,8 @@ files:
129
119
  - frogger.gemspec
130
120
  - lib/frogger.rb
131
121
  - lib/frogger/cucumber.rb
122
+ - lib/frogger/frog.rb
123
+ - spec/frogger/frog_spec.rb
132
124
  - spec/spec_helper.rb
133
125
  homepage: http://github.com/evolve2k/frogger
134
126
  licenses:
@@ -164,4 +156,5 @@ signing_key:
164
156
  specification_version: 3
165
157
  summary: Frogger makes logs easier to navigate.
166
158
  test_files:
159
+ - spec/frogger/frog_spec.rb
167
160
  - spec/spec_helper.rb
@@ -1,75 +0,0 @@
1
- = frogger
2
- 'Hop across the logs'
3
-
4
- Navigating your log files can feel like you are crossing a busy road while attempting to avoid the cars.
5
- Frogger makes your log files more fun by adding some 8 bit colour and a some nice formatting.
6
-
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.
9
-
10
- I thought surely this can be more fun.
11
-
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.
14
-
15
- == What it does
16
-
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
20
-
21
- == How
22
-
23
- 1. Add this to your Gemfile:
24
- gem 'frogger'
25
-
26
- 2. Add this to your cucumber env.rb file, below your cucumber requires:
27
- require 'frogger/cucumber'
28
-
29
- Windows users:
30
- You will need the Win32 Console Ansi gem. Get it by running this from the command line:
31
- gem install win32console
32
-
33
-
34
- == Usage
35
- Just tail your log files like you usually do.
36
- Eg.
37
-
38
- $ tail -f /log/test.log
39
-
40
- Then run your cucumber tests
41
- $ bundle exec cucumber
42
-
43
- And be amazed as your log files become just a little more fun.
44
- Disclaimer: Increased fun may vary from developer to developer.
45
-
46
- Try it on cucumber logs, we've done some fun things there.
47
- Eg.
48
- $ tail -f /log/cucumber.log
49
-
50
- == Who?
51
-
52
- Richie Khoo is a developer from Melbourne, Australia. Don't be shy, you can follow me on twitter via @evolve2k
53
-
54
- Special thanks to:
55
- Keith Pitt(@keithpitt), Pat Allan(@pat), Jared Fraser(@modsognir), Thomas Sinclair(@anathematic), mark_ryal(@markryall), Nathan Sampimon(@nathan_scott)
56
- and everyone else at Australian RailsCamp 9 who helped me with the code and understanding the inner workings of cucumber.
57
-
58
- == Compatibility
59
-
60
- No known issues
61
-
62
- == Contributing to frogger
63
-
64
- * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
65
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
66
- * Fork the project
67
- * Start a feature/bugfix branch
68
- * Commit and push until you are happy with your contribution
69
- * Make sure to add rspec tests for it. This is important so I don't break it in a future version unintentionally.
70
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
71
-
72
- == Copyright
73
-
74
- Copyright (c) 2011 Richie Khoo. See LICENSE.txt for
75
- further details.