the_metric_system 2.3.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
@@ -0,0 +1,6 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
4
+ rdoc
5
+ pkg
6
+ *.gem
@@ -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.
@@ -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.
@@ -0,0 +1,56 @@
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{ The metric system is an international decimalised system of measurement, first adopted by France in 1791.}
9
+ gem.description = %Q{ The metric system is an international decimalised system of measurement, first adopted by France in 1791.}
10
+ gem.email = "chad.humphries@gmail.com"
11
+ gem.homepage = "http://github.com/spicycode/the_metric_system"
12
+ gem.authors = ["Chad Humphries"]
13
+
14
+ gem.add_development_dependency "rspec-meta"
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 'rspec/core/rake_task'
27
+ Rspec::Core::RakeTask.new(:spec) do |t|
28
+ t.ruby_opts = '-Ilib -Ispec'
29
+ t.pattern = 'spec/**/*_spec.rb'
30
+ end
31
+
32
+ desc "Run all examples using rcov"
33
+ Rspec::Core::RakeTask.new :rcov do |t|
34
+ t.rcov = true
35
+ t.rcov_opts = %[-Ilib -Ispec --exclude "gems/*,spec/resources,spec/lib,spec/spec_helper.rb,db/*,/Library/Ruby/*,config/*"]
36
+ t.rcov_opts << %[--text-report --sort coverage]
37
+ t.pattern = "spec/**/*_spec.rb"
38
+ end
39
+
40
+ task :spec => :check_dependencies
41
+
42
+ task :default => :spec
43
+ rescue LoadError
44
+ task :default do
45
+ abort "Rspec is not available."
46
+ end
47
+ end
48
+
49
+ begin
50
+ require 'yard'
51
+ YARD::Rake::YardocTask.new
52
+ rescue LoadError
53
+ task :yardoc do
54
+ abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
55
+ end
56
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 2.3.6
@@ -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
+ reasonable_defaults.merge!(options)
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
+ reasonable_defaults.merge!(options)
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
@@ -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 'rspec'
6
+ require 'rr'
7
+
8
+ Rspec::Core.configure do |c|
9
+ c.mock_with :rr
10
+ c.color_enabled = true
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
@@ -0,0 +1,70 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{the_metric_system}
8
+ s.version = "2.3.6"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Chad Humphries"]
12
+ s.date = %q{2009-08-23}
13
+ s.description = %q{ The metric system is an international decimalised system of measurement, first adopted by France in 1791.}
14
+ s.email = %q{chad.humphries@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.md"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".gitignore",
22
+ ".treasure_map.rb",
23
+ "LICENSE",
24
+ "README.md",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "lib/the_metric_system.rb",
28
+ "lib/the_metric_system/units_of_measure/flay_units.rb",
29
+ "lib/the_metric_system/units_of_measure/flog_units.rb",
30
+ "spec/spec.opts",
31
+ "spec/spec_helper.rb",
32
+ "spec/the_metric_system/units_of_measure/flay_units_spec.rb",
33
+ "spec/the_metric_system/units_of_measure/flog_units_spec.rb",
34
+ "spec/the_metric_system_spec.rb",
35
+ "the_metric_system.gemspec"
36
+ ]
37
+ s.homepage = %q{http://github.com/spicycode/the_metric_system}
38
+ s.rdoc_options = ["--charset=UTF-8"]
39
+ s.require_paths = ["lib"]
40
+ s.rubygems_version = %q{1.3.5}
41
+ s.summary = %q{The metric system is an international decimalised system of measurement, first adopted by France in 1791.}
42
+ s.test_files = [
43
+ "spec/spec_helper.rb",
44
+ "spec/the_metric_system/units_of_measure/flay_units_spec.rb",
45
+ "spec/the_metric_system/units_of_measure/flog_units_spec.rb",
46
+ "spec/the_metric_system_spec.rb"
47
+ ]
48
+
49
+ if s.respond_to? :specification_version then
50
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
51
+ s.specification_version = 3
52
+
53
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
54
+ s.add_development_dependency(%q<rspec>, [">= 0"])
55
+ s.add_development_dependency(%q<yard>, [">= 0"])
56
+ s.add_runtime_dependency(%q<flog>, [">= 2.2.0"])
57
+ s.add_runtime_dependency(%q<flay>, [">= 1.4.0"])
58
+ else
59
+ s.add_dependency(%q<rspec>, [">= 0"])
60
+ s.add_dependency(%q<yard>, [">= 0"])
61
+ s.add_dependency(%q<flog>, [">= 2.2.0"])
62
+ s.add_dependency(%q<flay>, [">= 1.4.0"])
63
+ end
64
+ else
65
+ s.add_dependency(%q<rspec>, [">= 0"])
66
+ s.add_dependency(%q<yard>, [">= 0"])
67
+ s.add_dependency(%q<flog>, [">= 2.2.0"])
68
+ s.add_dependency(%q<flay>, [">= 1.4.0"])
69
+ end
70
+ end
metadata ADDED
@@ -0,0 +1,113 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: the_metric_system
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.3.6
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 -04: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: "\tThe metric system is an international decimalised system of measurement, first adopted by France in 1791."
56
+ email: chad.humphries@gmail.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
+ - the_metric_system.gemspec
81
+ has_rdoc: true
82
+ homepage: http://github.com/spicycode/the_metric_system
83
+ licenses: []
84
+
85
+ post_install_message:
86
+ rdoc_options:
87
+ - --charset=UTF-8
88
+ require_paths:
89
+ - lib
90
+ required_ruby_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: "0"
95
+ version:
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: "0"
101
+ version:
102
+ requirements: []
103
+
104
+ rubyforge_project:
105
+ rubygems_version: 1.3.5
106
+ signing_key:
107
+ specification_version: 3
108
+ summary: The metric system is an international decimalised system of measurement, first adopted by France in 1791.
109
+ test_files:
110
+ - spec/spec_helper.rb
111
+ - spec/the_metric_system/units_of_measure/flay_units_spec.rb
112
+ - spec/the_metric_system/units_of_measure/flog_units_spec.rb
113
+ - spec/the_metric_system_spec.rb