auto_cron 0.1.10 → 0.1.12

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -9,5 +9,6 @@ group :development do
9
9
  # gem "shoulda", ">= 0"
10
10
  gem "bundler", "~> 1.0.0"
11
11
  gem "jeweler", "~> 1.6.4"
12
+ gem "rake", "0.9.2"
12
13
  gem "rcov", ">= 0"
13
14
  end
@@ -15,4 +15,5 @@ PLATFORMS
15
15
  DEPENDENCIES
16
16
  bundler (~> 1.0.0)
17
17
  jeweler (~> 1.6.4)
18
+ rake (= 0.9.2)
18
19
  rcov
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.10
1
+ 0.1.12
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{auto_cron}
8
- s.version = "0.1.10"
8
+ s.version = "0.1.12"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Alex Farrill"]
12
- s.date = %q{2011-09-04}
12
+ s.date = %q{2011-11-19}
13
13
  s.description = %q{Generate a crontab}
14
14
  s.email = %q{alex.farrill@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -49,15 +49,18 @@ Gem::Specification.new do |s|
49
49
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
50
50
  s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
51
51
  s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
52
+ s.add_development_dependency(%q<rake>, ["= 0.9.2"])
52
53
  s.add_development_dependency(%q<rcov>, [">= 0"])
53
54
  else
54
55
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
55
56
  s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
57
+ s.add_dependency(%q<rake>, ["= 0.9.2"])
56
58
  s.add_dependency(%q<rcov>, [">= 0"])
57
59
  end
58
60
  else
59
61
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
60
62
  s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
63
+ s.add_dependency(%q<rake>, ["= 0.9.2"])
61
64
  s.add_dependency(%q<rcov>, [">= 0"])
62
65
  end
63
66
  end
@@ -1,11 +1,11 @@
1
1
  require 'auto_cron/railtie' if defined?(Rails)
2
2
 
3
3
  class AutoCron
4
- def initialize( template, application )
4
+ def initialize( templates, application )
5
5
  require 'erb'
6
6
 
7
7
  @auto_cron_dir = File.join( Rails.root, "config", "auto_cron" )
8
- @template = template
8
+ @templates = templates.split(",")
9
9
  @application = application
10
10
  end
11
11
 
@@ -41,18 +41,14 @@ protected
41
41
  else
42
42
  ''
43
43
  end
44
- full_template_path = File.join( @auto_cron_dir, "#{ @template }.erb" )
45
- header + "\n\n" + ERB.new( File.read( full_template_path ) ).result
44
+ @templates.each do |template|
45
+ full_template_path = File.join( @auto_cron_dir, "#{ template }.erb" )
46
+ header + "\n\n" + ERB.new( File.read( full_template_path ) ).result
47
+ end
46
48
  end
47
49
 
48
50
  def read_crontab
49
- return @current_crontab if @current_crontab
50
-
51
- # command = ['crontab -l']
52
- # command_results = %x[#{command.join(' ')} 2> /dev/null]
53
- # @current_crontab = $?.exitstatus.zero? ? command_results : ''
54
-
55
- @current_crontab = %x[crontab -l 2> /dev/null]
51
+ @current_crontab ||= %x[crontab -l 2> /dev/null]
56
52
  end
57
53
 
58
54
  def comment_base
@@ -1,5 +1,4 @@
1
1
  require 'auto_cron'
2
- require 'rails'
3
2
 
4
3
  class Railtie < Rails::Railtie
5
4
  rake_tasks do
@@ -1,21 +1,16 @@
1
1
  Capistrano::Configuration.instance.load do
2
2
  namespace :auto_cron do
3
- task :publish, :roles => :publish do
4
- run "cd #{release_path} && #{rake} TEMPLATE=publish APPLICATION=#{application} RAILS_ENV=#{rails_env} auto_cron"
5
- end
6
-
7
- desc "Connects to each box individually and installs the specified cron
8
- USAGE:: role :publish_cron, 'prilb', :crontab => 'cron' "
9
- task :publish_crons, :roles => :publish_cron do
3
+ desc "Connects to each box individually and installs the specifed cron
4
+ USAGE:: role :publish_cron, 'prilb', :crontabs => %w( publish production ) "
5
+ task :publish_crons, :roles => :publish_crons do
10
6
  find_servers_for_task( current_task ).each do |sd|
11
7
  establish_connections_to( sd )
12
8
  targets = []
13
9
  targets.push sessions[sd]
14
-
15
- Command.process( "cd #{release_path} && #{rake} TEMPLATE=#{sd.options[:crontab]} RAILS_ENV=#{rails_env} auto_cron",
10
+ Command.process( "cd #{release_path} && #{rake} TEMPLATES=#{sd.options[:crontabs].join(",")} APPLICATION=#{application} RAILS_ENV=#{rails_env} auto_cron",
16
11
  targets, options.merge(:logger => logger), &block)
17
12
 
18
- logger.debug "creating crontab:#{sd.options[:crontab]} on #{sd.host}"
13
+ logger.debug "creating crontabs: #{sd.options[:crontabs].join(", ")} on #{sd.host}"
19
14
  end
20
15
  end
21
16
  end
@@ -3,7 +3,7 @@ require File.dirname(__FILE__) + "/../auto_cron"
3
3
  desc "Generates the auto-cron and saves it to the crontab"
4
4
  task :auto_cron do
5
5
  require 'tempfile'
6
- auto_cron = AutoCron.new ENV['TEMPLATE'], ENV['APPLICATION']
6
+ auto_cron = AutoCron.new ENV['TEMPLATES'], ENV['APPLICATION']
7
7
  cron_body = auto_cron.updated_crontab
8
8
  tmp_cron_path = Tempfile.new( 'auto_cron' ).path
9
9
  File.open( tmp_cron_path, File::WRONLY | File::APPEND ) do |file|
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: auto_cron
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 3
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 10
10
- version: 0.1.10
9
+ - 12
10
+ version: 0.1.12
11
11
  platform: ruby
12
12
  authors:
13
13
  - Alex Farrill
@@ -15,11 +15,11 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-09-04 00:00:00 -04:00
18
+ date: 2011-11-19 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- requirement: &id001 !ruby/object:Gem::Requirement
22
+ version_requirements: &id001 !ruby/object:Gem::Requirement
23
23
  none: false
24
24
  requirements:
25
25
  - - ~>
@@ -30,12 +30,12 @@ dependencies:
30
30
  - 0
31
31
  - 0
32
32
  version: 1.0.0
33
+ requirement: *id001
33
34
  type: :development
34
35
  name: bundler
35
36
  prerelease: false
36
- version_requirements: *id001
37
37
  - !ruby/object:Gem::Dependency
38
- requirement: &id002 !ruby/object:Gem::Requirement
38
+ version_requirements: &id002 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -46,12 +46,28 @@ dependencies:
46
46
  - 6
47
47
  - 4
48
48
  version: 1.6.4
49
+ requirement: *id002
49
50
  type: :development
50
51
  name: jeweler
51
52
  prerelease: false
52
- version_requirements: *id002
53
53
  - !ruby/object:Gem::Dependency
54
- requirement: &id003 !ruby/object:Gem::Requirement
54
+ version_requirements: &id003 !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - "="
58
+ - !ruby/object:Gem::Version
59
+ hash: 63
60
+ segments:
61
+ - 0
62
+ - 9
63
+ - 2
64
+ version: 0.9.2
65
+ requirement: *id003
66
+ type: :development
67
+ name: rake
68
+ prerelease: false
69
+ - !ruby/object:Gem::Dependency
70
+ version_requirements: &id004 !ruby/object:Gem::Requirement
55
71
  none: false
56
72
  requirements:
57
73
  - - ">="
@@ -60,10 +76,10 @@ dependencies:
60
76
  segments:
61
77
  - 0
62
78
  version: "0"
79
+ requirement: *id004
63
80
  type: :development
64
81
  name: rcov
65
82
  prerelease: false
66
- version_requirements: *id003
67
83
  description: Generate a crontab
68
84
  email: alex.farrill@gmail.com
69
85
  executables: []