fukuzatsu 1.0.4 → 1.0.5

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: 65fa8bca4bbb758dc65c2689df39c7235f398280
4
- data.tar.gz: 8a1008b8017f8a9affdf31e882b9de64ab9c4228
3
+ metadata.gz: 8428f57be028d8631c44a4918b3b45e5a975f723
4
+ data.tar.gz: fec178eca577f552ad69e8706f4767a21283a551
5
5
  SHA512:
6
- metadata.gz: b2cff1c582f0e761a882a6aea091d532b81c9c4f77a98e6c612099ae9e2780a51bdf2017e649c066287dde9c6df7eb1afb150b81f612480ed9832bcdea9ada2f
7
- data.tar.gz: 98a3185b4c93950fc2deada10c42c83a17e50d9b8180800dce657cdc01f611f0b287e32a517a3719f45381b8d30f2dd51eef0e184feac14b1bcbef0c6de94257
6
+ metadata.gz: 0538641fea2e818d9d696318e0f78410acbbe6429448d8254d53fddd236a9530ab41f13f4309268e23c8c41b53621356cdd04e4a5c131303ad9932bec4ef0a7e
7
+ data.tar.gz: 461e0e1ee4e169e86f9c314ef1d0985e8c7dc7f0922d810628cd8500603f0aa6c23f738612e1b0d4b60c7e07c702af4808b5f314bf7e7735a041fc07724a0188
@@ -6,6 +6,8 @@ class Analyzer
6
6
 
7
7
  attr_accessor :content, :class_name, :edges, :nodes, :exits
8
8
 
9
+ DEFAULT_CLASS_NAME = "Unknown"
10
+
9
11
  def initialize(content)
10
12
  self.content = content
11
13
  self.edges = 0
@@ -18,17 +20,69 @@ class Analyzer
18
20
  self.edges - self.nodes + exits
19
21
  end
20
22
 
23
+ def class_name
24
+ find_class(parsed) || DEFAULT_CLASS_NAME
25
+ end
26
+
27
+ def methods
28
+ @methods ||= methods_from(parsed)
29
+ end
30
+
31
+ def constants
32
+ @constants ||= constants_from(parsed)
33
+ end
34
+
21
35
  def extract_methods
22
36
  @methods ||= methods_from(parsed)
23
37
  end
24
38
 
25
39
  def extract_class_name
26
- return self.class_name if self.class_name
27
- find_class(parsed) || "?"
40
+ return self.class_name if self.class_name && ! self.class_name.empty?
41
+ found = find_class(parsed)
42
+ self.class_name = ! found.empty? && found || DEFAULT_CLASS_NAME
28
43
  end
29
44
 
30
45
  private
31
46
 
47
+ def method_list
48
+ @method_list ||= method_names_from(parsed.children.first)
49
+ end
50
+
51
+ def method_names_from(node, found=[])
52
+ return found unless node.respond_to?(:type)
53
+ if node.type == :def || node.type == :defs
54
+ name = node.loc.name
55
+ found << content[name.begin_pos..name.end_pos - 1].to_sym
56
+ end
57
+ node.children.each do |child|
58
+ method_names_from(child, found) if parent_node?(child)
59
+ end
60
+ found
61
+ end
62
+
63
+ def constants_from(node, found=[])
64
+ if node.type == :const
65
+ expression = node.loc.expression
66
+ found << content[expression.begin_pos..expression.end_pos - 1]
67
+ end
68
+ node.children.each do |child|
69
+ constants_from(child, found) if parent_node?(child)
70
+ end
71
+ found.reject{ |constant| constant == class_name }
72
+ end
73
+
74
+ def extract_references_from(node, found=[])
75
+ return found unless node && node.respond_to?(:type)
76
+ if node.type == :send
77
+ reference = node.loc.expression
78
+ found << node.children.last
79
+ end
80
+ node.children.each do |child|
81
+ extract_references_from(child, found)
82
+ end
83
+ found.select{|name| method_list.include?(name)}
84
+ end
85
+
32
86
  def text_at(start_pos, end_pos)
33
87
  content[start_pos..end_pos - 1]
34
88
  end
@@ -50,7 +104,7 @@ class Analyzer
50
104
  end
51
105
 
52
106
  def methods_from(node, methods=[])
53
- if node.type == :def || node.type == :defs || node.type == :class
107
+ if node.type == :def || node.type == :defs
54
108
  name = node.loc.name
55
109
  expression = node.loc.expression
