This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10.200.160.83 apps.static1.prod.biola.edu | |
10.200.160.83 career.static1.prod.biola.edu | |
10.200.160.83 wireless.static1.prod.biola.edu | |
10.200.160.83 www.static1.prod.biola.edu | |
10.200.160.246 academics.ruby2.staging.biola.edu | |
10.200.160.246 answers.ruby2.staging.biola.edu | |
10.200.160.246 api.ruby2.staging.biola.edu | |
10.200.160.246 apps.ruby2.staging.biola.edu | |
10.200.160.246 forms.ruby2.staging.biola.edu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Usage: | |
# Log.info 'done' | |
# Log.debug @var.inspect | |
# Log.error 'OH NOES!!!1' | |
# etc. | |
module Log | |
def self.method_missing(meth, *args, &block) | |
if logger.respond_to? meth | |
logger.send meth, *args, &block |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'https://rubygems.org' | |
gem 'rack' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
script_name = File.basename(__FILE__) | |
file_path = ARGV[0] | |
abort "No input CSV file provided. Example: #{script_name} ./prod_center_accounts.csv" if file_path.nil? | |
abort 'File must have a .csv extension' unless file_path =~ /\.csv\Z/ | |
new_file_path = file_path.gsub(/\.csv\Z/, '_with_netids.csv') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TimeStringValidator < ActiveModel::EachValidator | |
def validate_each(record, attribute, value) | |
require 'chronic' | |
record.errors[attribute] << "doesn't seem to be a valid time" unless Chronic.parse(value) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Original credits: http://blog.inquirylabs.com/2006/04/13/simple-uri-validation/ | |
# HTTP Codes: http://www.ruby-doc.org/stdlib/libdoc/net/http/rdoc/classes/Net/HTTPResponse.html | |
require 'net/http' | |
class UriExistsValidator < ActiveModel::EachValidator | |
def validate_each(record, attribute, value) | |
begin # check header response | |
url = URI.parse(value) | |
request = Net::HTTP.new(url.host, url.port) | |
response = request.request_head(url.path.empty? ? '/' : url.path) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'uri' | |
class RelativeUriValidator < ActiveModel::EachValidator | |
def validate_each(record, attribute, value) | |
begin | |
unless URI.parse(value).relative? | |
record.errors[attribute] << 'is not a relative URL' | |
end | |
rescue URI::InvalidURIError => error | |
record.errors[attribute] << 'is not a valid URL' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'uri' | |
class AbsoluteUriValidator < ActiveModel::EachValidator | |
def validate_each(record, attribute, value) | |
begin | |
unless URI.parse(value).absolute? | |
record.errors[attribute] << 'is not an absolute URL' | |
end | |
rescue URI::InvalidURIError => error | |
record.errors[attribute] << 'is not a valid URL' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Examples: | |
# test_valid_attribute Link, :url => 'http://example.com' | |
# test_invalid_attribute Link, :url => 'OH NOES!!!1!' | |
module ValidationHelpers | |
def test_valid_attribute(model, attr_val_hash) | |
test_attribute(:valid, model, attr_val_hash) | |
end | |
def test_invalid_attribute(model, attr_val_hash) |
OlderNewer