metric_fu 4.6.0 → 4.7.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.
Files changed (97) hide show
  1. data.tar.gz.sig +0 -0
  2. data/.metrics +6 -0
  3. data/.travis.yml +6 -5
  4. data/CONTRIBUTING.md +15 -3
  5. data/Gemfile +3 -8
  6. data/Gemfile.devtools +3 -3
  7. data/HISTORY.md +23 -2
  8. data/README.md +42 -38
  9. data/checksum/metric_fu-4.6.0.gem.sha512 +1 -0
  10. data/gemfiles/Gemfile.travis +7 -0
  11. data/lib/metric_fu/cli/helper.rb +2 -1
  12. data/lib/metric_fu/configuration.rb +0 -2
  13. data/lib/metric_fu/formatter/html.rb +2 -0
  14. data/lib/metric_fu/formatter/syntax.rb +47 -0
  15. data/lib/metric_fu/gem_version.rb +44 -11
  16. data/lib/metric_fu/io.rb +5 -5
  17. data/lib/metric_fu/loader.rb +12 -5
  18. data/lib/metric_fu/metric.rb +10 -0
  19. data/lib/metric_fu/metrics/base_template.rb +2 -2
  20. data/lib/metric_fu/metrics/cane/cane.rb +1 -0
  21. data/lib/metric_fu/metrics/churn/churn.rb +16 -42
  22. data/lib/metric_fu/metrics/churn/init.rb +7 -1
  23. data/lib/metric_fu/metrics/hotspots/analysis/groupings.rb +1 -0
  24. data/lib/metric_fu/metrics/hotspots/analysis/problems.rb +1 -0
  25. data/lib/metric_fu/metrics/hotspots/analysis/ranked_problem_location.rb +2 -0
  26. data/lib/metric_fu/metrics/hotspots/analysis/rankings.rb +5 -0
  27. data/lib/metric_fu/metrics/hotspots/hotspot.rb +3 -0
  28. data/lib/metric_fu/metrics/hotspots/hotspot_analyzer.rb +8 -4
  29. data/lib/metric_fu/metrics/hotspots/hotspots.rb +11 -0
  30. data/lib/metric_fu/metrics/reek/reek.rb +1 -1
  31. data/lib/metric_fu/metrics/reek/reek_hotspot.rb +0 -1
  32. data/lib/metric_fu/metrics/saikuro/saikuro.rb +1 -0
  33. data/lib/metric_fu/reporting/graphs/grapher.rb +0 -1
  34. data/lib/metric_fu/reporting/templates/awesome/awesome_template.rb +8 -59
  35. data/lib/metric_fu/run.rb +1 -1
  36. data/lib/metric_fu/{reporting/templates/awesome → templates}/css/bluff.css +0 -0
  37. data/lib/metric_fu/{reporting/templates/awesome → templates}/css/buttons.css +0 -0
  38. data/lib/metric_fu/{reporting/templates/awesome → templates}/css/default.css +0 -0
  39. data/lib/metric_fu/{reporting/templates/awesome → templates}/css/integrity.css +0 -0
  40. data/lib/metric_fu/{reporting/templates/awesome → templates}/css/rcov.css +0 -0
  41. data/lib/metric_fu/{reporting/templates/awesome → templates}/css/reset.css +0 -0
  42. data/lib/metric_fu/{reporting/templates/awesome → templates}/css/syntax.css +0 -0
  43. data/lib/metric_fu/templates/report.html.erb +32 -0
  44. data/lib/metric_fu/templates/report.rb +36 -0
  45. data/lib/metric_fu/utility.rb +4 -0
  46. data/lib/metric_fu/version.rb +1 -1
  47. data/metric_fu.gemspec +11 -2
  48. data/spec/cli/helper_spec.rb +33 -33
  49. data/spec/metric_fu/configuration_spec.rb +20 -20
  50. data/spec/metric_fu/data_structures/line_numbers_spec.rb +12 -11
  51. data/spec/metric_fu/data_structures/location_spec.rb +27 -26
  52. data/spec/metric_fu/formatter/html_spec.rb +18 -8
  53. data/spec/metric_fu/formatter/yaml_spec.rb +14 -3
  54. data/spec/metric_fu/formatter_spec.rb +5 -5
  55. data/spec/metric_fu/loader_spec.rb +1 -1
  56. data/spec/metric_fu/metric_spec.rb +2 -2
  57. data/spec/metric_fu/metrics/base_template_spec.rb +50 -50
  58. data/spec/metric_fu/metrics/cane/cane_spec.rb +29 -28
  59. data/spec/metric_fu/metrics/churn/churn_spec.rb +10 -33
  60. data/spec/metric_fu/metrics/flay/flay_grapher_spec.rb +9 -8
  61. data/spec/metric_fu/metrics/flay/flay_spec.rb +14 -13
  62. data/spec/metric_fu/metrics/flog/flog_grapher_spec.rb +16 -15
  63. data/spec/metric_fu/metrics/flog/flog_spec.rb +10 -9
  64. data/spec/metric_fu/metrics/generator_spec.rb +19 -19
  65. data/spec/metric_fu/metrics/graph_spec.rb +11 -9
  66. data/spec/metric_fu/metrics/hotspots/analysis/analyzed_problems_spec.rb +5 -0
  67. data/spec/metric_fu/metrics/hotspots/analysis/analyzer_tables_spec.rb +11 -6
  68. data/spec/metric_fu/metrics/hotspots/analysis/ranking_spec.rb +4 -3
  69. data/spec/metric_fu/metrics/hotspots/analysis/rankings_spec.rb +16 -10
  70. data/spec/metric_fu/metrics/hotspots/analysis/table_spec.rb +2 -1
  71. data/spec/metric_fu/metrics/hotspots/hotspot_analyzer_spec.rb +2 -1
  72. data/spec/metric_fu/metrics/hotspots/hotspot_spec.rb +8 -2
  73. data/spec/metric_fu/metrics/hotspots/hotspots_spec.rb +4 -8
  74. data/spec/metric_fu/metrics/rails_best_practices/rails_best_practices_grapher_spec.rb +10 -9
  75. data/spec/metric_fu/metrics/rails_best_practices/rails_best_practices_spec.rb +8 -7
  76. data/spec/metric_fu/metrics/rcov/rcov_grapher_spec.rb +8 -8
  77. data/spec/metric_fu/metrics/rcov/rcov_hotspot_spec.rb +7 -4
  78. data/spec/metric_fu/metrics/rcov/rcov_spec.rb +15 -14
  79. data/spec/metric_fu/metrics/reek/reek_grapher_spec.rb +10 -9
  80. data/spec/metric_fu/metrics/reek/reek_spec.rb +17 -15
  81. data/spec/metric_fu/metrics/roodi/roodi_grapher_spec.rb +9 -8
  82. data/spec/metric_fu/metrics/roodi/roodi_spec.rb +4 -3
  83. data/spec/metric_fu/metrics/saikuro/saikuro_spec.rb +13 -10
  84. data/spec/metric_fu/metrics/stats/stats_grapher_spec.rb +13 -12
  85. data/spec/metric_fu/metrics/stats/stats_spec.rb +16 -14
  86. data/spec/metric_fu/reporter_spec.rb +8 -7
  87. data/spec/metric_fu/reporting/graphs/grapher_spec.rb +1 -1
  88. data/spec/metric_fu/reporting/result_spec.rb +12 -11
  89. data/spec/metric_fu/run_spec.rb +24 -8
  90. data/spec/spec_helper.rb +1 -2
  91. data/spec/support/helper_methods.rb +14 -1
  92. metadata +124 -57
  93. metadata.gz.sig +0 -0
  94. checksums.yaml +0 -7
  95. checksums.yaml.gz.sig +0 -0
  96. data/lib/metric_fu/initial_requires.rb +0 -13
  97. data/lib/metric_fu/load_files.rb +0 -34
data.tar.gz.sig CHANGED
Binary file
data/.metrics CHANGED
@@ -22,6 +22,12 @@
22
22
  # cane.no_doc = 'y'
23
23
  # cane.no_readme = 'y'
24
24
  # end
25
+ #
26
+ # config.configure_metric(:churn) do |churn|
27
+ # churn.enabled = true
28
+ # churn.ignore_files = 'HISTORY.md, TODO.md'
29
+ # churn.start_date = '6 months ago'
30
+ # end
25
31
  #
26
32
  # Or, to configure a group of metrics...
27
33
  # config.configure_metrics.each do |metric|
data/.travis.yml CHANGED
@@ -1,6 +1,7 @@
1
1
  language: ruby
2
- bundler_args: --without coverage
2
+ bundler_args: --without local_development yard metrics guard --path vendor/bundle
3
3
  script: bundle exec rspec
4
+ cache: bundler
4
5
  gemfile:
5
6
  - gemfiles/Gemfile.travis
6
7
  # before_install: some_command
@@ -11,7 +12,7 @@ rvm:
11
12
  - 1.9.3
12
13
  # - 1.9.2 # code_metric 0.1.0 requires ruby 1.9.3 or greater
13
14
  - jruby-19mode # JRuby in 1.9 mode
14
- - rbx-19mode
15
- # matrix:
16
- # allow_failures:
17
- # - rvm: rbx-19mode
15
+ - rbx
16
+ matrix:
17
+ allow_failures:
18
+ - rvm: rbx
data/CONTRIBUTING.md CHANGED
@@ -8,11 +8,11 @@ How to contribute:
8
8
 
