inch 0.3.1 → 0.3.2.rc1

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.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +8 -0
  3. data/config/defaults.rb +5 -0
  4. data/config/example.yml +6 -0
  5. data/lib/inch/cli/command/base_list.rb +2 -1
  6. data/lib/inch/code_object/provider.rb +2 -2
  7. data/lib/inch/code_object/provider/yard.rb +3 -3
  8. data/lib/inch/code_object/provider/yard/parser.rb +7 -6
  9. data/lib/inch/codebase.rb +5 -4
  10. data/lib/inch/codebase/proxy.rb +7 -4
  11. data/lib/inch/config.rb +9 -38
  12. data/lib/inch/config/base.rb +52 -0
  13. data/lib/inch/config/codebase.rb +66 -0
  14. data/lib/inch/version.rb +1 -1
  15. data/test/fixtures/inch-yml/.inch.yml +7 -0
  16. data/test/fixtures/inch-yml/foo/bar.rb +6 -0
  17. data/test/fixtures/inch-yml/foo/vendor/base.rb +6 -0
  18. data/test/{inch → integration}/cli/command/list_test.rb +0 -0
  19. data/test/{inch → integration}/cli/command/show_test.rb +0 -0
  20. data/test/{inch → integration}/cli/command/stats_test.rb +0 -0
  21. data/test/{inch → integration}/cli/command/suggest_test.rb +0 -0
  22. data/test/test_helper.rb +22 -0
  23. data/test/{inch → unit}/api/filter_test.rb +1 -2
  24. data/test/{inch → unit}/api/get_test.rb +1 -2
  25. data/test/{inch → unit}/api/list_test.rb +1 -2
  26. data/test/{inch → unit}/api/options/base_test.rb +0 -0
  27. data/test/{inch → unit}/api/stats_test.rb +1 -2
  28. data/test/{inch → unit}/api/suggest_test.rb +1 -2
  29. data/test/{inch → unit}/cli/arguments_test.rb +0 -0
  30. data/test/{inch → unit}/cli/command/base_test.rb +0 -0
  31. data/test/{inch → unit}/cli/command/options/base_list_test.rb +0 -0
  32. data/test/{inch → unit}/cli/command/options/base_object_test.rb +0 -0
  33. data/test/{inch → unit}/cli/command/options/base_test.rb +0 -0
  34. data/test/{inch → unit}/cli/command_parser_test.rb +0 -0
  35. data/test/{inch → unit}/cli/trace_helper_test.rb +0 -0
  36. data/test/{inch → unit}/cli/yardopts_helper_test.rb +0 -0
  37. data/test/{inch → unit}/code_object/converter_test.rb +0 -0
  38. data/test/{inch → unit}/code_object/provider/yard/docstring_test.rb +0 -0
  39. data/test/{inch → unit}/code_object/provider/yard/nodoc_helper_test.rb +1 -1
  40. data/test/{inch → unit}/code_object/provider/yard_test.rb +1 -1
  41. data/test/{inch → unit}/code_object/provider_test.rb +1 -1
  42. data/test/{inch → unit}/code_object/proxy/method_object_test.rb +33 -33
  43. data/test/{inch → unit}/code_object/proxy_test.rb +10 -10
  44. data/test/{inch → unit}/codebase/objects_test.rb +1 -3
  45. data/test/{inch → unit}/codebase/proxy_test.rb +5 -5
  46. data/test/unit/config/codebase_test.rb +19 -0
  47. data/test/{inch → unit}/evaluation/role/base_test.rb +0 -0
  48. data/test/{inch → unit}/utils/ui_test.rb +0 -0
  49. data/test/{inch → unit}/utils/weighted_list_test.rb +0 -0
  50. metadata +76 -65
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 65ac531a061df93776377170f9aabc79c4773c50
4
- data.tar.gz: eddc74ab9d1125cdb78d6880c1211650d906c7c1
3
+ metadata.gz: f173292eed0fa894560c5a2d899349d3e62bb55c
4
+ data.tar.gz: 2d52a21c83eccb32e43803d5b16f849700108037
5
5
  SHA512:
6
- metadata.gz: ebfaa638825acfc574fe1fab5e981ce72d0a19a179d5f5d80e3eeadf7abc4fb8a0b81b7521e8247d140c41bf344b5347a53ba2e1a7a76a69bb123b7a5669f00e
7
- data.tar.gz: b6a6112f4657649d9a03c78d93fe26d785b3962ed50f732bc006640abfe138aa2818ba6517a7e806d94bea0ea060b016c6909f3ff564fde9a7c1f3b87fe1f58e
6
+ metadata.gz: 3c98ae65f4e3e3cd4c2daea064da62c6580e5c4fa8b4b6fab4b5dff86dc2049a1f488e6a3d03fdb2ca5118041b5c2c76970ce7b366d44316b57d5fc5bb8872b2
7
+ data.tar.gz: b56177359ca54a305518c5cf367465a3c771afffad6ffb5f1e12c5e2ceb1c1b8972dc50097ad02bc41f2a92128b12525716d1b17e8192a211aff30d5cbd10a10
data/Rakefile CHANGED
@@ -6,4 +6,12 @@ Rake::TestTask.new do |t|
6
6
  t.pattern = "test/**/*_test.rb"
7
7
  end
8
8
 
9
+ Rake::TestTask.new(:"test:unit") do |t|
10
+ t.pattern = "test/unit/**/*_test.rb"
11
+ end
12
+
13
+ Rake::TestTask.new(:"test:integration") do |t|
14
+ t.pattern = "test/integration/**/*_test.rb"
15
+ end
16
+
9
17
  task :default => :test
data/config/defaults.rb CHANGED
@@ -1,6 +1,11 @@
1
1
  Inch::Config.run do
2
2
  # development!
3
3
 
4
+ codebase do
5
+ include_files ["lib/**/*.rb", "app/**/*.rb"]
6
+ exclude_files []
7
+ end
8
+
4
9
  evaluation do
5
10
  grade(:A) do
6
11
  scores 80..100
@@ -0,0 +1,6 @@
1
+ files:
2
+ included:
3
+ - lib/**/*.rb
4
+ - app/**/*.rb
5
+ excluded:
6
+ - lib/vendor/**/*.rb
@@ -21,7 +21,8 @@ module Inch
21
21
  @options.parse(args)
22
22
  @options.verify
23
23
 
24
- @codebase = ::Inch::Codebase.parse(Dir.pwd, @options.paths, @options.excluded)
24
+ config = Config::Codebase.new(@options.paths, @options.excluded)
25
+ @codebase = ::Inch::Codebase.parse(Dir.pwd, config)
25
26
  end
26
27
  end
27
28
  end
@@ -21,8 +21,8 @@ module Inch
21
21
  #
22
22
  #
23
23
  module Provider
24
- def self.parse(dir, paths, excluded, type = :YARD)
25
- provider_for(type).parse(dir, paths, excluded)
24
+ def self.parse(dir, config = Inch::Config.codebase, type = :YARD)
25
+ provider_for(type).parse(dir, config)
26
26
  end
27
27
 
28
28
  # @return [Module]
@@ -4,8 +4,8 @@ module Inch
4
4
  # Parses the source tree (using YARD)
5
5
  module YARD
6
6
 
7
- def self.parse(dir, paths, excluded)
8
- Parser.parse(dir, paths, excluded)
7
+ def self.parse(dir, config = Inch::Config.codebase)
8
+ Parser.parse(dir, config)
9
9
  end
10
10
 
11
11
  end
@@ -21,4 +21,4 @@ log.level = ::Logger::UNKNOWN # basically disable YARD's logging
21
21
  require_relative 'yard/parser'
22
22
  require_relative 'yard/docstring'
23
23
  require_relative 'yard/nodoc_helper'
24
- require_relative 'yard/object'
24
+ require_relative 'yard/object'
@@ -4,9 +4,6 @@ module Inch
4
4
  module YARD
5
5
  # Parses the source tree (using YARD)
6
6
  class Parser
7
- DEFAULT_PATHS = ["app/**/*.rb", "lib/**/*.rb"]
8
- DEFAULT_EXCLUDED = []
9
-
10
7
  IGNORE_TYPES = [:macro]
11
8
 
12
9
  # Helper method to parse an instance with the given +args+
@@ -19,14 +16,18 @@ module Inch
19
16
  parser
20
17
  end
21
18
 
22
- def parse(dir, paths, excluded)
19
+ # @param dir [String] directory
20
+ # @param config [Inch::Config::Codebase] configuration for codebase
21
+ # @return [void]
22
+ def parse(dir, config)
23
23
  old_dir = Dir.pwd
24
24
  Dir.chdir dir
25
- parse_yard_objects(paths, excluded)
25
+ parse_yard_objects(config.included_files, config.excluded_files)
26
26
  inject_base_dir(dir)
27
27
  Dir.chdir old_dir
28
28
  end
29
29
 
30
+ # @return [Array<YARD::Object::Base>]
30
31
  def objects
31
32
  @objects ||= parsed_objects.map do |o|
32
33
  YARD::Object.for(o) unless IGNORE_TYPES.include?(o.type)
@@ -37,7 +38,7 @@ module Inch
37
38
 
38
39
  def parse_yard_objects(paths, excluded)
39
40
  ::YARD::Registry.clear
40
- ::YARD.parse(paths || DEFAULT_PATHS, excluded || DEFAULT_EXCLUDED)
41
+ ::YARD.parse(paths, excluded)
41
42
  end
42
43
 
43
44
  def inject_base_dir(dir)
data/lib/inch/codebase.rb CHANGED
@@ -5,11 +5,12 @@ module Inch
5
5
  # Parses a codebase
6
6
  #
7
7
  # @param dir [String]
8
- # @param paths [Array<String>]
9
- # @param excluded [Array<String>]
8
+ # @param config [Inch::Config::Codebase,nil]
10
9
  # @return [Codebase::Proxy]
11
- def self.parse(dir, paths = nil, excluded = nil)
12
- Proxy.new(dir, paths, excluded)
10
+ def self.parse(dir, config = nil)
11
+ config ||= Config.codebase.clone
12
+ config.update_via_yaml(dir)
13
+ Proxy.parse(dir, config)
13
14
  end
14
15
  end
15
16
  end
@@ -3,9 +3,7 @@ module Inch
3
3
  class Proxy
4
4
  attr_reader :objects
5
5
 
6
- def initialize(dir = Dir.pwd, paths = nil, excluded = nil)
7
- @base_dir = dir
8
- provider = CodeObject::Provider.parse(dir, paths, excluded)
6
+ def initialize(provider)
9
7
  @objects = Codebase::Objects.new(provider.objects)
10
8
  end
11
9
 
@@ -17,6 +15,11 @@ module Inch
17
15
  end
18
16
  lists
19
17
  end
18
+
19
+ def self.parse(dir = Dir.pwd, config = Inch::Config.codebase)
20
+ provider = CodeObject::Provider.parse(dir, config)
21
+ new(provider)
22
+ end
20
23
  end
21
24
  end
22
- end
25
+ end
data/lib/inch/config.rb CHANGED
@@ -6,48 +6,19 @@ module Inch
6
6
  class << self
7
7
  attr_accessor :instance
8
8
 
9
+ def codebase
10
+ self.instance ||= Config::Base.new
11
+ instance.codebase
12
+ end
13
+
9
14
  def run(&block)
10
- self.instance ||= new
15
+ self.instance ||= Config::Base.new
11
16
  instance.update(&block)
12
17
  instance
13
18
  end
14
19
  end
