inch 0.1.1 → 0.1.2

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: 252dd36f4749f380d6f1a5c6c78ebf39cbb6a02b
4
- data.tar.gz: 189e4afb63928cfda6dceab1f855b8633a5490d7
3
+ metadata.gz: ac5ffa0638f44fe70c196dd422392a913745cc95
4
+ data.tar.gz: 23f1ce2ebdcd812be31f6bb530406c81518b2cbf
5
5
  SHA512:
6
- metadata.gz: 41efced3e37aac30b9a83ce7c278f0ea2e35d952f087242e24c11a59c2ad8ec8d4dd4a565023d8350c462afc46d21258478ce475c83bcf5cc4fe6126583fde3d
7
- data.tar.gz: 4f5b2baba065d521af008bffeaa1f911e0d54024865fa31c5167bf9a677aa42863a20231c7e52c9dbab55f51710babfd6951f3b16aabc57480555c740a2cb9ed
6
+ metadata.gz: 63f0021f750e0cfe86042fc54d668ccaccdee94cf240f8f39670ab5707f335bce7dca7798bb33f47e870b83c983c682c66590c975fbff2df34f09b86a1afb559
7
+ data.tar.gz: 80c5d8393b89fc3296f1f43873d30ac6069ce144b8369042d8a76f0f8b8630d570afe6bd5cb0d91fec23287173e9fe16f12ff551219449703f276aab12c1129a
data/README.md CHANGED
@@ -1,10 +1,12 @@
1
1
  # Inch
2
2
 
