Module: EDango
- Defined in:
- lib/edango/di/proxy.rb,
lib/edango.rb,
lib/edango/starter.rb,
lib/edango/executor.rb,
lib/edango/site/core.rb,
lib/edango/di/service.rb,
lib/edango/environment.rb,
lib/edango/di/container.rb,
lib/edango/context/files.rb,
lib/edango/context/language.rb,
lib/edango/context/services.rb,
lib/edango/context/parameters.rb,
lib/edango/di/service_factory.rb,
lib/edango/context/directories.rb,
lib/edango/logic/ticket_extractor.rb
Overview
EDango - torrent ticket extractor.
Copyright (C) 2010 Dmitrii Toksaitov
This file is part of EDango.
EDango is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
EDango is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with EDango. If not, see <http://www.gnu.org/licenses/>.
Defined Under Namespace
Modules: DI, Language Classes: Core, Environment, Executor, Starter, TicketExtractor
Constant Summary collapse
- FULL_NAME =
'EDango'
- UNIX_NAME =
'edango'
- VERSION =
'0.5.4'
- AUTHOR =
'Toksaitov Dmitrii Alexandrovich'
- EMAIL =
"[email protected]"
- URL =
"http://github.com/toksaitov/#{UNIX_NAME}/"
- COPYRIGHT =
"Copyright (C) 2010 #{AUTHOR}"
- USER_BASE_DIRECTORY =
ENV["#{UNIX_NAME.upcase()}_USER_BASE"] || File.join('~', ".#{UNIX_NAME}")
- GLOBALS =
{}
- FILES =
DI::Container.new do asset :log do File.join(DIRECTORIES[:log], 'application.log') end asset :options do File.join(DIRECTORIES[:user_base], 'options.yml') end asset :helpers do Dir[File.join(DIRECTORIES[:helpers], '**', '*.rb')] end end
- LANGUAGE =
LANG = Language::UN_US
- SERVICES =
DI::Container.new do service :environment do on_creation do require_all *FILES[:helpers] require 'edango/environment' Environment.instance() end interface :log_error do |instance, exception, | instance.log_error(exception, ) end interface :log_warning do |instance, text| instance.log_warning(text) end interface :log_message do |instance, text| instance.(text) end interface :show_message do |instance, text, log| instance.(text, log) end end service :starter do on_creation do require 'edango/starter'; Starter.new() end interface :run do |instance| instance.run() end interface :usage do |instance| instance. end end service :core do on_creation do require 'edango/site/core'; Core end interface :run do |instance| instance.run() end end service :executor do on_creation do require 'edango/executor'; Executor.new() end interface :run do |instance| instance.run() end end service :timer do on_creation do require 'timeout'; Timeout end end service :logic do on_creation do require 'edango/logic/ticket_extractor' TicketExtractor.new() end interface :process do |instance, *args| instance.extract_tickets(*args) end interface :errors do |instance| instance.errors end end service :web do on_creation do require 'sinatra/base'; Sinatra::Base end end service :views_processor do on_creation do require 'haml'; Haml end end service :agent do on_creation do require 'mechanize' WWW::Mechanize.new do |agent| agent.user_agent_alias = 'Windows Mozilla' agent.history.max_size = 0 proxy = EDango::PARAMETERS[:options][:proxy] if proxy agent.set_proxy(*proxy) unless proxy[0].nil_or_empty? or proxy[1].nil_or_empty? end end end end service :uri do on_creation do require 'uri'; URI end interface :host do |instance, uri| instance.parse(uri.to_s()).host.gsub(/^www\./, '') rescue '' end interface :valid? do |instance, uri| (instance.parse(uri.to_s()); true) rescue false end end service :logger do on_creation do require 'logger' logger = Logger.new(FILES[:log], 10, 1048576) logger.level = Logger::INFO logger end interface :error do |instance, | = .inspect.strip() instance.error() end interface :warn do |instance, | = .inspect.strip() instance.warn() end interface [:info, :put, :write, :<<] do |instance, | = .inspect.strip() instance.info() end interface :flush do |instance| end end end
- PARAMETERS =
DI::Container.new do asset :options, :file => FILES[:options] do {:environment => :production, :server_logging => true, :time_limit => 100, :servers => ['thin', 'mongrel', 'webrick'], :host => '0.0.0.0', :port => 6666, :proxy => false, :sites => []} end asset :modes do {:verbose => false, :quiet => false, :debug => false} end asset :tasks do {:show_version => false, :show_help => false} end end
- DIRECTORIES =
DI::Container.new do asset :user_base do File.prepare_directory(USER_BASE_DIRECTORY) end asset :helpers do File.(File.join(File.dirname(__FILE__), '..', 'helpers')) end asset :site do File.(File.join(File.dirname(__FILE__), '..', 'site')) end asset :views do File.join(DIRECTORIES[:site], 'views') end asset :public do File.join(DIRECTORIES[:site], 'public') end asset :styles do File.join(DIRECTORIES[:public], 'styles') end asset :scripts do File.join(DIRECTORIES[:public], 'scripts') end asset :images do File.join(DIRECTORIES[:public], 'images') end asset :tickets do File.prepare_directory(File.join(DIRECTORIES[:user_base], 'tickets')) end asset :log do File.prepare_directory(File.join(DIRECTORIES[:user_base], 'logs')) end end
- DIRS =
DIRECTORIES