Skip to content

Commit

Permalink
Merge pull request #44 from exaedv/master
Browse files Browse the repository at this point in the history
Copy subject/description before replacing variables
  • Loading branch information
jperelli committed Jan 6, 2016
2 parents f2fd69d + 96e887d commit 5256c31
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions lib/scheduled_tasks_checker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,23 @@ def self.checktasks!

# replace variables (set locale from shell)
I18n.locale = ENV['LOCALE'] || I18n.default_locale
task.subject.gsub!('**WEEK**', Time.now.strftime("%W"))
task.subject.gsub!('**MONTH**', Time.now.strftime("%m"))
task.subject.gsub!('**MONTHNAME**', I18n.localize(Time.now, :format => "%B"))
task.subject.gsub!('**YEAR**', Time.now.strftime("%Y"))
task.subject.gsub!('**PREVIOUS_MONTHNAME**', I18n.localize(Time.now - 2592000, :format => "%B"))
task.description.gsub!('**WEEK**', Time.now.strftime("%W"))
task.description.gsub!('**MONTH**', Time.now.strftime("%m"))
task.description.gsub!('**MONTHNAME**', I18n.localize(Time.now, :format => "%B"))
task.description.gsub!('**YEAR**', Time.now.strftime("%Y"))
task.description.gsub!('**PREVIOUS_MONTHNAME**', I18n.localize(Time.now - 2592000, :format => "%B"))

print "assigning #{task.subject}\n"
issue = Issue.new(:project_id=>task.project_id, :tracker_id=>task.tracker_id, :category_id=>task.issue_category_id, :assigned_to_id=>task.assigned_to_id, :author_id=>task.author_id, :subject=>task.subject, :description=>task.description);
# Copy subject and description and replace variables
subject = task.subject.dup
description = task.description.dup
subject.gsub!('**WEEK**', Time.now.strftime("%W"))
subject.gsub!('**MONTH**', Time.now.strftime("%m"))
subject.gsub!('**MONTHNAME**', I18n.localize(Time.now, :format => "%B"))
subject.gsub!('**YEAR**', Time.now.strftime("%Y"))
subject.gsub!('**PREVIOUS_MONTHNAME**', I18n.localize(Time.now - 2592000, :format => "%B"))
description.gsub!('**WEEK**', Time.now.strftime("%W"))
description.gsub!('**MONTH**', Time.now.strftime("%m"))
description.gsub!('**MONTHNAME**', I18n.localize(Time.now, :format => "%B"))
description.gsub!('**YEAR**', Time.now.strftime("%Y"))
description.gsub!('**PREVIOUS_MONTHNAME**', I18n.localize(Time.now - 2592000, :format => "%B"))

print "assigning #{subject}\n"
issue = Issue.new(:project_id=>task.project_id, :tracker_id=>task.tracker_id, :category_id=>task.issue_category_id, :assigned_to_id=>task.assigned_to_id, :author_id=>task.author_id, :subject=>subject, :description=>description);
issue.start_date ||= Date.today if task.set_start_date?
if task.due_date_number
due_date = task.due_date_number
Expand Down

0 comments on commit 5256c31

Please sign in to comment.