3
+ [![Build Status](https://travis-ci.org/rrrene/inch.png)](https://travis-ci.org/rrrene/inch)
4
+
3
5
  Inch is a documentation measurement tool for Ruby, based on
4
6
  [YARD](http://yardoc.org/).
5
7
 
6
- It does not measure *coverage*, but grades your documentation to give you
7
- hints where to improve your docs. One Inch at a time.
8
+ It does not measure *coverage*, but gives you hints where to improve your
9
+ docs. One Inch at a time.
8
10
 
9
11
 
10
12
  ## Installation
data/TODOS.md CHANGED
@@ -7,4 +7,3 @@
7
7
  visibility options
8
8
  * Add support for multiple signatures for methods
9
9
  (realized via the @overload tag in YARD)
10
- * Make `inch lib/optparse.rb` work (without explicit `suggest`)
@@ -55,12 +55,12 @@ module Inch
55
55
  f = Evaluation::File.for(filename, relevant_objects)
56
56
  end
57
57
 
58
- list = list.select do |f|
58
+ priority_list = list.select do |f|
59
59
  relevant_grades.include?(f.grade) &&
60
60
  relevant_priorities.include?(f.priority)
61
61
  end
62
62
 
63
- sort_by_priority(list)
63
+ sort_by_priority(priority_list.empty? ? list : priority_list)
64
64
  end
65
65
 
66
66
  def all_filenames(objects)
@@ -97,7 +97,6 @@ module Inch
97
97
  def select_by_priority(list, min_priority)
98
98
  list.select { |o| o.priority >= min_priority }
99
99
  end
100
-
101
100
  end
102
101
  end
103
102
  end
@@ -6,9 +6,7 @@ module Inch
6
6
  #
7
7
  # $ inch command_name [options]
8
8
  #
9
- # If no command or arguments are specified, or if the arguments immediately
10
- # begin with a +--opt+ (not +--help+), the {default_command} will be used
11
- # (which itself defaults to +:doc+).
9
+ # If no command_name is specified, the {default_command} will be used.
12
10
  #
13
11
  class CommandParser
14
12
  include TraceHelper
@@ -48,18 +46,11 @@ module Inch
48
46
  # argument.
49
47
  # @return [void]
50
48
  def run(*args)
51
- unless ['--help', '-h'].include?(args.join)
52
- if args.size == 0 || args.first =~ /^-/
53
- command_name = self.class.default_command
54
- else
55
- command_name = args.first.to_sym
56
- args.shift
57
- end
58
- if commands.has_key?(command_name)
59
- return commands[command_name].run(*args)
60
- end
49
+ if ['--help', '-h'].include?(args.join)
50
+ list_commands
51
+ else
52
+ run_command(*args)
61
53
  end
62
- list_commands
63
54
  end
64
55
 
65
56
  private
@@ -77,6 +68,23 @@ module Inch
77
68
  trace " %-8s %s" % [command_name, command.description]
78
69
  end
79
70
  end
71
+
72
+ def run_command(*args)
73
+ if args.empty?
74
+ command_name = self.class.default_command
75
+ else
76
+ possible_command_name = args.first.to_sym
77
+
78
+ if commands.has_key?(possible_command_name)
79
+ command_name = possible_command_name
80
+ args.shift
81
+ else
82
+ command_name = self.class.default_command
83
+ end
84
+ end
85
+
86
+ commands[command_name].run(*args)
87
+ end
80
88
  end
81
89
  end
82
90
  end
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module Inch
2
4
  module CLI
3
5
  module TraceHelper
@@ -30,11 +30,11 @@ module Inch
30
30
  end
31
31
 
32
32
  def mentions_return?
33
- @text.lines.last =~ /^Returns\ /
33
+ @text.lines.to_a.last =~ /^Returns\ /
34
34
  end
35
35
 
36
36
  def describes_return?
37
- @text.lines.last =~ /^Returns\ (\w+\s){2,}/
37
+ @text.lines.to_a.last =~ /^Returns\ (\w+\s){2,}/
38
38
  end
39
39
 
40
40
  def parse_code_examples
@@ -75,7 +75,7 @@ module Inch
75
75
  end
76
76
 
77
77
  def abbrev_source
78
- lines = object.source.to_s.lines
78
+ lines = object.source.to_s.lines.to_a
79
79
  if lines.size >= 5
80
80
  indent = lines[1].scan(/^(\s+)/).flatten.join('')
81
81
  lines = lines[0..1] +
data/lib/inch/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Inch
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -45,6 +45,12 @@ 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
+
49
+ it "should give error when run with --unknown-switch" do
50
+ out, err = capture_io do
51
+ assert_raises(SystemExit) { @command.run("--unknown-switch") }
52
+ end
53
+ end
48
54
 
49
55
  it "should output info when run with --help" do
50
56
  out, err = capture_io do
@@ -54,4 +60,13 @@ describe ::Inch::CLI::Command::Suggest do
54
60
  assert_match /\bUsage\b.+suggest/, out
55
61
  assert err.empty?, "there should be no errors"
56
62
  end
63
+
64
+ it "should output version when run with --version" do
65
+ out, err = capture_io do
66
+ assert_raises(SystemExit) { @command.run("--version") }
67
+ end
68
+ refute out.empty?, "there should be some output"
69
+ assert_match /inch\ \d\.\d\.\d/, out
70
+ assert err.empty?, "there should be no errors"
71
+ end
57
72
  end
@@ -3,28 +3,66 @@ require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
3
3
  describe ::Inch::CLI::CommandParser do
4
4
  before do
5
5
  Dir.chdir fixture_path(:simple)
6
- @command = ::Inch::CLI::CommandParser
6
+ @command_parser = ::Inch::CLI::CommandParser
7
7
  end
8
8
 
9
9
  it "should run without args" do
10
10
  out, err = capture_io do
11
- @command.run()
11
+ @command = @command_parser.run()
12
12
  end
13
13
  refute out.empty?, "there should be some output"
14
14
  assert err.empty?, "there should be no errors"
15
+ assert_equal ::Inch::CLI::Command::Suggest, @command.class
15
16
  end
16
17
 
17
18
  it "should run Command::Suggest with filelist in args" do
18
19
  out, err = capture_io do
19
- @command.run("suggest", "lib/**/*.rb", "app/**/*.rb")
20
+ @command = @command_parser.run("suggest", "lib/**/*.rb", "app/**/*.rb")
20
21
  end
21
22
  refute out.empty?, "there should be some output"
22
23
  assert err.empty?, "there should be no errors"
24
+ assert_equal ::Inch::CLI::Command::Suggest, @command.class
25
+ end
26
+
27
+ it "should run Command::Suggest with only filelist in args" do
28
+ out, err = capture_io do
29
+ @command = @command_parser.run("lib/**/*.rb", "app/**/*.rb")
30
+ end
31
+ refute out.empty?, "there should be some output"
32
+ assert err.empty?, "there should be no errors"
33
+ assert_equal ::Inch::CLI::Command::Suggest, @command.class
34
+ end
35
+
36
+ it "should run Command::Suggest with only switches in args" do
37
+ out, err = capture_io do
38
+ @command = @command_parser.run("--no-color")
39
+ end
40
+ refute out.empty?, "there should be some output"
41
+ assert err.empty?, "there should be no errors"
42
+ assert_equal ::Inch::CLI::Command::Suggest, @command.class
43
+ end
44
+
45
+ it "should run Command::List with filelist in args" do
46
+ out, err = capture_io do
47
+ @command = @command_parser.run("list", "lib/**/*.rb", "app/**/*.rb")
48
+ end
49
+ refute out.empty?, "there should be some output"
50
+ assert err.empty?, "there should be no errors"
51
+ assert_equal ::Inch::CLI::Command::List, @command.class
52
+ end
53
+
54
+ it "should run Command::Show with filelist in args" do
55
+ out, err = capture_io do
56
+ @command = @command_parser.run("show", "Foo")
57
+ end
58
+ refute out.empty?, "there should be some output"
59
+ assert err.empty?, "there should be no errors"
60
+ assert_equal ::Inch::CLI::Command::Show, @command.class
23
61
  end
24
62
 
25
63
  it "should output info when run with --help" do
26
64
  out, err = capture_io do
27
- @command.run("--help")
65
+ @command = @command_parser.run("--help")
28
66
  end
29
67
  refute out.empty?, "there should be some output"
30
68
  assert_match /\bUsage\b.+inch/, out
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.1.1
4
+ version: 0.1.2
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-01-28 00:00:00.000000000 Z
11
+ date: 2014-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler