nakajima-protocov 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,9 @@
1
+ === 0.0.3 / 2008-05-21 ===
2
+
3
+ * Bug fixes
4
+
5
+ * Fixed bug that didn't see tests in unit subdirectory, which caused missed method invocations.
6
+
1
7
  === 0.0.2 / 2008-05-21 ===
2
8
 
3
9
  * Initial release
data/Rakefile CHANGED
@@ -7,8 +7,6 @@ require './lib/protocov.rb'
7
7
  Hoe.new('protocov', ProtoCov::VERSION) do |p|
8
8
  # p.rubyforge_name = 'protocovx' # if different than lowercase project name
9
9
  p.developer('Pat Nakajima', 'patnakajima@gmail.com')
10
- p.description = 'Code coverage docs for Prototype-style Javascript projects'
11
- p.homepage = 'http://github.com/nakajima/protocov'
12
10
  end
13
11
 
14
12
  # vim: syntax=Ruby
@@ -9,6 +9,6 @@ require 'protocov/source_file'
9
9
  require 'protocov/runner'
10
10
 
11
11
  module ProtoCov
12
- VERSION = '0.0.2'
12
+ VERSION = '0.0.3'
13
13
  end
14
14
 
@@ -12,14 +12,6 @@ module ProtoCov
12
12
 
13
13
  # Parent class of SourceFile and TestFile. Defines common methods.
14
14
  class GenericFile
15
- class << self
16
- def find_files_in(dir)
17
- dir.entries \
18
- .select { |file| valid?(file) } \
19
- .collect { |file| new(file, File.expand_path(dir.path)) }
20
- end
21
- end
22
-
23
15
  def path
24
16
  File.expand_path(File.join(path_prefix, filename))
25
17
  end
@@ -11,7 +11,7 @@ module ProtoCov
11
11
  string.gsub!(/\bvar\b/, '')
12
12
  result = case thing
13
13
  when :method_definitions: self.scan(/(\w+)\s*:\s*function\s*\(|[A-Z][A-Za-z0-9]*\.prototype\.(\w+)/i)
14
- when :method_invocations: self.scan(/\.([a-zA-Z\_*]\w*)\(/)
14
+ when :method_invocations: self.scan(/\.(\w+)\(/)
15
15
  when :modules: self.scan(/\s*[^\/{2}]*\s+([A-Z][A-Za-z0-9]+)\s*[\=\:]\s*\{/)
16
16
  when :classes: self.scan(/\s*([A-Z][A-Za-z0-9]+)\s*[\=\:]\s*Class\.create/)
17
17
  else
@@ -4,16 +4,16 @@ module ProtoCov
4
4
 
5
5
  def initialize(args)
6
6
  parse_args(args)
7
- get_files
7
+ get_files!
8
8
  @source_files.invoke(:annotate!) and return if @annotate
9
9
  report!
10
10
  end
11
11
 
12
12
  # This could definitely be smarter
13
- def get_files
13
+ def get_files!
14
14
  @source_files = SourceFile.find_files_in(Dir.new(File.join(@dir.path, 'src')))
15
15
  @test_files = TestFile.find_files_in(Dir.new(File.join(@dir.path, 'test')))
16
- @test_files += TestFile.find_files_in(Dir.new(File.join(@dir.path, 'test', 'unit'))) if @dir.entries.include?('unit')
16
+ @test_files += TestFile.find_files_in(Dir.new(File.join(@dir.path, 'test', 'unit'))) if Dir.new(File.join(@dir.path, 'test')).entries.detect { |e| e.match(/unit/) }
17
17
  end
18
18
 
19
19
  # Holy cow this method is ugly.
@@ -48,7 +48,7 @@ module ProtoCov
48
48
  args = args.dup
49
49
  raise NoPathSpecified.new("Please specify your project's root directory, e.g. `protocov .") if args.empty?
50
50
  @annotate = args.delete('--annotate') ? true : false
51
- @dir = Dir.new(File.join(Dir.pwd, args.shift))
51
+ @dir = Dir.new(File.expand_path(File.join(Dir.pwd, args.shift)))
52
52
 
53
53
  rescue Errno::ENOENT => e
54
54
  d = e.to_s.match(/src/) ? 'src/' : 'test/'
@@ -3,6 +3,12 @@ module ProtoCov
3
3
  attr_reader :filename, :path_prefix
4
4
 
5
5
  class << self
6
+ def find_files_in(dir)
7
+ dir.entries \
8
+ .select { |file| valid?(file) } \
9
+ .collect { |file| new(file, File.expand_path(dir.path)) }
10
+ end
11
+
6
12
  def valid?(file)
7
13
  file.match(/\.js\z/)
8
14
  end
@@ -3,8 +3,14 @@ module ProtoCov
3
3
  attr_reader :filename, :path_prefix
4
4
 
5
5
  class << self
6
+ def find_files_in(dir)
7
+ dir.entries \
8
+ .select { |file| valid?(file) } \
9
+ .collect { |file| new(file, File.expand_path(dir.path)) }
10
+ end
11
+
6
12
  def valid?(file)
7
- file.match(/\.(html|js)\z/)
13
+ file.match(/\.(html|js)/i)
8
14
  end
9
15
  end
10
16
 
@@ -16,10 +16,30 @@ class TestStringExtensions < Test::Unit::TestCase
16
16
 
17
17
  def test_should_get_method_invocations
18
18
  method_invocations = @_test_string_2.parse_for(:method_invocations)
19
- assert_equal 10, method_invocations.length
20
- %w(any bindAsEventListener blank clear element findForms setup setupBehaviors stop uniq).each do |method|
21
- assert method_invocations.include?(method)
22
- end
19
+ assert_equal [
20
+ "Defaultable",
21
+ "addClassName",
22
+ "any",
23
+ "bindAsEventListener",
24
+ "blank",
25
+ "clear",
26
+ "create",
27
+ "delegators",
28
+ "each",
29
+ "element",
30
+ "extend",
31
+ "findForms",
32
+ "invoke",
33
+ "observe",
34
+ "pluck",
35
+ "readAttribute",
36
+ "removeClassName",
37
+ "select",
38
+ "setup",
39
+ "setupBehaviors",
40
+ "stop",
41
+ "uniq"
42
+ ].sort, method_invocations.sort, method_invocations.inspect
23
43
  end
24
44
 
25
45
  def test_should_get_modules
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nakajima-protocov
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pat Nakajima
@@ -73,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
73
  version:
74
74
  requirements: []
75
75
 
76
- rubyforge_project:
76
+ rubyforge_project: protocov
77
77
  rubygems_version: 1.0.1
78
78
  signing_key:
79
79
  specification_version: 2