fukuzatsu 1.0.6 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/README.md +11 -9
- data/doc/images/details.png +0 -0
- data/doc/images/overview.png +0 -0
- data/fukuzatsu.gemspec +5 -2
- data/lib/fukuzatsu.rb +18 -4
- data/lib/fukuzatsu/cli.rb +2 -15
- data/lib/fukuzatsu/file_reader.rb +38 -0
- data/lib/fukuzatsu/formatters/base.rb +61 -22
- data/lib/fukuzatsu/formatters/csv.rb +28 -29
- data/lib/fukuzatsu/formatters/html.rb +61 -66
- data/lib/fukuzatsu/formatters/html_index.rb +40 -33
- data/lib/fukuzatsu/formatters/json.rb +37 -0
- data/lib/fukuzatsu/formatters/json_index.rb +31 -0
- data/lib/fukuzatsu/formatters/templates/index.html.haml +21 -32
- data/lib/fukuzatsu/formatters/templates/output.html.haml +19 -50
- data/lib/fukuzatsu/formatters/text.rb +53 -41
- data/lib/fukuzatsu/parser.rb +31 -49
- data/lib/fukuzatsu/summary.rb +101 -0
- data/lib/fukuzatsu/version.rb +1 -1
- data/spec/cli_spec.rb +7 -40
- data/spec/fixtures/class.rb +30 -0
- data/spec/fixtures/module.rb +12 -0
- data/spec/fixtures/procedural.rb +8 -0
- data/spec/formatters/csv_spec.rb +43 -21
- data/spec/formatters/html_spec.rb +38 -19
- data/spec/formatters/json_spec.rb +81 -0
- data/spec/formatters/text_spec.rb +18 -18
- data/spec/parser_spec.rb +39 -0
- data/spec/summary_spec.rb +28 -0
- metadata +51 -43
- data/doc/details.png +0 -0
- data/doc/overview.png +0 -0
- data/lib/fukuzatsu/analyzer.rb +0 -162
- data/lib/fukuzatsu/line_of_code.rb +0 -19
- data/lib/fukuzatsu/parsed_file.rb +0 -89
- data/lib/fukuzatsu/parsed_method.rb +0 -32
- data/spec/analyzer_spec.rb +0 -122
- data/spec/fixtures/eg_class.rb +0 -8
- data/spec/fixtures/eg_mod_class.rb +0 -2
- data/spec/fixtures/eg_mod_class_2.rb +0 -5
- data/spec/fixtures/eg_module.rb +0 -2
- data/spec/fixtures/module_with_class.rb +0 -9
- data/spec/fixtures/multiple_methods.rb +0 -7
- data/spec/fixtures/nested_methods.rb +0 -8
- data/spec/fixtures/program_1.rb +0 -19
- data/spec/fixtures/program_2.rb +0 -25
- data/spec/fixtures/program_3.rb +0 -66
- data/spec/fixtures/program_4.rb +0 -1
- data/spec/fixtures/single_class.rb +0 -9
- data/spec/fixtures/single_method.rb +0 -3
- data/spec/formatters/html_index_spec.rb +0 -36
- data/spec/parsed_file_spec.rb +0 -67
- data/spec/parsed_method_spec.rb +0 -34
data/spec/parsed_file_spec.rb
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe ParsedFile do
|
4
|
-
|
5
|
-
let(:parsed_file) { ParsedFile.new(path_to_file: "./spec/fixtures/eg_class.rb") }
|
6
|
-
let(:analyzer) { Analyzer.new("class Foo; end") }
|
7
|
-
|
8
|
-
describe "#class_name" do
|
9
|
-
before do
|
10
|
-
allow(parsed_file).to receive(:analyzer) { analyzer }
|
11
|
-
end
|
12
|
-
it "retrieves class name from analyzer" do
|
13
|
-
expect(parsed_file.class_name).to eq "Foo"
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
describe "#content" do
|
18
|
-
it "reads from file" do
|
19
|
-
allow(File).to receive(:open).with("./spec/fixtures/eg_class.rb", "r") {
|
20
|
-
instance_double("File", read: "whatever")
|
21
|
-
}
|
22
|
-
expect(parsed_file.send(:content)).to eq("whatever")
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
describe "#analyzer" do
|
27
|
-
it "instantiates an Analyzer instance with content" do
|
28
|
-
allow(parsed_file).to receive("content") { "stuff" }
|
29
|
-
expect(parsed_file.send(:analyzer).class.name).to eq "Analyzer"
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
describe "#complexity" do
|
34
|
-
before do
|
35
|
-
allow(parsed_file).to receive(:analyzer) { analyzer }
|
36
|
-
end
|
37
|
-
it "retrieves complexity score from analyzer" do
|
38
|
-
allow(analyzer).to receive(:complexity) { 13 }
|
39
|
-
expect(parsed_file.complexity).to eq 13
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
describe "methods" do
|
44
|
-
before do
|
45
|
-
allow(parsed_file).to receive(:analyzer) { analyzer }
|
46
|
-
end
|
47
|
-
it "retrieves methods from analyzer" do
|
48
|
-
allow(analyzer).to receive(:methods) { [:talk, :walk] }
|
49
|
-
expect(parsed_file.methods).to eq([:talk, :walk])
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
describe "summary" do
|
54
|
-
it "builds a hash" do
|
55
|
-
allow(parsed_file).to receive(:path_to_results) { "doc/fukuzatsu/spec/fixtures/eg_class.rb" }
|
56
|
-
allow(parsed_file).to receive(:path_to_file) { "eg_class.rb.htm" }
|
57
|
-
allow(parsed_file).to receive(:class_name) { "Foo" }
|
58
|
-
allow(parsed_file).to receive(:complexity) { 11 }
|
59
|
-
expect(parsed_file.summary[:results_file]).to eq "doc/fukuzatsu/spec/fixtures/eg_class.rb"
|
60
|
-
expect(parsed_file.summary[:path_to_file]).to eq "eg_class.rb.htm"
|
61
|
-
expect(parsed_file.summary[:class_name]).to eq "Foo"
|
62
|
-
expect(parsed_file.summary[:complexity]).to eq 11
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
|
67
|
-
end
|
data/spec/parsed_method_spec.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe ParsedMethod do
|
4
|
-
|
5
|
-
let(:parsed_method) { ParsedMethod.new }
|
6
|
-
let(:analyzer) { Analyzer.new("class Foo; end") }
|
7
|
-
|
8
|
-
describe "#complexity" do
|
9
|
-
it "retrieves complexity from its analyzer" do
|
10
|
-
allow(parsed_method).to receive(:analyzer) { analyzer }
|
11
|
-
allow(analyzer).to receive(:complexity) { 23 }
|
12
|
-
expect(parsed_method.complexity).to eq 23
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
describe "#analyzer" do
|
17
|
-
it "instantiates an Analyzer instance with content" do
|
18
|
-
allow(parsed_method).to receive("content") { "stuff" }
|
19
|
-
expect(parsed_method.analyzer.class.name).to eq "Analyzer"
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
describe "#prefix" do
|
24
|
-
it "returns '.' if its type is class" do
|
25
|
-
allow(parsed_method).to receive("type") { :class }
|
26
|
-
expect(parsed_method.prefix).to eq "."
|
27
|
-
end
|
28
|
-
it "returns '#' if its type is instance" do
|
29
|
-
allow(parsed_method).to receive("type") { :instance }
|
30
|
-
expect(parsed_method.prefix).to eq "#"
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|