fukuzatsu 0.9.8 → 0.9.10

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: 1321229a0d5c57e3bd0b2938e295115514c2e73a
4
- data.tar.gz: c205ccb2a0e79826e14c6988f1beba80cacff8c3
3
+ metadata.gz: dc7d149f079d0f937f492a870b0afaf580b8a282
4
+ data.tar.gz: a07ef85ca31e0ac5091fc474f8b8624c31d378c0
5
5
  SHA512:
6
- metadata.gz: 99cb838cafffc71182f18591d22d5ec89c3e5af058a19abd3e3792e0938f5f4a1554e4da4c6c1bf133d78e87bd19d60701513751a68554b962b379c653df5897
7
- data.tar.gz: d7c6dfa10faf25af7b7b0cc6d431b02e05d4c09e058b52a5925e91d2bc8d8deef691d2e0c17c758382385b9a587cb01e863c60068668fe45b213950cba68b4d3
6
+ metadata.gz: 636161e9e1e6cb468d6027475aed98619ef62b624b2881f9bd52cff4ae83110ce605ee2826f624e1ac81b45ee9d4e08f76b40ea426a8ba0483cdc9d650aea22f
7
+ data.tar.gz: b62ff6dccd7cbbe91e5c8ca209c061008728e69e215d06f8436615453245cbe9152f17c5c65ef735e74a35808b8e67dd4b84080c441d7128365760a8b06ed419
data/.gitignore CHANGED
@@ -20,4 +20,5 @@ tmp
20
20
  *.o
21
21
  *.a
22
22
  mkmf.log
23
- .console_history
23
+ .console_history
24
+ *.swp
data/README.md CHANGED
@@ -2,11 +2,15 @@
2
2
 
3
3
  *Note: this gem is a work in progress and should not be considered production-ready until version 1.0*
4
4
 
5
- Fukuzatsu ("complexity") is a tool for measuring code complexity in Ruby class files. Its analysis generates relative complexity figures similar to the results of cyclomatic complexity algorithms. (You can learn more about cyclomatic complexity at http://en.wikipedia.org/wiki/Cyclomatic_complexity)
5
+ Fukuzatsu ("complexity") is a tool for measuring code complexity in Ruby class files. Its analysis
6
+ generates relative complexity figures similar to the results of cyclomatic complexity algorithms.
7
+ (You can learn more about cyclomatic complexity at http://en.wikipedia.org/wiki/Cyclomatic_complexity)
6
8
 
7
- Why should you care about this kind of complexity? More complex code tends to attract bugs and to increase the friction around extending features or refactoring code.
9
+ Why should you care about this kind of complexity? More complex code tends to attract bugs and to
10
+ increase the friction around extending features or refactoring code.
8
11
 
9
- Fukuzatsu was created by Coraline Ada Ehmke with invaluable assistance from Mike Ziwisky (mziwisky). It was inspired by Saikuro, written by Zev Blut.
12
+ Fukuzatsu was created by Coraline Ada Ehmke with invaluable assistance from Mike Ziwisky (mziwisky).
13
+ It was inspired by Saikuro, written by Zev Blut.
10
14
 
11
15
  ## Installation
12
16
 
@@ -18,12 +22,12 @@ This installs the CLI tool.
18
22
 
19
23
  ## Usage
20
24
 
21
- fuku parse path/to/file/my_file.rb
25
+ fuku check path/to/file/my_file.rb
22
26
 
23
- fuku parse path/to/file/my_file.rb -f html
27
+ fuku check path/to/file/my_file.rb -f html
24
28
  # Writes to doc/fuzuzatsu/path/to_file/my_file.rb.htm
25
29
 
26
- fuku parse path/to/file/my_file.rb -f csv
30
+ fuku check path/to/file/my_file.rb -f csv
27
31
  # Writes to doc/fuzuzatsu/path/to_file/my_file.rb.csv
28
32
 
29
33
  ## Contributing
@@ -24,23 +24,23 @@ class Analyzer
24
24
 
25
25
  def extract_class_name
26
26
  return self.class_name if self.class_name
27
- child = find_class(parsed)
28
- return "?" unless child
29
- name = child.loc.name
30
- self.class_name = self.content[name.begin_pos..(name.end_pos - 1)]
27
+ find_class(parsed) || "?"
31
28
  end
32
29
 
33
30
  private
34
31
 
35
- def find_class(parsed)
36
- return parsed if parsed.respond_to?(:type) && (parsed.type == :class || (parsed.type == :module && parsed.children.empty?))
37
- child_nodes = parsed.respond_to?(:children) ? parsed.children : parsed
38
- child_nodes.each do |child_node|
39
- next unless child_node.respond_to?(:type)
40
- return child_node if child_node.type == :class
41
- return find_class(child_node.children) if child_node.type == :module
32
+ def text_at(start_pos, end_pos)
33
+ content[start_pos..end_pos - 1]
34
+ end
35
+
36
+ def find_class(node)
37
+ return unless node && node.respond_to?(:type)
38
+ concat = []
39
+ if node.type == :module || node.type == :class
40
+ concat << text_at(node.loc.name.begin_pos, node.loc.name.end_pos)
42
41
  end
43
- false
42
+ concat << node.children.map{|child| find_class(child)}.compact
43
+ concat.flatten.select(&:present?).join('::')
44
44
  end
45
45
 
46
46
  def extend_graph
@@ -25,6 +25,7 @@ module Formatters
25
25
  header: header,
26
26
  rows: rows,
27
27
  class_name: file.class_name,
28
+ complexity: file.complexity,
28
29
  path_to_file: file.path_to_file,
29
30
  date: Time.now.strftime("%Y/%m/%d"),
30
31
  time: Time.now.strftime("%l:%M %P")
@@ -59,4 +60,4 @@ module Formatters
59
60
 
60
61
  end
61
62
 
62
- end
63
+ end
@@ -10,20 +10,28 @@
10
10
 
11
11
  %style{media: "screen", type: "text/css"}
12
12
  body { background: #593232; color: #fff; font-family: arial, sans-serif; padding: 2em; }
13
- table { border: 10px solid #000; border-collapse: collapse; min-width: 50%; }
14
- tr { border-top: 1px solid #000; }
15
- tr.header { background: rgba(255, 255, 255, 0.75)}
13
+ table { box-shadow: 0 5px 0 rgba(0,0,0,.8); background: #444; border-spacing: 0; border: 5px solid #000; border-radius: 25px; border-collapse: collapse; min-width: 50%; }
14
+ th.sorting_asc, th.sorting_desc { text-transform: uppercase !important; font-size: .8em !important; background-image: none !important; background: rgba(64, 41, 41, .5) !important;}
15
+ th.sorting { background-position: left !important; border-right: 1px solid #222; text-transform: uppercase !important; font-size: .8em !important}
16
+ tr.header th:first-child { border-radius: 6px 0 0 0; }
17
+ tr.header th:last-child { border-radius: 0 6px 0 0; }
18
+ tr.header th:only-child { border-radius: 6px 6px 0 0; }
19
+ tr.header { background-color: #222; }
16
20
  tr.even { background: rgba(128, 128, 128, 0.5) !important;}
17
- tr.odd { background: rgba(128, 128, 128, 0.25) !important;}
21
+ tr.odd { background: rgba(128, 128, 128, 0.25) !important}
18
22
  tr.even:hover, tr.odd:hover { background: rgba(128, 128, 128, 0.75) !important;}
19
- th { background: #000; text-align: left; padding: .5em; text-transform: uppercase; font-size: .8em}
23
+ th { background: #000; text-align: left; padding: .5em; }
20
24
  td { text-align: left; padding: .5em; padding-left: 1.25em !important;}
21
25
  td.center { text-align: center; }
26
+ td.sorting_1 { background: none !important; padding-left: 1.25em !important; }
22
27
  tfoot { background: #000; border-top: 10px solid #000; font-family: courier; margin-top: 4em; font-size: .75em; }
23
28
  a:link, a:visited { color: #aaa }
24
- h1 { color:#593232; font-size: 1.25em; }
25
- h2 { color:#593232; font-size: .75em; margin-top: -1em}
29
+ div.file_meta { float: left; height: 3em; width: 30%; }
30
+ h1 { color:#fff; font-size: 1.25em; margin-top: .25em; }
31
+ h2 { color:#fff; font-size: .75em; margin-top: -1em; }
32
+ h3 { color:#fff; font-size: 1em; float: right; margin-top: 1em; }
26
33
  td.sorting_1 { background: none !important; padding-left: 1.25em !important; }
34
+ div.dataTables_filter { margin-bottom: 2em !important; }
27
35
  div.dataTables_filter label { color: #fff; }
28
36
  div.dataTables_paginate { display: none !important; }
29
37
  div.dataTables_info { display: none !important; }
@@ -31,6 +39,11 @@
31
39
  %body
32
40
  %table{class: "output-table"}
33
41
  %thead
42
+ %tr.header
43
+ %th{colspan: 4}
44
+ .file_meta
45
+ %h1
46
+ Project Overview
34
47
  %tr
35
48
  %th
36
49
  File
@@ -11,48 +11,60 @@
11
11
 
12
12
  %style{media: "screen", type: "text/css"}
13
13
  body { background: #593232; color: #fff; font-family: arial, sans-serif; padding: 2em; }
14
- table { border: 10px solid #000; border-collapse: collapse; min-width: 50%; }
15
- tr { border-top: 1px solid #000; }
16
- tr.header { background: rgba(255, 255, 255, 0.75)}
14
+ table { box-shadow: 0 5px 0 rgba(0,0,0,.8); background: #444; border-spacing: 0; border: 5px solid #000; border-radius: 25px; border-collapse: collapse; min-width: 50%; }
15
+ th.sorting_asc, th.sorting_desc { text-transform: uppercase !important; font-size: .8em !important; background-image: none !important; background: rgba(64, 41, 41, .5) !important;}
16
+ th.sorting { background-position: left !important; border-right: 1px solid #222; text-transform: uppercase !important; font-size: .8em !important}
17
+ tr.header th:first-child { border-radius: 6px 0 0 0; }
18
+ tr.header th:last-child { border-radius: 0 6px 0 0; }
19
+ tr.header th:only-child { border-radius: 6px 6px 0 0; }
20
+ tfoot tr { border-radius: 6px 6px 6px 6px; }
21
+ tr.header { background-color: #222; }
17
22
  tr.even { background: rgba(128, 128, 128, 0.5) !important;}
18
23
  tr.odd { background: rgba(128, 128, 128, 0.25) !important}
19
24
  tr.even:hover, tr.odd:hover { background: rgba(128, 128, 128, 0.75) !important;}
20
- th { background: #000; text-align: left; padding: .5em; text-transform: uppercase; font-size: .8em}
25
+ th { background: #000; text-align: left; padding: .5em;}
21
26
  td { text-align: left; padding: .5em; padding-left: 1.25em !important;}
22
27
  td.center { text-align: center; }
23
- td.sorting_1 { background: none !important; padding-left: 1.25em !important; }
24
- tfoot { background: #000; border-top: 10px solid #000; font-family: courier; margin-top: 4em; font-size: .75em; }
28
+ td.sorting_1 { background: none !important; padding-left: 1.25em !important; text-transform: uppercase; font-size: .8em}
29
+ tfoot { background: #000; font-family: courier; margin-top: 4em; font-size: .75em; }
25
30
  a:link, a:visited { color: #aaa }
26
- h1 { color:#593232; font-size: 1.25em; }
27
- h2 { color:#593232; font-size: .75em; margin-top: -1em}
31
+ div.file_meta { float: left; height: 3em; width: 30%; }
32
+ h1 { color:#fff; font-size: 1.25em; margin-top: .25em; }
33
+ h2 { color:#fff; font-size: .75em; margin-top: -1em; }
34
+ h3 { color:#fff; font-size: 1em; float: right; margin-top: 1em; }
28
35
  div.dataTables_filter { display: none !important; }
29
36
  div.dataTables_paginate { display: none !important; }
30
37
  div.dataTables_info { display: none !important; }
31
38
 
32
39
  %body
33
- %table{class: "output-table"}
34
- %thead
35
- %tr.header
36
- %td{colspan: 3}
37
- %h1
38
- = class_name
39
- %h2
40
- = path_to_file
41
- %tr
42
- = header
43
- %tbody
44
- = rows
45
- %tfoot
46
- %tr
47
- %td.center{colspan: 3}
48
- %em
49
- Analyzed on
50
- = date
51
- at
52
- = time
53
- by
54
- %a{href: "https://gitlab.com/coraline/fukuzatsu", target: "_new"}
55
- Fukuzatsu
40
+ .container
41
+ %table{class: "output-table"}
42
+ %thead
43
+ %tr.header
44
+ %th{colspan: 3}
45
+ .file_meta
46
+ %h1
47
+ = class_name
48
+ %h2
49
+ = path_to_file
50
+ .file_meta_right
51
+ %h3
52
+ = "Overall Complexity: #{complexity}"
53
+ %tr
54
+ = header
55
+ %tbody
56
+ = rows
57
+ %tfoot
58
+ %tr
59
+ %td.center{colspan: 3}
60
+ %em
61
+ Analyzed on
62
+ = date
63
+ at
64
+ = time
65
+ by
66
+ %a{href: "https://gitlab.com/coraline/fukuzatsu", target: "_new"}
67
+ Fukuzatsu
56
68
  :javascript
57
69
  $(document).ready(function(){
58
70
  $('.output-table').dataTable({
@@ -1,3 +1,3 @@
1
1
  module Fukuzatsu
2
- VERSION = "0.9.8"
2
+ VERSION = "0.9.10"
3
3
  end
@@ -4,6 +4,37 @@ describe Analyzer do
4
4
 
5
5
  let(:content_1) { File.read("spec/fixtures/program_1.rb") }
6
6
  let(:content_2) { File.read("spec/fixtures/program_2.rb") }
7
+ let(:content_3) { File.read("spec/fixtures/eg_class.rb") }
8
+ let(:content_4) { File.read("spec/fixtures/eg_mod_class.rb") }
9
+ let(:content_5) { File.read("spec/fixtures/eg_module.rb") }
10
+ let(:content_6) { File.read("spec/fixtures/eg_mod_class_2.rb") }
11
+
12
+ context "#extract_class_name" do
13
+
14
+ context "from Class Foo" do
15
+ it "returns Foo" do
16
+ expect(Analyzer.new(content_3).extract_class_name).to eq("Foo")
17
+ end
18
+ end
19
+
20
+ context "from Module::Class Foo" do
21
+ it "returns Foo::Bar" do
22
+ expect(Analyzer.new(content_4).extract_class_name).to eq("Foo::Bar")
23
+ end
24
+ end
25
+
26
+ context "from Module; Class" do
27
+ it "returns Extracted::Thing" do
28
+ expect(Analyzer.new(content_6).extract_class_name).to eq("Extracted::Thing")
29
+ end
30
+ end
31
+
32
+ context "from Module" do
33
+ it "returns Something" do
34
+ expect(Analyzer.new(content_5).extract_class_name).to eq("Something")
35
+ end
36
+ end
37
+ end
7
38
 
8
39
  context "program_1" do
9
40
 
@@ -25,4 +56,4 @@ describe Analyzer do
25
56
 
26
57
  end
27
58
 
28
- end
59
+ end
@@ -0,0 +1,8 @@
1
+ require 'fukuzatsu'
2
+
3
+ class Foo
4
+ def say_hello
5
+ "Oh hi there."
6
+ end
7
+ end
8
+
@@ -0,0 +1,2 @@
1
+ class Foo::Bar
2
+ end
@@ -0,0 +1,5 @@
1
+ module Extracted
2
+ class Thing
3
+ end
4
+ end
5
+
@@ -0,0 +1,2 @@
1
+ module Something
2
+ 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: 0.9.8
4
+ version: 0.9.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bantik
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-02 00:00:00.000000000 Z
11
+ date: 2014-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ephemeral
@@ -153,6 +153,10 @@ files:
153
153
  - lib/fukuzatsu/parsed_method.rb
154
154
  - lib/fukuzatsu/version.rb
155
155
  - spec/analyzer_spec.rb
156
+ - spec/fixtures/eg_class.rb
157
+ - spec/fixtures/eg_mod_class.rb
158
+ - spec/fixtures/eg_mod_class_2.rb
159
+ - spec/fixtures/eg_module.rb
156
160
  - spec/fixtures/program_1.rb
157
161
  - spec/fixtures/program_2.rb
158
162
  - spec/fixtures/program_3.rb
@@ -184,6 +188,10 @@ specification_version: 4
184
188
  summary: A simple code complexity analyzer.
185
189
  test_files:
186
190
  - spec/analyzer_spec.rb
191
+ - spec/fixtures/eg_class.rb
192
+ - spec/fixtures/eg_mod_class.rb
193
+ - spec/fixtures/eg_mod_class_2.rb
194
+ - spec/fixtures/eg_module.rb
187
195
  - spec/fixtures/program_1.rb
188
196
  - spec/fixtures/program_2.rb
189
197
  - spec/fixtures/program_3.rb