duvet 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2009 Joshua Hawxwell
1
+ Copyright (c) 2010 Joshua Hawxwell
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -11,15 +11,17 @@ Then add this to the __very__ top of your `test/helper.rb` (or similar)
11
11
 
12
12
  You can change the defaults by passing an options hash to Duvet.start, eg
13
13
 
14
- Duvet.start({:dir => 'coverage', :filter => 'app/lib'})
14
+ Duvet.start :dir => 'coverage', :filter => 'app/lib'
15
15
 
16
16
  `:dir` is the directory to write the coverage to.
17
17
  `:filter` allows you to display only coverage for files that include the string.
18
18
 
19
+ You can see what the output of running duvet on itself is [here](http://hawx.github.com/duvet).
20
+
19
21
 
20
22
  ## Credits
21
23
 
22
- This gem was created because I read this blog post http://engineering.attinteractive.com/2010/08/code-coverage-in-ruby-1-9/.
24
+ This gem was created because I read this blog post <http://engineering.attinteractive.com/2010/08/code-coverage-in-ruby-1-9/>.
23
25
 
24
26
  ## Copyright
25
27
 
data/Rakefile CHANGED
@@ -5,10 +5,10 @@ require 'rake/testtask'
5
5
  Rake::TestTask.new(:test) do |test|
6
6
  test.libs << 'lib' << 'test'
7
7
  test.pattern = 'test/**/test_*.rb'
8
- test.verbose = true
8
+ # test.verbose = true
9
9
  end
10
10
 
11
- task :test => :check_dependencies
11
+ # task :test => :check_dependencies
12
12
 
13
13
  task :default => :test
14
14
 
data/lib/duvet.rb CHANGED
@@ -11,12 +11,11 @@ require 'pathname'
11
11
  require 'haml'
12
12
  require 'sass'
13
13
 
14
- require 'duvet/ext'
14
+ require 'duvet/core_ext'
15
15
  require 'duvet/covs'
16
16
  require 'duvet/cov'
17
17
  require 'duvet/version'
18
18
 
19
-
20
19
  module Duvet
21
20
 
22
21
  attr_accessor :opts
@@ -28,7 +27,7 @@ module Duvet
28
27
  # Start tracking
29
28
  def self.start(opts={})
30
29
  @opts = DEFAULTS.merge(opts)
31
-
30
+
32
31
  Coverage.start
33
32
  @running = true
34
33
  end
File without changes
data/lib/duvet/cov.rb CHANGED
@@ -5,7 +5,7 @@ module Duvet
5
5
  def initialize(path, cov)
6
6
  @path = Pathname.new(path)
7
7
  if @path.to_s.include?(Dir.pwd)
8
- a = Dir.pwd.size+1
8
+ a = Dir.pwd.size + 1
9
9
  @path = Pathname.new(path[a..-1])
10
10
  #@path = @path.relative_path_from(Pathname.getwd)
11
11
  end
@@ -32,8 +32,9 @@ module Duvet
32
32
  # been executed. It ignores all lines that couldn't be executed
33
33
  # such as comments.
34
34
  #
35
- # @return [Integer] lines of code executed as a fraction
35
+ # @return [Float] lines of code executed as a fraction
36
36
  def code_coverage
37
+ return 0.0 if code_lines.size.zero?
37
38
  ran_lines.size.to_f / code_lines.size.to_f
38
39
  end
39
40
 
@@ -42,6 +43,7 @@ module Duvet
42
43
  #
43
44
  # @return [Integer] lines executed as a fraction
44
45
  def total_coverage
46
+ return 0.0 if lines.size.zero?
45
47
  ran_lines.size.to_f / lines.size.to_f
46
48
  end
47
49
 
@@ -55,27 +57,11 @@ module Duvet
55
57
  "%.2f%" % (total_coverage*100)
56
58
  end
57
59
 
58
- # Creates a report showing the source code.
59
- #
60
- # @return [String] a report showing line number, source and
61
- # times run
62
- def source_report
63
- source = @path.readlines
64
- str = ""
65
- source.zip(@cov).each_with_index do |a, i|
66
- line, count = a[0], a[1]
67
- str << "#{i}| #{line.gsub("\n", "")}"
68
- str << " #=> #{count}" if count
69
- str << "\n"
70
- end
71
- str
72
- end
73
-
74
60
  # @return [String]
75
61
  def report
76
- str = "For #{@path}\n\n" << source_report << "\n"
77
- str << "total coverage: #{total_coverage_percent}\n"
78
- str << "code coverage: #{code_coverage_percent}\n"
62
+ str = "#{@path}\n"
63
+ str << " total: #{total_coverage_percent}\n"
64
+ str << " code: #{code_coverage_percent}\n\n"
79
65
  str
80
66
  end
81
67
 
@@ -0,0 +1,16 @@
1
+ # Allows duvet to generate it's own code coverage
2
+
3
+ require 'coverage'
4
+
5
+ module Duvet
6
+
7
+ DEFAULTS = {:dir => 'cov', :style => 'rcov'}
8
+
9
+ def self.start(opts={})
10
+ @opts = DEFAULTS.merge(opts)
11
+
12
+ Coverage.start
13
+ @running = true
14
+ end
15
+
16
+ end
data/lib/duvet/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Duvet
2
- VERSION = '0.2.2'
2
+ VERSION = '0.3.0'
3
3
  end
@@ -9,9 +9,15 @@ $unran: #ce8b8c
9
9
  $ran: #bed2be
10
10
 
11
11
  // Main
12
+ html
13
+ margin: 0
14
+ padding: 0
15
+ width: 100%
16
+
12
17
  body
13
18
  background: #f4f2ed
14
19
  font: 12px/1.3em Helvetica
20
+ margin: 8px
15
21
 
16
22
  a
17
23
  text-decoration: none
@@ -20,6 +26,7 @@ a
20
26
  // Header
21
27
  header
22
28
  margin: 2em .5em
29
+ text-shadow: 0 1px 0 rgba(255, 255, 255, .5)
23
30
 
24
31
  h1, h1 a
25
32
  color: $dark-grey
@@ -33,13 +40,18 @@ header
33
40
  position: absolute
34
41
  top: 20px
35
42
  right: 8px
36
- border: 1px solid black
37
- background: #eee
38
- -webkit-border-radius: 5px
39
- padding: 3px
43
+ border: 1px solid rgb(120, 120, 120)
44
+ background: rgb(240, 240, 240)
45
+ -webkit-border-radius: 3px
46
+ -webkit-box-shadow: inset 0 2px 4px rgba(0, 0, 0, .1), 0 1px 0 white
47
+ -webkit-transition: all .2s
48
+ padding: 4px
49
+ width: 180px
40
50
 
41
51
  &:focus
42
- border: 1px solid transparent
52
+ outline: none
53
+ background: rgb(244, 244, 244)
54
+ border: 1px solid rgb(100, 100, 100)
43
55
 
44
56
 
45
57
  // Table
@@ -48,10 +60,11 @@ header
48
60
 
49
61
  table
50
62
  border: 1px solid grey
51
- background: $light-grey
63
+ background: $excluded
52
64
  border-collapse: collapse
53
65
  width: 100%
54
66
  margin-bottom: 1em
67
+ -webkit-box-shadow: 0 1px 0 white
55
68
 
56
69
  table.source, pre, code
57
70
  font: 11px/1.2em Menlo
@@ -76,6 +89,9 @@ td pre
76
89
  thead
77
90
  background: $dark-grey
78
91
  color: $light-grey
92
+
93
+ th
94
+ cursor: pointer
79
95
 
80
96
  tr
81
97
  text-align: left
@@ -98,7 +114,7 @@ td pre
98
114
 
99
115
  // Totals
100
116
  .totals
101
- border-top: 1px solid black
117
+ border-top: 1px solid grey
102
118
  background: darken($excluded, 10%)
103
119
  font-weight: bold
104
120
 
@@ -154,6 +170,7 @@ td pre
154
170
  // Footer
155
171
  footer
156
172
  color: rgba(0, 0, 0, .6)
173
+ text-shadow: 0 1px 0 rgba(255, 255, 255, .5)
157
174
 
158
175
  a
159
176
  color: rgb(0, 0, 0)
@@ -44,6 +44,8 @@
44
44
  %pre
45
45
  %code
46
46
  #{line}
47
+
48
+ %td
47
49
 
48
50
  - else
49
51
  %tr{:class => (count.zero? ? "unran" : "ran") }
@@ -54,13 +56,13 @@
54
56
  %code
55
57
  #{line}
56
58
 
57
- %td
58
- %span{:class => "count"}= count
59
+ %td
60
+ %span{:class => "count"}= count
59
61
 
60
62
 
61
63
 
62
64
  %footer
63
65
  %span
64
- Generated on #{time} with
66
+ Generated at #{time} with
65
67
  %a{:href => "http://github.com/hawx/duvet"}= "#{name} #{version}"
66
68
 
@@ -12,7 +12,7 @@
12
12
  %header
13
13
  %h1 Coverage
14
14
 
15
- %input{:id => "filter", :name => "filter", :type => "text", :placeholder => "Filter"}
15
+ %input{:id => "filter", :name => "filter", :type => "text", :placeholder => "Filter..."}
16
16
 
17
17
  .table-wrapper
18
18
  %table{:class => "summary sort", :border => "none"}
@@ -48,6 +48,6 @@
48
48
 
49
49
  %footer
50
50
  %span
51
- Generated on #{time} with
51
+ Generated at #{time} with
52
52
  %a{:href => "http://github.com/hawx/duvet"}= "#{name} #{version}"
53
53
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: duvet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,12 +9,12 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-04-16 00:00:00.000000000 +01:00
12
+ date: 2011-04-22 00:00:00.000000000 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: haml
17
- requirement: &2153122340 !ruby/object:Gem::Requirement
17
+ requirement: &2153468120 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ~>
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: 3.0.25
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *2153122340
25
+ version_requirements: *2153468120
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: thoughtbot-shoulda
28
- requirement: &2153121880 !ruby/object:Gem::Requirement
28
+ requirement: &2153467660 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,7 +33,7 @@ dependencies:
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
- version_requirements: *2153121880
36
+ version_requirements: *2153467660
37
37
  description: ! " A simple code coverage tool for Ruby 1.9. Add 'Duvet.start' to
38
38
  the top\n of your test helper, to have it write code coverage stuff to 'cov/'.\n"
39
39
  email: m@hawx.me
@@ -44,9 +44,10 @@ files:
44
44
  - README.md
45
45
  - Rakefile
46
46
  - LICENSE
47
+ - lib/duvet/core_ext.rb
47
48
  - lib/duvet/cov.rb
48
49
  - lib/duvet/covs.rb
49
- - lib/duvet/ext.rb
50
+ - lib/duvet/test_helper.rb
50
51
  - lib/duvet/version.rb
51
52
  - lib/duvet.rb
52
53
  - templates/css/dark.sass