Module: Crabfarm
- Defined in:
- lib/crabfarm.rb,
lib/crabfarm/cli.rb,
lib/crabfarm/base.rb,
lib/crabfarm/errors.rb,
lib/crabfarm/context.rb,
lib/crabfarm/version.rb,
lib/crabfarm/modes/live.rb,
lib/crabfarm/strategies.rb,
lib/crabfarm/base_struct.rb,
lib/crabfarm/driver_pool.rb,
lib/crabfarm/http_client.rb,
lib/crabfarm/state_store.rb,
lib/crabfarm/support/gli.rb,
lib/crabfarm/base_reducer.rb,
lib/crabfarm/live/context.rb,
lib/crabfarm/live/manager.rb,
lib/crabfarm/live/watcher.rb,
lib/crabfarm/modes/server.rb,
lib/crabfarm/utils/naming.rb,
lib/crabfarm/configuration.rb,
lib/crabfarm/modes/console.rb,
lib/crabfarm/utils/console.rb,
lib/crabfarm/utils/resolve.rb,
lib/crabfarm/base_navigator.rb,
lib/crabfarm/crabtrap_runner.rb,
lib/crabfarm/live/controller.rb,
lib/crabfarm/modes/generator.rb,
lib/crabfarm/modes/publisher.rb,
lib/crabfarm/utils/processes.rb,
lib/crabfarm/utils/webdriver.rb,
lib/crabfarm/assertion/fields.rb,
lib/crabfarm/crabtrap_context.rb,
lib/crabfarm/forked_navigator.rb,
lib/crabfarm/assertion/context.rb,
lib/crabfarm/assertion/parsers.rb,
lib/crabfarm/assertion/wrapper.rb,
lib/crabfarm/factories/context.rb,
lib/crabfarm/factories/reducer.rb,
lib/crabfarm/live/interactable.rb,
lib/crabfarm/rspec/reducer_spy.rb,
lib/crabfarm/transition_service.rb,
lib/crabfarm/utils/rspec_runner.rb,
lib/crabfarm/factories/decorable.rb,
lib/crabfarm/factories/navigator.rb,
lib/crabfarm/live/reducer_runner.rb,
lib/crabfarm/support/custom_puma.rb,
lib/crabfarm/utils/port_discovery.rb,
lib/crabfarm/adapters/browser/noop.rb,
lib/crabfarm/assertion/validations.rb,
lib/crabfarm/live/navigator_runner.rb,
lib/crabfarm/modes/recorder/memento.rb,
lib/crabfarm/support/phantom_runner.rb,
lib/crabfarm/adapters/browser/chrome.rb,
lib/crabfarm/adapters/parser/pincers.rb,
lib/crabfarm/modes/recorder/snapshot.rb,
lib/crabfarm/adapters/browser/firefox.rb,
lib/crabfarm/adapters/parser/nokogiri.rb,
lib/crabfarm/live/reducer_runner_rspec.rb,
lib/crabfarm/rspec/reducer_spy_manager.rb,
lib/crabfarm/support/webdriver_factory.rb,
lib/crabfarm/adapters/parser/pdf_reader.rb,
lib/crabfarm/engines/sync_state_manager.rb,
lib/crabfarm/factories/snapshot_reducer.rb,
lib/crabfarm/live/reducer_runner_direct.rb,
lib/crabfarm/rspec/reducer_spec_helpers.rb,
lib/crabfarm/adapters/browser/phantom_js.rb,
lib/crabfarm/engines/async_state_manager.rb,
lib/crabfarm/live/navigator_runner_rspec.rb,
lib/crabfarm/live/navigator_runner_direct.rb,
lib/crabfarm/rspec/navigator_spec_helpers.rb,
lib/crabfarm/modes/shared/snapshot_decorator.rb,
lib/crabfarm/adapters/driver_wrapper/capybara.rb,
lib/crabfarm/adapters/browser/remote_webdriver.rb,
lib/crabfarm/modes/shared/interactive_decorator.rb,
lib/crabfarm/adapters/browser/abstract_webdriver.rb,
lib/crabfarm/adapters/driver_wrapper/pincers.rb,
lib/crabfarm/adapters/driver_wrapper/watir.rb
Defined Under Namespace
Modules: Adapters, Assertion, Base, Engines, Factories, Live, Modes, RSpec, Strategies, Support, Utils
Classes: ApiError, ArgumentError, AssertionError, BaseNavigator, BaseReducer, BaseStruct, BinaryMissingError, CLI, Configuration, ConfigurationError, Context, CrabtrapContext, CrabtrapRunner, CrawlerBaseError, CrawlerError, DriverPool, Error, ForkedNavigator, HttpClient, ResourceNotFoundError, StateStore, StillWorkingError, TimeoutError, TransitionService
Constant Summary
collapse
- VERSION =
"0.6.0"
- @@config =
Configuration.new
- @@logger =
nil
- @@live =
nil
- @@debug =
false
Class Method Summary
collapse
Class Method Details
.app_path ⇒ Object
43
44
45
|
# File 'lib/crabfarm.rb', line 43
def self.app_path
CF_PATH
end
|
.config ⇒ Object
47
48
49
|
# File 'lib/crabfarm.rb', line 47
def self.config
@@config
end
|
.debug? ⇒ Boolean
81
82
83
|
# File 'lib/crabfarm.rb', line 81
def self.debug?
@@debug
end
|
.enable_debugging! ⇒ Object
76
77
78
79
|
# File 'lib/crabfarm.rb', line 76
def self.enable_debugging!
require 'pry-byebug'
@@debug = true
end
|
.inside_crawler_app? ⇒ Boolean
39
40
41
|
# File 'lib/crabfarm.rb', line 39
def self.inside_crawler_app?
defined? CF_PATH
end
|
.install_live_backend! ⇒ Object
63
64
65
66
|
# File 'lib/crabfarm.rb', line 63
def self.install_live_backend!
require "crabfarm/live/manager"
@@live = Live::Manager.new
end
|
.live ⇒ Object
68
69
70
|
# File 'lib/crabfarm.rb', line 68
def self.live
@@live
end
|
.live? ⇒ Boolean
72
73
74
|
# File 'lib/crabfarm.rb', line 72
def self.live?
not @@live.nil?
end
|
.logger ⇒ Object
51
52
53
54
55
56
57
|
# File 'lib/crabfarm.rb', line 51
def self.logger
if @@logger.nil?
@@logger = Logger.new(@@config.log_path.nil? ? STDOUT : File.join(@@config.log_path, 'crawler.log'))
@@logger.level = Logger::INFO
end
@@logger
end
|
.read_crabfile(_path) ⇒ Object
59
60
61
|
# File 'lib/crabfarm.rb', line 59
def self.read_crabfile(_path)
@@config.instance_eval File.read _path
end
|
.root ⇒ Object
35
36
37
|
# File 'lib/crabfarm.rb', line 35
def self.root
File.dirname __dir__
end
|
.with_context(_memento = nil) ⇒ Object
85
86
87
88
89
90
91
92
93
|
# File 'lib/crabfarm.rb', line 85
def self.with_context(_memento=nil)
ctx = Factories::Context.build _memento
begin
ctx.prepare
yield ctx
ensure
ctx.release
end
end
|