spicycode-the_metric_system 2.3.4

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/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
4
+ rdoc
5
+ pkg
data/.treasure_map.rb ADDED
@@ -0,0 +1 @@
1
+ Beholder.runner = 'spec --options spec/spec.opts'
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Chad Humphries
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,7 @@
1
+ # The Metric System
2
+
3
+ After a long discussion with wikipedia today I decided I'm sick and tired of hearing how ["the US is the only industrialized nation that does not mainly use the metric system in its commercial and standards activities"](http://en.wikipedia.org/wiki/United_States_customary_units). So I went and made a rubygem to solve it. Or maybe I had a different goal, the jury is out after all, it being a weekend.
4
+
5
+ The **Metric System (tm)** is most probably an attempt to generate simple, quick metrics without any fancy reporting, or other bits. It is currently in early alpha shape at version 2.3.4.
6
+
7
+ Copyright (c) 2009 Chad Humphries. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,57 @@
1
+ require 'rake'
2
+
3
+ begin
4
+ require 'rubygems'
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "the_metric_system"
8
+ gem.summary = %Q{TODO: one-line summary of your gem}
9
+ gem.description = %Q{TODO: longer description of your gem}
10
+ gem.email = "chad@spicycode.com"
11
+ gem.homepage = "http://github.com/spicycode/the_metric_system"
12
+ gem.authors = ["Chad Humphries"]
13
+
14
+ gem.add_development_dependency "rspec"
15
+ gem.add_development_dependency "yard"
16
+
17
+ gem.add_dependency "flog", ">=2.2.0"
18
+ gem.add_dependency "flay", ">=1.4.0"
19
+ end
20
+ Jeweler::GemcutterTasks.new
21
+ rescue LoadError
22
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
23
+ end
24
+
25
+ begin
26
+ require 'spec/rake/spectask'
27
+
28
+ Spec::Rake::SpecTask.new(:spec) do |spec|
29
+ spec.libs << 'lib' << 'spec'
30
+ spec.spec_files = FileList['spec/**/*_spec.rb']
31
+ spec.spec_opts = ['-c', '-fs']
32
+ end
33
+
34
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
35
+ spec.libs << 'lib' << 'spec'
36
+ spec.pattern = 'spec/**/*_spec.rb'
37
+ spec.spec_opts = ['-c', '-fs']
38
+ spec.rcov = true
39
+ end
40
+
41
+ task :spec => :check_dependencies
42
+
43
+ task :default => :spec
44
+ rescue LoadError
45
+ task :default do
46
+ abort "Rspec is not available."
47
+ end
48
+ end
49
+
50
+ begin
51
+ require 'yard'
52
+ YARD::Rake::YardocTask.new
53
+ rescue LoadError
54
+ task :yardoc do
55
+ abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
56
+ end
57
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 2.3.4
@@ -0,0 +1,10 @@
1
+ module TheMetricSystem
2
+
3
+ def self.version
4
+ File.read('VERSION')
5
+ end
6
+
7
+ end
8
+
9
+ require 'the_metric_system/units_of_measure/flay_units'
10
+ require 'the_metric_system/units_of_measure/flog_units'
@@ -0,0 +1,22 @@
1
+ module TheMetricSystem::UnitsOfMeasure
2
+ class FlayUnits
3
+
4
+ def self.reasonable_defaults
5
+ { :threshold => 70, :directories => Dir["app/**/*.rb", "lib/**/*.rb"] }
6
+ end
7
+
8
+ def self.report_to_standards_body(options={})
9
+ options.merge!(reasonable_defaults)
10
+
11
+ # Don't like this, but still getting used to this whole, don't require rubygems in classes thing
12
+ # Will refactor soon
13
+ require 'flay'
14
+ flay = Flay.new(:fuzzy => false, :diff => true, :summary => false, :verbose => false, :mass => options[:threshold])
15
+ flay.process(*options[:directories])
16
+ flay.report
17
+
18
+ raise "Flay found #{flay.masses.size} chunks of code have a duplicate mass > #{options[:threshold]}" unless flay.masses.empty?
19
+ end
20
+
21
+ end
22
+ end
@@ -0,0 +1,28 @@
1
+ module TheMetricSystem::UnitsOfMeasure
2
+ class FlogUnits
3
+
4
+ def self.reasonable_defaults
5
+ { :threshold => 25, :directories => ['lib'] }
6
+ end
7
+
8
+ def self.report_to_standards_body(options={})
9
+ options.merge!(reasonable_defaults)
10
+
11
+ # Don't like this, but still getting used to this whole, don't require rubygems in classes thing
12
+ # Will refactor soon
13
+ require 'flog'
14
+ flog = Flog.new :methods => true
15
+ flog.flog options[:directories]
16
+ threshold = options[:threshold]
17
+
18
+ bad_methods = flog.totals.select { |name, score| score > threshold }
19
+
20
+ bad_methods.sort { |a,b| a[1] <=> b[1] }.each do |name, score|
21
+ puts "%8.1f: %s" % [score, name]
22
+ end
23
+
24
+ raise "Flog found #{bad_methods.size} methods with a complexity > #{options[:threshold]}" unless bad_methods.empty?
25
+ end
26
+
27
+ end
28
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1,2 @@
1
+ --colour
2
+ --format nested
@@ -0,0 +1,11 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'the_metric_system'
4
+ require 'rubygems'
5
+ require 'spec'
6
+ require 'spec/autorun'
7
+ require 'rr'
8
+
9
+ Spec::Runner.configure do |config|
10
+ config.mock_with :rr
11
+ end
@@ -0,0 +1,11 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+
3
+ describe TheMetricSystem::UnitsOfMeasure::FlayUnits do
4
+
5
+ describe "reasonable defaults" do
6
+ it "should have a default threshold of 70" do
7
+ TheMetricSystem::UnitsOfMeasure::FlayUnits.reasonable_defaults[:threshold].should == 70
8
+ end
9
+ end
10
+
11
+ end
@@ -0,0 +1,11 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+
3
+ describe TheMetricSystem::UnitsOfMeasure::FlogUnits do
4
+
5
+ describe "reasonable defaults" do
6
+ it "should have a default threshold of 25" do
7
+ TheMetricSystem::UnitsOfMeasure::FlogUnits.reasonable_defaults[:threshold].should == 25
8
+ end
9
+ end
10
+
11
+ end
@@ -0,0 +1,8 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/spec_helper")
2
+
3
+ describe TheMetricSystem do
4
+ it "should load it's version number from the VERSION file" do
5
+ stub(File).read('VERSION') { '7.8.9' }
6
+ TheMetricSystem.version.should == '7.8.9'
7
+ end
8
+ end
metadata ADDED
@@ -0,0 +1,111 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: spicycode-the_metric_system
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.3.4
5
+ platform: ruby
6
+ authors:
7
+ - Chad Humphries
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-08-23 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rspec
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: yard
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: flog
37
+ type: :runtime
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 2.2.0
44
+ version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: flay
47
+ type: :runtime
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: 1.4.0
54
+ version:
55
+ description: "TODO: longer description of your gem"
56
+ email: chad@spicycode.com
57
+ executables: []
58
+
59
+ extensions: []
60
+
61
+ extra_rdoc_files:
62
+ - LICENSE
63
+ - README.md
64
+ files:
65
+ - .document
66
+ - .gitignore
67
+ - .treasure_map.rb
68
+ - LICENSE
69
+ - README.md
70
+ - Rakefile
71
+ - VERSION
72
+ - lib/the_metric_system.rb
73
+ - lib/the_metric_system/units_of_measure/flay_units.rb
74
+ - lib/the_metric_system/units_of_measure/flog_units.rb
75
+ - spec/spec.opts
76
+ - spec/spec_helper.rb
77
+ - spec/the_metric_system/units_of_measure/flay_units_spec.rb
78
+ - spec/the_metric_system/units_of_measure/flog_units_spec.rb
79
+ - spec/the_metric_system_spec.rb
80
+ has_rdoc: false
81
+ homepage: http://github.com/spicycode/the_metric_system
82
+ licenses:
83
+ post_install_message:
84
+ rdoc_options:
85
+ - --charset=UTF-8
86
+ require_paths:
87
+ - lib
88
+ required_ruby_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: "0"
93
+ version:
94
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: "0"
99
+ version:
100
+ requirements: []
101
+
102
+ rubyforge_project:
103
+ rubygems_version: 1.3.5
104
+ signing_key:
105
+ specification_version: 3
106
+ summary: "TODO: one-line summary of your gem"
107
+ test_files:
108
+ - spec/spec_helper.rb
109
+ - spec/the_metric_system/units_of_measure/flay_units_spec.rb
110
+ - spec/the_metric_system/units_of_measure/flog_units_spec.rb
111
+ - spec/the_metric_system_spec.rb