coco 0.8 → 0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 3e417f05d79b2e611dceda9c526600d5a327e440
4
- data.tar.gz: a78c5a379014dd5e2b6aee98eda621f9377dbf18
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NTg5MjFhOTYwMDMxYWE4YzNkMzc2YjdjN2EyOGZjMWE4MmE0NDNiMQ==
5
+ data.tar.gz: !binary |-
6
+ ODNkODRiOWU0ZTgwNWIzNjA1MDU0M2U4NWE0MTYyZmNjYWE1ZmRkYg==
5
7
  SHA512:
6
- metadata.gz: df9305b624eb92c01202cafece504f88db6823e1748e7b279330c0600ea2bd7290bdaf165472c426415f4c235d492e46ce04403a8169ba98d0326270599c0537
7
- data.tar.gz: 7ebd0be73e14fb5bc5be32fca2478e031aa888b2e5355436010fc48025b105ad81c18f813dc92b57204c7ec7793f969ca8a201f656a63d3f6fb46313fdc76e29
8
+ metadata.gz: !binary |-
9
+ ZjhmMGFiNGJkYWM3Zjc4NjE4NWQzZTBiY2M1NjhlMmI5MjEwOGY5MDg4NWE2
10
+ YTM5N2IxNjY2MzBiNTE4MTNmNDEwMGMwZDJhNjVjNDY0MjI4ZTk1ODAwYzZl
11
+ Njc1OGVjZmU2YmQ5MGRmMDhjNjhmODQ4MDJiZGU0NGNmMzMzZDA=
12
+ data.tar.gz: !binary |-
13
+ MDVkNTcyOTA4NjkzN2JjNTlkZjFiMjIyNTMzOGVkN2JlMDQ2MGM1ZjBkN2M1
14
+ MTAwMmM2NmZhMmJjYTQ5Yzg4MTkwODY3NjZkYTllMDY1MjkxODc4MWE5ZGYz
15
+ NmFiZWFkNzU1MDAxNTBjNjk4ZTgzOWNiODA1NTVhNGRmNDdmMTE=
@@ -1,3 +1,15 @@
1
+ v0.9 (2014-02-02)
2
+ =================================================
3
+
4
+ * New configuration option: `always_run`, to control when to start coco
5
+ and when to not start it.
6
+ + ajouter link dans le terminal
7
+ * New configuration option: `show_link_in_terminal`, to display the
8
+ report's index page URI in the terminal.
9
+ * Partially converts developer's documentation in tomdoc format.
10
+ * Update gemspec for ruby version 2.1
11
+
12
+
1
13
  v0.8 (2013-12-21)
2
14
  =================================================
3
15
 
data/Gemfile CHANGED
@@ -2,5 +2,5 @@ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
- gem 'rake'
5
+ gem 'rake', '>= 10.1.0'
6
6
  gem 'rspec'
@@ -1,13 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- coco (0.8)
4
+ coco (0.9)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
9
  diff-lcs (1.2.4)
10
- rake (10.0.4)
10
+ rake (10.1.1)
11
11
  rspec (2.13.0)
12
12
  rspec-core (~> 2.13.0)
13
13
  rspec-expectations (~> 2.13.0)
@@ -22,5 +22,5 @@ PLATFORMS
22
22
 
23
23
  DEPENDENCIES
24
24
  coco!
25
- rake
25
+ rake (>= 10.1.0)
26
26
  rspec
