Commit 478d6a95 by Thanh Hung Pham

Config autoload

parent 9604a13f
...@@ -14,5 +14,7 @@ module VeNJOB ...@@ -14,5 +14,7 @@ module VeNJOB
# Settings in config/environments/* take precedence over those specified here. # Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers # Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded. # -- all .rb files in that directory are automatically loaded.
config.autoload_paths += %W[#{config.root}/lib]
config.eager_load_paths += %W[#{config.root}/lib]
end end
end end
...@@ -3,7 +3,7 @@ require 'open-uri' ...@@ -3,7 +3,7 @@ require 'open-uri'
require 'nokogiri' require 'nokogiri'
require 'logger' require 'logger'
class Careerbuilder class Crawler::Careerbuilder
attr_reader :domain, :thread_count, :logger attr_reader :domain, :thread_count, :logger
def initialize(domain, thread_count = 1) def initialize(domain, thread_count = 1)
......
namespace :crawler do namespace :crawler do
desc 'client crawler' desc 'client crawler'
task load: :environment do task load: :environment do
require "#{Rails.root}/lib/tasks/careerbuilder"
thread_count = ENV['THREAD_COUNT'] || 1 thread_count = ENV['THREAD_COUNT'] || 1
Careerbuilder.new('http://careerbuilder.vn', thread_count.to_i).crawl Crawler::Careerbuilder.new('http://careerbuilder.vn', thread_count.to_i).crawl
end end
end end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment