analyst 0.13.1 → 0.14.0
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 +4 -4
- data/analyst.gemspec +4 -3
- data/lib/analyst/{entity_parser/association.rb → association.rb} +0 -0
- data/lib/analyst/entities/begin.rb +13 -0
- data/lib/analyst/entities/class.rb +97 -0
- data/lib/analyst/entities/empty.rb +10 -0
- data/lib/analyst/entities/entity.rb +67 -0
- data/lib/analyst/entities/method.rb +41 -0
- data/lib/analyst/entities/method_call.rb +28 -0
- data/lib/analyst/entities/module.rb +33 -0
- data/lib/analyst/entities/root.rb +22 -0
- data/lib/analyst/entities/singleton_class.rb +21 -0
- data/lib/analyst/parser.rb +30 -55
- data/lib/analyst/version.rb +1 -1
- data/lib/analyst.rb +40 -9
- data/spec/class_spec.rb +30 -0
- data/spec/fixtures/music.rb +70 -0
- data/spec/method_spec.rb +9 -0
- data/spec/parser_spec.rb +29 -0
- data/spec/spec_helper.rb +1 -0
- metadata +38 -87
- data/lib/analyst/cli.rb +0 -42
- data/lib/analyst/entity_parser/entities/class.rb +0 -92
- data/lib/analyst/entity_parser/entities/empty.rb +0 -13
- data/lib/analyst/entity_parser/entities/entity.rb +0 -29
- data/lib/analyst/entity_parser/entities/method.rb +0 -16
- data/lib/analyst/entity_parser/entities/module.rb +0 -31
- data/lib/analyst/formatters/base.rb +0 -33
- data/lib/analyst/formatters/csv.rb +0 -43
- data/lib/analyst/formatters/html.rb +0 -87
- data/lib/analyst/formatters/html_index.rb +0 -47
- data/lib/analyst/formatters/templates/index.html.haml +0 -92
- data/lib/analyst/formatters/templates/output.html.haml +0 -114
- data/lib/analyst/formatters/text.rb +0 -56
- data/lib/analyst/fukuzatsu/analyzer.rb +0 -162
- data/lib/analyst/fukuzatsu/cli.rb +0 -42
- data/lib/analyst/fukuzatsu/entity_parser/association.rb +0 -24
- data/lib/analyst/fukuzatsu/entity_parser/entities/class.rb +0 -92
- data/lib/analyst/fukuzatsu/entity_parser/entities/empty.rb +0 -13
- data/lib/analyst/fukuzatsu/entity_parser/entities/entity.rb +0 -29
- data/lib/analyst/fukuzatsu/entity_parser/entities/method.rb +0 -16
- data/lib/analyst/fukuzatsu/entity_parser/entities/module.rb +0 -31
- data/lib/analyst/fukuzatsu/formatters/base.rb +0 -33
- data/lib/analyst/fukuzatsu/formatters/csv.rb +0 -43
- data/lib/analyst/fukuzatsu/formatters/html.rb +0 -87
- data/lib/analyst/fukuzatsu/formatters/html_index.rb +0 -47
- data/lib/analyst/fukuzatsu/formatters/templates/index.html.haml +0 -92
- data/lib/analyst/fukuzatsu/formatters/templates/output.html.haml +0 -114
- data/lib/analyst/fukuzatsu/formatters/text.rb +0 -56
- data/lib/analyst/fukuzatsu/line_of_code.rb +0 -19
- data/lib/analyst/fukuzatsu/parsed_file.rb +0 -85
- data/lib/analyst/fukuzatsu/parsed_method.rb +0 -32
- data/lib/analyst/fukuzatsu/parser_original.rb +0 -76
- data/lib/analyst/fukuzatsu/rethink/parser.rb +0 -346
- data/lib/analyst/fukuzatsu/version.rb +0 -3
- data/lib/analyst/line_of_code.rb +0 -19
- data/lib/analyst/parsed_file.rb +0 -85
- data/lib/analyst/parsed_method.rb +0 -32
- data/lib/analyst/rethink/parser.rb +0 -346
- data/spec/analyzer_spec.rb +0 -122
- data/spec/cli_spec.rb +0 -48
- 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/csv_spec.rb +0 -37
- data/spec/formatters/html_index_spec.rb +0 -36
- data/spec/formatters/html_spec.rb +0 -48
- data/spec/formatters/text_spec.rb +0 -39
- data/spec/parsed_file_spec.rb +0 -67
- data/spec/parsed_method_spec.rb +0 -34
data/spec/formatters/csv_spec.rb
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe "Formatters::Csv" do
|
|
4
|
-
|
|
5
|
-
let (:method_1) { ParsedMethod.new(
|
|
6
|
-
name: "initialize",
|
|
7
|
-
complexity: 13,
|
|
8
|
-
type: :instance
|
|
9
|
-
)
|
|
10
|
-
}
|
|
11
|
-
let (:method_2) { ParsedMethod.new(
|
|
12
|
-
name: "report",
|
|
13
|
-
complexity: 11,
|
|
14
|
-
type: :instance
|
|
15
|
-
)
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
let(:parsed_file) { Struct.new(:path_to_file, :class_name) }
|
|
19
|
-
let(:mock_parsed_file) { parsed_file.new("fred/foo.rb", "Foo") }
|
|
20
|
-
let (:formatter) { Formatters::Csv.new(mock_parsed_file) }
|
|
21
|
-
|
|
22
|
-
describe "#rows" do
|
|
23
|
-
it "returns comma-separated rows" do
|
|
24
|
-
allow(mock_parsed_file).to receive(:methods) { [method_1, method_2] }
|
|
25
|
-
expect(formatter.rows).to eq(
|
|
26
|
-
"fred/foo.rb,Foo,#initialize,13\r\nfred/foo.rb,Foo,#report,11"
|
|
27
|
-
)
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
describe "#file_extension" do
|
|
32
|
-
it "returns the proper extension" do
|
|
33
|
-
expect(formatter.file_extension).to eq ".csv"
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
end
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe "Formatters::HtmlIndex" do
|
|
4
|
-
|
|
5
|
-
let(:file_summary) {
|
|
6
|
-
[
|
|
7
|
-
{
|
|
8
|
-
results_file: "doc/analyst/file_1.rb.htm",
|
|
9
|
-
path_to_file: "file_1.rb",
|
|
10
|
-
class_name: "File_1",
|
|
11
|
-
complexity: 13
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
results_file: "doc/analyst/file_2.rb.htm",
|
|
15
|
-
path_to_file: "file_2.rb",
|
|
16
|
-
class_name: "File_2",
|
|
17
|
-
complexity: 11
|
|
18
|
-
}
|
|
19
|
-
]
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
let (:formatter) { Formatters::HtmlIndex.new(file_summary) }
|
|
23
|
-
|
|
24
|
-
describe "#initialize" do
|
|
25
|
-
it "initializes with a file summary" do
|
|
26
|
-
expect(formatter.file_summary).to eq file_summary
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
describe "#filename" do
|
|
31
|
-
it "returns the expected filename" do
|
|
32
|
-
expect(formatter.filename).to eq "index.htm"
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
end
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe "Formatters::Text" do
|
|
4
|
-
|
|
5
|
-
let(:parsed_file) { Struct.new(:path_to_file, :class_name)}
|
|
6
|
-
let(:mock_parsed_file) { parsed_file.new("fred/foo.rb", "Foo") }
|
|
7
|
-
let (:method_1) { ParsedMethod.new(
|
|
8
|
-
name: "initialize",
|
|
9
|
-
complexity: 13,
|
|
10
|
-
type: :instance
|
|
11
|
-
)
|
|
12
|
-
}
|
|
13
|
-
let (:method_2) { ParsedMethod.new(
|
|
14
|
-
name: "report",
|
|
15
|
-
complexity: 11,
|
|
16
|
-
type: :instance
|
|
17
|
-
)
|
|
18
|
-
}
|
|
19
|
-
let (:formatter) { Formatters::Html.new(mock_parsed_file) }
|
|
20
|
-
|
|
21
|
-
before do
|
|
22
|
-
allow(mock_parsed_file).to receive(:methods) { [method_1, method_2] }
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
describe "#header" do
|
|
26
|
-
it "returns an HTML-formatted header" do
|
|
27
|
-
expect(formatter.header).to eq(
|
|
28
|
-
"<th>Class</th>\r\n<th>Method</th>\r\n<th>Complexity</th>"
|
|
29
|
-
)
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
describe "#rows" do
|
|
34
|
-
it "returns HTML-formatted rows" do
|
|
35
|
-
expected = "<tr class='even'>\r\n <td>Foo</td>\r\n <td>#initialize</td>\r\n <td>13</td>\r\n</tr>\r\n"
|
|
36
|
-
expected << "<tr class='odd'>\r\n <td>Foo</td>\r\n <td>#report</td>\r\n <td>11</td>\r\n</tr>"
|
|
37
|
-
allow(mock_parsed_file).to receive(:methods) { [method_1, method_2] }
|
|
38
|
-
expect(formatter.rows).to eq(expected)
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
describe "#file_extension" do
|
|
43
|
-
it "returns the proper extension" do
|
|
44
|
-
expect(formatter.file_extension).to eq ".htm"
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
end
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe "Formatters::Text" do
|
|
4
|
-
|
|
5
|
-
let (:parsed_file) { ParsedFile.new(class_name: "Foo", complexity: 11) }
|
|
6
|
-
let (:method_1) { ParsedMethod.new(
|
|
7
|
-
name: "initialize",
|
|
8
|
-
complexity: 13,
|
|
9
|
-
type: "instance"
|
|
10
|
-
)
|
|
11
|
-
}
|
|
12
|
-
let (:method_2) { ParsedMethod.new(
|
|
13
|
-
name: "report",
|
|
14
|
-
complexity: 11,
|
|
15
|
-
type: "instance"
|
|
16
|
-
)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
let(:parsed_file) { Struct.new(:path_to_file, :class_name, :average_complexity)}
|
|
21
|
-
let(:mock_parsed_file) { parsed_file.new("fred/foo.rb", "Foo", 12) }
|
|
22
|
-
let (:formatter) { Formatters::Text.new(mock_parsed_file) }
|
|
23
|
-
|
|
24
|
-
describe "#header" do
|
|
25
|
-
it "returns a header array" do
|
|
26
|
-
expect(formatter.header).to eq ["Class/Module", "Method", "Complexity"]
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
describe "#rows" do
|
|
31
|
-
it "returns formatted rows" do
|
|
32
|
-
allow(mock_parsed_file).to receive(:methods) { [method_1, method_2] }
|
|
33
|
-
expect(formatter.rows).to eq(
|
|
34
|
-
[["\e[31mFoo\e[0m", "\e[31m*initialize\e[0m", "\e[31m13\e[0m"], ["\e[33mFoo\e[0m", "\e[33m*report\e[0m", "\e[33m11\e[0m"]]
|
|
35
|
-
)
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
end
|
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/analyst/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/analyst/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
|