inch 0.5.0.rc4 → 0.5.0.rc5

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,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 204a55bbfb702da63ab9b62d8e68b6e97b46d7e8
4
- data.tar.gz: 9237fdad678102759b3924c464718181560de4d9
3
+ metadata.gz: 93877a4281619360271a03029ae4368cf71c7e57
4
+ data.tar.gz: f76a3b46211e7d258a41bef437839a56ee66826c
5
5
  SHA512:
6
- metadata.gz: d5e38320c4c26fcbb2bf22f67fce5f5fc1d6c8d6acd4953e069f106b6440d31b531179284611be268b26bc8cad49cd3722b9f8dd48e669ef067fbbab07b5f79f
7
- data.tar.gz: 0c5772bcc6822ef6652611ec82ec370cb5b1f7fb122078055bcb69a53ab6efefad5fa10aa15e29312cb21a9eb2035894f7d60d56e18b43a693f5f26d9780432a
6
+ metadata.gz: fb8cb6914e685eed7eb4b008757bf91d4ab56efe96e74b6d4faa57321cc9b75fb259a05b085ff6a90b34321e5f2d2d8b8c07b0cfbdc7df4d03a5ea6afb5b6b3c
7
+ data.tar.gz: 1804964c134ae38cf0108cdeeafe5809af0114da80b65d583a6edb2bf20f7070c38142a10fc532d0121c59900e91fb8542ac8467a0044f2fe2f6b551731e18bc
@@ -105,6 +105,7 @@ module Inch
105
105
  options_class = Command::Options.const_get(name)
106
106
  @options = options_class.new
107
107
  @options.usage = usage
108
+ @options.ui = ui
108
109
  end
109
110
 
110
111
  # Creates a Config::Codebase object and returns it
@@ -42,6 +42,8 @@ module Inch
42
42
  attribute :paths, [] # the paths of the to-be-analysed sources
43
43
  attribute :excluded, [] # paths to be excluded from the analysis
44
44
 
45
+ attr_accessor :ui
46
+
45
47
  # Parses the given +args+ "into" the current Options object
46
48
  #
47
49
  # @param args [Array<String>] command-line arguments
@@ -30,6 +30,11 @@ module Inch
30
30
  end
31
31
  echo separator
32
32
  end
33
+
34
+ # this is used to use Inch::Utils::BufferedIO
35
+ def ui
36
+ @options.ui
37
+ end
33
38
  end
34
39
  end
35
40
  end
@@ -30,29 +30,29 @@ module Inch
30
30
  print_grades
31
31
  print_grades_by_priority
32
32
  print_priorities
33
- puts
34
- puts "Try `--format json|yaml` for raw numbers.".dark
33
+ ui.trace
34
+ ui.trace "Try `--format json|yaml` for raw numbers.".dark
35
35
  end
36
36
 
37
37
  def print_grades
38
38
  sparkline = grade_lists_sparkline(@grade_lists).to_s(" ")
39
- puts
40
- puts "Grade distribution: (undocumented, C, B, A)"
41
- puts
42
- puts " Overall: #{sparkline} #{objects.size.to_s.rjust(5)} " \
39
+ ui.trace
40
+ ui.trace "Grade distribution: (undocumented, C, B, A)"
41
+ ui.trace
42
+ ui.trace " Overall: #{sparkline} #{objects.size.to_s.rjust(5)} " \
43
43
  "objects"
44
- puts
44
+ ui.trace
45
45
  end
46
46
 
47
47
  def print_grades_by_priority
48
- puts "Grade distribution by priority:"
49
- puts
48
+ ui.trace "Grade distribution by priority:"
49
+ ui.trace
50
50
  Evaluation::PriorityRange.all.each do |priority_range|
51
51
  list = objects.select { |o| priority_range.include?(o.priority) }
52
52
  sparkline = grades_sparkline(list).to_s(" ")
53
- puts " #{priority_range.arrow} #{sparkline} " \
53
+ ui.trace " #{priority_range.arrow} #{sparkline} " \
54
54
  "#{list.size.to_s.rjust(5)} objects"
55
- puts
55
+ ui.trace
56
56
  end
57
57
  end
58
58
 
@@ -68,27 +68,27 @@ module Inch
68
68
  sparkline.format do |tick, _count, index|
69
69
  tick.color(PRIORITY_COLORS[index])
70
70
  end
71
- puts " #{grade_list.grade}: " + sparkline.to_s(" ") +
71
+ ui.trace " #{grade_list.grade}: " + sparkline.to_s(" ") +
72
72
  " #{grade_list.objects.size.to_s.rjust(5)} objects"
73
- puts
73
+ ui.trace
74
74
  end
75
75
 
76
76
  def print_priorities
77
77
  arrows = Evaluation::PriorityRange.all.map(&:arrow)
78
- puts "Priority distribution in grades: (low to high)"
79
- puts
80
- puts " #{arrows.reverse.join(" ")}"
78
+ ui.trace "Priority distribution in grades: (low to high)"
79
+ ui.trace
80
+ ui.trace " #{arrows.reverse.join(" ")}"
81
81
  @grade_lists.reverse.each do |grade_list|
82
82
  print_grade_list(grade_list)
83
83
  end
84
84
  end
85
85
 
86
86
  def display_json
87
- puts JSON.pretty_generate(stats_hash)
87
+ ui.trace JSON.pretty_generate(stats_hash)
88
88
  end
89
89
 
90
90
  def display_yaml
91
- puts YAML.dump(stats_hash)
91
+ ui.trace YAML.dump(stats_hash)
92
92
  end
93
93
 
94
94
  def stats_hash
@@ -48,9 +48,9 @@ module Inch
48
48
 
49
49
  def display_distribution
50
50
  sparkline = grades_sparkline(@relevant_objects).to_s(" ")
51
- puts "Grade distribution (undocumented, C, B, A): " + sparkline
52
- puts
53
- puts priority_filter_hint
51
+ ui.trace "Grade distribution (undocumented, C, B, A): " + sparkline
52
+ ui.trace
53
+ ui.trace priority_filter_hint
54
54
  end
55
55
 
56
56
  def priority_filter_hint
@@ -26,8 +26,10 @@ module Inch
26
26
  arg =~ /^\-/ && !VALID_YARD_SWITCHES.include?(arg)
27
27
  end
28
28
 
29
- ui.debug "Sending args to YARD:\n" \
29
+ if ui
30
+ ui.debug "Sending args to YARD:\n" \
30
31
  " args: #{dupped_args}"
32
+ end
31
33
 
32
34
  wrapper.parse_arguments(*dupped_args)
33
35
 
data/lib/inch/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Inch
2
- VERSION = "0.5.0.rc4"
2
+ VERSION = "0.5.0.rc5"
3
3
  end
@@ -1,4 +1,5 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + "/../../../test_helper")
2
+ require 'inch/utils/buffered_ui'
2
3
 
3
4
  describe ::Inch::CLI::Command::Suggest do
4
5
  before do
@@ -81,6 +82,15 @@ describe ::Inch::CLI::Command::Suggest do
81
82
  assert err.empty?, "there should be no errors"
82
83
  end
83
84
 
85
+ it "should not output anything to stdout when used with BufferedUI" do
86
+ ui = ::Inch::Utils::BufferedUI.new
87
+ out, err = capture_io do
88
+ @command.run(:ui => ui)
89
+ end
90
+ assert out.empty?, "there should be no output"
91
+ assert err.empty?, "there should be no errors"
92
+ end
93
+
84
94
  # Edge case: Really good codebase
85
95
 
86
96
  it "should run without args on really good fixture" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0.rc4
4
+ version: 0.5.0.rc5
5
5
  platform: ruby
6
6
  authors:
7
7
  - René Föhring