sandi_meter 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NzI2Nzc1NDI0OWYyNTExZTJjMGViMWQ2YmNkNzU3YmNhNWU5YmM0MQ==
4
+ NTkxMGM4NTg4OTVkNjY2MjkyNGZlNTg3YTM0YjdlMTFkNmJlZjcwZA==
5
5
  data.tar.gz: !binary |-
6
- Njg4MzcxYmMyMDhiOTBhNTJjYTE1MzFhYWM5Yjc0ZWU2YjgyZGE0NA==
6
+ NTRkZDc2YzMzNDAzMDczM2ZlNTI1MTNmNjk4NGFhMGRiMmM3NDM1OA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- YTI5YzRhNDExYTg5MTg2ZGUyM2E4NGI0ODE5MjI5YjY1MTg5MTQ1MDNmYTM1
10
- NzM2NWU2Y2ZlZGQxNmZlMzIyMmE4ZDI3MjgzY2E1MDYzMWIzZTRjMTI4MDQ4
11
- M2Y5MWZhYTA5MzZlM2NjMDk3ZTM2OTI4Y2UyMWM4ZWUwMmNjYWU=
9
+ ZWMwNTNhZTgyZjY0OGIyYmNmNjc2OTQ2ZWQyMTkzMGIyMjliOGVmNGFhOGQz
10
+ YmQ1NTU0NTA1ZTYwNmY2YmU5OGRmZmVjZDU0ZDgzYjg5MmE2MWY3MWEzM2Mx
11
+ MzZlNTI5ZmU3YTg2ZmY2ZWU5MWM3NzVkZjAyNWJhYjlmZDdiN2Y=
12
12
  data.tar.gz: !binary |-
13
- ZDExZWRiZTA3ODQ1YWY5YTA0NGY4NzZkYzc5YWE5NTNhODBhYzI5M2RlYTkz
14
- NzMwMzE1NDJhZjE5OTI3MWVkNzhmMTVmOGY0NmM0Y2MwYmI5MmZjYTJlYmRl
15
- MWE4NTVlNmRkNDI2NzJiYzU0NWE0MWEwMTFjMDVmZGZiNDA4YTc=
13
+ MDNiOGNlYjc3MjdjMmE4Njg2MWU4ODhmNmVjMTg1ODAyOTM5NTMwNTdjNmFk
14
+ ODczMjczNWMyMDZiZmUwY2FlYTJkYmY3MmM1OTA3YjVhZGU1NDA4M2UyZjk1
15
+ NTBjYTQ1NGMyMmJhMmY5YjU2NDM0ZWQ1NzQ1NWQwMjU5MWYyYjM=
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # SandiMeter
2
2
 
3
- Static analysis tool for checking your Ruby code for [Sandi Metz' for rules](http://robots.thoughtbot.com/post/50655960596/sandi-metz-rules-for-developers).
3
+ Static analysis tool for checking your Ruby code for [Sandi Metz' four rules](http://robots.thoughtbot.com/post/50655960596/sandi-metz-rules-for-developers).
4
4
 
5
5
  * 100 lines per class
6
6
  * 5 lines per method
data/bin/sandi_meter CHANGED
@@ -1,10 +1,55 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ require 'mixlib/cli'
3
4
  require_relative '../lib/sandi_meter/file_scanner'
4
5
  require_relative '../lib/sandi_meter/formatter'
5
6
 
6
- scanner = SandiMeter::FileScanner.new(ARGV[1] == "--log")
7
- data = scanner.scan(ARGV[0])
7
+ class MyCLI
8
+ include Mixlib::CLI
9
+
10
+ option :path,
11
+ short: "-p PATH",
12
+ long: "--path PATH",
13
+ description: "Path to folder or file to analyze",
14
+ default: "."
15
+
16
+ option :log,
17
+ short: "-l",
18
+ long: "--log",
19
+ description: "Show syntax error and indentation log output",
20
+ boolean: true
21
+
22
+ option :help,
23
+ short: "-h",
24
+ long: "--help",
25
+ description: "Help",
26
+ on: :tail,
27
+ boolean: true,
28
+ show_options: true,
29
+ exit: 0
30
+
31
+ option :rules,
32
+ short: "-r",
33
+ long: "--rules",
34
+ description: "Show rules",
35
+ boolean: 0
36
+ end
37
+
38
+ cli = MyCLI.new
39
+ cli.parse_options
40
+
41
+ if cli.config[:rules]
42
+ puts %(
43
+ 1. 100 lines per class
44
+ 2. 5 lines per method
45
+ 3. 4 params per method call (and don't even try cheating with hash params)
46
+ 4. 1 instance variables per controller' action
47
+ )
48
+ exit 0
49
+ end
50
+
51
+ scanner = SandiMeter::FileScanner.new(cli.config[:log])
52
+ data = scanner.scan(cli.config[:path])
8
53
  formatter = SandiMeter::Formatter.new
9
54
 
10
55
  formatter.print_data(data)
@@ -13,7 +13,7 @@ module SandiMeter
13
13
 
14
14
  private
15
15
  def locs_size(first_line, last_line)
16
- file_lines[first_line - 1..last_line - 1].map(&:strip).reject(&:empty?).size
16
+ file_lines[first_line - 1..last_line - 1].size
17
17
  end
18
18
  end
19
19
  end
@@ -1,3 +1,3 @@
1
1
  module SandiMeter
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -4,7 +4,7 @@ require_relative '../lib/sandi_meter/analyzer'
4
4
  describe SandiMeter::Analyzer do
5
5
  let(:analyzer) { SandiMeter::Analyzer.new }
6
6
 
7
- describe 'finds properly indended classes with lines' do
7
+ describe 'finds properly indented classes with lines' do
8
8
  let(:test_class) { test_file_path(3) }
9
9
 
10
10
  before do
@@ -44,7 +44,7 @@ describe SandiMeter::Analyzer do
44
44
  end
45
45
  end
46
46
 
47
- describe 'finds properly indended classes in one file' do
47
+ describe 'finds properly indented classes in one file' do
48
48
  let(:test_class) { test_file_path(4) }
49
49
 
50
50
  before do
@@ -160,4 +160,20 @@ describe SandiMeter::Analyzer do
160
160
  analyzer.method_calls.should eq([[5, 3]])
161
161
  end
162
162
  end
163
+
164
+ describe 'empty lines inside class' do
165
+ let(:test_class) { test_file_path(12) }
166
+
167
+ before do
168
+ analyzer.analyze(test_class)
169
+ end
170
+
171
+ it 'are count for class definition' do
172
+ analyzer.classes.should eq([["Valera", 1, 109, false]])
173
+ end
174
+
175
+ it 'are count for method definition' do
176
+ analyzer.methods.should eq({"Valera"=>[["doodle", 2, 9, 0, false]]})
177
+ end
178
+ end
163
179
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sandi_meter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anatoli Makarevich
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-18 00:00:00.000000000 Z
11
+ date: 2013-09-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -65,6 +65,7 @@ files:
65
65
  - spec/test_classes/1.rb
66
66
  - spec/test_classes/10.rb
67
67
  - spec/test_classes/11.rb
68
+ - spec/test_classes/12.rb
68
69
  - spec/test_classes/2.rb
69
70
  - spec/test_classes/3.rb
70
71
  - spec/test_classes/4.rb