strawberry_cough 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.
data/tasks/ci.rake ADDED
@@ -0,0 +1,3 @@
1
+ desc 'Heckle and run metrics'
2
+ task :ci => [ :verify_measurements, :flog, :flay, :reek, 'metrics:all' ]
3
+
@@ -0,0 +1,42 @@
1
+ begin
2
+ require 'flay'
3
+ require 'yaml'
4
+
5
+ config = YAML.load_file(File.expand_path('../../../config/flay.yml', __FILE__)).freeze
6
+ threshold = config.fetch('threshold').to_i
7
+ total_score = config.fetch('total_score').to_f
8
+ files = Flay.expand_dirs_to_files(config.fetch('path', 'lib'))
9
+
10
+ # original code by Marty Andrews:
11
+ # http://blog.martyandrews.net/2009/05/enforcing-ruby-code-quality.html
12
+ desc 'Analyze for code duplication'
13
+ task :flay do
14
+ # run flay once without a threshold to ensure the max mass matches the threshold
15
+ flay = Flay.new(:fuzzy => false, :verbose => false, :mass => 0)
16
+ flay.process(*files)
17
+
18
+ max = flay.masses.map { |hash, mass| mass.to_f / flay.hashes[hash].size }.max
19
+ unless max >= threshold
20
+ raise "Adjust flay threshold down to #{max}"
21
+ end
22
+
23
+ total = flay.masses.reduce(0.0) { |total, (hash, mass)| total + (mass.to_f / flay.hashes[hash].size) }
24
+ unless total == total_score
25
+ raise "Flay total is now #{total}, but expected #{total_score}"
26
+ end
27
+
28
+ # run flay a second time with the threshold set
29
+ flay = Flay.new(:fuzzy => false, :verbose => false, :mass => threshold.succ)
30
+ flay.process(*files)
31
+
32
+ if flay.masses.any?
33
+ flay.report
34
+ raise "#{flay.masses.size} chunks of code have a duplicate mass > #{threshold}"
35
+ end
36
+ end
37
+ rescue LoadError
38
+ task :flay do
39
+ abort 'Flay is not available. In order to run flay, you must: gem install flay'
40
+ end
41
+ end
42
+
@@ -0,0 +1,44 @@
1
+ begin
2
+ require 'flog'
3
+ require 'yaml'
4
+
5
+ class Float
6
+ def round_to(n)
7
+ (self * 10**n).round.to_f * 10**-n
8
+ end
9
+ end
10
+
11
+ config = YAML.load_file(File.expand_path('../../../config/flog.yml', __FILE__)).freeze
12
+ threshold = config.fetch('threshold').to_f.round_to(1)
13
+
14
+ # original code by Marty Andrews:
15
+ # http://blog.martyandrews.net/2009/05/enforcing-ruby-code-quality.html
16
+ desc 'Analyze for code complexity'
17
+ task :flog do
18
+ flog = Flog.new
19
+ flog.flog Array(config.fetch('path', 'lib'))
20
+
21
+ totals = flog.totals.select { |name, score| name[-5, 5] != '#none' }.
22
+ map { |name, score| [ name, score.round_to(1) ] }.
23
+ sort_by { |name, score| score }
24
+
25
+ max = totals.last[1]
26
+ unless max >= threshold
27
+ raise "Adjust flog score down to #{max}"
28
+ end
29
+
30
+ bad_methods = totals.select { |name, score| score > threshold }
31
+ if bad_methods.any?
32
+ bad_methods.reverse_each do |name, score|
33
+ puts '%8.1f: %s' % [ score, name ]
34
+ end
35
+
36
+ raise "#{bad_methods.size} methods have a flog complexity > #{threshold}"
37
+ end
38
+ end
39
+ rescue LoadError
40
+ task :flog do
41
+ abort 'Flog is not available. In order to run flog, you must: gem install flog'
42
+ end
43
+ end
44
+
@@ -0,0 +1,26 @@
1
+ begin
2
+ require 'metric_fu'
3
+
4
+ MetricFu::Configuration.run do |config|
5
+ config.rcov = {
6
+ :environment => 'test',
7
+ :test_files => %w[ spec/**/*_spec.rb ],
8
+ :rcov_opts => %w[
9
+ --sort coverage
10
+ --no-html
11
+ --text-coverage
12
+ --no-color
13
+ --profile
14
+ --include spec
15
+ --exclude /gems/,/Library/,/usr/,spec
16
+ ]
17
+ }
18
+ end
19
+ rescue LoadError
20
+ namespace :metrics do
21
+ task :all do
22
+ abort "metric_fu is not available. Install with: gem install metric_fu"
23
+ end
24
+ end
25
+ end
26
+
@@ -0,0 +1,10 @@
1
+ begin
2
+ require 'reek/rake/task'
3
+
4
+ Reek::Rake::Task.new
5
+ rescue LoadError
6
+ task :reek do
7
+ abort "reek not available. Install with: gem install reek"
8
+ end
9
+ end
10
+
@@ -0,0 +1,24 @@
1
+ begin
2
+ require 'pathname'
3
+ require 'yardstick'
4
+ require 'yardstick/rake/measurement'
5
+ require 'yardstick/rake/verify'
6
+ require 'yaml'
7
+
8
+ config = YAML.load_file(File.expand_path('../../../config/yardstick.yml', __FILE__))
9
+
10
+ # yardstick_measure task
11
+ Yardstick::Rake::Measurement.new
12
+
13
+ # verify_measurements task
14
+ Yardstick::Rake::Verify.new do |verify|
15
+ verify.threshold = config.fetch('threshold')
16
+ end
17
+ rescue LoadError
18
+ %w[ yardstick_measure verify_measurements ].each do |name|
19
+ task name.to_s do
20
+ abort "Yardstick is not available. In order to run #{name}, you must: gem install yardstick"
21
+ end
22
+ end
23
+ end
24
+
metadata CHANGED
@@ -1,50 +1,44 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: strawberry_cough
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 1
8
- - 0
9
- version: 0.1.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Craig Savolainen
13
9
  - Nate Smith
