code_poetry-html 0.1.0 → 0.2.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/assets/stylesheets/screen.css.scss +2 -0
 - data/lib/code_poetry-html/version.rb +1 -1
 - data/lib/code_poetry-html.rb +12 -8
 - data/public/application.css +2 -0
 - data/views/file_list.erb +2 -0
 - data/views/smells/complex_class.erb +4 -0
 - data/views/smells/complex_class_definition.erb +5 -0
 - data/views/smells/complex_method.erb +5 -0
 - data/views/smells/duplication.erb +10 -0
 - data/views/source_file.erb +1 -18
 - metadata +6 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: a59640d523afcdcd22294bf2fff32d8f957ec747
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: c3cdeedd0d6fdb0aafc9e556f20c6d9f0a6ec540
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: a14d366c0dc71769896451bfb614cd6c84d634a8b11ded62a529149229a8d46e258181f3877e75ba7efc4b3fbaec13982a477cd5616c6a046d8538a2edfc863b
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: bca34bc40ddfce47b8021d230669a53aabc121be6dc2aa6c5c07dd435738db1a6f48a06e2237f374aece1bb2418fa07641f2a8cd490df2d004d5b0ffc4955934
         
     | 
    
        data/lib/code_poetry-html.rb
    CHANGED
    
    | 
         @@ -11,7 +11,7 @@ class CodePoetry::Formatter::HTMLFormatter 
     | 
|
| 
       11 
11 
     | 
    
         
             
                end
         
     | 
| 
       12 
12 
     | 
    
         | 
| 
       13 
13 
     | 
    
         
             
                File.open(File.join(output_path, "index.html"), "w+") do |file|
         
     | 
| 
       14 
     | 
    
         
            -
                  file.puts template('layout').result(binding)
         
     | 
| 
      
 14 
     | 
    
         
            +
                  file.puts template('views', 'layout').result(binding)
         
     | 
| 
       15 
15 
     | 
    
         
             
                end
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
       17 
17 
     | 
    
         
             
                puts "Code Poetry report generated to #{output_path}."
         
     | 
| 
         @@ -19,8 +19,8 @@ class CodePoetry::Formatter::HTMLFormatter 
     | 
|
| 
       19 
19 
     | 
    
         | 
| 
       20 
20 
     | 
    
         
             
            private
         
     | 
| 
       21 
21 
     | 
    
         | 
| 
       22 
     | 
    
         
            -
              def template(name)
         
     | 
| 
       23 
     | 
    
         
            -
                ERB.new(File.read(File.join(File.dirname(__FILE__),  
     | 
| 
      
 22 
     | 
    
         
            +
              def template(path, name)
         
     | 
| 
      
 23 
     | 
    
         
            +
                ERB.new(File.read(File.join(File.dirname(__FILE__), "../#{path}/", "#{name}.erb")))
         
     | 
| 
       24 
24 
     | 
    
         
             
              end
         
     | 
| 
       25 
25 
     | 
    
         | 
| 
       26 
26 
     | 
    
         
             
              def output_path
         
     | 
| 
         @@ -35,11 +35,15 @@ private 
     | 
|
| 
       35 
35 
     | 
    
         
             
              end
         
     | 
| 
       36 
36 
     | 
    
         | 
| 
       37 
37 
     | 
    
         
             
              def formatted_source_file(stat)
         
     | 
| 
       38 
     | 
    
         
            -
                template('source_file').result(binding)
         
     | 
| 
      
 38 
     | 
    
         
            +
                template('views', 'source_file').result(binding)
         
     | 
| 
       39 
39 
     | 
    
         
             
              end
         
     | 
| 
       40 
40 
     | 
    
         | 
| 
       41 
41 
     | 
    
         
             
              def formatted_file_list(stats)
         
     | 
| 
       42 
     | 
    
         
            -
                template('file_list').result(binding)
         
     | 
| 
      
 42 
     | 
    
         
            +
                template('views', 'file_list').result(binding)
         
     | 
| 
      
 43 
     | 
    
         
            +
              end
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
              def formatted_smell(stat, smell)
         
     | 
| 
      
 46 
     | 
    
         
            +
                template('views/smells', smell.type).result(binding)
         
     | 
| 
       43 
47 
     | 
    
         
             
              end
         
     | 
| 
       44 
48 
     | 
    
         | 
| 
       45 
49 
     | 
    
         
             
              def id(stat)
         
     | 
| 
         @@ -47,18 +51,18 @@ private 
     | 
|
| 
       47 
51 
     | 
    
         
             
              end
         
     | 
| 
       48 
52 
     | 
    
         | 
| 
       49 
53 
     | 
    
         
             
              def timeago(time)
         
     | 
| 
       50 
     | 
    
         
            -
                % 
     | 
| 
      
 54 
     | 
    
         
            +
                %(<abbr class="timeago" title="#{time.iso8601}">#{time.iso8601}</abbr>)
         
     | 
| 
       51 
55 
     | 
    
         
             
              end
         
     | 
| 
       52 
56 
     | 
    
         | 
| 
       53 
57 
     | 
    
         
             
              def link_to_source_file(stat)
         
     | 
| 
       54 
     | 
    
         
            -
                % 
     | 
| 
      
 58 
     | 
    
         
            +
                %(<a href="##{id(stat)}" class="src_link" title="#{stat.name}">#{stat.name}</a>)
         
     | 
| 
       55 
59 
     | 
    
         
             
              end
         
     | 
| 
       56 
60 
     | 
    
         | 
| 
       57 
61 
     | 
    
         
             
              def line_status(stat, line_number)
         
     | 
| 
       58 
62 
     | 
    
         
             
                method = stat.get_method_at_line(line_number)
         
     | 
| 
       59 
63 
     | 
    
         | 
| 
       60 
64 
     | 
    
         
             
                unless method.nil?
         
     | 
| 
       61 
     | 
    
         
            -
                  'smelly' if method.smelly?
         
     | 
| 
      
 65 
     | 
    
         
            +
                  'smelly' if method.smelly? || method.duplicated?
         
     | 
| 
       62 
66 
     | 
    
         
             
                end
         
     | 
| 
       63 
67 
     | 
    
         
             
              end
         
     | 
| 
       64 
68 
     | 
    
         
             
            end
         
     | 
    
        data/public/application.css
    CHANGED
    
    
    
        data/views/file_list.erb
    CHANGED
    
    | 
         @@ -7,6 +7,7 @@ 
     | 
|
| 
       7 
7 
     | 
    
         
             
                    <th>Lines of Code</th>
         
     | 
| 
       8 
8 
     | 
    
         
             
                    <th>Churns</th>
         
     | 
| 
       9 
9 
     | 
    
         
             
                    <th>Smells</th>
         
     | 
| 
      
 10 
     | 
    
         
            +
                    <th>Duplication</th>
         
     | 
| 
       10 
11 
     | 
    
         
             
                    <th>Complexity</th>
         
     | 
| 
       11 
12 
     | 
    
         
             
                    <th>Complexity/Method</th>
         
     | 
| 
       12 
13 
     | 
    
         
             
                  </tr>
         
     | 
| 
         @@ -19,6 +20,7 @@ 
     | 
|
| 
       19 
20 
     | 
    
         
             
                    <td><%= stat.lines_of_code %></td>
         
     | 
| 
       20 
21 
     | 
    
         
             
                    <td><%= stat.churns %></td>
         
     | 
| 
       21 
22 
     | 
    
         
             
                    <td><%= stat.smells.count %></td>
         
     | 
| 
      
 23 
     | 
    
         
            +
                    <td><%= stat.duplication %></td>
         
     | 
| 
       22 
24 
     | 
    
         
             
                    <td><%= stat.complexity %></td>
         
     | 
| 
       23 
25 
     | 
    
         
             
                    <td><%= stat.complexity_per_method %></td>
         
     | 
| 
       24 
26 
     | 
    
         
             
                  </tr>
         
     | 
| 
         @@ -0,0 +1,10 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            <li>
         
     | 
| 
      
 2 
     | 
    
         
            +
              <span class="smell"><%= smell.object.severity %> Code</span> found in
         
     | 
| 
      
 3 
     | 
    
         
            +
              <span class="smell-name">:<%= smell.object.node %></span> nodes
         
     | 
| 
      
 4 
     | 
    
         
            +
              <span class="smell-complexity">(mass  = <%= smell.object.mass %>)</span>
         
     | 
| 
      
 5 
     | 
    
         
            +
              <ul class="duplications">
         
     | 
| 
      
 6 
     | 
    
         
            +
                <% smell.object.methods.each do |method| %>
         
     | 
| 
      
 7 
     | 
    
         
            +
                  <li><%= method.pretty_location %></li>
         
     | 
| 
      
 8 
     | 
    
         
            +
                <% end %>
         
     | 
| 
      
 9 
     | 
    
         
            +
              </ul>
         
     | 
| 
      
 10 
     | 
    
         
            +
            </li>
         
     | 
    
        data/views/source_file.erb
    CHANGED
    
    | 
         @@ -17,24 +17,7 @@ 
     | 
|
| 
       17 
17 
     | 
    
         
             
                  <% end %>
         
     | 
| 
       18 
18 
     | 
    
         | 
| 
       19 
19 
     | 
    
         
             
                  <% stat.smells.each do |smell| %>
         
     | 
| 
       20 
     | 
    
         
            -
                     
     | 
| 
       21 
     | 
    
         
            -
                      <li>
         
     | 
| 
       22 
     | 
    
         
            -
                        <span class="smell">Complex class</span>
         
     | 
| 
       23 
     | 
    
         
            -
                        <span class="smell-complexity">(complexity <%= stat.complexity %>)</span>
         
     | 
| 
       24 
     | 
    
         
            -
                      </li>
         
     | 
| 
       25 
     | 
    
         
            -
                    <% elsif smell.complex_class_definition? %>
         
     | 
| 
       26 
     | 
    
         
            -
                      <li>
         
     | 
| 
       27 
     | 
    
         
            -
                        <span class="smell">Complex</span> code in
         
     | 
| 
       28 
     | 
    
         
            -
                        <span class="smell-name"><%= stat.name %></span> definition outside of methods
         
     | 
| 
       29 
     | 
    
         
            -
                        <span class="smell-complexity">(complexity <%= stat.definition_complexity %>)</span>
         
     | 
| 
       30 
     | 
    
         
            -
                      </li>
         
     | 
| 
       31 
     | 
    
         
            -
                    <% elsif smell.complex_method? %>
         
     | 
| 
       32 
     | 
    
         
            -
                      <li>
         
     | 
| 
       33 
     | 
    
         
            -
                        <span class="smell">Complex method</span>
         
     | 
| 
       34 
     | 
    
         
            -
                        <span class="smell-name"><%= smell.method.pretty_name %></span>
         
     | 
| 
       35 
     | 
    
         
            -
                        <span class="smell-complexity">(complexity <%= smell.method.complexity %>)</span>
         
     | 
| 
       36 
     | 
    
         
            -
                      </li>
         
     | 
| 
       37 
     | 
    
         
            -
                    <% end %>
         
     | 
| 
      
 20 
     | 
    
         
            +
                    <%= formatted_smell(stat, smell) %>
         
     | 
| 
       38 
21 
     | 
    
         
             
                  <% end %>
         
     | 
| 
       39 
22 
     | 
    
         
             
                </ul>
         
     | 
| 
       40 
23 
     | 
    
         
             
              </div>
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: code_poetry-html
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.2.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Bastian Bartmann
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date:  
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2014-02-22 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: bundler
         
     | 
| 
         @@ -103,6 +103,10 @@ files: 
     | 
|
| 
       103 
103 
     | 
    
         
             
            - public/magnify.png
         
     | 
| 
       104 
104 
     | 
    
         
             
            - views/file_list.erb
         
     | 
| 
       105 
105 
     | 
    
         
             
            - views/layout.erb
         
     | 
| 
      
 106 
     | 
    
         
            +
            - views/smells/complex_class.erb
         
     | 
| 
      
 107 
     | 
    
         
            +
            - views/smells/complex_class_definition.erb
         
     | 
| 
      
 108 
     | 
    
         
            +
            - views/smells/complex_method.erb
         
     | 
| 
      
 109 
     | 
    
         
            +
            - views/smells/duplication.erb
         
     | 
| 
       106 
110 
     | 
    
         
             
            - views/source_file.erb
         
     | 
| 
       107 
111 
     | 
    
         
             
            homepage: https://github.com/coding-chimp/code_poetry-html
         
     | 
| 
       108 
112 
     | 
    
         
             
            licenses:
         
     |