Permalink
Browse files

Reorganize lib files to not rely on autoload

* Update code to bring it closer inline to more recent gems.
  • Loading branch information...
1 parent ec43c0f commit 4878094e2bd4d73f6dbcd691ce7af695ec5a720d @dkubb committed Oct 26, 2012
View
@@ -2,7 +2,8 @@
source 'https://rubygems.org'
-gem 'yard', '~> 0.8.3'
+gem 'backports', '~> 2.6.4'
+gem 'yard', '~> 0.8.3'
group :development do
gem 'jeweler', '~> 1.8.3'
View
@@ -1,20 +1,7 @@
require 'rake'
-begin
- require 'jeweler'
+require File.expand_path('../lib/yardstick/version', __FILE__)
- Jeweler::Tasks.new do |gem|
- gem.name = 'yardstick'
- gem.summary = 'A tool for verifying YARD documentation coverage'
- gem.description = 'Measure YARD documentation coverage'
- gem.email = 'dan.kubb@gmail.com'
- gem.homepage = 'http://github.com/dkubb/yardstick'
- gem.authors = [ 'Dan Kubb' ]
- end
+FileList['tasks/**/*.rake'].each { |task| import task }
- Jeweler::GemcutterTasks.new
-
- FileList['tasks/**/*.rake'].each { |task| import task }
-rescue LoadError
- puts 'Jeweler (or a dependency) not available. Install it with: gem install jeweler'
-end
+task :default => :spec
View
@@ -1,7 +1,8 @@
#!/usr/bin/env ruby -KU
-require 'rubygems'
-require 'pathname'
-require File.expand_path('../../lib/yardstick', __FILE__)
+$LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__))
+
+require 'yardstick'
+require 'yardstick/cli'
Yardstick::CLI.run(*ARGV)
View
@@ -1,8 +1,26 @@
require 'pathname'
+require 'rational'
+
+require 'backports'
+require 'yard'
+
+require 'yardstick/yard_ext'
+
+require 'yardstick/ordered_set'
+require 'yardstick/rule_set'
+require 'yardstick/measurement'
+
+require 'yardstick/measurement_set'
+require 'yardstick/processor'
+require 'yardstick/rule'
+
+require 'yardstick/measurable'
+require 'yardstick/method'
+
+require 'yardstick/version'
module Yardstick
- VERSION = '0.6.0'.freeze
- ROOT = Pathname(__FILE__).dirname.parent.expand_path.freeze
+ ROOT = Pathname(__FILE__).dirname.parent.expand_path.freeze
# Measure a list of files
#
@@ -43,9 +61,3 @@ def self.measure_string(string, options = {})
end
end # module Yardstick
-
-$LOAD_PATH.unshift((Yardstick::ROOT + 'lib').to_s)
-
-require 'yardstick/core_ext/object'
-require 'yardstick/yard_ext'
-require 'yardstick/autoload'
View
@@ -1,16 +0,0 @@
-module Yardstick
- autoload :CLI, 'yardstick/cli'
- autoload :Measurable, 'yardstick/measurable'
- autoload :Measurement, 'yardstick/measurement'
- autoload :MeasurementSet, 'yardstick/measurement_set'
- autoload :Method, 'yardstick/method'
- autoload :OrderedSet, 'yardstick/ordered_set'
- autoload :Processor, 'yardstick/processor'
- autoload :Rule, 'yardstick/rule'
- autoload :RuleSet, 'yardstick/rule_set'
-
- module Rake
- autoload :Measurement, 'yardstick/rake/measurement'
- autoload :Verify, 'yardstick/rake/verify'
- end # module Rake
-end # module Yardstick
@@ -1,13 +0,0 @@
-class Object #:nodoc:
-
- # Return the meta class for this instance
- #
- # @return [Class]
- # the meta class
- #
- # @api private
- def meta_class
- class << self; self end
- end
-
-end # class Object
@@ -55,7 +55,7 @@ def included(mod)
#
# @api private
def extended(docstring)
- included(docstring.meta_class)
+ included(docstring.singleton_class)
end
end # module ClassMethods
@@ -72,7 +72,7 @@ def extended(docstring)
#
# @api public
def measure
- meta_class.rules.measure(self)
+ singleton_class.rules.measure(self)
end
end # module Measurable
@@ -1,5 +1,3 @@
-require 'rational'
-
module Yardstick
class MeasurementSet < OrderedSet
@@ -1,5 +1,3 @@
-require 'yard'
-
module Yardstick
class Processor
@@ -1,6 +1,8 @@
require 'rake'
require 'rake/tasklib'
+require 'yardstick'
+
module Yardstick
module Rake
class Verify < ::Rake::TaskLib
View
@@ -0,0 +1,3 @@
+module Yardstick
+ VERSION = '0.7.0'
+end # module Yardstick
@@ -1,4 +1,5 @@
require 'spec_helper'
+require 'yardstick/cli'
shared_examples_for 'displays help' do
it 'should display the help message' do
@@ -1,4 +1,5 @@
require 'spec_helper'
+require 'yardstick/rake/measurement'
shared_examples_for 'set default name for measurement task' do
it 'should set name to :yardstick_measure' do
@@ -1,4 +1,5 @@
require 'spec_helper'
+require 'yardstick/rake/verify'
shared_examples_for 'set default name for verify task' do
it 'should set name to :verify_measurements' do
View
@@ -1,13 +1,6 @@
-require 'pathname'
-require 'rubygems'
-require 'spec/autorun'
-
-require 'yard'
require 'yardstick'
-
-Pathname.glob(Yardstick::ROOT.join('lib', '**', '*.rb').to_s).sort.each do |file|
- require file.to_s.chomp('.rb')
-end
+require 'spec'
+require 'spec/autorun'
Spec::Runner.configure do |config|
clear_tasks = proc { Rake::Task.clear }
View
@@ -0,0 +1,18 @@
+begin
+ require 'jeweler'
+
+ Jeweler::Tasks.new do |gem|
+ gem.name = 'yardstick'
+ gem.summary = 'A tool for verifying YARD documentation coverage'
+ gem.description = 'Measure YARD documentation coverage'
+ gem.email = 'dan.kubb@gmail.com'
+ gem.homepage = 'http://github.com/dkubb/yardstick'
+ gem.authors = [ 'Dan Kubb' ]
+
+ gem.version = Yardstick::VERSION
+ end
+
+ Jeweler::GemcutterTasks.new
+rescue LoadError
+ puts 'Jeweler (or a dependency) not available. Install it with: gem install jeweler'
+end
View
@@ -3,7 +3,6 @@ require 'spec/rake/verify_rcov'
spec_defaults = lambda do |spec|
spec.pattern = 'spec/**/*_spec.rb'
- spec.libs << 'lib' << 'spec'
spec.spec_opts << '--options' << 'spec/spec.opts'
end
View
@@ -1,4 +1,7 @@
-require File.expand_path('../../lib/yardstick', __FILE__)
+$LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__))
+
+require 'yardstick/rake/measurement'
+require 'yardstick/rake/verify'
# yardstick_measure task
Yardstick::Rake::Measurement.new
View
@@ -5,11 +5,11 @@
Gem::Specification.new do |s|
s.name = "yardstick"
- s.version = "0.6.0"
+ s.version = "0.7.0"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Dan Kubb"]
- s.date = "2012-10-25"
+ s.date = "2012-10-26"
s.description = "Measure YARD documentation coverage"
s.email = "dan.kubb@gmail.com"
s.executables = ["yardstick"]
@@ -28,9 +28,7 @@ Gem::Specification.new do |s|
"VERSION",
"bin/yardstick",
"lib/yardstick.rb",
- "lib/yardstick/autoload.rb",
"lib/yardstick/cli.rb",
- "lib/yardstick/core_ext/object.rb",
"lib/yardstick/measurable.rb",
"lib/yardstick/measurement.rb",
"lib/yardstick/measurement_set.rb",
@@ -70,21 +68,23 @@ Gem::Specification.new do |s|
s.specification_version = 3
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
+ s.add_runtime_dependency(%q<backports>, ["~> 2.6.4"])
s.add_runtime_dependency(%q<yard>, ["~> 0.8.3"])
s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
s.add_development_dependency(%q<rake>, ["~> 0.9.2"])
s.add_development_dependency(%q<rspec>, ["~> 1.3.2"])
else
+ s.add_dependency(%q<backports>, ["~> 2.6.4"])
s.add_dependency(%q<yard>, ["~> 0.8.3"])
s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
s.add_dependency(%q<rake>, ["~> 0.9.2"])
s.add_dependency(%q<rspec>, ["~> 1.3.2"])
end
else
+ s.add_dependency(%q<backports>, ["~> 2.6.4"])
s.add_dependency(%q<yard>, ["~> 0.8.3"])
s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
s.add_dependency(%q<rake>, ["~> 0.9.2"])
s.add_dependency(%q<rspec>, ["~> 1.3.2"])
end
end
-

0 comments on commit 4878094

Please sign in to comment.