diff --git a/Rakefile b/Rakefile index c870436..9cd17dc 100644 --- a/Rakefile +++ b/Rakefile @@ -1,7 +1,7 @@ require 'rubygems' require 'rake' -require 'lib/whenever/version.rb' +require File.expand_path(File.dirname(__FILE__) + "/lib/whenever/version") begin require 'jeweler' @@ -13,7 +13,10 @@ begin gemspec.email = "javan@javan.us" gemspec.homepage = "http://github.com/javan/whenever" gemspec.authors = ["Javan Makhmali"] - gemspec.add_dependency("chronic", '>= 0.2.3') + gemspec.add_dependency 'chronic', '>= 0.2.3' + gemspec.add_dependency 'activesupport', '>= 2.3.4' + gemspec.add_development_dependency 'shoulda', '>= 2.1.1' + gemspec.add_development_dependency 'mocha', '>= 0.9.5' end Jeweler::GemcutterTasks.new rescue LoadError @@ -22,10 +25,10 @@ end require 'rake/testtask' Rake::TestTask.new(:test) do |test| - test.libs << 'lib' << 'test' - test.pattern = 'test/*.rb' - test.verbose = true -end + test.libs << 'lib' << 'test' + test.pattern = 'test/{functional,unit}/**/*_test.rb' + test.verbose = true + end task :test => :check_dependencies diff --git a/lib/whenever.rb b/lib/whenever.rb index 8fbd12c..cf925c9 100644 --- a/lib/whenever.rb +++ b/lib/whenever.rb @@ -1,20 +1,10 @@ require 'chronic' +require 'active_support/all' -# It was previously defined as a dependency of this gem, but that became -# problematic. See: http://github.com/javan/whenever/issues#issue/1 -begin - require 'active_support/all' -rescue LoadError - warn 'To use Whenever you need the active_support gem:' - warn '$ gem install activesupport' - exit(1) -end - -# Whenever files require 'whenever/base' require 'whenever/job_list' require 'whenever/job' -require 'whenever/outputs/cron' -require 'whenever/outputs/cron/output_redirection' +require 'whenever/cron' +require 'whenever/output_redirection' require 'whenever/command_line' require 'whenever/version' \ No newline at end of file diff --git a/lib/whenever/outputs/cron.rb b/lib/whenever/cron.rb similarity index 95% rename from lib/whenever/outputs/cron.rb rename to lib/whenever/cron.rb index 044cd9a..b673d95 100644 --- a/lib/whenever/outputs/cron.rb +++ b/lib/whenever/cron.rb @@ -1,6 +1,5 @@ module Whenever module Output - class Cron attr_accessor :time, :task @@ -43,7 +42,7 @@ module Whenever end def output_redirection - OutputRedirection.new(@output_redirection).to_s unless @output_redirection == :not_set + Whenever::Output::Cron::OutputRedirection.new(@output_redirection).to_s unless @output_redirection == :not_set end protected @@ -60,7 +59,7 @@ module Whenever end if shortcut - if @at.is_a?(Time) || (@at.is_a?(Numeric) && @at>0) + if @at.is_a?(Time) || (@at.is_a?(Numeric) && @at > 0) raise ArgumentError, "You cannot specify an ':at' when using the shortcuts for times." else return shortcut @@ -134,6 +133,5 @@ module Whenever end end - end end diff --git a/lib/whenever/outputs/cron/output_redirection.rb b/lib/whenever/output_redirection.rb similarity index 100% rename from lib/whenever/outputs/cron/output_redirection.rb rename to lib/whenever/output_redirection.rb diff --git a/test/command_line_test.rb b/test/functional/command_line_test.rb similarity index 98% rename from test/command_line_test.rb rename to test/functional/command_line_test.rb index e6d39f7..04811a4 100644 --- a/test/command_line_test.rb +++ b/test/functional/command_line_test.rb @@ -1,4 +1,4 @@ -require File.expand_path(File.dirname(__FILE__) + "/test_helper") +require File.expand_path(File.dirname(__FILE__) + "/../test_helper") class CommandLineTest < Test::Unit::TestCase diff --git a/test/output_at_test.rb b/test/functional/output_at_test.rb similarity index 98% rename from test/output_at_test.rb rename to test/functional/output_at_test.rb index 95ce0bf..e942715 100644 --- a/test/output_at_test.rb +++ b/test/functional/output_at_test.rb @@ -1,4 +1,4 @@ -require File.expand_path(File.dirname(__FILE__) + "/test_helper") +require File.expand_path(File.dirname(__FILE__) + "/../test_helper") class OutputAtTest < Test::Unit::TestCase diff --git a/test/output_command_test.rb b/test/functional/output_command_test.rb similarity index 91% rename from test/output_command_test.rb rename to test/functional/output_command_test.rb index fff6baf..beb3d5c 100644 --- a/test/output_command_test.rb +++ b/test/functional/output_command_test.rb @@ -1,4 +1,4 @@ -require File.expand_path(File.dirname(__FILE__) + "/test_helper") +require File.expand_path(File.dirname(__FILE__) + "/../test_helper") class OutputCommandTest < Test::Unit::TestCase diff --git a/test/output_defined_job_test.rb b/test/functional/output_defined_job_test.rb similarity index 97% rename from test/output_defined_job_test.rb rename to test/functional/output_defined_job_test.rb index a135054..6081a5a 100644 --- a/test/output_defined_job_test.rb +++ b/test/functional/output_defined_job_test.rb @@ -1,4 +1,4 @@ -require File.expand_path(File.dirname(__FILE__) + "/test_helper") +require File.expand_path(File.dirname(__FILE__) + "/../test_helper") class OutputDefinedJobTest < Test::Unit::TestCase diff --git a/test/output_env_test.rb b/test/functional/output_env_test.rb similarity index 95% rename from test/output_env_test.rb rename to test/functional/output_env_test.rb index 7ecfc60..6deac9b 100644 --- a/test/output_env_test.rb +++ b/test/functional/output_env_test.rb @@ -1,4 +1,4 @@ -require File.expand_path(File.dirname(__FILE__) + "/test_helper") +require File.expand_path(File.dirname(__FILE__) + "/../test_helper") class OutputEnvTest < Test::Unit::TestCase diff --git a/test/output_rake_test.rb b/test/functional/output_rake_test.rb similarity index 96% rename from test/output_rake_test.rb rename to test/functional/output_rake_test.rb index e1a1767..d5104c9 100644 --- a/test/output_rake_test.rb +++ b/test/functional/output_rake_test.rb @@ -1,4 +1,4 @@ -require File.expand_path(File.dirname(__FILE__) + "/test_helper") +require File.expand_path(File.dirname(__FILE__) + "/../test_helper") class OutputRakeTest < Test::Unit::TestCase diff --git a/test/output_redirection_test.rb b/test/functional/output_redirection_test.rb similarity index 99% rename from test/output_redirection_test.rb rename to test/functional/output_redirection_test.rb index 807582e..2b9a09f 100644 --- a/test/output_redirection_test.rb +++ b/test/functional/output_redirection_test.rb @@ -1,4 +1,4 @@ -require File.expand_path(File.dirname(__FILE__) + "/test_helper") +require File.expand_path(File.dirname(__FILE__) + "/../test_helper") class OutputRedirectionTest < Test::Unit::TestCase diff --git a/test/output_runner_test.rb b/test/functional/output_runner_test.rb similarity index 98% rename from test/output_runner_test.rb rename to test/functional/output_runner_test.rb index de61012..b344861 100644 --- a/test/output_runner_test.rb +++ b/test/functional/output_runner_test.rb @@ -1,4 +1,4 @@ -require File.expand_path(File.dirname(__FILE__) + "/test_helper") +require File.expand_path(File.dirname(__FILE__) + "/../test_helper") class OutputRunnerTest < Test::Unit::TestCase diff --git a/test/test_helper.rb b/test/test_helper.rb index 04128f5..c2002bc 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,24 +1,11 @@ require 'rubygems' -require 'test/unit' -require File.expand_path(File.dirname(__FILE__) + "/../lib/whenever") - -begin - require 'shoulda' -rescue LoadError - warn 'To test Whenever you need the shoulda gem:' - warn '$ sudo gem install thoughtbot-shoulda' - exit(1) -end - -begin - require 'mocha' -rescue LoadError - warn 'To test Whenever you need the mocha gem:' - warn '$ sudo gem install mocha' - exit(1) -end +# Want to test the files here, in lib, not in an installed version of the gem. +$:.unshift File.expand_path(File.dirname(__FILE__) + '/../lib') +require 'whenever' +require 'shoulda' +require 'mocha' module TestExtensions diff --git a/test/cron_test.rb b/test/unit/cron_test.rb similarity index 99% rename from test/cron_test.rb rename to test/unit/cron_test.rb index c643e75..6eafa4c 100644 --- a/test/cron_test.rb +++ b/test/unit/cron_test.rb @@ -1,4 +1,4 @@ -require File.expand_path(File.dirname(__FILE__) + "/test_helper") +require File.expand_path(File.dirname(__FILE__) + "/../test_helper") class CronTest < Test::Unit::TestCase diff --git a/test/job_test.rb b/test/unit/job_test.rb similarity index 94% rename from test/job_test.rb rename to test/unit/job_test.rb index cd878aa..9cb2210 100644 --- a/test/job_test.rb +++ b/test/unit/job_test.rb @@ -1,4 +1,4 @@ -require File.expand_path(File.dirname(__FILE__) + "/test_helper") +require File.expand_path(File.dirname(__FILE__) + "/../test_helper") class JobTest < Test::Unit::TestCase