15
-
16
- def update(&block)
17
- instance_eval(&block)
18
- end
19
-
20
- def development?
21
- @development
22
- end
23
-
24
- def development!
25
- @development = true
26
- end
27
-
28
- def evaluation(&block)
29
- @evaluation ||= Evaluation.new
30
- @evaluation.update(&block) if block
31
- @evaluation
32
- end
33
-
34
- class Evaluation
35
- def update(&block)
36
- instance_eval(&block)
37
- end
38
-
39
- def grade(symbol, &block)
40
- ::Inch::Evaluation::Grade.grade(symbol, &block)
41
- end
42
-
43
- def priority(symbol, &block)
44
- ::Inch::Evaluation::PriorityRange.priority_range(symbol, &block)
45
- end
46
-
47
- def schema(constant_name, &block)
48
- constant = ::Inch::Evaluation::Proxy.const_get(constant_name)
49
- constant.criteria(&block)
50
- end
51
- end
52
20
  end
53
21
  end
22
+
23
+ require_relative 'config/base'
24
+ require_relative 'config/codebase'
@@ -0,0 +1,52 @@
1
+ module Inch
2
+ # Stores the configuration for Inch
3
+ #
4
+ # @see config/defaults.rb
5
+ class Config
6
+ class Base
7
+
8
+ def update(&block)
9
+ instance_eval(&block)
10
+ end
11
+
12
+ def development?
13
+ @development
14
+ end
15
+
16
+ def development!
17
+ @development = true
18
+ end
19
+
20
+ def codebase(&block)
21
+ @codebase ||= Config::Codebase.new
22
+ @codebase.update(&block) if block
23
+ @codebase
24
+ end
25
+
26
+ def evaluation(&block)
27
+ @evaluation ||= Evaluation.new
28
+ @evaluation.update(&block) if block
29
+ @evaluation
30
+ end
31
+
32
+ class Evaluation
33
+ def update(&block)
34
+ instance_eval(&block)
35
+ end
36
+
37
+ def grade(symbol, &block)
38
+ ::Inch::Evaluation::Grade.grade(symbol, &block)
39
+ end
40
+
41
+ def priority(symbol, &block)
42
+ ::Inch::Evaluation::PriorityRange.priority_range(symbol, &block)
43
+ end
44
+
45
+ def schema(constant_name, &block)
46
+ constant = ::Inch::Evaluation::Proxy.const_get(constant_name)
47
+ constant.criteria(&block)
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,66 @@
1
+ module Inch
2
+ class Config
3
+ # Stores the configuration for an individual single codebase
4
+ class Codebase
5
+ attr_reader :included_files
6
+ attr_reader :excluded_files
7
+
8
+ YAML_FILE = ".inch.yml"
9
+
10
+ def initialize(included = nil, excluded = nil)
11
+ @included_files = included || []
12
+ @excluded_files = excluded || []
13
+ end
14
+
15
+ # Returns the contents of +dir+/.inch.yml, if present.
16
+ # Returns nil otherwise.
17
+ #
18
+ # @param dir [String]
19
+ # @return [Hash,nil]
20
+ def self.yaml(dir)
21
+ yaml_file = File.join(dir, YAML_FILE)
22
+ YAML.load(File.read(yaml_file)) if File.exist?(yaml_file)
23
+ end
24
+
25
+ def update(&block)
26
+ instance_eval(&block)
27
+ end
28
+
29
+ def update_via_yaml(dir)
30
+ if yaml = self.class.yaml(dir)
31
+ old_dir = Dir.pwd
32
+ Dir.chdir dir
33
+ update_files yaml["files"]
34
+ Dir.chdir old_dir
35
+ end
36
+ end
37
+
38
+ def include_files(*files)
39
+ @included_files.concat(files).flatten!
40
+ end
41
+
42
+ def exclude_files(*files)
43
+ @excluded_files.concat(files).flatten!
44
+ end
45
+
46
+ private
47
+
48
+ def expand_files(files)
49
+ files.map do |f|
50
+ case f
51
+ when String
52
+ f =~ /[\*\{]/ ? Dir[f] : f
53
+ else
54
+ f
55
+ end
56
+ end.flatten
57
+ end
58
+
59
+ def update_files(files)
60
+ return if files.nil?
61
+ include_files expand_files(files["included"])
62
+ exclude_files expand_files(files["excluded"])
63
+ end
64
+ end
65
+ end
66
+ end
data/lib/inch/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Inch
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2.rc1"
3
3
  end
@@ -0,0 +1,7 @@
1
+ files:
2
+ included:
3
+ - foo/**/*.rb
4
+ excluded:
5
+ - foo/vendor/**/*.rb
6
+ # or
7
+ - !ruby/regexp /vendor/
@@ -0,0 +1,6 @@
1
+ class Foo
2
+ class Bar
3
+ def initialize
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Vendor
2
+ class Base
3
+ def initialize
4
+ end
5
+ end
6
+ end
File without changes
File without changes
data/test/test_helper.rb CHANGED
@@ -10,3 +10,25 @@ require 'inch'
10
10
  def fixture_path(name)
11
11
  File.join(File.dirname(__FILE__), "fixtures", name.to_s)
12
12
  end
13
+
14
+ module Inch
15
+ module Test
16
+ class << self
17
+ attr_accessor :object_providers
18
+
19
+ def codebase(name)
20
+ Inch::Codebase::Proxy.new object_provider(name)
21
+ end
22
+
23
+ def object_provider(name)
24
+ self.object_providers ||= {}
25
+ self.object_providers[name] ||= ::Inch::CodeObject::Provider.parse(fixture_path(name))
26
+ end
27
+ end
28
+ end
29
+ end
30
+
31
+ def test_codebase(name)
32
+ codebase = Inch::Test.codebase(name)
33
+ codebase
34
+ end
@@ -2,8 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
2
2
 
3
3
  describe ::Inch::API::Filter do
4
4
  before do
5
- @dir = fixture_path(:simple)
6
- @codebase = ::Inch::Codebase.parse(@dir)
5
+ @codebase = test_codebase(:simple)
7
6
  end
8
7
 
9
8
  it "should work" do
@@ -2,8 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
2
2
 
3
3
  describe ::Inch::API::Get do
4
4
  before do
5
- @dir = fixture_path(:simple)
6
- @codebase = ::Inch::Codebase.parse(@dir)
5
+ @codebase = test_codebase(:simple)
7
6
  end
8
7
 
9
8
  it "should work" do
@@ -2,8 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
2
2
 
3
3
  describe ::Inch::API::List do
4
4
  before do
5
- @dir = fixture_path(:simple)
6
- @codebase = ::Inch::Codebase.parse(@dir)
5
+ @codebase = test_codebase(:simple)
7
6
  end
8
7
 
9
8
  it "should work" do
File without changes
@@ -2,8 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
2
2
 
3
3
  describe ::Inch::API::Stats do
4
4
  before do
5
- @dir = fixture_path(:simple)
6
- @codebase = ::Inch::Codebase.parse(@dir)
5
+ @codebase = test_codebase(:simple)
7
6
  end
8
7
 
9
8
  it "should work" do
@@ -2,8 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
2
2
 
3
3
  describe ::Inch::API::Suggest do
4
4
  before do
5
- @dir = fixture_path(:simple)
6
- @codebase = ::Inch::Codebase.parse(@dir)
5
+ @codebase = test_codebase(:simple)
7
6
  end
8
7
 
9
8
  it "should work" do
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../../test_helper')
2
2
 
3
3
  describe ::Inch::CodeObject::Provider::YARD::NodocHelper do
4
4
  before do
5
- @provider = ::Inch::CodeObject::Provider::YARD.parse(fixture_path(:simple), ["lib/**/*.rb"], [])
5
+ @provider = ::Inch::CodeObject::Provider::YARD.parse(fixture_path(:simple))
6
6
  @objects = @provider.objects
7
7
  end
8
8
 
@@ -4,7 +4,7 @@ describe ::Inch::CodeObject::Provider::YARD do
4
4
  let(:described_class) { ::Inch::CodeObject::Provider::YARD }
5
5
 
6
6
  it "should parse" do
7
- provider = described_class.parse(fixture_path(:simple), ["lib/**/*.rb"], [])
7
+ provider = described_class.parse(fixture_path(:simple))
8
8
  assert !provider.objects.empty?
9
9
  end
10
10
 
@@ -3,7 +3,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
3
3
  describe ::Inch::CodeObject::Provider do
4
4
  it "should parse all objects" do
5
5
  Dir.chdir File.dirname(__FILE__)
6
- @provider = ::Inch::CodeObject::Provider.parse(fixture_path(:simple), ["lib/**/*.rb"], [])
6
+ @provider = ::Inch::CodeObject::Provider.parse(fixture_path(:simple))
7
7
  refute @provider.objects.empty?
8
8
  end
9
9
  end
@@ -2,24 +2,24 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../test_helper')
2
2
 
3
3
  describe ::Inch::CodeObject::Proxy::MethodObject do
4
4
  before do
5
- Dir.chdir fixture_path(:simple)
6
- @codebase = Inch::Codebase.parse(fixture_path(:simple), ["lib/**/*.rb"])
5
+ @codebase = test_codebase(:simple)
6
+ @objects = @codebase.objects
7
7
  end
8
8
 
9
9
  def test_transitive_tags_dont_matter
10
- m = @codebase.objects.find("InchTest::Deprecated::ClassMethods")
10
+ m = @objects.find("InchTest::Deprecated::ClassMethods")
11
11
  assert_equal 0, m.score
12
12
  assert m.undocumented?
13
13
  end
14
14
 
15
15
  def test_raising_method_with_comment
16
- m = @codebase.objects.find("InchTest#raising_method_with_comment")
16
+ m = @objects.find("InchTest#raising_method_with_comment")
17
17
  assert m.score > 0
18
18
  refute m.undocumented?
19
19
  end
20
20
 
21
21
  def test_raising_method
22
- m = @codebase.objects.find("InchTest#raising_method")
22
+ m = @objects.find("InchTest#raising_method")
23
23
  assert_equal 0, m.score
24
24
  assert m.undocumented?
25
25
  end
@@ -27,7 +27,7 @@ describe ::Inch::CodeObject::Proxy::MethodObject do
27
27
  def test_tagged_as_private
28
28
  %w( InchTest#method_with_private_tag
29
29
  InchTest#private_method_with_tomdoc).each do |fullname|
30
- m = @codebase.objects.find(fullname)
30
+ m = @objects.find(fullname)
31
31
  assert m.tagged_as_private?
32
32
  end
33
33
  end
@@ -35,13 +35,13 @@ describe ::Inch::CodeObject::Proxy::MethodObject do
35
35
  def test_tagged_as_internal_api
36
36
  %w( InchTest#private_api_with_yard
37
37
  InchTest#internal_api_with_tomdoc).each do |fullname|
38
- m = @codebase.objects.find(fullname)
38
+ m = @objects.find(fullname)
39
39
  assert m.tagged_as_internal_api?
40
40
  end
41
41
  end
42
42
 
43
43
  def test_method_without_doc
44
- m = @codebase.objects.find("Foo::Bar#method_without_doc")
44
+ m = @objects.find("Foo::Bar#method_without_doc")
45
45
  refute m.has_doc?
46
46
  refute m.has_parameters?
47
47
  refute m.return_mentioned?
@@ -51,7 +51,7 @@ describe ::Inch::CodeObject::Proxy::MethodObject do
51
51
  end
52
52
 
53
53
  def test_method_with_missing_param_doc
54
- m = @codebase.objects.find("Foo::Bar#method_with_missing_param_doc")
54
+ m = @objects.find("Foo::Bar#method_with_missing_param_doc")
55
55
  assert m.has_doc?
56
56
  assert m.has_parameters?
57
57
  assert m.return_mentioned?
@@ -68,7 +68,7 @@ describe ::Inch::CodeObject::Proxy::MethodObject do
68
68
  end
69
69
 
70
70
  def test_method_with_wrong_doc
71
- m = @codebase.objects.find("Foo::Bar#method_with_wrong_doc")
71
+ m = @objects.find("Foo::Bar#method_with_wrong_doc")
72
72
  assert m.has_doc?
73
73
  assert m.has_parameters?
74
74
  assert m.return_mentioned?
@@ -91,7 +91,7 @@ describe ::Inch::CodeObject::Proxy::MethodObject do
91
91
  end
92
92
 
93
93
  def test_method_with_full_doc
94
- m = @codebase.objects.find("Foo::Bar#method_with_full_doc")
94
+ m = @objects.find("Foo::Bar#method_with_full_doc")
95
95
  assert m.has_doc?
96
96
  assert m.has_parameters?
97
97
  assert m.return_mentioned?
@@ -108,7 +108,7 @@ describe ::Inch::CodeObject::Proxy::MethodObject do
108
108
  end
109
109
 
110
110
  def test_method_without_params_or_return_type
111
- m = @codebase.objects.find("Foo::Bar#method_without_params_or_return_type")
111
+ m = @objects.find("Foo::Bar#method_without_params_or_return_type")
112
112
  assert m.has_doc?
113
113
  refute m.has_parameters?
114
114
  refute m.return_mentioned?
@@ -117,7 +117,7 @@ describe ::Inch::CodeObject::Proxy::MethodObject do
117
117
  end
118
118
 
119
119
  def test_method_without_docstring
120
- m = @codebase.objects.find("Foo::Bar#method_without_docstring")
120
+ m = @objects.find("Foo::Bar#method_without_docstring")
121
121
  refute m.has_doc?
122
122
  assert m.has_parameters?
123
123
  assert m.return_mentioned?
@@ -126,7 +126,7 @@ describe ::Inch::CodeObject::Proxy::MethodObject do
126
126
  end
127
127
 
128
128
  def test_method_without_params_or_docstring
129
- m = @codebase.objects.find("Foo::Bar#method_without_params_or_docstring")
129
+ m = @objects.find("Foo::Bar#method_without_params_or_docstring")
130
130
  refute m.has_doc?
131
131
  refute m.has_parameters?
132
132
  assert m.return_mentioned?
@@ -135,7 +135,7 @@ describe ::Inch::CodeObject::Proxy::MethodObject do
135
135
  end
136
136
 
137
137
  def test_method_with_rdoc_doc
138
- m = @codebase.objects.find("Foo::Bar#method_with_rdoc_doc")
138
+ m = @objects.find("Foo::Bar#method_with_rdoc_doc")
139
139
  assert m.has_doc?
140
140
  assert m.has_parameters?
141
141
  p = m.parameter(:param1)
@@ -146,7 +146,7 @@ describe ::Inch::CodeObject::Proxy::MethodObject do
146
146
  end
147
147
 
148
148
  def test_method_with_other_rdoc_doc
149
- m = @codebase.objects.find("Foo::Bar#method_with_other_rdoc_doc")
149
+ m = @objects.find("Foo::Bar#method_with_other_rdoc_doc")
150
150
  assert m.has_doc?
151
151
  assert m.has_parameters?
152
152
  p = m.parameter(:param1)
@@ -161,7 +161,7 @@ describe ::Inch::CodeObject::Proxy::MethodObject do
161
161
  end
162
162
 
163
163
  def test_method_with_unstructured_doc
164
- m = @codebase.objects.find("Foo::Bar#method_with_unstructured_doc")
164
+ m = @objects.find("Foo::Bar#method_with_unstructured_doc")
165
165
  assert m.has_doc?
166
166
  assert m.has_parameters?
167
167
  p = m.parameter(:param1)
@@ -172,7 +172,7 @@ describe ::Inch::CodeObject::Proxy::MethodObject do
172
172
  end
173
173
 
174
174
  def test_method_with_unstructured_doc_missing_params
175
- m = @codebase.objects.find("Foo::Bar#method_with_unstructured_doc_missing_params")
175
+ m = @objects.find("Foo::Bar#method_with_unstructured_doc_missing_params")
176
176
  assert m.has_doc?
177
177
  assert m.has_parameters?
178
178
  p = m.parameter(:format)
@@ -183,7 +183,7 @@ describe ::Inch::CodeObject::Proxy::MethodObject do
183
183
  end
184
184
 
185
185
  def test_question_mark_method
186
- m = @codebase.objects.find("InchTest#question_mark_method?")
186
+ m = @objects.find("InchTest#question_mark_method?")
187
187
  refute m.has_doc?
188
188
  refute m.has_parameters?
189
189
 
@@ -191,7 +191,7 @@ describe ::Inch::CodeObject::Proxy::MethodObject do
191
191
  end
192
192
 
193
193
  def test_question_mark_method_with_description
194
- m = @codebase.objects.find("InchTest#question_mark_method_with_description?")
194
+ m = @objects.find("InchTest#question_mark_method_with_description?")
195
195
  refute m.has_doc?
196
196
  refute m.has_parameters?
197
197
 
@@ -200,7 +200,7 @@ describe ::Inch::CodeObject::Proxy::MethodObject do
200
200
  end
201
201
 
202
202
  def test_method_with_description_and_parameters
203
- m = @codebase.objects.find("InchTest#method_with_description_and_parameters?")
203
+ m = @objects.find("InchTest#method_with_description_and_parameters?")
204
204
  refute m.has_doc?
205
205
  assert m.has_parameters?
206
206
 
@@ -208,59 +208,59 @@ describe ::Inch::CodeObject::Proxy::MethodObject do
208
208
  end
209
209
 
210
210
  def test_depth
211
- m = @codebase.objects.find("#root_method")
211
+ m = @objects.find("#root_method")
212
212
  assert_equal 1, m.depth
213
- m = @codebase.objects.find("InchTest#getter")
213
+ m = @objects.find("InchTest#getter")
214
214
  assert_equal 2, m.depth
215
- m = @codebase.objects.find("Foo::Bar#method_without_doc")
215
+ m = @objects.find("Foo::Bar#method_without_doc")
216
216
  assert_equal 3, m.depth
217
217
  end
218
218
 
219
219
  def test_getter
220
- m = @codebase.objects.find("InchTest#getter")
220
+ m = @objects.find("InchTest#getter")
221
221
  assert m.getter?, "should be a getter"
222
222
  refute m.setter?
223
223
  end
224
224
 
225
225
  def test_setter
226
- m = @codebase.objects.find("InchTest#attr_setter=")
226
+ m = @objects.find("InchTest#attr_setter=")
227
227
  refute m.getter?
228
228
  assert m.setter?, "should be a setter"
229
229
  end
230
230
 
231
231
  def test_setter2
232
- m = @codebase.objects.find("InchTest#manual_setter=")
232
+ m = @objects.find("InchTest#manual_setter=")
233
233
  refute m.getter?
234
234
  assert m.setter?, "should be a setter"
235
235
  end
236
236
 
237
237
  def test_manual_getset
238
- m = @codebase.objects.find("InchTest#manual_getset")
238
+ m = @objects.find("InchTest#manual_getset")
239
239
  assert m.getter?, "should be a getter"
240
240
  refute m.setter?
241
241
  end
242
242
 
243
243
  def test_manual_getset2
244
- m = @codebase.objects.find("InchTest#manual_getset=")
244
+ m = @objects.find("InchTest#manual_getset=")
245
245
  refute m.getter?
246
246
  assert m.setter?, "should be a setter"
247
247
  end
248
248
 
249
249
  def test_attr_getset
250
- m = @codebase.objects.find("InchTest#attr_getset")
250
+ m = @objects.find("InchTest#attr_getset")
251
251
  assert m.getter?, "should be a getter"
252
252
  refute m.setter?
253
253
  end
254
254
 
255
255
  def test_attr_getset2
256
- m = @codebase.objects.find("InchTest#attr_getset=")
256
+ m = @objects.find("InchTest#attr_getset=")
257
257
  refute m.getter?
258
258
  assert m.setter?, "should be a setter"
259
259
  end
260
260
 
261
261
  def test_splat_parameter_notation
262
- m1 = @codebase.objects.find("Foo#method_with_splat_parameter")
263
- m2 = @codebase.objects.find("Foo#method_with_splat_parameter2")
262
+ m1 = @objects.find("Foo#method_with_splat_parameter")
263
+ m2 = @objects.find("Foo#method_with_splat_parameter2")
264
264
  assert_equal m1.score, m2.score
265
265
  end
266
266
  end
@@ -2,48 +2,48 @@ require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
2
2
 
3
3
  describe ::Inch::CodeObject::Proxy::Base do
4
4
  before do
5
- dir = fixture_path(:code_examples)
6
- @codebase = Inch::Codebase.parse(dir, ["lib/**/*.rb"])
5
+ @codebase = test_codebase(:code_examples)
6
+ @objects = @codebase.objects
7
7
  end
8
8
 
9
9
  def test_inspect_gives_original_name
10
- m = @codebase.objects.find("Foo::Bar#method_with_code_example")
10
+ m = @objects.find("Foo::Bar#method_with_code_example")
11
11
  assert_match /Foo::Bar#method_with_code_example/, m.inspect
12
12
  end
13
13
 
14
14
  def test_grade_is_not_nil
15
- m = @codebase.objects.find("Foo::Bar#method_with_code_example")
15
+ m = @objects.find("Foo::Bar#method_with_code_example")
16
16
  assert m.grade
17
17
  end
18
18
 
19
19
  def test_method_with_code_example
20
- m = @codebase.objects.find("Foo::Bar#method_with_code_example")
20
+ m = @objects.find("Foo::Bar#method_with_code_example")
21
21
  assert m.has_code_example?
22
22
  end
23
23
 
24
24
  def test_method_with_code_example2
25
- m = @codebase.objects.find("Foo::Bar#method_with_code_example2")
25
+ m = @objects.find("Foo::Bar#method_with_code_example2")
26
26
  assert m.has_code_example?
27
27
  end
28
28
 
29
29
  def test_method_with_code_examples
30
- m = @codebase.objects.find("Foo::Bar#method_with_one_example")
30
+ m = @objects.find("Foo::Bar#method_with_one_example")
31
31
  assert m.has_code_example?
32
32
  refute m.has_multiple_code_examples?
33
33
  end
34
34
 
35
35
  def test_method_with_code_examples
36
- m = @codebase.objects.find("Foo::Bar#method_with_examples")
36
+ m = @objects.find("Foo::Bar#method_with_examples")
37
37
  assert m.has_multiple_code_examples?
38
38
  end
39
39
 
40
40
  def test_method_with_code_examples
41
- m = @codebase.objects.find("Foo::Bar#method_with_tagged_example")
41
+ m = @objects.find("Foo::Bar#method_with_tagged_example")
42
42
  assert m.has_multiple_code_examples?
43
43
  end
44
44
 
45
45
  def test_method_with_code_examples
46
- m = @codebase.objects.find("Foo::Bar#method_with_2tagged_examples")
46
+ m = @objects.find("Foo::Bar#method_with_2tagged_examples")
47
47
  assert m.has_multiple_code_examples?
48
48
  end
49
49
  end
@@ -2,9 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
2
2
 
3
3
  describe ::Inch::Codebase::Objects do
4
4
  before do
5
- dir = fixture_path(:simple)
6
- paths = ["lib/**/*.rb"]
7
- @codebase = Inch::Codebase::Proxy.new dir, paths
5
+ @codebase = test_codebase(:simple)
8
6
  @objects = @codebase.objects
9
7
  end
10
8
 
@@ -3,15 +3,15 @@ require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
3
3
  describe ::Inch::Codebase::Proxy do
4
4
  it "should parse all objects" do
5
5
  dir = fixture_path(:simple)
6
- paths = ["lib/**/*.rb"]
7
- @codebase = Inch::Codebase::Proxy.new dir, paths
6
+ config = Inch::Config::Codebase.new(["lib/**/*.rb"])
7
+ @codebase = Inch::Codebase::Proxy.parse dir, config
8
8
  refute_nil @codebase.objects
9
9
  end
10
10
 
11
- it "should parse all objects" do
11
+ it "should parse given paths" do
12
12
  dir = fixture_path(:simple)
13
- paths = ["app/**/*.rb"]
14
- @codebase = Inch::Codebase::Proxy.new dir, paths
13
+ config = Inch::Config::Codebase.new(["app/**/*.rb"])
14
+ @codebase = Inch::Codebase::Proxy.parse dir, config
15
15
  assert @codebase.objects.empty?
16
16
  end
17
17
  end
@@ -0,0 +1,19 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
2
+
3
+ describe ::Inch::Config::Codebase do
4
+ it "should parse .inch.yml" do
5
+ dir = fixture_path(:simple)
6
+ config = Inch::Config::Codebase.new
7
+ config.update_via_yaml(dir)
8
+ assert config.included_files.empty?
9
+ assert config.excluded_files.empty?
10
+ end
11
+
12
+ it "should parse .inch.yml" do
13
+ dir = fixture_path(:"inch-yml")
14
+ config = Inch::Config::Codebase.new
15
+ config.update_via_yaml(dir)
16
+ refute config.included_files.empty?
17
+ refute config.excluded_files.empty?
18
+ end
19
+ end
File without changes
File without changes
File without changes
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - René Föhring
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-28 00:00:00.000000000 Z
11
+ date: 2014-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -128,6 +128,7 @@ files:
128
128
  - TODOS.md
129
129
  - bin/inch
130
130
  - config/defaults.rb
131
+ - config/example.yml
131
132
  - inch.gemspec
132
133
  - lib/inch.rb
133
134
  - lib/inch/api.rb
@@ -194,6 +195,8 @@ files:
194
195
  - lib/inch/codebase/objects_filter.rb
195
196
  - lib/inch/codebase/proxy.rb
196
197
  - lib/inch/config.rb
198
+ - lib/inch/config/base.rb
199
+ - lib/inch/config/codebase.rb
197
200
  - lib/inch/core_ext.rb
198
201
  - lib/inch/core_ext/string.rb
199
202
  - lib/inch/evaluation.rb
@@ -223,6 +226,9 @@ files:
223
226
  - lib/inch/utils/weighted_list.rb
224
227
  - lib/inch/version.rb
225
228
  - test/fixtures/code_examples/lib/foo.rb
229
+ - test/fixtures/inch-yml/.inch.yml
230
+ - test/fixtures/inch-yml/foo/bar.rb
231
+ - test/fixtures/inch-yml/foo/vendor/base.rb
226
232
  - test/fixtures/parameters/lib/foo.rb
227
233
  - test/fixtures/readme/lib/foo.rb
228
234
  - test/fixtures/really_good/lib/foo.rb
@@ -236,40 +242,41 @@ files:
236
242
  - test/fixtures/visibility/lib/foo.rb
237
243
  - test/fixtures/yardopts/.yardopts
238
244
  - test/fixtures/yardopts/foo/bar.rb
239
- - test/inch/api/filter_test.rb
240
- - test/inch/api/get_test.rb
241
- - test/inch/api/list_test.rb
242
- - test/inch/api/options/base_test.rb
243
- - test/inch/api/stats_test.rb
244
- - test/inch/api/suggest_test.rb
245
- - test/inch/cli/arguments_test.rb
246
- - test/inch/cli/command/base_test.rb
247
- - test/inch/cli/command/list_test.rb
248
- - test/inch/cli/command/options/base_list_test.rb
249
- - test/inch/cli/command/options/base_object_test.rb
250
- - test/inch/cli/command/options/base_test.rb
251
- - test/inch/cli/command/show_test.rb
252
- - test/inch/cli/command/stats_test.rb
253
- - test/inch/cli/command/suggest_test.rb
254
- - test/inch/cli/command_parser_test.rb
255
- - test/inch/cli/trace_helper_test.rb
256
- - test/inch/cli/yardopts_helper_test.rb
257
- - test/inch/code_object/converter_test.rb
258
- - test/inch/code_object/provider/yard/docstring_test.rb
259
- - test/inch/code_object/provider/yard/nodoc_helper_test.rb
260
- - test/inch/code_object/provider/yard_test.rb
261
- - test/inch/code_object/provider_test.rb
262
- - test/inch/code_object/proxy/method_object_test.rb
263
- - test/inch/code_object/proxy_test.rb
264
- - test/inch/codebase/objects_test.rb
265
- - test/inch/codebase/proxy_test.rb
266
- - test/inch/evaluation/role/base_test.rb
267
- - test/inch/utils/ui_test.rb
268
- - test/inch/utils/weighted_list_test.rb
245
+ - test/integration/cli/command/list_test.rb
246
+ - test/integration/cli/command/show_test.rb
247
+ - test/integration/cli/command/stats_test.rb
248
+ - test/integration/cli/command/suggest_test.rb
269
249
  - test/integration/stats_options_test.rb
270
250
  - test/integration/visibility_options_test.rb
271
251
  - test/shared/base_list.rb
272
252
  - test/test_helper.rb
253
+ - test/unit/api/filter_test.rb
254
+ - test/unit/api/get_test.rb
255
+ - test/unit/api/list_test.rb
256
+ - test/unit/api/options/base_test.rb
257
+ - test/unit/api/stats_test.rb
258
+ - test/unit/api/suggest_test.rb
259
+ - test/unit/cli/arguments_test.rb
260
+ - test/unit/cli/command/base_test.rb
261
+ - test/unit/cli/command/options/base_list_test.rb
262
+ - test/unit/cli/command/options/base_object_test.rb
263
+ - test/unit/cli/command/options/base_test.rb
264
+ - test/unit/cli/command_parser_test.rb
265
+ - test/unit/cli/trace_helper_test.rb
266
+ - test/unit/cli/yardopts_helper_test.rb
267
+ - test/unit/code_object/converter_test.rb
268
+ - test/unit/code_object/provider/yard/docstring_test.rb
269
+ - test/unit/code_object/provider/yard/nodoc_helper_test.rb
270
+ - test/unit/code_object/provider/yard_test.rb
271
+ - test/unit/code_object/provider_test.rb
272
+ - test/unit/code_object/proxy/method_object_test.rb
273
+ - test/unit/code_object/proxy_test.rb
274
+ - test/unit/codebase/objects_test.rb
275
+ - test/unit/codebase/proxy_test.rb
276
+ - test/unit/config/codebase_test.rb
277
+ - test/unit/evaluation/role/base_test.rb
278
+ - test/unit/utils/ui_test.rb
279
+ - test/unit/utils/weighted_list_test.rb
273
280
  homepage: http://trivelop.de/inch/
274
281
  licenses:
275
282
  - MIT
@@ -285,17 +292,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
285
292
  version: '0'
286
293
  required_rubygems_version: !ruby/object:Gem::Requirement
287
294
  requirements:
288
- - - ">="
295
+ - - ">"
289
296
  - !ruby/object:Gem::Version
290
- version: '0'
297
+ version: 1.3.1
291
298
  requirements: []
292
299
  rubyforge_project:
293
- rubygems_version: 2.2.0
300
+ rubygems_version: 2.2.2
294
301
  signing_key:
295
302
  specification_version: 4
296
303
  summary: Documentation measurement tool for Ruby
297
304
  test_files:
298
305
  - test/fixtures/code_examples/lib/foo.rb
306
+ - test/fixtures/inch-yml/.inch.yml
307
+ - test/fixtures/inch-yml/foo/bar.rb
308
+ - test/fixtures/inch-yml/foo/vendor/base.rb
299
309
  - test/fixtures/parameters/lib/foo.rb
300
310
  - test/fixtures/readme/lib/foo.rb
301
311
  - test/fixtures/really_good/lib/foo.rb
@@ -309,38 +319,39 @@ test_files:
309
319
  - test/fixtures/visibility/lib/foo.rb
310
320
  - test/fixtures/yardopts/.yardopts
311
321
  - test/fixtures/yardopts/foo/bar.rb
312
- - test/inch/api/filter_test.rb
313
- - test/inch/api/get_test.rb
314
- - test/inch/api/list_test.rb
315
- - test/inch/api/options/base_test.rb
316
- - test/inch/api/stats_test.rb
317
- - test/inch/api/suggest_test.rb
318
- - test/inch/cli/arguments_test.rb
319
- - test/inch/cli/command/base_test.rb
320
- - test/inch/cli/command/list_test.rb
321
- - test/inch/cli/command/options/base_list_test.rb
322
- - test/inch/cli/command/options/base_object_test.rb
323
- - test/inch/cli/command/options/base_test.rb
324
- - test/inch/cli/command/show_test.rb
325
- - test/inch/cli/command/stats_test.rb
326
- - test/inch/cli/command/suggest_test.rb
327
- - test/inch/cli/command_parser_test.rb
328
- - test/inch/cli/trace_helper_test.rb
329
- - test/inch/cli/yardopts_helper_test.rb
330
- - test/inch/code_object/converter_test.rb
331
- - test/inch/code_object/provider/yard/docstring_test.rb
332
- - test/inch/code_object/provider/yard/nodoc_helper_test.rb
333
- - test/inch/code_object/provider/yard_test.rb
334
- - test/inch/code_object/provider_test.rb
335
- - test/inch/code_object/proxy/method_object_test.rb
336
- - test/inch/code_object/proxy_test.rb
337
- - test/inch/codebase/objects_test.rb
338
- - test/inch/codebase/proxy_test.rb
339
- - test/inch/evaluation/role/base_test.rb
340
- - test/inch/utils/ui_test.rb
341
- - test/inch/utils/weighted_list_test.rb
322
+ - test/integration/cli/command/list_test.rb
323
+ - test/integration/cli/command/show_test.rb
324
+ - test/integration/cli/command/stats_test.rb
325
+ - test/integration/cli/command/suggest_test.rb
342
326
  - test/integration/stats_options_test.rb
343
327
  - test/integration/visibility_options_test.rb
344
328
  - test/shared/base_list.rb
345
329
  - test/test_helper.rb
330
+ - test/unit/api/filter_test.rb
331
+ - test/unit/api/get_test.rb
332
+ - test/unit/api/list_test.rb
333
+ - test/unit/api/options/base_test.rb
334
+ - test/unit/api/stats_test.rb
335
+ - test/unit/api/suggest_test.rb
336
+ - test/unit/cli/arguments_test.rb
337
+ - test/unit/cli/command/base_test.rb
338
+ - test/unit/cli/command/options/base_list_test.rb
339
+ - test/unit/cli/command/options/base_object_test.rb
340
+ - test/unit/cli/command/options/base_test.rb
341
+ - test/unit/cli/command_parser_test.rb
342
+ - test/unit/cli/trace_helper_test.rb
343
+ - test/unit/cli/yardopts_helper_test.rb
344
+ - test/unit/code_object/converter_test.rb
345
+ - test/unit/code_object/provider/yard/docstring_test.rb
346
+ - test/unit/code_object/provider/yard/nodoc_helper_test.rb
347
+ - test/unit/code_object/provider/yard_test.rb
348
+ - test/unit/code_object/provider_test.rb
349
+ - test/unit/code_object/proxy/method_object_test.rb
350
+ - test/unit/code_object/proxy_test.rb
351
+ - test/unit/codebase/objects_test.rb
352
+ - test/unit/codebase/proxy_test.rb
353
+ - test/unit/config/codebase_test.rb
354
+ - test/unit/evaluation/role/base_test.rb
355
+ - test/unit/utils/ui_test.rb
356
+ - test/unit/utils/weighted_list_test.rb
346
357
  has_rdoc: