inch 0.3.0.rc2 → 0.3.0.rc3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 046545a24888cdc2d037b07d709243a04baba11b
4
- data.tar.gz: 2ab6a0eafc028456a47f17df493fd54b1fab12ec
3
+ metadata.gz: 5b1114bf285aefdab3d5ce943131521fb16f30e7
4
+ data.tar.gz: 9a658e477c9b85e871361a609c69d7776c5a6acb
5
5
  SHA512:
6
- metadata.gz: 340b586066c472db633786ae08498716b6c8a2ae2d897baf9a333fec477872604d1176430d4f05f881a1f0beafc87566e6476bb8478be622c58e4c7919b25316
7
- data.tar.gz: ce72b2c5a035a68fb53839b31db58e2e6087e2cab9a5bbe140fcddd50307a040cc25ffbe4c9c88e19849a79770e0a5e5392233ac4bb119acc0965bad61b2a032
6
+ metadata.gz: a8f1cbeed106ce59753024ee7d283865dbd61b49e3b92d714822dafec40be16ee5d8932dee7d74ec4c62dea0641c477ff4f9da1ae971ad98a87d8240fbe3a762
7
+ data.tar.gz: 3880bab38166a913aa39a2d165bd273141143a537189f716947416f6e47cfd0efefc206b08796dcd0e41768b038e11a393d7e8001437e4d0230cdaaa56481455
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-2.0.0
1
+ ruby-2.1.0
data/TODOS.md CHANGED
@@ -5,3 +5,5 @@
5
5
  * --[no-]api API
6
6
  * Add support for multiple signatures for methods
7
7
  (realized via the @overload tag in YARD)
8
+
9
+ * Add message to `inch suggest` when no objects are found
@@ -73,7 +73,7 @@ module Inch
73
73
 
74
74
  def all_filenames(objects)
75
75
  codebase.objects.map do |o|
76
- o.files.map(&:first)
76
+ o.files.map(&:filename)
77
77
  end.flatten
78
78
  end
79
79
 
@@ -60,8 +60,9 @@ module Inch
60
60
  end
61
61
 
62
62
  def initialize
63
- options_class = "Command::Options::#{self.class.to_s.split('::').last}"
64
- @options = eval(options_class).new
63
+ name = self.class.to_s.split('::').last
64
+ options_class = Command::Options.const_get(name)
65
+ @options = options_class.new
65
66
  @options.usage = usage
66
67
  end
67
68
 
@@ -28,7 +28,7 @@ module Inch
28
28
 
29
29
  def print_file_info(o, _color)
30
30
  o.files.each do |f|
31
- echo "-> #{f[0]}:#{f[1]}".color(_color)
31
+ echo "-> #{f.filename}:#{f.line_no}".color(_color)
32
32
  end
33
33
  echo separator
34
34
  end
@@ -30,7 +30,7 @@ module Inch
30
30
  @files = files
31
31
 
32
32
  if objects.empty?
33
- # TODO: show hint
33
+ display_no_objects_hint
34
34
  else
35
35
  display_list
36
36
  display_files
@@ -40,6 +40,10 @@ module Inch
40
40
 
41
41
  private
42
42
 
43
+ def base_dir
44
+ "#{Dir.pwd}/"
45
+ end
46
+
43
47
  def display_distribution
44
48
  sparkline = grades_sparkline(@relevant_objects).to_s(' ')
45
49
  puts "Grade distribution (undocumented, C, B, A): " + sparkline
@@ -62,8 +66,9 @@ module Inch
62
66
  trace "You might want to look at these files:"
63
67
  trace
64
68
 
65
- files.each do |f|
66
- trace edged(FILE_COLOR, f.fullname.color(FILE_COLOR))
69
+ files.each do |file|
70
+ filename = file.fullname.gsub(base_dir, '')
71
+ trace edged(FILE_COLOR, filename.color(FILE_COLOR))
67
72
  end
68
73
  trace
69
74
  end
@@ -84,6 +89,15 @@ module Inch
84
89
  end
85
90
  end
86
91
 
92
+ def display_no_objects_hint
93
+ hint = if @options.pedantic
94
+ "Even by my standards."
95
+ else
96
+ "Try --pedantic to be excessively concerned with minor details and rules."
97
+ end
98
+ trace "Nothing to suggest.".color(:green) + " #{hint}"
99
+ end
100
+
87
101
  def min_priority_arrows
88
102
  priority_arrows_gte(@options.object_min_priority).join(' ')
89
103
  end
@@ -8,7 +8,7 @@ module Inch
8
8
  register_command_as :suggest, true
9
9
 
10
10
  def description
11
- 'Suggests some objects to be doucmented (better)'
11
+ 'Suggests some objects to be documented (better)'
12
12
  end
13
13
 
14
14
  def usage
@@ -70,14 +70,14 @@ module Inch
70
70
  attributes = {}
71
71
  OBJECT_ATTRIBUTES.each do |name|
72
72
  if o.respond_to?(name)
73
- attributes[name] = o.method(name).call
73
+ attributes[name] = o.public_send(name)
74
74
  end
75
75
  end
76
76
  attributes[:parameters] = o.parameters.map do |parameter|
77
77
  hash = {}
78
78
  PARAMETER_ATTRIBUTES.each do |pname|
79
79
  if parameter.respond_to?(pname)
80
- hash[pname] = parameter.method(pname).call
80
+ hash[pname] = parameter.public_send(pname)
81
81
  end
82
82
  end
83
83
  hash
@@ -27,7 +27,7 @@ module Inch
27
27
 
28
28
  # @return [Module]
29
29
  def self.provider_for(type)
30
- eval("::Inch::CodeObject::Provider::#{type}")
30
+ const_get(type)
31
31
  end
32
32
  end
33
33
  end
@@ -27,8 +27,8 @@ module Inch
27
27
  # @return [Class]
28
28
  def class_for(yard_object)
29
29
  class_name = yard_object.class.to_s.split('::').last
30
- eval("::Inch::CodeObject::Provider::YARD::Object::#{class_name}")
31
- rescue
30
+ const_get(class_name)
31
+ rescue NameError
32
32
  Base
33
33
  end
34
34
 
@@ -28,9 +28,7 @@ module Inch
28
28
  # @return [Class]
29
29
  def class_for(code_object)
30
30
  class_name = code_object.class.to_s.split('::').last
31
- eval("::Inch::CodeObject::Proxy::#{class_name}")
32
- rescue
33
- Base
31
+ const_get(class_name)
34
32
  end
35
33
 
36
34
  # Returns a cache key for the given +code_object+
@@ -21,6 +21,7 @@ module Inch
21
21
  proxy
22
22
  end
23
23
  @list = list
24
+ index_by_fullname
24
25
  # the @list has to be set for the priority sorting
25
26
  # since the priority needs the object_lookup, which
26
27
  # in turn depends on @list - it's a crazy world
@@ -45,7 +46,7 @@ module Inch
45
46
  # @param fullname [String] partial fullname/name of an object
46
47
  # @return [CodeObject::Proxy::Base]
47
48
  def find(fullname)
48
- all.detect { |o| o.fullname == fullname }
49
+ @by_fullname[fullname]
49
50
  end
50
51
 
51
52
  # Returns all objects where the +fullname+ starts_with the given
@@ -67,6 +68,15 @@ module Inch
67
68
  # @return [void]
68
69
  def filter!(options)
69
70
  @list = ObjectsFilter.new(all, options).objects
71
+ index_by_fullname
72
+ end
73
+
74
+ private
75
+
76
+ def index_by_fullname
77
+ @by_fullname = @list.map.with_object({}) do |object, index|
78
+ index[object.fullname] = object
79
+ end
70
80
  end
71
81
  end
72
82
  end
data/lib/inch/config.rb CHANGED
@@ -45,7 +45,7 @@ module Inch
45
45
  end
46
46
 
47
47
  def schema(constant_name, &block)
48
- constant = eval("::Inch::Evaluation::Proxy::#{constant_name}")
48
+ constant = ::Inch::Evaluation::Proxy.const_get(constant_name)
49
49
  constant.criteria(&block)
50
50
  end
51
51
  end
@@ -10,7 +10,7 @@ module Inch
10
10
 
11
11
  def self.class_for(code_object)
12
12
  class_name = code_object.class.to_s.split('::').last
13
- eval(class_name)
13
+ const_get(class_name)
14
14
  end
15
15
  end
16
16
  end
@@ -11,7 +11,7 @@ module Inch
11
11
 
12
12
  def self.class_for(code_object)
13
13
  class_name = code_object.class.to_s.split('::').last
14
- eval(class_name)
14
+ const_get(class_name)
15
15
  end
16
16
  end
17
17
  end
data/lib/inch/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Inch
2
- VERSION = "0.3.0.rc2"
2
+ VERSION = "0.3.0.rc3"
3
3
  end
@@ -0,0 +1,22 @@
1
+ # Foo is the classical name for a module
2
+ class Foo
3
+ # A complicated method
4
+ def complicated
5
+ # ... snip ...
6
+ end
7
+
8
+ # An example of a method that takes a parameter (+param1+)
9
+ # and does nothing.
10
+ #
11
+ # param1 - The first param
12
+ #
13
+ # Returns nil
14
+ def nothing(param1)
15
+ end
16
+
17
+ private
18
+
19
+ def filename
20
+ "#{self.class}_#{id}.foo"
21
+ end
22
+ end
@@ -0,0 +1,23 @@
1
+ # Foo is the classical name for a module
2
+ class Foo
3
+ # A complicated method
4
+ # @return [void]
5
+ def complicated
6
+ # ... snip ...
7
+ end
8
+
9
+ # An example of a method that takes a parameter (+param1+)
10
+ # and does nothing.
11
+ #
12
+ # param1 - The first param
13
+ #
14
+ # Returns a String or nil
15
+ def nothing(param1)
16
+ end
17
+
18
+ private
19
+
20
+ def filename
21
+ "#{self.class}_#{id}.foo"
22
+ end
23
+ end
@@ -45,7 +45,7 @@ describe ::Inch::CLI::Command::Suggest do
45
45
  #assert out.empty?, "there should be no output"
46
46
  #assert err.empty?, "there should be no errors"
47
47
  end
48
-
48
+
49
49
  it "should run with --objects switch" do
50
50
  out, err = capture_io do
51
51
  @command.run("lib/**/*.rb", "app/**/*.rb", "--objects=30")
@@ -80,4 +80,25 @@ describe ::Inch::CLI::Command::Suggest do
80
80
  assert_match /inch\ \d\.\d\.\d/, out
81
81
  assert err.empty?, "there should be no errors"
82
82
  end
83
+
84
+ # Edge case: Really good codebase
85
+
86
+ it "should run without args on really good fixture" do
87
+ out, err = capture_io do
88
+ Dir.chdir fixture_path(:really_good)
89
+ @command.run()
90
+ end
91
+ refute out.empty?, "there should be some output"
92
+ assert err.empty?, "there should be no errors"
93
+ end
94
+
95
+ it "should run with --pedantic switch" do
96
+ out, err = capture_io do
97
+ Dir.chdir fixture_path(:really_good)
98
+ @command.run("--pedantic")
99
+ end
100
+ refute out.empty?, "there should be some output"
101
+ assert err.empty?, "there should be no errors"
102
+ end
103
+
83
104
  end
metadata CHANGED
@@ -1,111 +1,111 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0.rc2
4
+ version: 0.3.0.rc3
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-16 00:00:00.000000000 Z
11
+ date: 2014-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.5'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.5'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: pry
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: minitest
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '5.2'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '5.2'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: sparkr
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: 0.2.0
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: 0.2.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: term-ansicolor
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - '>='
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - '>='
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: yard
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ~>
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
103
  version: 0.8.7
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ~>
108
+ - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: 0.8.7
111
111
  description: Documentation measurement tool for Ruby, based on YARD.
@@ -116,11 +116,11 @@ executables:
116
116
  extensions: []
117
117
  extra_rdoc_files: []
118
118
  files:
119
- - .gitignore
120
- - .ruby-gemset
121
- - .ruby-version
122
- - .simplecov
123
- - .travis.yml
119
+ - ".gitignore"
120
+ - ".ruby-gemset"
121
+ - ".ruby-version"
122
+ - ".simplecov"
123
+ - ".travis.yml"
124
124
  - Gemfile
125
125
  - LICENSE
126
126
  - README.md
@@ -223,6 +223,8 @@ files:
223
223
  - lib/inch/version.rb
224
224
  - test/fixtures/code_examples/lib/foo.rb
225
225
  - test/fixtures/readme/lib/foo.rb
226
+ - test/fixtures/really_good/lib/foo.rb
227
+ - test/fixtures/really_good_pedantic/lib/foo.rb
226
228
  - test/fixtures/simple/README
227
229
  - test/fixtures/simple/lib/broken.rb
228
230
  - test/fixtures/simple/lib/foo.rb
@@ -275,23 +277,25 @@ require_paths:
275
277
  - lib
276
278
  required_ruby_version: !ruby/object:Gem::Requirement
277
279
  requirements:
278
- - - '>='
280
+ - - ">="
279
281
  - !ruby/object:Gem::Version
280
282
  version: '0'
281
283
  required_rubygems_version: !ruby/object:Gem::Requirement
282
284
  requirements:
283
- - - '>'
285
+ - - ">"
284
286
  - !ruby/object:Gem::Version
285
287
  version: 1.3.1
286
288
  requirements: []
287
289
  rubyforge_project:
288
- rubygems_version: 2.0.6
290
+ rubygems_version: 2.2.2
289
291
  signing_key:
290
292
  specification_version: 4
291
293
  summary: Documentation measurement tool for Ruby
292
294
  test_files:
293
295
  - test/fixtures/code_examples/lib/foo.rb
294
296
  - test/fixtures/readme/lib/foo.rb
297
+ - test/fixtures/really_good/lib/foo.rb
298
+ - test/fixtures/really_good_pedantic/lib/foo.rb
295
299
  - test/fixtures/simple/README
296
300
  - test/fixtures/simple/lib/broken.rb
297
301
  - test/fixtures/simple/lib/foo.rb