56
110
  type = case(node.type)
@@ -64,7 +118,8 @@ class Analyzer
64
118
  methods << ParsedMethod.new(
65
119
  name: content[name.begin_pos..name.end_pos - 1],
66
120
  content: content[expression.begin_pos..expression.end_pos - 1],
67
- type: type
121
+ type: type,
122
+ refs: extract_references_from(node)
68
123
  )
69
124
  end
70
125
  node.children.each do |child|
@@ -72,7 +127,7 @@ class Analyzer
72
127
  methods_from(child, methods)
73
128
  end
74
129
  end
75
- methods
130
+ methods.reject{ |m| m.name.empty? }
76
131
  end
77
132
 
78
133
  def parent_node?(node)
@@ -8,7 +8,7 @@ module Formatters
8
8
  klass.send(:attr_accessor, :output_directory)
9
9
  end
10
10
 
11
- def initialize(file, output_directory, source="")
11
+ def initialize(file, output_directory=nil, source="")
12
12
  self.file = file
13
13
  self.source = source
14
14
  self.output_directory = output_directory
@@ -34,7 +34,7 @@ module Formatters
34
34
 
35
35
  def rows
36
36
  file.methods.map do |method|
37
- "#{file.path_to_file},#{file.class_name},#{method.prefix}#{method.name},#{method.complexity}"
37
+ "#{file.path_to_file},#{file.class_name},#{method.name},#{method.complexity}"
38
38
  end.join("\r\n")
39
39
  end
40
40
 
@@ -6,7 +6,7 @@ module Formatters
6
6
 
7
7
  attr_reader :file_summary, :output_directory
8
8
 
9
- def initialize(file_summary, output_directory)
9
+ def initialize(file_summary, output_directory=nil)
10
10
  @file_summary = file_summary
11
11
  @output_directory = output_directory
12
12
  end
@@ -47,7 +47,7 @@ module Formatters
47
47
 
48
48
  def wrap(string)
49
49
  return string if string.length < 25
50
- string[0..24] << "..."
50
+ string[0..20] << "..."
51
51
  end
52
52
 
53
53
  end
@@ -1,21 +1,26 @@
1
1
  class ParsedFile
2
2
 
3
- include PoroPlus
4
- include Ephemeral::Base
5
-
6
- attr_accessor :complexity, :path_to_file, :class_name, :path_to_results
7
3
  attr_accessor :lines_of_code, :source
4
+ attr_accessor :complexity, :path_to_file, :class_name, :path_to_results
5
+
6
+ def initialize(path_to_file: path_to_file, class_name: class_name=nil, complexity: complexity)
7
+ @path_to_file = path_to_file
8
+ @class_name = class_name
9
+ @lines_of_code = []
10
+ @complexity = complexity
11
+ @source = parse!
12
+ end
8
13
 
9
14
  def class_name
10
- @class_name ||= analyzer.extract_class_name
15
+ @class_name ||= analyzer.class_name
11
16
  end
12
17
 
13
- def content
14
- @content ||= File.open(path_to_file, "r").read
18
+ def class_references
19
+ @class_references ||= analyzer.constants
15
20
  end
16
21
 
17
- def analyzer
18
- @analyzer ||= Analyzer.new(content)
22
+ def content
23
+ @content ||= File.open(path_to_file, "r").read
19
24
  end
20
25
 
21
26
  def average_complexity
@@ -27,7 +32,16 @@ class ParsedFile
27
32
  end
28
33
 
29
34
  def methods
30
- @methods ||= analyzer.extract_methods
35
+ @methods ||= analyzer.methods
36
+ end
37
+
38
+ def method_counts
39
+ referenced_methods = methods.map(&:references).flatten
40
+ referenced_methods.inject({}) do |hash, method|
41
+ hash[method] ||= 0
42
+ hash[method] += 1
43
+ hash
44
+ end
31
45
  end
32
46
 
33
47
  def source
@@ -45,10 +59,31 @@ class ParsedFile
45
59
  def summary
46
60
  {
47
61
  path_to_file: self.path_to_file,
62
+ results_file: self.path_to_results,
48
63
  source: source,
49
64
  class_name: self.class_name,
50
65
  complexity: complexity
51
66
  }
52
67
  end
53
68
 
54
- end
69
+ private
70
+
71
+ def analyzer
72
+ @analyzer ||= Analyzer.new(content)
73
+ end
74
+
75
+ def content
76
+ @content ||= File.open(path_to_file, "r").read
77
+ end
78
+
79
+ def parse!
80
+ end_pos = 0
81
+ File.readlines(self.path_to_file).each_with_index do |line, index|
82
+ start_pos = end_pos + 1
83
+ end_pos += line.size
84
+ self.lines_of_code << LineOfCode.new(line_number: index + 1, range: (start_pos..end_pos))
85
+ line
86
+ end.join
87
+ end
88
+
89
+ end
@@ -1,8 +1,14 @@
1
1
  class ParsedMethod
2
2
 
3
- include PoroPlus
3
+ attr_reader :name, :content, :type, :complexity, :references
4
4
 
5
- attr_accessor :name, :content, :type, :complexity
5
+ def initialize(name: name, content: content, type: type, refs: refs=[], complexity: complexity)
6
+ @name = name
7
+ @content = content
8
+ @type = type
9
+ @references = refs
10
+ @complexity = complexity
11
+ end
6
12
 
7
13
  def complexity
8
14
  @complexity ||= analyzer.complexity
@@ -1,3 +1,3 @@
1
1
  module Fukuzatsu
2
- VERSION = "1.0.4"
2
+ VERSION = "1.0.5"
3
3
  end
@@ -22,7 +22,7 @@ describe Analyzer do
22
22
  expect(Analyzer.new(content_4).extract_class_name).to eq("Foo::Bar")
23
23
  end
24
24
  end
25
-
25
+
26
26
  context "from Module; Class" do
27
27
  it "returns Extracted::Thing" do
28
28
  expect(Analyzer.new(content_6).extract_class_name).to eq("Extracted::Thing")
@@ -57,7 +57,7 @@ describe Analyzer do
57
57
 
58
58
  end
59
59
  end
60
-
60
+
61
61
  describe "extract_class_name" do
62
62
  context "from a file with a class in it" do
63
63
  let(:analyzer) { Analyzer.new(File.read("spec/fixtures/single_class.rb")) }
@@ -68,18 +68,18 @@ describe Analyzer do
68
68
  context "from a file with a class inside a module" do
69
69
  let(:analyzer) { Analyzer.new(File.read("spec/fixtures/module_with_class.rb")) }
70
70
  it "should return the name of the class" do
71
- expect(analyzer.extract_class_name).to eq "Bee"
71
+ expect(analyzer.extract_class_name).to eq "Symbolics::Insects::Bee"
72
72
  end
73
73
  end
74
74
  context "from a file with no class in it" do
75
75
  let(:analyzer) { Analyzer.new(File.read("spec/fixtures/single_method.rb")) }
76
- it "should return '?'" do
77
- expect(analyzer.extract_class_name).to eq "?"
76
+ it "should return 'Unknown'" do
77
+ expect(analyzer.extract_class_name).to eq "Unknown"
78
78
  end
79
79
  end
80
-
80
+
81
81
  end
82
-
82
+
83
83
  describe "extract_methods" do
84
84
  # Note: should implicitly trust private method #methods_from
85
85
  context "from a file with a single method" do
@@ -88,7 +88,7 @@ describe Analyzer do
88
88
  expect(analyzer.extract_methods.count).to eq 1
89
89
  end
90
90
  it "should extract the method name" do
91
- expect(analyzer.extract_methods[0].name).to eq "read_poem"
91
+ expect(analyzer.extract_methods[0].name).to eq "#read_poem"
92
92
  end
93
93
  it "should extract the method content" do
94
94
  expect(analyzer.extract_methods[0].content).to eq 'def read_poem
@@ -102,22 +102,19 @@ end'
102
102
  context "from a file with multiple methods" do
103
103
  let(:analyzer) { Analyzer.new(File.read("spec/fixtures/multiple_methods.rb")) }
104
104
  it "should return multiple methods" do
105
- expect(analyzer.extract_methods.map { |m| m.name }).to eq ["bake_treats", "lower_from_window"]
105
+ expect(analyzer.extract_methods.map { |m| m.name }).to eq ["#bake_treats", "#lower_from_window"]
106
106
  end
107
107
  end
108
108
  context "from a file with nested methods" do
109
109
  let(:analyzer) { Analyzer.new(File.read("spec/fixtures/nested_methods.rb")) }
110
110
  it "should return the root method, and its child" do
111
- expect(analyzer.extract_methods.map { |m| m.name }).to eq ["grow_flowers", "water_earth"]
111
+ expect(analyzer.extract_methods.map { |m| m.name }).to eq ["#grow_flowers", "#water_earth"]
112
112
  end
113
113
  end
114
114
  context "from a file with a class" do
115
115
  let(:analyzer) { Analyzer.new(File.read("spec/fixtures/single_class.rb")) }
116
116
  it "should return the class and its methods" do
117
- expect(analyzer.extract_methods.map { |m| m.name }).to eq ["Gown", "initialize", "color"]
118
- end
119
- it "should set the type of class to :class" do
120
- expect(analyzer.extract_methods[0].type).to eq :class
117
+ expect(analyzer.extract_methods.map { |m| m.name }).to eq ["#initialize", "#color"]
121
118
  end
122
119
  end
123
120
  end
data/spec/cli_spec.rb CHANGED
@@ -30,12 +30,6 @@ describe "Fukuzatsu::CLI" do
30
30
  allow(cli).to receive(:summaries) { [summary_1, summary_2] }
31
31
  end
32
32
 
33
- describe "#complexities" do
34
- it "extracts complexities from its file summaries" do
35
- expect(cli.send(:complexities)).to eq([13,11])
36
- end
37
- end
38
-
39
33
  describe "#formatter" do
40
34
  it "returns a csv formatter" do
41
35
  allow(cli).to receive(:options) { {'format' => 'csv'} }
@@ -51,35 +45,4 @@ describe "Fukuzatsu::CLI" do
51
45
  end
52
46
  end
53
47
 
54
- describe "#report" do
55
- it "does not report if format is text" do
56
- allow(cli).to receive(:options) { {'format' => 'text'} }
57
- expect(cli.send(:report)).to be_nil
58
- end
59
- end
60
-
61
- describe "#report_complexity" do
62
- it "does not report if threshold is not set" do
63
- expect(cli.send(:report_complexity)).to be_nil
64
- end
65
-
66
- it "does not report if threshold is respected" do
67
- allow(cli).to receive(:options) { {'threshold' => 15} }
68
- allow(cli).to receive(:complexities) { [0,13,11] }
69
- expect(cli.send(:report_complexity)).to be_nil
70
-
71
- end
72
- end
73
-
74
- describe "#results_files" do
75
- it "extracts results files from its file summaries" do
76
- expect(cli.send(:results_files)).to eq(
77
- [
78
- "doc/fukuzatsu/file_1.rb.htm",
79
- "doc/fukuzatsu/file_2.rb.htm"
80
- ]
81
- )
82
- end
83
- end
84
-
85
48
  end
@@ -2,32 +2,28 @@ require 'spec_helper'
2
2
 
3
3
  describe "Formatters::Csv" do
4
4
 
5
- let (:parsed_file) { ParsedFile.new(class_name: "Foo") }
6
5
  let (:method_1) { ParsedMethod.new(
7
6
  name: "initialize",
8
7
  complexity: 13,
9
- type: "instance"
8
+ type: :instance
10
9
  )
11
10
  }
12
11
  let (:method_2) { ParsedMethod.new(
13
12
  name: "report",
14
13
  complexity: 11,
15
- type: "instance"
14
+ type: :instance
16
15
  )
17
16
  }
18
- let (:formatter) { Formatters::Csv.new(parsed_file) }
19
17
 
20
- describe "#header" do
21
- it "returns a comma-separated header" do
22
- expect(formatter.header).to eq "class,method,complexity"
23
- end
24
- end
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) }
25
21
 
26
22
  describe "#rows" do
27
23
  it "returns comma-separated rows" do
28
- allow(parsed_file).to receive(:methods) { [method_1, method_2] }
24
+ allow(mock_parsed_file).to receive(:methods) { [method_1, method_2] }
29
25
  expect(formatter.rows).to eq(
30
- "Foo,#initialize,13\r\nFoo,#report,11"
26
+ "fred/foo.rb,Foo,#initialize,13\r\nfred/foo.rb,Foo,#report,11"
31
27
  )
32
28
  end
33
29
  end
@@ -2,23 +2,24 @@ require 'spec_helper'
2
2
 
3
3
  describe "Formatters::Text" do
4
4
 
5
- let (:parsed_file) { ParsedFile.new(class_name: "Foo", complexity: 11) }
5
+ let(:parsed_file) { Struct.new(:path_to_file, :class_name)}
6
+ let(:mock_parsed_file) { parsed_file.new("fred/foo.rb", "Foo") }
6
7
  let (:method_1) { ParsedMethod.new(
7
8
  name: "initialize",
8
9
  complexity: 13,
9
- type: "instance"
10
+ type: :instance
10
11
  )
11
12
  }
