From 60eb6f818fe89791b36928fadb5601db38ff3dfa Mon Sep 17 00:00:00 2001 From: Jason Khoe Date: Fri, 26 Apr 2013 03:45:27 -0700 Subject: [PATCH] Added script to output JSON of candidate address/grad semester info --- script/candidate_info.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100755 script/candidate_info.rb diff --git a/script/candidate_info.rb b/script/candidate_info.rb new file mode 100755 index 00000000..e0cecfd5 --- /dev/null +++ b/script/candidate_info.rb @@ -0,0 +1,18 @@ +#!/usr/bin/env ruby + +# Outputs a JSON format of candidate names, local addresses, and permanent +# addresses as well as expected graduation semesters. +# - jkhoe + +# Trick Ruby into loading all of our Rails configurations +# Note: You MUST have the environment variable $RAILS_ENV set to 'production' +require File.expand_path('../../config/environment', __FILE__) + +candidate_group = Group.find_by_name("candidates") + +puts '[' +candidate_group.people.where(:approved => true).each do |person| + info = '["' + person.full_name + '","' + person.local_address + '","' + person.perm_address + '","' + person.grad_semester + '"],' + puts info +end +puts ']'