10
+ - Shawn Lee-Kwong
14
11
  autorequire:
15
12
  bindir: bin
16
13
  cert_chain: []
17
-
18
- date: 2010-09-25 00:00:00 -04:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
14
+ date: 2012-12-04 00:00:00.000000000 Z
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
22
17
  name: bundler
23
- requirement: &id001 !ruby/object:Gem::Requirement
18
+ requirement: !ruby/object:Gem::Requirement
24
19
  none: false
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- segments:
29
- - 1
30
- - 0
31
- - 0
20
+ requirements:
21
+ - - ! '>='
22
+ - !ruby/object:Gem::Version
32
23
  version: 1.0.0
33
24
  type: :development
34
25
  prerelease: false
35
- version_requirements: *id001
26
+ version_requirements: !ruby/object:Gem::Requirement
27
+ none: false
28
+ requirements:
29
+ - - ! '>='
30
+ - !ruby/object:Gem::Version
31
+ version: 1.0.0
36
32
  description:
37
- email:
33
+ email:
38
34
  - support@threewisemen.ca
39
35
  executables: []
40
-
41
36
  extensions: []
42
-
43
37
  extra_rdoc_files: []
44
-
45
- files:
38
+ files:
46
39
  - .gitignore
47
40
  - .rspec
41
+ - .rvmrc
48
42
  - Gemfile
49
43
  - Gemfile.lock
50
44
  - LICENSE
@@ -52,51 +46,52 @@ files:
52
46
  - Rakefile
53
47
  - TODO
54
48
  - autotest/discover.rb
49
+ - config/flay.yml
50
+ - config/flog.yml
51
+ - config/site.reek
52
+ - config/yardstick.yml
53
+ - lib/assets/javascripts/routes.js.strawberry_cough
55
54
  - lib/strawberry_cough.rb
56
55
  - lib/strawberry_cough/path_compiler.rb
57
56
  - lib/strawberry_cough/path_parser.rb
58
- - lib/strawberry_cough/railtie.rb
57
+ - lib/strawberry_cough/rails/engine.rb
59
58
  - lib/strawberry_cough/routes_compiler.rb
59
+ - lib/strawberry_cough/routes_js_template.rb
60
60
  - lib/strawberry_cough/version.rb
61
61
  - spec/path_compiler_spec.rb
62
62
  - spec/path_parser_spec.rb
63
63
  - spec/routes_compiler_spec.rb
64
64
  - spec/spec_helper.rb
65
65
  - strawberry_cough.gemspec
66
- has_rdoc: true
66
+ - tags
67
+ - tasks/ci.rake
68
+ - tasks/quality/flay.rake
69
+ - tasks/quality/flog.rake
70
+ - tasks/quality/metric_fu.rake
71
+ - tasks/quality/reek.rake
72
+ - tasks/quality/yardstick.rake
67
73
  homepage: http://github.com/ThreeWiseMen/strawberry_cough
68
74
  licenses: []
69
-
70
75
  post_install_message:
71
76
  rdoc_options: []
72
-
73
- require_paths:
77
+ require_paths:
74
78
  - lib
75
- required_ruby_version: !ruby/object:Gem::Requirement
79
+ required_ruby_version: !ruby/object:Gem::Requirement
76
80
  none: false
77
- requirements:
78
- - - ">="
79
- - !ruby/object:Gem::Version
80
- hash: -3654356472966179208
81
- segments:
82
- - 0
83
- version: "0"
84
- required_rubygems_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ! '>='
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
86
  none: false
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- segments:
90
- - 1
91
- - 3
92
- - 6
87
+ requirements:
88
+ - - ! '>='
89
+ - !ruby/object:Gem::Version
93
90
  version: 1.3.6
94
91
  requirements: []
95
-
96
92
  rubyforge_project: strawberry_cough
97
- rubygems_version: 1.3.7
93
+ rubygems_version: 1.8.24
98
94
  signing_key:
99
95
  specification_version: 3
100
96
  summary: Strawberry Cough lets you access your Rails 3 routes in your JavaScripts.
101
97
  test_files: []
102
-
@@ -1,19 +0,0 @@
1
- require 'strawberry_cough/routes_compiler'
2
- require 'rails/railtie'
3
-
4
- module StrawberryCough
5
-
6
- class Railtie < Rails::Railtie
7
-
8
- config.to_prepare do
9
- app = Rails.application
10
- routes = app.routes.routes
11
- file = File.join(app.root, "public", "javascripts", "routes.js")
12
- File.open(file, "w") do |io|
13
- RoutesCompiler.compile_to_io(routes, io)
14
- end
15
- end
16
-
17
- end
18
-
19
- end