inch 0.4.0.rc2 → 0.4.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: b68244a51e9f493211a0f8b1fda1773c74120d42
4
- data.tar.gz: ffe7a9384808c79be81875ac1a6fdce2c832f8af
3
+ metadata.gz: be1d3023cb43e15c6a141ed20de1543d20a8be64
4
+ data.tar.gz: 5c7c5638b7998464f36dcbae6016c5742d17e8d7
5
5
  SHA512:
6
- metadata.gz: fc0121c7348a0ad6daf269d1daf2ee570f95be5c5fec62c5647543d15e9aadd1eb9c8d5129c69caa1c81acda48d4878fde4a05a2ede1e538549bd2d36983da85
7
- data.tar.gz: c1fa923fa045fd962426f938c2d6ce3fcf70a9638387dbfc2e292c45d11ad252273e500867f638c1dd0974f78f1f714049064aa8c5614b045064deed8bd5f98b
6
+ metadata.gz: 02501af74e5e84a9fbf0b25c69e9c319b46c2d35e8a9507ed97488917748bc3c98c9cecda89a1f704e0fd37633189d55ddfdb63e5877e1c34c8af4b65bbfc140
7
+ data.tar.gz: f9c15371028b15ae3cb630d55cf0eff00e008296ca93f6cce4af98361430466760e5024712abd975b0341172c37d24f969b7a78b123a5c3975c4664dee96f4fe
@@ -29,11 +29,11 @@ module Inch
29
29
  end
30
30
 
31
31
  def degraded?
32
- changed? && @before.score.to_i > @after.score.to_i
32
+ changed? && @before.score > @after.score
33
33
  end
34
34
 
35
35
  def improved?
36
- changed? && @before.score.to_i < @after.score.to_i
36
+ changed? && @before.score < @after.score
37
37
  end
38
38
 
39
39
  def present?
@@ -45,11 +45,11 @@ module Inch
45
45
  end
46
46
 
47
47
  def unchanged?
48
- present? && @before.score.to_i == @after.score.to_i
48
+ present? && @before.score == @after.score
49
49
  end
50
50
 
51
51
  def scores
52
- [@before.score.to_i, @after.score.to_i]
52
+ [@before.score, @after.score]
53
53
  end
54
54
  end
55
55
  end
@@ -6,6 +6,8 @@ module Inch
6
6
  module CLI
7
7
  module Command
8
8
  class Diff < Base
9
+ include Utils::ShellHelper
10
+
9
11
  register_command_as :diff
10
12
 
11
13
  def description
@@ -28,14 +30,6 @@ module Inch
28
30
 
29
31
  private
30
32
 
31
- def git(dir, command)
32
- old_pwd = Dir.pwd
33
- Dir.chdir dir
34
- out = `git #{command}`
35
- Dir.chdir old_pwd
36
- out
37
- end
38
-
39
33
  # @return [Array<String>] the revisions passed in the command_line
40
34
  def revisions
41
35
  @revisions ||= @options.revisions.map do |rev|
@@ -40,7 +40,7 @@ module Inch
40
40
  min = o.evaluation.min_score
41
41
  max = o.evaluation.max_score
42
42
  echo "Score (min: #{min}, max: #{max})".ljust(40) +
43
- "#{o.score.to_i}".rjust(5) + "#{o.priority.to_i}".rjust(4)
43
+ "#{o.score}".rjust(5) + "#{o.priority.to_i}".rjust(4)
44
44
  echo
45
45
  end
46
46
 
@@ -97,9 +97,9 @@ module Inch
97
97
 
98
98
  def colored_role_score(role)
99
99
  if role.potential_score
100
- "(#{role.potential_score.to_i})".rjust(5).yellow.dark
100
+ "(#{role.potential_score})".rjust(5).yellow.dark
101
101
  else
102
- value = role.score.to_i
102
+ value = role.score
103
103
  colored_score value, value.abs.to_s.rjust(4)
104
104
  end
105
105
  end
