inch 0.6.0 → 0.6.1

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: 1e584f4139915b6bcbbd5e2332d03b94d33b1ad8
4
- data.tar.gz: 0bfcf44873522d1584e8f6d293e91e98b8ee090a
3
+ metadata.gz: ba3a203a48459da4bf88d52ff9855712483543f7
4
+ data.tar.gz: 31403afde0e69710d5d6ab5c6f997f3940eee18f
5
5
  SHA512:
6
- metadata.gz: 1bca0fc44a9dc92d165d516d0bc52383063c54673c0f4316e58e3ca4f10413332b4bc5f5b295357259a172e6667e8bd8f9b92a209648d55604f9fdd10c7651d8
7
- data.tar.gz: faa675fb58e0aa8cd56f7058a8e43870e2bb0fa346635dd179802392e4db458f1ca7177335ed46eb569b50dddd5d89bdcff4af901552fad2da8b8d545f449e31
6
+ metadata.gz: 5efa4c765863b66ddb2775f4b14027645bb3dfb6fb06701a4dec796506ef3e59924222810fa58c7ea321515dc274110cb5011828d152b7ce6ec6f5cfa53303be
7
+ data.tar.gz: 6b81968eeba91c2403550c649f877cc6d9f703afef025eb15e21162ba0e49e13375d5dc4d7c9f2486f63749c44099b7ed1605a841b0e7b27cf6388cc00af428d
@@ -4,13 +4,20 @@ module Inch
4
4
  class Filter
5
5
  attr_reader :codebase
6
6
  attr_reader :objects
7
- attr_reader :grade_lists
8
7
 
9
8
  def initialize(codebase, options)
10
9
  @codebase = codebase
11
10
  codebase.objects.filter! Options::Filter.new(options)
12
11
  @objects = codebase.objects.to_a
13
- @grade_lists = @codebase.grade_lists
12
+ end
13
+
14
+ def grade_lists(_objects = objects)
15
+ lists = Evaluation.new_grade_lists
16
+ lists.each do |range|
17
+ list = _objects.select { |o| range.scores.include?(o.score) }
18
+ range.objects = Codebase::Objects.sort_by_priority(list)
19
+ end
20
+ lists
14
21
  end
15
22
  end
16
23
  end
@@ -14,6 +14,10 @@ module Inch
14
14
  list[0...how_many]
15
15
  end
16
16
 
17
+ def grade_lists
18
+ super(relevant_objects)
19
+ end
20
+
17
21
  # @return [Array] the +@options.object_count+ objects the API suggests
18
22
  def objects
19
23
  filter_objects_to_display
@@ -3,6 +3,11 @@ module Inch
3
3
  module Command
4
4
  module Options
5
5
  class Suggest < BaseList
6
+ FORMAT_TEXT = "text"
7
+ FORMATS = [FORMAT_TEXT] + %w(json yaml)
8
+
9
+ attribute :format, FORMATS.first
10
+
6
11
  include API::Options::Suggest::DefaultAttributeValues
7
12
 
8
13
  attribute :object_count, DEFAULT_OBJECT_COUNT
@@ -46,6 +51,10 @@ module Inch
46
51
  opts.on('-n', '--objects [COUNT]', 'Show COUNT objects') do |count|
47
52
  @object_count = count.to_i
48
53
  end
54
+ opts.on('-f', '--format [FORMAT]', FORMATS,
55
+ 'Set output FORMAT') do |format|
56
+ @format = format
57
+ end
49
58
  opts.on('--pedantic',
50
59
  'Be excessively concerned with minor details and rules') do
51
60
  # all objects are considered a priority
@@ -23,8 +23,12 @@ module Inch
23
23
  def run(*args)
24
24
  prepare_codebase(*args)
25
25
  context = API::Suggest.new(codebase, @options)
26
- Output::Suggest.new(@options, context.all_objects, context.objects,
27
- context.grade_lists, context.files)
26
+ if @options.format == Options::Suggest::FORMAT_TEXT
27
+ Output::Suggest.new(@options, context.all_objects, context.objects,
28
+ context.grade_lists, context.files)
29
+ else
30
+ Output::Stats.new(@options, context.all_objects, context.grade_lists)
31
+ end
28
32
  end
29
33
  end
30
34
  end
@@ -7,15 +7,6 @@ module Inch
7
7
  @objects = Codebase::Objects.new(language, provider.objects)
8
8
  end
9
9
 
10
- def grade_lists
11
- lists = Evaluation.new_grade_lists
12
- lists.each do |range|
13
- list = objects.select { |o| range.scores.include?(o.score) }
14
- range.objects = Objects.sort_by_priority(list)
15
- end
16
- lists
17
- end
18
-
19
10
  def self.parse(dir, config)
20
11
  provider = CodeObject::Provider.parse(dir, config)
21
12
  new(config.language, provider)
@@ -114,13 +114,13 @@ module Inch
114
114
  # @return [Float] the max score that is assignable to +object+
115
115
  def __max_score
116
116
  arr = @roles.map(&:max_score).compact
117
- [MAX_SCORE].concat(arr).min
117
+ [MAX_SCORE].concat(arr).min.to_i
118
118
  end
119
119
 
120
120
  # @return [Float] the max score that is assignable to +object+
121
121
  def __min_score
122
122
  arr = @roles.map(&:min_score).compact
123
- [MIN_SCORE].concat(arr).max
123
+ [MIN_SCORE].concat(arr).max.to_i
124
124
  end
125
125
 
126
126
  # @return [Float]
@@ -1,3 +1,3 @@
1
1
  module Inch
2
- VERSION = '0.6.0'
2
+ VERSION = '0.6.1'
3
3
  end
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.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - René Föhring