9
9
  ## Code
10
10
 
11
- 1. Clone the repo: `git clone git://github.com/metricfu/metric_fu.git && cd metric_fu`
11
+ 1. Fork and clone the repo: `git clone git://github.com/yourghname/metric_fu.git && cd metric_fu`
12
12
  2. Install the gem dependencies: `bundle install`
13
13
  3. Make the changes you want and back them up with tests.
14
- * Run the tests (`bundle exec rake`)
15
- * Run metric_fu on itself (`bundle exec rake metrics:all`)
14
+ * Run the tests (`bundle exec rspec`)
15
+ * Run metric_fu on itself (`bundle exec ruby -Ilib bin/metric_fu`)
16
16
  4. Update the HISTORY.md file with your changes and give yourself credit
17
17
  5. Commit and create a pull request with details as to what has been changed and why
18
18
  * Use well-described, small (atomic) commits.
@@ -29,6 +29,18 @@ How I handle pull requests:
29
29
  * by force pushing to it
30
30
  * I can make any changes myself and manually merge the code in.
31
31
 
32
+ ### Commit Messages
33
+
34
+ * [A Note About Git Commit Messages](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html)
35
+ * [http://stopwritingramblingcommitmessages.com/](http://stopwritingramblingcommitmessages.com/)
36
+ * [ThoughtBot style guide](https://github.com/thoughtbot/guides/tree/master/style#git)
37
+
38
+ ### About Pull Requests (PR's)
39
+
40
+ * [All Your Open Source Code Are Belong To Us](http://www.benjaminfleischer.com/2013/07/30/all-your-open-source-code-are-belong-to-us/)
41
+ * [Using Pull Requests](https://help.github.com/articles/using-pull-requests)
42
+ * [Github pull requests made easy](http://www.element84.com/github-pull-requests-made-easy.html)
43
+
32
44
  ## Documentation
33
45
 
34
46
  * If relevant, you may update [the metric_fu website](https://github.com/metricfu/metricfu.github.com) in a separate pull request to that repo
data/Gemfile CHANGED
@@ -1,16 +1,11 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
 
4
- group :test, :coverage do
5
- # https://github.com/kina/simplecov-rcov-text
6
- gem 'simplecov-rcov-text'
7
- end
8
-
9
- group :test do
10
- gem 'test-construct'
11
- gem 'json'
4
+ group :test, :local_development do
12
5
  gem 'pry'
13
6
  gem 'pry-nav'
7
+ # https://github.com/kina/simplecov-rcov-text
8
+ gem 'simplecov-rcov-text', group: :metrics
14
9
  end
15
10
 
16
11
  gemspec :path => File.expand_path('..', __FILE__)
data/Gemfile.devtools CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  group :development do
4
4
  gem 'rake', '~> 10.1.0'
5
- gem 'rspec', '~> 2.14.1'
6
- gem 'yard', '~> 0.8.7'
5
+ gem 'rspec', '~> 3.0.0.beta1'
6
+ gem 'yard', '~> 0.8.7', group: :yard
7
7
  end
8
8
 
9
9
  group :yard do
@@ -13,7 +13,7 @@ end
13
13
  group :guard do
14
14
  gem 'guard', '~> 1.8.1'
15
15
  gem 'guard-bundler', '~> 1.0.0'
16
- gem 'guard-rspec', '~> 3.0.2'
16
+ gem 'guard-rspec'#, '~> 3.0.2'
17
17
  # gem 'guard-rubocop', '~> 0.2.0'
18
18
 
19
19
  # file system change event handling
data/HISTORY.md CHANGED
@@ -4,12 +4,32 @@ Each change should fall into categories that would affect whether the release is
4
4
 
5
5
  As such, a _Feature_ would map to either major or minor. A _bug fix_ to a patch. And _misc_ is either minor or patch, the difference being kind of fuzzy for the purposes of history. Adding tests would be patch level.
6
6
 
7
- ### Master
7
+ ### Master [changes](https://github.com/metricfu/metric_fu/compare/v4.7.0...master)
8
8
 
9
+ * Breaking Changes
9
10
  * Features
10
11
  * Fixes
11
12
  * Misc
12
13
 
14
+ ### [4.7.0 / 2013-12-31](https://github.com/metricfu/metric_fu/compare/v4.6.0...v4.7.0)
15
+
16
+ * Features
17
+ * Move to using churn library and allowing all churn options to be passed through to churn library. (Dan Mayer, #182)
18
+ * Create template for syntax highlighting in report. (Benjamin Fleischer, #179)
19
+ * Gem deps now derirved from gemspec via regex (from Gemnasium). Related to #184.
20
+ `--debug-info` will now show the version of the activated gem, if available. (Benjamin Fleischer, #189)
21
+ * Fixes
22
+ * Force gemspec to use utf-8 encoding when importing the AUTHORS file. (Paul Swagerty, #183)
23
+ * Ensure gemspec doesn't crash when reading in AUTHORS file. (saltracer, #184)
24
+ * Fix bad parsing of reek output. (Greg Allen, #185)
25
+ * Misc
26
+ * Spelling correction. (mdb, #177)
27
+ * Clean up README indentation. (simi, #187)
28
+ * Tests run faster. (Benjamin Fleischer, #181)
29
+ * Simplify load paths. (Benjamin Fleicher, #139)
30
+ * Update to RSpec 3.0.0.beta1. (Benjamin Fleischer)
31
+ * Update to new release of TestConstruct. (Benjamin Fleischer)
32
+
13
33
  ### MetricFu [4.6.0 / 2013-11-20](https://github.com/metricfu/metric_fu/compare/v4.5.2...v4.6.0)
14
34
 
15
35
  * Features
@@ -121,6 +141,8 @@ add all contriubtors
121
141
 
122
142
  ### MetricFu 4.4.0 / 2013-08-15
123
143
 
144
+ * Breaking Changes
145
+ * Removed configuration methods / MetricFu module methods: add_graph, add_metric, configure_graph, configure_metric, configure_graph_engine, graph_engine, metrics, formatters, graphs, graph_engines, rails?, code_dirs, base_directory, scratch_directory, output_directory, data_directory, file_globs_to_ignore, metric_fu_root_directory, template_directory, template_class, link_prefix, darwin_txmt_protocol_no_thanks, syntax_highlighting
124
146
  * Features
125
147
  * Metrics now configure themselves in a subclass of MetricFu::Metric ( Benjamin Fleischer / Robin Curry #91, #111)
126
148
  * Metrics can be configured individually via Metric.configuration.configure_metric(:some_metric) or Metric.configuration.configure_metrics {|metric| }. See .metrics file for examples ( Benjamin Fleischer / Robin Curry #91, #111)
@@ -141,7 +163,6 @@ add all contriubtors
141
163
  * Exposed RubyParser patch ( Benjamin Fleischer / Robin Curry #91, #111)
142
164
  * Separated out io / filesystem /templating concerns into their own classes or modules. Thus, we removed all the metaprogrammatically defined methods and instance variables.( Benjamin Fleischer / Robin Curry #91, #111, #112, #115)
143
165
  * Generator subclasses can now be found by metric name. MetricFu::Generator.get_generator(:flog) (Benjamin Fleischer, #126)
144
- * Breaking change related to the above: removed configuration methods / MetricFu module methods: add_graph, add_metric, configure_graph, configure_metric, configure_graph_engine, graph_engine, metrics, formatters, graphs, graph_engines, rails?, code_dirs, base_directory, scratch_directory, output_directory, data_directory, file_globs_to_ignore, metric_fu_root_directory, template_directory, template_class, link_prefix, darwin_txmt_protocol_no_thanks, syntax_highlighting
145
166
 
146
167
  ### MetricFu 4.3.1 / 2013-08-02
147
168
 
data/README.md CHANGED
@@ -12,10 +12,14 @@ If you have trouble installing the gem
12
12
  - try adding metric_fu to your Gemfile and bundling.
13
13
  - file a ticket on the issues page.
14
14
 
15
- MetricFu is cryptographically signed. To be sure the gem you install hasn't been tampered with:
15
+ MetricFu is [cryptographically signed](http://guides.rubygems.org/security/).
16
+ To be sure the gem you install hasn't been tampered with:
16
17
  - Add my public key (if you haven't already) as a trusted certificate `gem cert --add <(curl -Ls https://raw.github.com/metricfu/metric_fu/master/certs/bf4.pem)`
17
- - `gem install metric_fu -P HighSecurity`
18
- - This may cause installation to fail if non-signed dependent gems are also being installed.
18
+ - `gem install metric_fu -P MediumSecurity`
19
+
20
+ The MediumSecurity trust profile will verify signed gems, but allow the installation of unsigned dependencies.
21
+
22
+ This is necessary because not all of MetricFu’s dependencies are signed, so we cannot use HighSecurity.
19
23
 
20
24
  ## Usage
21
25
 
@@ -55,26 +59,26 @@ These reports are generated in metric_fu's output directory (```tmp/metric_fu/ou
55
59
  using a relative path:
56
60
 
57
61
  ```sh
58
- metric_fu --out custom_directory # outputs to tmp/metric_fu/custom_directory
62
+ metric_fu --out custom_directory # outputs to tmp/metric_fu/custom_directory
59
63
  ```
60
64
 
61
65
  or a full path:
62
66
 
63
67
  ```sh
64
- metric_fu --out /home/metrics # outputs to /home/metrics
68
+ metric_fu --out /home/metrics # outputs to /home/metrics
65
69
  ```
66
70
 
67
71
  You can specify a different formatter at the command line by referencing a built-in formatter or providing the fully-qualified name of a custom formatter.
68
72
 
69
73
 
70
74
  ```sh
71
- metric_fu --format yaml --out custom_report.yml
75
+ metric_fu --format yaml --out custom_report.yml
72
76
  ```
73
77
 
74
78
  or
75
79
 
76
80
  ```sh
77
- metric_fu --format MyCustomFormatter
81
+ metric_fu --format MyCustomFormatter
78
82
  ```
79
83
 
80
84
  ### Custom Formatters
@@ -85,16 +89,16 @@ To create a custom formatter, you simply need to create a class
85
89
  that takes an options hash and responds to one or more notifications:
86
90
 
87
91
  ```ruby
88
- class MyCustomFormatter
89
- def initialize(opts={}); end # metric_fu will pass in an output param if provided.
90
-
91
- # Should include one or more of...
92
- def start; end # Sent before metric_fu starts metric measurements.
93
- def start_metric(metric); end # Sent before individual metric is measured.
94
- def finish_metric(metric); end # Sent after individual metric measurement is complete.
95
- def finish; end # Sent after metric_fu has completed all measurements.
96
- def display_results; end # Used to open results in browser, etc.
97
- end
92
+ class MyCustomFormatter
93
+ def initialize(opts={}); end # metric_fu will pass in an output param if provided.
94
+
95
+ # Should include one or more of...
96
+ def start; end # Sent before metric_fu starts metric measurements.
97
+ def start_metric(metric); end # Sent before individual metric is measured.
98
+ def finish_metric(metric); end # Sent after individual metric measurement is complete.
99
+ def finish; end # Sent after metric_fu has completed all measurements.
100
+ def display_results; end # Used to open results in browser, etc.
101
+ end
98
102
  ```
99
103
 
100
104
  See [lib/metric_fu/formatter/](lib/metric_fu/formatter/) for examples.
@@ -116,13 +120,13 @@ require './lib/my_custom_formatter.rb'
116
120
  in your .metrics file add the below to run pre-generated metrics
117
121
 
118
122
  ```ruby
119
- MetricFu::Configuration.run do |config|
120
- config.configure_metric(:rcov) do |rcov|
121
- rcov.enabled = true
122
- rcov.external = File.expand_path("coverage/rcov/rcov.txt", Dir.pwd)
123
- rcov.activate
124
- end
125
- end
123
+ MetricFu::Configuration.run do |config|
124
+ config.configure_metric(:rcov) do |rcov|
125
+ rcov.enabled = true
126
+ rcov.external = File.expand_path("coverage/rcov/rcov.txt", Dir.pwd)
127
+ rcov.activate
128
+ end
129
+ end
126
130
  ```
127
131
 
128
132
  If you want metric_fu to actually run rcov itself (1.8 only), don't specify an external file to read from
@@ -132,7 +136,7 @@ If you want metric_fu to actually run rcov itself (1.8 only), don't specify an e
132
136
  To generate the same metrics metric_fu has been generating run from the root of your project before running metric_fu
133
137
 
134
138
  ```sh
135
- RAILS_ENV=test rcov $(ruby -e "puts Dir['{spec,test}/**/*_{spec,test}.rb'].join(' ')") --sort coverage --no-html --text-coverage --no-color --profile --exclude-only '.*' --include-file "\Aapp,\Alib" -Ispec > coverage/rcov/rcov.txt
139
+ RAILS_ENV=test rcov $(ruby -e "puts Dir['{spec,test}/**/*_{spec,test}.rb'].join(' ')") --sort coverage --no-html --text-coverage --no-color --profile --exclude-only '.*' --include-file "\Aapp,\Alib" -Ispec > coverage/rcov/rcov.txt
136
140
  ```
137
141
 
138
142
  #### Simplecov metrics with Ruby 1.9 and 2.0
@@ -140,24 +144,24 @@ To generate the same metrics metric_fu has been generating run from the root of
140
144
  Add to your Gemfile or otherwise install
141
145
 
142
146
  ```ruby
143
- gem 'simplecov'
144
- # https://github.com/kina/simplecov-rcov-text
145
- gem 'simplecov-rcov-text'
147
+ gem 'simplecov'
148
+ # https://github.com/kina/simplecov-rcov-text
149
+ gem 'simplecov-rcov-text'
146
150
  ```
147
151
 
148
152
  Modify your [spec_helper](https://github.com/metricfu/metric_fu/blob/master/spec/spec_helper.rb) as per the SimpleCov docs and run your tests before running metric_fu
149
153
 
150
154
  ```ruby
151
- #in your spec_helper
152
- require 'simplecov'
153
- require 'simplecov-rcov-text'
154
- SimpleCov.formatter = SimpleCov::Formatter::RcovTextFormatter
155
- # or
156
- SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
157
- SimpleCov::Formatter::HTMLFormatter,
158
- SimpleCov::Formatter::RcovTextFormatter
159
- ]
160
- SimpleCov.start
155
+ #in your spec_helper
156
+ require 'simplecov'
157
+ require 'simplecov-rcov-text'
158
+ SimpleCov.formatter = SimpleCov::Formatter::RcovTextFormatter
159
+ # or
160
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
161
+ SimpleCov::Formatter::HTMLFormatter,
162
+ SimpleCov::Formatter::RcovTextFormatter
163
+ ]
164
+ SimpleCov.start
161
165
  ```
162
166
 
163
167
  ## Compatibility
@@ -0,0 +1 @@
1
+ b9488463cdbac040cc3f4fdff3ec18385b3129876464ae14de2078c1742a1be7951ba40b7f2efba54809cb8e7766fc53ff63c2672ffd25452ddca2f9a9387ac4
@@ -4,6 +4,13 @@ source 'https://rubygems.org'
4
4
  # export BUNDLE_GEMFILE=$PWD/gemfiles/Gemfile.travis
5
5
  # when done, unset BUNDLE_GEMFILE
6
6
  # for 1.9.2 support because of https://github.com/railsbp/rails_best_practices/blob/master/rails_best_practices.gemspec
7
+
8
+ platforms :rbx do
9
+ gem 'racc'
10
+ gem 'rubysl', '~> 2.0'
11
+ gem 'psych'
12
+ end
13
+
7
14
  gem 'activesupport', '~> 3.2'
8
15
 
9
16
  eval_gemfile File.expand_path('../../Gemfile', __FILE__)
@@ -1,5 +1,6 @@
1
1
  require 'metric_fu'
2
2
  require 'metric_fu/cli/parser'
3
+ MetricFu.lib_require { 'run' }
3
4
  # see https://github.com/grosser/pru/blob/master/bin/pru
4
5
  module MetricFu
5
6
  module Cli
@@ -21,7 +22,7 @@ module MetricFu
21
22
  MetricFu::VERSION
22
23
  end
23
24
  def shutdown
24
- out "\nShuting down. Bye"
25
+ out "\nShutting down. Bye"
25
26
  MetricFu::Cli.immediate_shutdown!
26
27
  end
27
28
  def banner
@@ -12,8 +12,6 @@ module MetricFu
12
12
  end
13
13
 
14
14
  def self.configure
15
- Dir.glob(File.join(MetricFu.metrics_dir, '**/init.rb')).each{|init_file|require(init_file)}
16
- Dir.glob(File.join(MetricFu.reporting_dir, '**/init.rb')).each{|init_file|require(init_file)}
17
15
  configuration.tap do |config|
18
16
  config.configure_metrics
19
17
  end
@@ -1,3 +1,5 @@
1
+ MetricFu.formatter_require { 'yaml' }
2
+ MetricFu.metrics_require { 'graph' }
1
3
  module MetricFu
2
4
  module Formatter
3
5
  class HTML
@@ -0,0 +1,47 @@
1
+ require 'coderay'
2
+ MetricFu.lib_require { 'utility' }
3
+ # CodeRay options
4
+ # used to analyze source code, because object Tokens is a list of tokens with specified types.
5
+ # :tab_width – tabulation width in spaces. Default: 8
6
+ # :css – how to include the styles (:class и :style). Default: :class)
7
+ #
8
+ # :wrap – wrap result in html tag :page, :div, :span or not to wrap (nil)
9
+ #
10
+ # :line_numbers – how render line numbers (:table, :inline, :list or nil)
11
+ #
12
+ # :line_number_start – first line number
13
+ #
14
+ # :bold_every – make every n-th line number bold. Default: 10
15
+ module MetricFu
16
+ module Formatter
17
+ class Syntax
18
+
19
+ def initialize
20
+ @options = { :css => :class, :style => :alpha }
21
+ @line_number_options = {:line_numbers => :inline, :line_number_start => 0 }
22
+ end
23
+
24
+ def highlight(ruby_text, line_number)
25
+ tokens = tokenize(ruby_text)
26
+ tokens.div(highlight_options(line_number))
27
+ end
28
+
29
+ def highlight_options(line_number)
30
+ line_number = line_number.to_i
31
+ if line_number > 0
32
+ @options.merge(@line_number_options.merge(:line_number_start => line_number))
33
+ else
34
+ @options
35
+ end
36
+ end
37
+
38
+ private
39
+
40
+ def tokenize(ruby_text)
41
+ ascii_text = MetricFu::Utility.clean_ascii_text(ruby_text)
42
+ tokens = CodeRay.scan(ascii_text, :ruby)
43
+ end
44
+
45
+ end
46
+ end
47
+ end
@@ -1,13 +1,26 @@
1
+ # coding: utf-8
1
2
  require 'rubygems'
2
3
  module MetricFu
3
4
  class GemVersion
5
+ # regexp from https://github.com/gemnasium/gemnasium-parser/blob/807d7ccc/lib/gemnasium/parser/patterns.rb#L11
6
+ # under MIT License
7
+ GEM_NAME = /[a-zA-Z0-9\-_\.]+/
8
+ QUOTED_GEM_NAME = /(?:(?<gq>["'])(?<name>#{GEM_NAME})\k<gq>|%q<(?<name>#{GEM_NAME})>)/
9
+ MATCHER = /(?:=|!=|>|<|>=|<=|~>)/
10
+ VERSION = /[0-9]+(?:\.[a-zA-Z0-9]+)*/
11
+ REQUIREMENT = /[ \t]*(?:#{MATCHER}[ \t]*)?#{VERSION}[ \t]*/
12
+ REQUIREMENT_LIST = /(?<qr1>["'])(?<req1>#{REQUIREMENT})\k<qr1>(?:[ \t]*,[ \t]*(?<qr2>["'])(?<req2>#{REQUIREMENT})\k<qr2>)?/
13
+ REQUIREMENTS = /(?:#{REQUIREMENT_LIST}|\[[ \t]*#{REQUIREMENT_LIST}[ \t]*\])/
14
+ COMMENT = /(#[^\n]*)?/
15
+ ADD_DEPENDENCY_CALL = /^[ \t]*\w+\.add(?<type>_runtime|_development)?_dependency\(?[ \t]*#{QUOTED_GEM_NAME}(?:[ \t]*,[ \t]*#{REQUIREMENTS})?[ \t]*\)?[ \t]*#{COMMENT}$/
16
+
4
17
 
5
18
  def initialize
6
- @gem_spec = Gem::Specification.load(gemspec)
19
+ @gem_spec = File.open(gemspec, 'rb') {|f| f.readlines }
7
20
  end
8
21
 
9
22
  def gemspec
10
- gemspec = File.join(MetricFu.root_dir, 'metric_fu.gemspec')
23
+ File.join(MetricFu.root_dir, 'metric_fu.gemspec')
11
24
  end
12
25
 
13
26
  def new_dependency(name, version)
@@ -15,11 +28,15 @@ module MetricFu
15
28
  end
16
29
 
17
30
  def gem_runtime_dependencies
18
- @gem_runtime_dependencies ||= begin
19
- @gem_spec.dependencies.select{|gem| gem.type == :runtime}.each do |gem_dep|
20
- gem_dep.name = gem_dep.name.downcase.sub('metric_fu-','')
21
- end << new_dependency('rcov', ['~> 0.8'])
22
- end
31
+ @gem_runtime_dependencies ||=
32
+ begin
33
+ @gem_spec.grep(/add_dependency|add_runtime/).map do |line|
34
+ match = line.match(ADD_DEPENDENCY_CALL)
35
+ name = match['name'].downcase.sub('metric_fu-', '')
36
+ version = [match['req1'], match['req2']].compact
37
+ new_dependency(name, version)
38
+ end.compact << new_dependency('rcov', ['~> 0.8'])
39
+ end
23
40
  end
24
41
 
25
42
  def for(name)
@@ -44,12 +61,28 @@ module MetricFu
44
61
  RESOLVER.gem_runtime_dependencies.dup
45
62
  end
46
63
 
64
+ def self.activated_gems
65
+ Gem::Specification.stubs.select(&:activated?)
66
+ end
67
+
68
+ def self.activated_version(name)
69
+ activated_gems.find do |gem|
70
+ return gem.version.version if gem.name == name
71
+ end
72
+ end
73
+
74
+ def self.dependency_summary(gem_dep)
75
+ name = gem_dep.name
76
+ version = activated_version(gem_dep.name) || gem_dep.requirements_list
77
+ {
78
+ 'name' => name,
79
+ 'version' => version,
80
+ }
81
+ end
82
+
47
83
  def self.dependencies_summary
48
84
  dependencies.map do |gem_dep|
49
- {
50
- 'name' => gem_dep.name,
51
- 'version' => gem_dep.requirements_list,
52
- }
85
+ dependency_summary(gem_dep)
53
86
  end
54
87
  end
55
88