@@ -74,7 +74,7 @@ module Inch
74
74
  end
75
75
 
76
76
  def result_numbers(object, color)
77
- score = object.score.to_i.to_s
77
+ score = object.score.to_s
78
78
  score = score.rjust(3).color(color)
79
79
  priority = object.priority
80
80
  "#{score} #{priority} #{object.fullname}"
@@ -109,8 +109,8 @@ module Inch
109
109
  def __scores
110
110
  hash = {}
111
111
  @objects.sort_by(&:score).each do |o|
112
- hash[o.score.to_i] ||= 0
113
- hash[o.score.to_i] += 1
112
+ hash[o.score] ||= 0
113
+ hash[o.score] += 1
114
114
  end
115
115
  hash
116
116
  end
@@ -20,11 +20,10 @@ module Inch
20
20
  # @param config [Inch::Config::Codebase] configuration for codebase
21
21
  # @return [void]
22
22
  def parse(dir, config)
23
- old_dir = Dir.pwd
24
- Dir.chdir dir
25
- parse_yard_objects(config.included_files, config.excluded_files)
26
- inject_base_dir(dir)
27
- Dir.chdir old_dir
23
+ Dir.chdir(dir) do
24
+ parse_yard_objects(config.included_files, config.excluded_files)
25
+ inject_base_dir(dir)
26
+ end
28
27
  end
29
28
 
30
29
  # @return [Array<YARD::Object::Base>]
@@ -28,10 +28,9 @@ module Inch
28
28
 
29
29
  def update_via_yaml(dir)
30
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
31
+ Dir.chdir(dir) do
32
+ update_files yaml["files"]
33
+ end
35
34
  end
36
35
  end
37
36
 
@@ -56,7 +56,7 @@ module Inch
56
56
  @__min_score = __min_score
57
57
  end
58
58
 
59
- # @return [Float] the final score for +object+
59
+ # @return [Fixnum] the final score for +object+
60
60
  def score
61
61
  @__score ||= __score
62
62
  end
@@ -144,7 +144,7 @@ module Inch
144
144
 
145
145
  # @return [Float]
146
146
  def __score
147
- value = @roles.inject(0) { |sum,r| sum + r.score.to_f }
147
+ value = @roles.inject(0) { |sum,r| sum + r.score.to_f }.to_i
148
148
  if value < min_score
149
149
  min_score
150
150
  elsif value > max_score
@@ -8,11 +8,11 @@ module Inch
8
8
  nil
9
9
  end
10
10
 
11
- # @return [Float]
11
+ # @return [Fixnum]
12
12
  # a score that can be achieved by adding the missing thing mentioned
13
13
  # by the role
14
14
  def potential_score
15
- @value.to_f
15
+ @value.to_i
16
16
  end
17
17
  end
18
18
  end
@@ -2,11 +2,9 @@ module Inch
2
2
  module Utils
3
3
  module ShellHelper
4
4
  def git(dir, command)
5
- old_pwd = Dir.pwd
6
- Dir.chdir dir
7
- out = sh("git #{command}")
8
- Dir.chdir old_pwd
9
- out
5
+ Dir.chdir(dir) do
6
+ out = sh("git #{command}")
7
+ end
10
8
  end
11
9
 
12
10
  def sh(command)
data/lib/inch/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Inch
2
- VERSION = "0.4.0.rc2"
2
+ VERSION = "0.4.0.rc3"
3
3
  end
@@ -278,7 +278,7 @@ describe ::Inch::CodeObject::Proxy::MethodObject do
278
278
  list << @objects.find("Overloading#mix")
279
279
  list << @objects.find("Overloading#hooks")
280
280
  list.each do |m|
281
- assert_equal 100, m.score.to_i, "#{m.fullname} did not get 100"
281
+ assert_equal 100, m.score, "#{m.fullname} did not get 100"
282
282
  end
283
283
  end
284
284
  end
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.4.0.rc2
4
+ version: 0.4.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-03-30 00:00:00.000000000 Z
11
+ date: 2014-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler