aboutsummaryrefslogtreecommitdiffstats
path: root/lib/tasks
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2014-08-08 16:19:49 +0100
committerLouise Crow <louise.crow@gmail.com>2014-08-08 16:19:49 +0100
commita760114de869ce3f07358dde19b8b5cc5d36003b (patch)
treec55b0b5037bc42cbc6b4a65cbb7d8b048c056efd /lib/tasks
parentc3e1825ffbdd86f477491447972ff24416d8ba96 (diff)
parentd700f325de56c8a039cbe4178dd44842ef0ee977 (diff)
Merge branch 'rails-3-develop' of ssh://git.mysociety.org/data/git/public/alaveteli into rails-3-develop
Diffstat (limited to 'lib/tasks')
-rw-r--r--lib/tasks/config_files.rake21
-rw-r--r--lib/tasks/stats.rake4
2 files changed, 13 insertions, 12 deletions
diff --git a/lib/tasks/config_files.rake b/lib/tasks/config_files.rake
index 438b63fc0..5dda64a04 100644
--- a/lib/tasks/config_files.rake
+++ b/lib/tasks/config_files.rake
@@ -28,22 +28,23 @@ namespace :config_files do
'VHOST_DIR',
'SCRIPT_FILE'], example)
- script_file = ENV['SCRIPT_FILE']
- site = ENV.fetch('SITE', 'foi')
-
replacements = {
:user => ENV['DEPLOY_USER'],
:vhost_dir => ENV['VHOST_DIR'],
- :vcspath => ENV.fetch('VCSPATH', 'alaveteli'),
- :site => site
+ :vcspath => ENV.fetch('VCSPATH') { 'alaveteli' },
+ :site => ENV.fetch('SITE') { 'foi' }
}
- daemon_name = File.basename(script_file, '-debian.ugly')
- replacements.update(:daemon_name => "#{ site }-#{ daemon_name }")
- converted = convert_ugly(script_file, replacements)
- rails_env_file = File.expand_path(File.join(Rails.root, 'config', 'rails_env.rb'))
+ # Use the filename for the $daemon_name ugly variable
+ daemon_name = File.basename(ENV['SCRIPT_FILE'], '-debian.ugly')
+ replacements.update(:daemon_name => "#{ replacements[:site] }-#{ daemon_name }")
+
+ # Generate the template for potential further processing
+ converted = convert_ugly(ENV['SCRIPT_FILE'], replacements)
- unless File.exists?(rails_env_file)
+ # gsub the RAILS_ENV in to the generated template if its not set by the
+ # hard coded config file
+ unless File.exists?("#{ Rails.root }/config/rails_env.rb")
converted.each do |line|
line.gsub!(/^#\s*RAILS_ENV=your_rails_env/, "RAILS_ENV=#{Rails.env}")
line.gsub!(/^#\s*export RAILS_ENV/, "export RAILS_ENV")
diff --git a/lib/tasks/stats.rake b/lib/tasks/stats.rake
index f09594529..46a645b4d 100644
--- a/lib/tasks/stats.rake
+++ b/lib/tasks/stats.rake
@@ -119,7 +119,7 @@ DESC
count ? count : 0
end
- row = [body.name] + stats
+ row = [%Q("#{ body.name }")] + stats
puts row.join(",")
end
end
@@ -147,7 +147,7 @@ DESC
count ? count : 0
end
- row = [body.name] + stats
+ row = [%Q("#{ body.name }")] + stats
puts row.join(",")
end
end