diff --git a/Gemfile b/Gemfile index 3a7eb60..1e79841 100644 --- a/Gemfile +++ b/Gemfile @@ -1,9 +1,9 @@ -source :gemcutter +source "https://rubygems.org" gem "sinatra" +gem "puma" gem "choice" -gem "json" -gem "postgres", "=0.7.9.2008.01.28" +gem "pg" gem "haml" gem "bluecloth" gem "text" @@ -11,5 +11,4 @@ gem "levenshtein" gem "hpricot" gem "activesupport" gem "htmlentities" -gem "text" gem "chronic" diff --git a/Gemfile.lock b/Gemfile.lock index a9ac7dc..ce120e2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,5 +1,5 @@ GEM - remote: http://rubygems.org/ + remote: https://rubygems.org/ specs: activesupport (3.2.11) i18n (~> 0.6) @@ -11,10 +11,10 @@ GEM hpricot (0.8.6) htmlentities (4.3.1) i18n (0.6.1) - json (1.5.1) levenshtein (0.2.2) multi_json (1.5.0) - postgres (0.7.9.2008.01.28) + pg (0.18.4) + puma (3.4.0) rack (1.2.1) sinatra (1.2.0) rack (~> 1.1) @@ -33,8 +33,11 @@ DEPENDENCIES haml hpricot htmlentities - json levenshtein - postgres (= 0.7.9.2008.01.28) + pg + puma sinatra text + +BUNDLED WITH + 1.12.5 diff --git a/config.ru b/config.ru index 46fd92e..00a0797 100644 --- a/config.ru +++ b/config.ru @@ -1,4 +1,4 @@ # This file is used by Rack-based servers to start the application. -require 'dstk_server' +require_relative 'dstk_server' run Sinatra::Application diff --git a/config/puma.rb b/config/puma.rb new file mode 100644 index 0000000..c10e830 --- /dev/null +++ b/config/puma.rb @@ -0,0 +1,21 @@ +# Change to match your CPU core count +workers 16 +port 4567 + +# Min and Max threads per worker +threads 1, 2 + +app_dir = File.expand_path("../..", __FILE__) +shared_dir = File.expand_path("shared", app_dir) + +# Default to production +rails_env = ENV['RAILS_ENV'] || "production" +environment rails_env + +# Set up socket location +bind "unix://#{shared_dir}/sockets/puma.sock" + +# Set master PID and state locations +pidfile "#{shared_dir}/pids/puma.pid" +state_path "#{shared_dir}/pids/puma.state" + diff --git a/dstk_config.rb b/dstk_config.rb index 243f2a8..ce6b4da 100755 --- a/dstk_config.rb +++ b/dstk_config.rb @@ -62,9 +62,9 @@ module DSTKConfig # The location of the TIGER/Line database used by the US address geocoder # For backwards compatibility, look for any of these versions, starting with the first - GEOCODER_DB_FILES = ['../geocoderdata/geocoder2012.db', '../geocoderdata/geocoder2011.db'] + GEOCODER_DB_FILES = ['/dev/shm/geocoder2015.db', '../geocoderdata/geocoder2011.db'] # The location of the MaxMind database file holding IP to location mappings ETHNICITY_OF_SURNAMES_FILE = '../dstkdata/ethnicityofsurnames.csv' -end \ No newline at end of file +end diff --git a/dstk_server.rb b/dstk_server.rb index 18b0cb9..a44ebd6 100644 --- a/dstk_server.rb +++ b/dstk_server.rb @@ -20,8 +20,7 @@ require 'rubygems' if RUBY_VERSION < '1.9' require 'sinatra' require 'json' -require 'net/geoip' -require 'postgres' +require 'pg' require 'hpricot' require 'htmlentities' require 'tempfile' diff --git a/genderfromname.rb b/genderfromname.rb index a98de89..694348f 100755 --- a/genderfromname.rb +++ b/genderfromname.rb @@ -91,7 +91,7 @@ def one_only(name) if female_hit and not male_hit gender = 'f' - elsif male_hit and not female_hit: + elsif male_hit and not female_hit gender = 'm' end @@ -2389,4 +2389,4 @@ def v1_rules(name) 'racquel' => 0.00843702508359597, 'shanice' => 0.00843702508359597, 'valeria' => 0.00843702508359597 -} \ No newline at end of file +} diff --git a/geodict_lib.rb b/geodict_lib.rb index 6057849..941764a 100755 --- a/geodict_lib.rb +++ b/geodict_lib.rb @@ -16,7 +16,7 @@ require 'rubygems' -require 'postgres' +require 'pg' require 'set' # Some hackiness to include the library script, even if invoked from another directory @@ -296,9 +296,9 @@ def is_city(text, text_starting_index, previous_result) found_tokens = previous_result[:found_tokens] found_tokens.each do |found_token| type = found_token[:type] - if type == :COUNTRY: + if type == :COUNTRY country_code = found_token[:code] - elsif type == :REGION: + elsif type == :REGION region_code = found_token[:code] end end @@ -430,7 +430,7 @@ def is_region(text, text_starting_index, previous_result) candidate_dicts = [] all_candidate_dicts.each do |possible_dict| candidate_country = possible_dict['country_code'] - if candidate_country.downcase() == country_code.downcase(): + if candidate_country.downcase() == country_code.downcase() candidate_dicts << possible_dict end end diff --git a/street2coordinates.rb b/street2coordinates.rb index eefefb1..848c880 100644 --- a/street2coordinates.rb +++ b/street2coordinates.rb @@ -893,4 +893,4 @@ def canonicalize_street_string(street_string) puts '************' end -end \ No newline at end of file +end diff --git a/text2people.rb b/text2people.rb index db27485..b0f7e79 100755 --- a/text2people.rb +++ b/text2people.rb @@ -26,7 +26,7 @@ require File.join(File.expand_path(File.dirname(__FILE__)), 'dstk_config') require File.join(File.expand_path(File.dirname(__FILE__)), 'geodict_lib') -require 'genderfromname' +require_relative './genderfromname' CURRENT_YEAR = Time.now.year @@ -297,4 +297,4 @@ def get_ethnicity_from_last_name(last_name) puts '************' end -end \ No newline at end of file +end