Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Smash trailing spaces.

  • Loading branch information...
commit 7ba9a2f838f5f588763557c198d3b43bdfe8fb2f 1 parent ac44634
@threedaymonk threedaymonk authored
View
7 lib/tasks/autocomplete_build_top_trumps.rake
@@ -7,7 +7,7 @@ namespace :autocomplete do
input_file = "autocomplete-top-trumps.csv"
output_file = "search-top-trumps.json"
raise "Can't read #{input_file}" unless File.exist?(input_file)
-
+
docs = []
i = 0
CSV.foreach(input_file) do |row|
@@ -24,7 +24,7 @@ namespace :autocomplete do
"keywords" => phrase,
"weight" => weight
}
-
+
docs << {
"title" => a.name,
"link" => "/" + a.slug,
@@ -37,7 +37,7 @@ namespace :autocomplete do
end
end
- File.open(output_file, "w") do |f|
+ File.open(output_file, "w") do |f|
f << %q{if (typeof(GDS) == 'undefined') { GDS = {}; };} + "\n"
f << %q{GDS.search_top_trumps = }
f << JSON.dump(docs).gsub(/},{/, "},\n{")
@@ -45,4 +45,3 @@ namespace :autocomplete do
end
end
end
-
View
4 lib/tasks/bulk_set_sections.rake
@@ -1,10 +1,10 @@
namespace :sections do
-
+
desc "Set sections in bulk (specify DOCUMENT_SECTIONS_FILE)"
task :bulk_set => :environment do
raise "Specify DOCUMENT_SECTIONS_FILE" unless ENV['DOCUMENT_SECTIONS_FILE']
raise "DOCUMENT_SECTIONS_FILE '#{ENV['DOCUMENT_SECTIONS_FILE']} not found" unless File.exist?(ENV['DOCUMENT_SECTIONS_FILE'])
-
+
require 'bulk_section_setter'
s = BulkSectionSetter.new(ENV['DOCUMENT_SECTIONS_FILE'], Logger.new(STDOUT))
s.set_all
View
10 lib/tasks/messenger.rake
@@ -6,17 +6,17 @@ namespace :messenger do
Rake::Task["environment"].invoke
DeletedPublicationListener.new.listen
end
-
+
Daemonette.run('panopticon_contact_listener') do
require 'contact_listener.rb'
Rake::Task['environment'].invoke
ContactListener.new.listen
end
-
+
Daemonette.run('panopticon_need_listener') do
- require 'need_listener.rb'
+ require 'need_listener.rb'
Rake::Task['environment'].invoke
- NeedListener.new.listen
+ NeedListener.new.listen
end
- end
+ end
end
View
24 lib/tasks/need_matcher.rake
@@ -1,30 +1,30 @@
namespace :needs do
-
- require 'csv'
+
+ require 'csv'
require 'ansi/code'
-
+
task :import_csv => :environment do
-
+
@artefacts = CSV.read( File.join( Rails.root, 'lib', 'import', '20111129_need_ids.csv' ) ).collect{ |row| { :artefact_id => row[0].to_i, :need_id => row[2] } }
- @artefacts.each_with_index do |a, i|
+ @artefacts.each_with_index do |a, i|
puts "[#{i+1}/#{@artefacts.size}] Looking for artefact #{a[:artefact_id]}..."
- record = Artefact.find(a[:artefact_id].to_i) rescue nil
-
+ record = Artefact.find(a[:artefact_id].to_i) rescue nil
+
if (a[:need_id].match(/delete/i) rescue false) || (a[:need_id].match(/Not found/i) rescue false)
print "\t----> #{ANSI.cyan('Need is marked for deletion, skipping.')}\n"
elsif a[:need_id].to_i == 0
print "\t----> #{ANSI.red('No need ID specified in the CSV.')}\n"
elsif record
print "\t----> Updating artefact #{a[:artefact_id]}: "
- if record.update_attribute('need_id', a[:need_id])
+ if record.update_attribute('need_id', a[:need_id])
print ANSI.green("Success!\n")
else
print ANSI.red("Failed\n")
- end
+ end
else
print "\t----> #{ANSI.red('Could not find artefact.')}\n"
- end
- end
+ end
+ end
end
-
+
end
View
12 lib/tasks/sections.rake
@@ -1,22 +1,22 @@
namespace :sections do
-
+
desc "Migrate section assignments to new sections"
task :migrate => :environment do
-
+
@section_migrations = {
'Driving:Owning a car/motorbike' => 'Driving:Owning a car or motorbike',
'Education:In schools' => 'Education:In school',
'Family:Separation and divorce' => 'Family:Divorce and separation',
'Driving:Buying/selling a vehicle'=> 'Driving:Buying and selling a vehicle'
}
-
+
Artefact.all.each do |a|
-
+
current_section = a.section
new_section = @section_migrations[current_section]
-
+
if !new_section or new_section.nil?
- puts "Not updating \"#{a.name}\" (\"#{current_section}\")".colorize(:white)
+ puts "Not updating \"#{a.name}\" (\"#{current_section}\")".colorize(:white)
elsif a.update_attribute(:section, new_section)
puts "Updated \"#{a.name}\" from \"#{current_section}\" to \"#{new_section}\"".colorize(:green)
else
Please sign in to comment.
Something went wrong with that request. Please try again.