Sets the PATH automatically unless it's already provided or told not to.
This commit is contained in:
parent
ed86aeb792
commit
51a6b3720a
@ -1,6 +1,11 @@
|
|||||||
|
== 0.3.6 / June 15th, 2009
|
||||||
|
|
||||||
|
* Setting a PATH in the crontab automatically based on the user's PATH. [Javan Makhmali]
|
||||||
|
|
||||||
|
|
||||||
== 0.3.5 / June 13th, 2009
|
== 0.3.5 / June 13th, 2009
|
||||||
|
|
||||||
* Added ability to accept lists of every's and at's and intelligently group them. (ex: every 'monday, wednesday', :at => ['3pm, 6am']). [Sam Ruby]
|
* Added ability to accept lists of every's and at's and intelligently group them. (ex: every 'monday, wednesday', :at => ['3pm', '6am']). [Sam Ruby]
|
||||||
|
|
||||||
* Fixed issue with new lines. #18 [Javan Makhmali]
|
* Fixed issue with new lines. #18 [Javan Makhmali]
|
||||||
|
|
||||||
|
@ -57,6 +57,8 @@ module Whenever
|
|||||||
end
|
end
|
||||||
|
|
||||||
def generate_cron_output
|
def generate_cron_output
|
||||||
|
set_path_environment_variable
|
||||||
|
|
||||||
[environment_variables, cron_jobs].compact.join
|
[environment_variables, cron_jobs].compact.join
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -77,6 +79,19 @@ module Whenever
|
|||||||
set(variable.strip, value.strip) unless variable.blank? || value.blank?
|
set(variable.strip, value.strip) unless variable.blank? || value.blank?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def set_path_environment_variable
|
||||||
|
return if path_should_not_be_set_automatically?
|
||||||
|
@env[:PATH] = read_path unless read_path.blank?
|
||||||
|
end
|
||||||
|
|
||||||
|
def read_path
|
||||||
|
ENV['PATH'] if ENV
|
||||||
|
end
|
||||||
|
|
||||||
|
def path_should_not_be_set_automatically?
|
||||||
|
@set_path_automatically === false || @env[:PATH] || @env["PATH"]
|
||||||
|
end
|
||||||
|
|
||||||
def environment_variables
|
def environment_variables
|
||||||
return if @env.empty?
|
return if @env.empty?
|
||||||
|
@ -2,7 +2,7 @@ module Whenever
|
|||||||
module VERSION #:nodoc:
|
module VERSION #:nodoc:
|
||||||
MAJOR = 0
|
MAJOR = 0
|
||||||
MINOR = 3
|
MINOR = 3
|
||||||
TINY = 5
|
TINY = 6
|
||||||
|
|
||||||
STRING = [MAJOR, MINOR, TINY].join('.')
|
STRING = [MAJOR, MINOR, TINY].join('.')
|
||||||
end
|
end
|
||||||
|
@ -19,5 +19,38 @@ class OutputEnvTest < Test::Unit::TestCase
|
|||||||
assert_match "MAILTO=someone@example.com", @output
|
assert_match "MAILTO=someone@example.com", @output
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "No PATH environment variable set" do
|
||||||
|
setup do
|
||||||
|
Whenever::JobList.any_instance.expects(:read_path).at_least_once.returns('/usr/local/bin')
|
||||||
|
@output = Whenever.cron ""
|
||||||
|
end
|
||||||
|
|
||||||
|
should "add a PATH variable based on the user's PATH" do
|
||||||
|
assert_match "PATH=/usr/local/bin", @output
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "A PATH environment variable set" do
|
||||||
|
setup do
|
||||||
|
Whenever::JobList.stubs(:read_path).returns('/usr/local/bin')
|
||||||
|
@output = Whenever.cron "env :PATH, '/my/path'"
|
||||||
|
end
|
||||||
|
|
||||||
|
should "use that path and the user's PATH" do
|
||||||
|
assert_match "PATH=/my/path", @output
|
||||||
|
assert_no_match /local/, @output
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "No PATH set and instructed not to automatically load the user's path" do
|
||||||
|
setup do
|
||||||
|
@output = Whenever.cron "set :set_path_automatically, false"
|
||||||
|
end
|
||||||
|
|
||||||
|
should "not have a PATH set" do
|
||||||
|
assert_no_match /PATH/, @output
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
@ -2,11 +2,11 @@
|
|||||||
|
|
||||||
Gem::Specification.new do |s|
|
Gem::Specification.new do |s|
|
||||||
s.name = %q{whenever}
|
s.name = %q{whenever}
|
||||||
s.version = "0.3.5"
|
s.version = "0.3.6"
|
||||||
|
|
||||||
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
||||||
s.authors = ["Javan Makhmali"]
|
s.authors = ["Javan Makhmali"]
|
||||||
s.date = %q{2009-07-13}
|
s.date = %q{2009-07-15}
|
||||||
s.description = %q{Provides clean ruby syntax for defining messy cron jobs and running them Whenever.}
|
s.description = %q{Provides clean ruby syntax for defining messy cron jobs and running them Whenever.}
|
||||||
s.email = %q{javan@javan.us}
|
s.email = %q{javan@javan.us}
|
||||||
s.executables = ["whenever", "wheneverize"]
|
s.executables = ["whenever", "wheneverize"]
|
||||||
|
Loading…
Reference in New Issue
Block a user