12
13
  let (:method_2) { ParsedMethod.new(
13
14
  name: "report",
14
15
  complexity: 11,
15
- type: "instance"
16
+ type: :instance
16
17
  )
17
18
  }
18
- let (:formatter) { Formatters::Html.new(parsed_file) }
19
+ let (:formatter) { Formatters::Html.new(mock_parsed_file) }
19
20
 
20
21
  before do
21
- allow(parsed_file).to receive(:methods) { [method_1, method_2] }
22
+ allow(mock_parsed_file).to receive(:methods) { [method_1, method_2] }
22
23
  end
23
24
 
24
25
  describe "#header" do
@@ -33,7 +34,7 @@ describe "Formatters::Text" do
33
34
  it "returns HTML-formatted rows" do
34
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"
35
36
  expected << "<tr class='odd'>\r\n <td>Foo</td>\r\n <td>#report</td>\r\n <td>11</td>\r\n</tr>"
36
- allow(parsed_file).to receive(:methods) { [method_1, method_2] }
37
+ allow(mock_parsed_file).to receive(:methods) { [method_1, method_2] }
37
38
  expect(formatter.rows).to eq(expected)
38
39
  end
39
40
  end
@@ -15,19 +15,23 @@ describe "Formatters::Text" do
15
15
  type: "instance"
16
16
  )
17
17
  }
18
- let (:formatter) { Formatters::Text.new(parsed_file) }
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) }
19
23
 
20
24
  describe "#header" do
21
- it "returns a tab-separated header" do
22
- expect(formatter.header).to eq "Foo\t\t11"
25
+ it "returns a header array" do
26
+ expect(formatter.header).to eq ["Class/Module", "Method", "Complexity"]
23
27
  end
24
28
  end
25
29
 
26
30
  describe "#rows" do
27
- it "returns tab-separated rows" do
28
- allow(parsed_file).to receive(:methods) { [method_1, method_2] }
31
+ it "returns formatted rows" do
32
+ allow(mock_parsed_file).to receive(:methods) { [method_1, method_2] }
29
33
  expect(formatter.rows).to eq(
30
- ["Foo\t#initialize\t13", "Foo\t#report\t11"]
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"]]
31
35
  )
32
36
  end
33
37
  end
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe ParsedFile do
4
4
 
5
- let(:parsed_file) { ParsedFile.new(path_to_file: "bar/foo.rb") }
5
+ let(:parsed_file) { ParsedFile.new(path_to_file: "./spec/fixtures/eg_class.rb") }
6
6
  let(:analyzer) { Analyzer.new("class Foo; end") }
7
7
 
8
8
  describe "#class_name" do
@@ -16,17 +16,17 @@ describe ParsedFile do
16
16
 
17
17
  describe "#content" do
18
18
  it "reads from file" do
19
- allow(File).to receive(:open).with("bar/foo.rb", "r") {
19
+ allow(File).to receive(:open).with("./spec/fixtures/eg_class.rb", "r") {
20
20
  instance_double("File", read: "whatever")
21
21
  }
22
- expect(parsed_file.content).to eq("whatever")
22
+ expect(parsed_file.send(:content)).to eq("whatever")
23
23
  end
24
24
  end
25
25
 
26
26
  describe "#analyzer" do
27
27
  it "instantiates an Analyzer instance with content" do
28
28
  allow(parsed_file).to receive("content") { "stuff" }
29
- expect(parsed_file.analyzer.class.name).to eq "Analyzer"
29
+ expect(parsed_file.send(:analyzer).class.name).to eq "Analyzer"
30
30
  end
31
31
  end
32
32
 
@@ -45,19 +45,19 @@ describe ParsedFile do
45
45
  allow(parsed_file).to receive(:analyzer) { analyzer }
46
46
  end
47
47
  it "retrieves methods from analyzer" do
48
- allow(analyzer).to receive(:extract_methods) { [:talk, :walk] }
48
+ allow(analyzer).to receive(:methods) { [:talk, :walk] }
49
49
  expect(parsed_file.methods).to eq([:talk, :walk])
50
50
  end
51
51
  end
52
52
 
53
53
  describe "summary" do
54
54
  it "builds a hash" do
55
- allow(parsed_file).to receive(:path_to_results) { "doc/fukuzatsu/foo.rb.htm" }
56
- allow(parsed_file).to receive(:path_to_file) { "foo.rb.htm" }
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
57
  allow(parsed_file).to receive(:class_name) { "Foo" }
58
58
  allow(parsed_file).to receive(:complexity) { 11 }
59
- expect(parsed_file.summary[:results_file]).to eq "doc/fukuzatsu/foo.rb.htm"
60
- expect(parsed_file.summary[:path_to_file]).to eq "foo.rb.htm"
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
61
  expect(parsed_file.summary[:class_name]).to eq "Foo"
62
62
  expect(parsed_file.summary[:complexity]).to eq 11
63
63
  end
@@ -22,11 +22,11 @@ describe ParsedMethod do
22
22
 
23
23
  describe "#prefix" do
24
24
  it "returns '.' if its type is class" do
25
- allow(parsed_method).to receive("type") { "class" }
25
+ allow(parsed_method).to receive("type") { :class }
26
26
  expect(parsed_method.prefix).to eq "."
27
27
  end
28
28
  it "returns '#' if its type is instance" do
29
- allow(parsed_method).to receive("type") { "instance" }
29
+ allow(parsed_method).to receive("type") { :instance }
30
30
  expect(parsed_method.prefix).to eq "#"
31
31
  end
32
32
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fukuzatsu
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bantik
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-07 00:00:00.000000000 Z
11
+ date: 2014-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ephemeral
@@ -228,7 +228,6 @@ files:
228
228
  - spec/fixtures/program_4.rb
229
229
  - spec/fixtures/single_class.rb
230
230
  - spec/fixtures/single_method.rb
231
- - spec/formatters/base_spec.rb
232
231
  - spec/formatters/csv_spec.rb
233
232
  - spec/formatters/html_index_spec.rb
234
233
  - spec/formatters/html_spec.rb
@@ -277,7 +276,6 @@ test_files:
277
276
  - spec/fixtures/program_4.rb
278
277
  - spec/fixtures/single_class.rb
279
278
  - spec/fixtures/single_method.rb
280
- - spec/formatters/base_spec.rb
281
279
  - spec/formatters/csv_spec.rb
282
280
  - spec/formatters/html_index_spec.rb
283
281
  - spec/formatters/html_spec.rb
@@ -285,3 +283,4 @@ test_files:
285
283
  - spec/parsed_file_spec.rb
286
284
  - spec/parsed_method_spec.rb
287
285
  - spec/spec_helper.rb
286
+ has_rdoc:
@@ -1,56 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "Formatters::Base" do
4
-
5
- class Formatters::Sample; include Formatters::Base; end
6
-
7
- let (:parsed_file) { ParsedFile.new(class_name: "Foo", path_to_file: "lib/foo.rb") }
8
- let (:formatter) { Formatters::Sample.new(parsed_file) }
9
-
10
- before do
11
- allow(formatter).to receive(:header) { "class,method,complexity" }
12
- allow(formatter).to receive(:rows) { "Foo,#initialize,24" }
13
- allow(formatter).to receive(:footer) { "TOTAL,,24" }
14
- end
15
-
16
- describe "#columns" do
17
- it "returns default columns" do
18
- expect(formatter.columns).to eq(["class", "method", "complexity"])
19
- end
20
- end
21
-
22
- describe "#content" do
23
- it "returns expected content" do
24
- expect(formatter.content).to eq "class,method,complexity\r\nFoo,#initialize,24\r\nTOTAL,,24"
25
- end
26
- end
27
-
28
- describe "#filename" do
29
- it "builds a filename" do
30
- allow(formatter).to receive(:file_extension) { '.doc' }
31
- expect(formatter.filename).to eq "foo.rb.doc"
32
- end
33
- end
34
-
35
- describe "#output_path" do
36
- it "builds a path" do
37
- allow(FileUtils).to receive(:mkpath)
38
- expect(formatter.output_path).to eq "doc/fukuzatsu/lib"
39
- end
40
- end
41
-
42
- describe "#path_to_results" do
43
- it "builds a path" do
44
- allow(formatter).to receive(:file_extension) { '.doc' }
45
- allow(formatter).to receive(:output_path) { 'doc/fukuzatsu/lib' }
46
- expect(formatter.path_to_results).to eq "doc/fukuzatsu/lib/foo.rb.doc"
47
- end
48
- end
49
-
50
- describe "#root_path" do
51
- it "returns the expected path" do
52
- expect(formatter.root_path).to eq "doc/fukuzatsu"
53
- end
54
- end
55
-
56
- end