@@ -1,7 +1,7 @@
1
1
  coco [![Build Status](https://travis-ci.org/lkdjiin/coco.png)](https://travis-ci.org/lkdjiin/coco) [![Gem Version](https://badge.fury.io/rb/coco.png)](http://badge.fury.io/rb/coco)
2
2
  ==============================
3
3
 
4
- Code coverage tool for ruby 1.9.2, 1.9.3 and 2.0.
4
+ Code coverage tool for ruby 1.9.2, 1.9.3, 2.0 and 2.1.
5
5
 
6
6
  Features
7
7
  --------------------------------
@@ -82,6 +82,62 @@ to not put any leading spaces or tab at all._
82
82
 
83
83
  See [more examples](https://github.com/lkdjiin/coco/wiki) on the wiki.
84
84
 
85
+ Advanced configuration
86
+ ---------------------------------
87
+
88
+ ### When to start coco, and when not to start it
89
+ For projects whose complete test suite runs in a matter of seconds,
90
+ running code coverage with every test is fine.
91
+ But when the test suite takes longer to complete, we typically start to
92
+ run a single test more often than the complete suite. In such cases,
93
+ the behavior of **coco** could be really annoying: you run a single
94
+ test and **coco** reports a infinite list of uncovered files. The
95
+ problem here is this is a lie. To avoid this behavior, I recommend to
96
+ run code coverage only from time to time, and with the entire test
97
+ suite. To do so, **coco** provide the following configuration key:
98
+
99
+ __always_run__: If true, **coco** will run every time you start a test.
100
+ If false, **coco** will run only when you explicitly set an
101
+ environement variable named `COCO` with something other than `false`,
102
+ `0` or the empty string.
103
+
104
+ #### Example
105
+
106
+ Put this in your `.coco.yml` configuration file:
107
+
108
+ :always_run: false
109
+
110
+ Now, when you run:
111
+
112
+ rspec spec/
113
+
114
+ **coco** will no start. To start it, you have to set the
115
+ environement variable `COCO`, like this:
116
+
117
+ COCO=1 rspec spec/
118
+
119
+ ### Index page URI in your terminal
120
+
121
+ If your terminal supports opening an URI with a double-clic (or any
122
+ other method), you may want to display the URI of the report's index
123
+ page. For that, you have to set the __show_link_in_terminal__ key.
124
+
125
+ #### Example
126
+
127
+ Put this in your `.coco.yml` configuration file:
128
+
129
+ :show_link_in_terminal: true
130
+
131
+ Now, when running tests, you will see something like the following:
132
+
133
+ $ rspec spec
134
+ .............
135
+ [...]
136
+
137
+ 97% /path/to/bad/tested/file.rb
138
+ See file:///path/to/your/coverage/index.html
139
+
140
+
85
141
  Dependencies
86
142
  --------------------------------
87
143
 
data/TODO CHANGED
@@ -1,3 +1,18 @@
1
+ + option pour lancer coco si présence d'une variable d'environement
2
+ + doc dev
3
+ + doc readme & examples (maybe wiki ?)
4
+ + manual tests
5
+
6
+ + update gemspec -> add ruby version 2.1
7
+
8
+ + ajouter link dans le terminal
9
+ + option on/off
10
+ + doc readme
11
+
12
+ - add 'How to contribute' section
13
+
14
+ - translate dev's doc into tomdoc format.
15
+
1
16
  en gras: def, class, module
2
17
 
3
18
  exclure spec et test par défaut
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.8
1
+ 0.9
@@ -17,17 +17,21 @@ Coverage.start
17
17
 
18
18
  at_exit do
19
19
  config = Coco::Configuration.new
20
- result = Coco::CoverageResult.new(config, Coverage.result)
21
- covered = result.covered_from_domain
22
-
23
- sources = Coco::SourceLister.new(config).list
24
- uncovered = Coco::UncoveredLister.new(sources, result.all_from_domain).list
25
-
26
- puts Coco::ConsoleFormatter.new(covered, uncovered).format(config[:single_line_report])
27
-
28
- html_files = Coco::HtmlFormatter.new(covered).format
29
- Coco::HtmlFilesWriter.new(html_files).write
30
-
31
- index = Coco::HtmlIndexFormatter.new(covered, uncovered).format
32
- Coco::HtmlIndexWriter.new(index).write
20
+ if config.user_wants_to_run?
21
+ result = Coco::CoverageResult.new(config, Coverage.result)
22
+ covered = result.covered_from_domain
23
+
24
+ sources = Coco::SourceLister.new(config).list
25
+ uncovered = Coco::UncoveredLister.new(sources, result.all_from_domain).list
26
+
27
+ cf = Coco::ConsoleFormatter.new(covered, uncovered)
28
+ puts cf.format(config[:single_line_report])
29
+ puts cf.link if config[:show_link_in_terminal]
30
+
31
+ html_files = Coco::HtmlFormatter.new(covered).format
32
+ Coco::HtmlFilesWriter.new(html_files).write
33
+
34
+ index = Coco::HtmlIndexFormatter.new(covered, uncovered).format
35
+ Coco::HtmlIndexWriter.new(index).write
36
+ end
33
37
  end
@@ -4,31 +4,35 @@ require 'yaml'
4
4
 
5
5
  module Coco
6
6
 
7
- # I know the configuration of coco.
7
+ # Public: I know the configuration of coco.
8
+ # You can override the default configuration by putting a '.coco.yml'
9
+ # file in YAML format in the project root directory.
8
10
  #
9
- # @example read the threshold value
11
+ # Examples
12
+ #
13
+ # # Read the threshold value
10
14
  # config = Configuration.new
11
15
  # config[:threshold]
12
- # => 90
16
+ # # => 100
13
17
  #
14
- # You can override the default configuration by putting a '.coco' file
15
- # in YAML format in the project root directory.
16
- # @example to override the threshold put this line in a '.coco' file:
17
- # :threshold: 70
18
+ # # To override the threshold, put this line in '.coco.yml' file:
19
+ # # :threshold: 70
18
20
  #
19
- # @note You can set the threshold above 100% (to be sure to see all files) but you
20
- # cannot set it under 0.
21
+ # Note you can set the threshold above 100% (to be sure to see all
22
+ # files) but you cannot set it under 0.
21
23
  class Configuration < Hash
22
-
24
+
25
+ # Public: Initialize a Configuration.
23
26
  def initialize
24
27
  self[:threshold] = 100
25
28
  self[:directories] = ['lib']
26
29
  self[:excludes] = []
27
30
  self[:single_line_report] = false
31
+ self[:always_run] = true
32
+ self[:show_link_in_terminal] = false
28
33
  if File.exist?('.coco.yml')
29
34
  self.merge!(YAML.load_file('.coco.yml'))
30
- # Deprecated: Support of '.coco' file will be remove in a future
31
- # version.
35
+ # Deprecated: Support of '.coco' file will be removed in v1.0.
32
36
  elsif File.exist?('.coco')
33
37
  self.merge!(YAML.load_file('.coco'))
34
38
  end
@@ -37,19 +41,39 @@ module Coco
37
41
  expand_directories
38
42
  remove_directories
39
43
  end
40
-
44
+
45
+ # Public: Code coverage not have to run with every test/spec runs.
46
+ #
47
+ # Here are the rules:
48
+ # If the configuration key :always_run is set to true, we always
49
+ # run the coverage.
50
+ # In case the configuration key :always_run is set to false, we have
51
+ # to check for an environement variable named 'COCO' to decide if
52
+ # we launch the coverage or not. When 'COCO' doesn't exist, or is
53
+ # the empty string, or '0', or 'false', we don't run coverage.
54
+ # When 'COCO' is set to any other value, we start coverage.
55
+ #
56
+ # Returns true if coverage should start.
57
+ def user_wants_to_run?
58
+ if self[:always_run]
59
+ true
60
+ else
61
+ ![nil, '', '0', 'false'].include?(ENV['COCO'])
62
+ end
63
+ end
64
+
41
65
  private
42
-
66
+
43
67
  def expand_directories
44
68
  self[:excludes].each do |file_or_dir|
45
69
  add_files file_or_dir if File.directory?(file_or_dir)
46
70
  end
47
71
  end
48
-
72
+
49
73
  def add_files dir
50
74
  Helpers.rb_files_from(dir).each {|file| self[:excludes] << file }
51
75
  end
52
-
76
+
53
77
  def remove_directories
54
78
  self[:excludes].delete_if {|file_or_dir| File.directory?(file_or_dir)}
55
79
  end
@@ -57,7 +81,7 @@ module Coco
57
81
  def ensure_threeshold_compatibility
58
82
  self[:threshold] = self[:threeshold] unless self[:threeshold].nil?
59
83
  end
60
-
84
+
61
85
  end
62
-
86
+
63
87
  end
@@ -2,17 +2,24 @@
2
2
 
3
3
  module Coco
4
4
 
5
- # Compute results of interest from the big results information (from Coverage.result)
5
+ # Compute results of interest from the big results information (from
6
+ # Coverage.result)
6
7
  class CoverageResult
7
- # @return [Hash] Coverage for all the sources that live in the root project folder.
8
+
9
+ # Returns a Hash coverage for all the sources that live in the root
10
+ # project folder.
8
11
  attr_reader :all_from_domain
9
- # @return [Hash] Coverage for sources that are not sufficiently covered.
10
- # More technically, the sources that live in the root project folder and for
11
- # which the coverage percentage is under the threshold.
12
+
13
+ # Returns a Hash coverage for sources that are not sufficiently
14
+ # covered. More technically, the sources that live in the root
15
+ # project folder and for which the coverage percentage is under the
16
+ # threshold.
12
17
  attr_reader :covered_from_domain
13
18
 
14
- # @param [Hash] config
15
- # @param [Hash] raw_results Results obtained from Coverage.result
19
+ # Public: Initialize a CoverageResult.
20
+ #
21
+ # config - Hash
22
+ # raw_results - Hash results obtained from Coverage.result.
16
23
  def initialize config, raw_results
17
24
  @exclude_files = config[:excludes]
18
25
  @threshold = config[:threshold]
@@ -8,7 +8,7 @@ module Coco
8
8
  # @param [Boolean] single_line_report
9
9
  #
10
10
  # return [string] percent covered and associated filenames
11
- def format single_line_report = false
11
+ def format(single_line_report = false)
12
12
  if single_line_report
13
13
  single_line_message
14
14
  else
@@ -16,6 +16,15 @@ module Coco
16
16
  end
17
17
  end
18
18
 
19
+ # Returns String.
20
+ def link
21
+ unless @formatted_output.empty?
22
+ "See file://" +
23
+ File.expand_path(File.join(Coco::HtmlDirectory.new.coverage_dir,
24
+ 'index.html'))
25
+ end
26
+ end
27
+
19
28
  # @param [Hash] covered
20
29
  # @param [Array] uncovered
21
30
  def initialize covered, uncovered
@@ -2,43 +2,59 @@
2
2
 
3
3
  module Coco
4
4
 
5
- # @todo The app is full of <tt>Dir.pwd</tt>. This is the root project directory
6
- # and must be in Configuration class (or Coco module ?).
5
+ # Public: Collection of application's helpers methods.
6
+ #
7
+ # TODO The app is full of `Dir.pwd`. This is the root project
8
+ # directory and must be in Configuration class (or Coco module ?).
7
9
  module Helpers
8
-
9
- # Get html filename (from a ruby filename) suitable for the coverage
10
- # directory.
11
- #
12
- # @example
13
- # ruby = '/home/user/my_project/lib/source.rb'
14
- # html = Helpers.rb2html(ruby)
15
- # => '_lib_source.rb.html'
16
- #
17
- # @param [String] name Ruby filename
18
- # @return [String] Html filename
19
- def Helpers.rb2html name
20
- name.sub(Dir.pwd, '').tr('/\\', '_') + '.html'
21
- end
22
-
23
- # @return [String] The title of the index.html file
24
- def Helpers.index_title
25
- project_name = File.basename(Dir.pwd)
26
- version = File.read(File.join($COCO_PATH, 'VERSION')).strip
27
- "#{project_name} - Code coverage (coco #{version})"
28
- end
29
-
30
- # @param [Array<String>] files List of filenames
31
- # @return [Array<String>]
32
- def Helpers.expand files
33
- files.map {|file| File.expand_path file}
34
- end
35
-
36
- # @return [Array<String>] The list of ruby source files from +directory+. Recursive.
37
- def Helpers.rb_files_from directory
38
- rb_files = File.join(directory, "**", "*.rb")
39
- Dir.glob(rb_files)
10
+ class << self
11
+
12
+ # Public: Get html filename (from a ruby filename) suitable for
13
+ # the coverage directory.
14
+ #
15
+ # name - String full path filename.
16
+ #
17
+ # Examples
18
+ #
19
+ # ruby = '/home/user/my_project/lib/source.rb'
20
+ # html = Helpers.rb2html(ruby)
21
+ # #=> '_lib_source.rb.html'
22
+ #
23
+ # Returns String HTML filename.
24
+ def rb2html name
25
+ name.sub(Dir.pwd, '').tr('/\\', '_') + '.html'
26
+ end
27
+
28
+ # Public: Get page title for the index.html file.
29
+ #
30
+ # Returns String.
31
+ def index_title
32
+ project_name = File.basename(Dir.pwd)
33
+ version = File.read(File.join($COCO_PATH, 'VERSION')).strip
34
+ "#{project_name} - Code coverage (coco #{version})"
35
+ end
36
+
37
+ # Public: Expands a bulk of filenames into full path filenames.
38
+ #
39
+ # files - List of filenames as an Array of String.
40
+ #
41
+ # Returns an Array of String.
42
+ def expand files
43
+ files.map {|file| File.expand_path file}
44
+ end
45
+
46
+ # Public: Get all ruby files from a directory, including
47
+ # sub-directories.
48
+ #
49
+ # directory - String directory to look into.
50
+ #
51
+ # Returns an Array of String.
52
+ def rb_files_from directory
53
+ rb_files = File.join(directory, "**", "*.rb")
54
+ Dir.glob(rb_files)
55
+ end
40
56
  end
41
-
57
+
42
58
  end
43
-
59
+
44
60
  end
metadata CHANGED
@@ -1,62 +1,66 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coco
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.8'
4
+ version: '0.9'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Xavier Nayrac
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-21 00:00:00.000000000 Z
11
+ date: 2014-02-02 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: |-
14
- "Code coverage tool for ruby 1.9.2 to 2.0.
15
- Use it by "require 'coco'" from rspec or unit/test.
13
+ description: ! '"Code coverage tool for ruby 1.9.2 to 2.1.
14
+
15
+ Use it by "require ''coco''" from rspec or unit/test.
16
+
16
17
  It display names of uncovered files on console.
18
+
17
19
  It builds simple html report.
20
+
18
21
  It reports sources that have no tests.
19
- It's configurable with a simple yaml file.
22
+
23
+ It''s configurable with a simple yaml file.'
20
24
  email: xavier.nayrac@gmail.com
21
25
  executables: []
22
26
  extensions: []
23
27
  extra_rdoc_files: []
24
28
  files:
25
29
  - lib/coco.rb
30
+ - lib/coco/writer.rb
31
+ - lib/coco/lister/uncovered_lister.rb
32
+ - lib/coco/lister/source_lister.rb
33
+ - lib/coco/lister.rb
26
34
  - lib/coco/configuration.rb
27
- - lib/coco/cover.rb
28
- - lib/coco/cover/coverage_result.rb
29
- - lib/coco/cover/coverage_stat.rb
30
- - lib/coco/formatter.rb
31
- - lib/coco/formatter/colored_string.rb
32
35
  - lib/coco/formatter/console_formatter.rb
36
+ - lib/coco/formatter/template.rb
33
37
  - lib/coco/formatter/context.rb
38
+ - lib/coco/formatter/colored_string.rb
39
+ - lib/coco/formatter/html_index_formatter.rb
34
40
  - lib/coco/formatter/formatter.rb
35
41
  - lib/coco/formatter/html_formatter.rb
36
- - lib/coco/formatter/html_index_formatter.rb
37
- - lib/coco/formatter/template.rb
42
+ - lib/coco/cover.rb
38
43
  - lib/coco/helpers.rb
39
- - lib/coco/lister.rb
40
- - lib/coco/lister/source_lister.rb
41
- - lib/coco/lister/uncovered_lister.rb
42
- - lib/coco/writer.rb
44
+ - lib/coco/cover/coverage_result.rb
45
+ - lib/coco/cover/coverage_stat.rb
43
46
  - lib/coco/writer/file_writer.rb
44
- - lib/coco/writer/html_directory.rb
45
47
  - lib/coco/writer/html_files_writer.rb
48
+ - lib/coco/writer/html_directory.rb
46
49
  - lib/coco/writer/html_index_writer.rb
47
- - template/css/coco.css
50
+ - lib/coco/formatter.rb
48
51
  - template/file.erb
49
- - template/img/coconut16.png
50
- - template/img/licenses
51
52
  - template/index.erb
53
+ - template/css/coco.css
54
+ - template/img/licenses
55
+ - template/img/coconut16.png
56
+ - VERSION
52
57
  - COPYING
58
+ - README.markdown
53
59
  - Changelog.markdown
54
60
  - Gemfile
55
- - Gemfile.lock
56
- - README.markdown
57
61
  - Rakefile
58
62
  - TODO
59
- - VERSION
63
+ - Gemfile.lock
60
64
  homepage: http://lkdjiin.github.com/coco/
61
65
  licenses:
62
66
  - GPL-3
@@ -67,12 +71,12 @@ require_paths:
67
71
  - lib
68
72
  required_ruby_version: !ruby/object:Gem::Requirement
69
73
  requirements:
70
- - - '>='
74
+ - - ! '>='
71
75
  - !ruby/object:Gem::Version
72
76
  version: 1.9.2
73
77
  required_rubygems_version: !ruby/object:Gem::Requirement
74
78
  requirements:
75
- - - '>='
79
+ - - ! '>='
76
80
  - !ruby/object:Gem::Version
77
81
  version: '0'
78
82
  requirements: []
@@ -80,5 +84,5 @@ rubyforge_project:
80
84
  rubygems_version: 2.1.11
81
85
  signing_key:
82
86
  specification_version: 4
83
- summary: Code coverage tool for ruby 1.9.2 to 2.0
87
+ summary: Code coverage tool for ruby 1.9.2 to 2.1
84
88
  test_files: []