wayfarer 0.0.3 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/ci.yaml +32 -0
- data/.gitignore +3 -4
- data/.rubocop.yml +25 -9
- data/.ruby-version +1 -1
- data/Dockerfile +5 -0
- data/Gemfile +1 -7
- data/Gemfile.lock +221 -0
- data/RELEASING.md +17 -0
- data/Rakefile +38 -90
- data/bin/wayfarer +1 -111
- data/docker-compose.yml +32 -0
- data/docs/cookbook/batch_routing.md +22 -0
- data/docs/cookbook/consent_screen.md +36 -0
- data/docs/cookbook/executing_javascript.md +41 -0
- data/docs/cookbook/querying_html.md +42 -0
- data/docs/cookbook/screenshots.md +27 -0
- data/docs/cookbook/user_agent.md +7 -0
- data/docs/guides/browser_automation/capybara.md +69 -0
- data/docs/guides/browser_automation/custom_adapters.md +100 -0
- data/docs/guides/browser_automation/ferrum.md +39 -0
- data/docs/guides/browser_automation/selenium.md +63 -0
- data/docs/guides/callbacks.md +131 -31
- data/docs/guides/configuration.md +24 -169
- data/docs/guides/debugging.md +17 -0
- data/docs/guides/error_handling.md +30 -45
- data/docs/guides/jobs.md +101 -0
- data/docs/guides/navigation.md +73 -0
- data/docs/guides/networking.md +94 -0
- data/docs/guides/pages.md +52 -0
- data/docs/guides/performance.md +130 -0
- data/docs/guides/reliability.md +41 -0
- data/docs/guides/routing/steering.md +30 -0
- data/docs/guides/tasks.md +14 -0
- data/docs/index.md +40 -66
- data/docs/reference/api/base.md +48 -0
- data/docs/reference/api/route.md +182 -0
- data/docs/reference/cli.md +61 -0
- data/docs/reference/configuration_keys.md +42 -0
- data/docs/reference/environment_variables.md +83 -0
- data/lib/wayfarer/base.rb +50 -0
- data/lib/wayfarer/callbacks.rb +71 -0
- data/lib/wayfarer/cli/base.rb +27 -0
- data/lib/wayfarer/cli/generate.rb +17 -0
- data/lib/wayfarer/cli/job.rb +60 -0
- data/lib/wayfarer/cli/route.rb +29 -0
- data/lib/wayfarer/cli/route_printer.rb +116 -0
- data/lib/wayfarer/cli/runner.rb +34 -0
- data/lib/wayfarer/cli/templates/Gemfile.tt +5 -0
- data/lib/wayfarer/cli/templates/job.rb.tt +10 -0
- data/lib/wayfarer/config/capybara.rb +10 -0
- data/lib/wayfarer/config/ferrum.rb +11 -0
- data/lib/wayfarer/config/networking.rb +26 -0
- data/lib/wayfarer/config/redis.rb +14 -0
- data/lib/wayfarer/config/root.rb +11 -0
- data/lib/wayfarer/config/selenium.rb +21 -0
- data/lib/wayfarer/config/strconv.rb +45 -0
- data/lib/wayfarer/config/struct.rb +72 -0
- data/lib/wayfarer/gc.rb +15 -0
- data/lib/wayfarer/middleware/chain.rb +19 -0
- data/lib/wayfarer/middleware/dedup.rb +25 -0
- data/lib/wayfarer/middleware/fetch.rb +47 -0
- data/lib/wayfarer/middleware/normalize.rb +25 -0
- data/lib/wayfarer/middleware/router.rb +53 -0
- data/lib/wayfarer/middleware/stage.rb +23 -0
- data/lib/wayfarer/middleware/worker.rb +30 -0
- data/lib/wayfarer/networking/capybara.rb +28 -0
- data/lib/wayfarer/networking/context.rb +36 -0
- data/lib/wayfarer/networking/ferrum.rb +35 -0
- data/lib/wayfarer/networking/http.rb +34 -0
- data/lib/wayfarer/networking/pool.rb +40 -0
- data/lib/wayfarer/networking/result.rb +18 -0
- data/lib/wayfarer/networking/selenium.rb +43 -0
- data/lib/wayfarer/networking/strategy.rb +38 -0
- data/lib/wayfarer/page.rb +17 -74
- data/lib/wayfarer/parsing/json.rb +17 -0
- data/lib/wayfarer/parsing/xml.rb +17 -0
- data/lib/wayfarer/redis/.#barrier.rb +1 -0
- data/lib/wayfarer/redis/barrier.rb +36 -0
- data/lib/wayfarer/redis/connection.rb +13 -0
- data/lib/wayfarer/redis/counter.rb +29 -0
- data/lib/wayfarer/redis/pool.rb +20 -0
- data/lib/wayfarer/redis/version.rb +19 -0
- data/lib/wayfarer/routing/dsl.rb +57 -0
- data/lib/wayfarer/routing/matchers/custom.rb +25 -0
- data/lib/wayfarer/routing/matchers/host.rb +19 -0
- data/lib/wayfarer/routing/matchers/path.rb +49 -0
- data/lib/wayfarer/routing/matchers/query.rb +63 -0
- data/lib/wayfarer/routing/matchers/scheme.rb +17 -0
- data/lib/wayfarer/routing/matchers/suffix.rb +17 -0
- data/lib/wayfarer/routing/matchers/url.rb +17 -0
- data/lib/wayfarer/routing/path_finder.rb +46 -0
- data/lib/wayfarer/routing/result.rb +15 -0
- data/lib/wayfarer/routing/root_route.rb +7 -0
- data/lib/wayfarer/routing/route.rb +47 -0
- data/lib/wayfarer/routing/router.rb +10 -54
- data/lib/wayfarer/routing/target_route.rb +7 -0
- data/lib/wayfarer/serializer.rb +17 -0
- data/lib/wayfarer/stringify.rb +47 -0
- data/lib/wayfarer/task.rb +34 -0
- data/lib/wayfarer.rb +48 -57
- data/mkdocs.yml +47 -0
- data/requirements.txt +1 -0
- data/spec/base_spec.rb +233 -0
- data/spec/callbacks_spec.rb +102 -0
- data/spec/cli/generate_spec.rb +39 -0
- data/spec/cli/job_spec.rb +74 -0
- data/spec/cli/version_spec.rb +13 -0
- data/spec/config/capybara_spec.rb +18 -0
- data/spec/config/ferrum_spec.rb +24 -0
- data/spec/config/networking_spec.rb +73 -0
- data/spec/config/redis_spec.rb +32 -0
- data/spec/config/root_spec.rb +31 -0
- data/spec/config/selenium_spec.rb +56 -0
- data/spec/config/strconv_spec.rb +58 -0
- data/spec/config/struct_spec.rb +66 -0
- data/spec/factories/middleware.rb +15 -0
- data/spec/factories/page.rb +78 -0
- data/spec/factories/task.rb +12 -0
- data/spec/fixtures/dummy_job.rb +7 -0
- data/spec/gc_spec.rb +63 -0
- data/spec/middleware/chain_spec.rb +96 -0
- data/spec/middleware/dedup_spec.rb +76 -0
- data/spec/middleware/fetch_spec.rb +100 -0
- data/spec/middleware/normalize_spec.rb +28 -0
- data/spec/middleware/router_spec.rb +80 -0
- data/spec/middleware/stage_spec.rb +39 -0
- data/spec/middleware/worker_spec.rb +117 -0
- data/spec/networking/capybara_spec.rb +12 -0
- data/spec/networking/context_spec.rb +127 -0
- data/spec/networking/ferrum_spec.rb +12 -0
- data/spec/networking/http_spec.rb +12 -0
- data/spec/networking/pool_spec.rb +67 -0
- data/spec/networking/selenium_spec.rb +12 -0
- data/spec/networking/strategy.rb +170 -0
- data/spec/page_spec.rb +21 -12
- data/spec/{parsers/json_parser_spec.rb → parsing/json_spec.rb} +5 -4
- data/spec/{parsers/xml_parser_spec.rb → parsing/xml_spec.rb} +3 -2
- data/spec/redis/barrier_spec.rb +78 -0
- data/spec/redis/counter_spec.rb +32 -0
- data/spec/redis/pool_spec.rb +18 -0
- data/spec/redis/version_spec.rb +13 -0
- data/spec/routing/dsl_spec.rb +98 -0
- data/spec/routing/integration_spec.rb +110 -0
- data/spec/routing/matchers/custom_spec.rb +31 -0
- data/spec/routing/matchers/host_spec.rb +49 -0
- data/spec/routing/matchers/path_spec.rb +43 -0
- data/spec/routing/matchers/query_spec.rb +137 -0
- data/spec/routing/matchers/scheme_spec.rb +25 -0
- data/spec/routing/{filetypes_rule_spec.rb → matchers/suffix_spec.rb} +14 -13
- data/spec/routing/matchers/uri_spec.rb +27 -0
- data/spec/routing/path_finder_spec.rb +33 -0
- data/spec/routing/root_route_spec.rb +29 -0
- data/spec/routing/route_spec.rb +43 -0
- data/spec/routing/router_spec.rb +13 -56
- data/spec/spec_helpers.rb +73 -38
- data/spec/stringify_spec.rb +23 -0
- data/{support → spec/support}/static/finders.html +0 -0
- data/{support → spec/support}/static/graph/details/a.html +0 -0
- data/{support → spec/support}/static/graph/details/b.html +0 -0
- data/{support → spec/support}/static/graph/index.html +0 -0
- data/{support → spec/support}/static/json/dummy.json +0 -0
- data/{support → spec/support}/static/links/links.html +0 -0
- data/{support → spec/support}/static/xml/dummy.xml +0 -0
- data/{support → spec/support}/test_app.rb +9 -2
- data/spec/task_spec.rb +27 -0
- data/spec/wayfarer_spec.rb +2 -13
- data/wayfarer.gemspec +40 -42
- metadata +234 -361
- data/.travis.yml +0 -5
- data/Changelog.md +0 -10
- data/README.md +0 -21
- data/benchmark/frontiers.rb +0 -143
- data/docs/.gitignore +0 -2
- data/docs/_config.yml +0 -15
- data/docs/_includes/base.html +0 -7
- data/docs/_includes/head.html +0 -10
- data/docs/_includes/navigation.html +0 -187
- data/docs/_layouts/default.html +0 -42
- data/docs/_sass/base.scss +0 -439
- data/docs/_sass/variables.scss +0 -24
- data/docs/_sass/vendor/bourbon/_bourbon-deprecate.scss +0 -19
- data/docs/_sass/vendor/bourbon/_bourbon-deprecated-upcoming.scss +0 -425
- data/docs/_sass/vendor/bourbon/_bourbon.scss +0 -90
- data/docs/_sass/vendor/bourbon/addons/_border-color.scss +0 -29
- data/docs/_sass/vendor/bourbon/addons/_border-radius.scss +0 -48
- data/docs/_sass/vendor/bourbon/addons/_border-style.scss +0 -28
- data/docs/_sass/vendor/bourbon/addons/_border-width.scss +0 -28
- data/docs/_sass/vendor/bourbon/addons/_buttons.scss +0 -69
- data/docs/_sass/vendor/bourbon/addons/_clearfix.scss +0 -25
- data/docs/_sass/vendor/bourbon/addons/_ellipsis.scss +0 -30
- data/docs/_sass/vendor/bourbon/addons/_font-stacks.scss +0 -31
- data/docs/_sass/vendor/bourbon/addons/_hide-text.scss +0 -27
- data/docs/_sass/vendor/bourbon/addons/_margin.scss +0 -29
- data/docs/_sass/vendor/bourbon/addons/_padding.scss +0 -29
- data/docs/_sass/vendor/bourbon/addons/_position.scss +0 -51
- data/docs/_sass/vendor/bourbon/addons/_prefixer.scss +0 -66
- data/docs/_sass/vendor/bourbon/addons/_retina-image.scss +0 -27
- data/docs/_sass/vendor/bourbon/addons/_size.scss +0 -56
- data/docs/_sass/vendor/bourbon/addons/_text-inputs.scss +0 -118
- data/docs/_sass/vendor/bourbon/addons/_timing-functions.scss +0 -34
- data/docs/_sass/vendor/bourbon/addons/_triangle.scss +0 -63
- data/docs/_sass/vendor/bourbon/addons/_word-wrap.scss +0 -29
- data/docs/_sass/vendor/bourbon/css3/_animation.scss +0 -61
- data/docs/_sass/vendor/bourbon/css3/_appearance.scss +0 -5
- data/docs/_sass/vendor/bourbon/css3/_backface-visibility.scss +0 -5
- data/docs/_sass/vendor/bourbon/css3/_background-image.scss +0 -44
- data/docs/_sass/vendor/bourbon/css3/_background.scss +0 -57
- data/docs/_sass/vendor/bourbon/css3/_border-image.scss +0 -61
- data/docs/_sass/vendor/bourbon/css3/_calc.scss +0 -6
- data/docs/_sass/vendor/bourbon/css3/_columns.scss +0 -67
- data/docs/_sass/vendor/bourbon/css3/_filter.scss +0 -6
- data/docs/_sass/vendor/bourbon/css3/_flex-box.scss +0 -327
- data/docs/_sass/vendor/bourbon/css3/_font-face.scss +0 -29
- data/docs/_sass/vendor/bourbon/css3/_font-feature-settings.scss +0 -6
- data/docs/_sass/vendor/bourbon/css3/_hidpi-media-query.scss +0 -12
- data/docs/_sass/vendor/bourbon/css3/_hyphens.scss +0 -6
- data/docs/_sass/vendor/bourbon/css3/_image-rendering.scss +0 -15
- data/docs/_sass/vendor/bourbon/css3/_keyframes.scss +0 -38
- data/docs/_sass/vendor/bourbon/css3/_linear-gradient.scss +0 -40
- data/docs/_sass/vendor/bourbon/css3/_perspective.scss +0 -12
- data/docs/_sass/vendor/bourbon/css3/_placeholder.scss +0 -10
- data/docs/_sass/vendor/bourbon/css3/_radial-gradient.scss +0 -40
- data/docs/_sass/vendor/bourbon/css3/_selection.scss +0 -44
- data/docs/_sass/vendor/bourbon/css3/_text-decoration.scss +0 -27
- data/docs/_sass/vendor/bourbon/css3/_transform.scss +0 -21
- data/docs/_sass/vendor/bourbon/css3/_transition.scss +0 -81
- data/docs/_sass/vendor/bourbon/css3/_user-select.scss +0 -5
- data/docs/_sass/vendor/bourbon/functions/_assign-inputs.scss +0 -16
- data/docs/_sass/vendor/bourbon/functions/_contains-falsy.scss +0 -25
- data/docs/_sass/vendor/bourbon/functions/_contains.scss +0 -31
- data/docs/_sass/vendor/bourbon/functions/_is-length.scss +0 -16
- data/docs/_sass/vendor/bourbon/functions/_is-light.scss +0 -26
- data/docs/_sass/vendor/bourbon/functions/_is-number.scss +0 -16
- data/docs/_sass/vendor/bourbon/functions/_is-size.scss +0 -23
- data/docs/_sass/vendor/bourbon/functions/_modular-scale.scss +0 -74
- data/docs/_sass/vendor/bourbon/functions/_px-to-em.scss +0 -24
- data/docs/_sass/vendor/bourbon/functions/_px-to-rem.scss +0 -26
- data/docs/_sass/vendor/bourbon/functions/_shade.scss +0 -24
- data/docs/_sass/vendor/bourbon/functions/_strip-units.scss +0 -22
- data/docs/_sass/vendor/bourbon/functions/_tint.scss +0 -24
- data/docs/_sass/vendor/bourbon/functions/_transition-property-name.scss +0 -37
- data/docs/_sass/vendor/bourbon/functions/_unpack.scss +0 -32
- data/docs/_sass/vendor/bourbon/helpers/_convert-units.scss +0 -26
- data/docs/_sass/vendor/bourbon/helpers/_directional-values.scss +0 -108
- data/docs/_sass/vendor/bourbon/helpers/_font-source-declaration.scss +0 -53
- data/docs/_sass/vendor/bourbon/helpers/_gradient-positions-parser.scss +0 -24
- data/docs/_sass/vendor/bourbon/helpers/_linear-angle-parser.scss +0 -35
- data/docs/_sass/vendor/bourbon/helpers/_linear-gradient-parser.scss +0 -51
- data/docs/_sass/vendor/bourbon/helpers/_linear-positions-parser.scss +0 -77
- data/docs/_sass/vendor/bourbon/helpers/_linear-side-corner-parser.scss +0 -41
- data/docs/_sass/vendor/bourbon/helpers/_radial-arg-parser.scss +0 -74
- data/docs/_sass/vendor/bourbon/helpers/_radial-gradient-parser.scss +0 -55
- data/docs/_sass/vendor/bourbon/helpers/_radial-positions-parser.scss +0 -28
- data/docs/_sass/vendor/bourbon/helpers/_render-gradients.scss +0 -31
- data/docs/_sass/vendor/bourbon/helpers/_shape-size-stripper.scss +0 -15
- data/docs/_sass/vendor/bourbon/helpers/_str-to-num.scss +0 -55
- data/docs/_sass/vendor/bourbon/settings/_asset-pipeline.scss +0 -7
- data/docs/_sass/vendor/bourbon/settings/_deprecation-warnings.scss +0 -8
- data/docs/_sass/vendor/bourbon/settings/_prefixer.scss +0 -9
- data/docs/_sass/vendor/bourbon/settings/_px-to-em.scss +0 -1
- data/docs/_sass/vendor/neat/_neat-helpers.scss +0 -11
- data/docs/_sass/vendor/neat/_neat.scss +0 -23
- data/docs/_sass/vendor/neat/functions/_new-breakpoint.scss +0 -49
- data/docs/_sass/vendor/neat/functions/_private.scss +0 -114
- data/docs/_sass/vendor/neat/grid/_box-sizing.scss +0 -15
- data/docs/_sass/vendor/neat/grid/_direction-context.scss +0 -33
- data/docs/_sass/vendor/neat/grid/_display-context.scss +0 -28
- data/docs/_sass/vendor/neat/grid/_fill-parent.scss +0 -22
- data/docs/_sass/vendor/neat/grid/_media.scss +0 -92
- data/docs/_sass/vendor/neat/grid/_omega.scss +0 -87
- data/docs/_sass/vendor/neat/grid/_outer-container.scss +0 -34
- data/docs/_sass/vendor/neat/grid/_pad.scss +0 -25
- data/docs/_sass/vendor/neat/grid/_private.scss +0 -35
- data/docs/_sass/vendor/neat/grid/_row.scss +0 -52
- data/docs/_sass/vendor/neat/grid/_shift.scss +0 -50
- data/docs/_sass/vendor/neat/grid/_span-columns.scss +0 -94
- data/docs/_sass/vendor/neat/grid/_to-deprecate.scss +0 -97
- data/docs/_sass/vendor/neat/grid/_visual-grid.scss +0 -42
- data/docs/_sass/vendor/neat/mixins/_clearfix.scss +0 -25
- data/docs/_sass/vendor/neat/settings/_disable-warnings.scss +0 -13
- data/docs/_sass/vendor/neat/settings/_grid.scss +0 -51
- data/docs/_sass/vendor/neat/settings/_visual-grid.scss +0 -27
- data/docs/_sass/vendor/normalize-3.0.2.scss +0 -427
- data/docs/_sass/vendor/pygments.scss +0 -356
- data/docs/automating_browsers/capybara.md +0 -70
- data/docs/css/screen.scss +0 -7
- data/docs/guides/cli.md +0 -52
- data/docs/guides/frontiers.md +0 -93
- data/docs/guides/halting.md +0 -23
- data/docs/guides/job_queues.md +0 -26
- data/docs/guides/locals.md +0 -36
- data/docs/guides/logging.md +0 -22
- data/docs/guides/page_objects.md +0 -67
- data/docs/guides/peeking.md +0 -46
- data/docs/guides/selenium_capybara.md +0 -100
- data/docs/guides/tutorial.md +0 -452
- data/docs/js/navigation.js +0 -11
- data/docs/misc/contributing.md +0 -20
- data/docs/misc/testing.md +0 -11
- data/docs/recipes/authentication.md +0 -23
- data/docs/recipes/csv.md +0 -29
- data/docs/recipes/javascript.md +0 -20
- data/docs/recipes/multiple_uris.md +0 -18
- data/docs/recipes/screenshots.md +0 -20
- data/docs/routing/custom_rules.md +0 -16
- data/docs/routing/filetypes_rules.md +0 -21
- data/docs/routing/host_rules.md +0 -24
- data/docs/routing/path_rules.md +0 -33
- data/docs/routing/protocol_rules.md +0 -17
- data/docs/routing/query_rules.md +0 -69
- data/docs/routing/routes.md +0 -96
- data/docs/routing/uri_rules.md +0 -18
- data/examples/collect_github_issues.rb +0 -65
- data/examples/find_foobar_on_wikipedia.rb +0 -23
- data/lib/wayfarer/configuration.rb +0 -86
- data/lib/wayfarer/crawl.rb +0 -79
- data/lib/wayfarer/crawl_observer.rb +0 -103
- data/lib/wayfarer/dispatcher.rb +0 -104
- data/lib/wayfarer/finders.rb +0 -61
- data/lib/wayfarer/frontiers/frontier.rb +0 -79
- data/lib/wayfarer/frontiers/memory_bloomfilter.rb +0 -32
- data/lib/wayfarer/frontiers/memory_frontier.rb +0 -76
- data/lib/wayfarer/frontiers/memory_trie_frontier.rb +0 -39
- data/lib/wayfarer/frontiers/normalize_uris.rb +0 -48
- data/lib/wayfarer/frontiers/redis_bloomfilter.rb +0 -34
- data/lib/wayfarer/frontiers/redis_frontier.rb +0 -83
- data/lib/wayfarer/http_adapters/adapter_pool.rb +0 -62
- data/lib/wayfarer/http_adapters/net_http_adapter.rb +0 -77
- data/lib/wayfarer/http_adapters/selenium_adapter.rb +0 -80
- data/lib/wayfarer/job.rb +0 -211
- data/lib/wayfarer/locals.rb +0 -40
- data/lib/wayfarer/parsers/json_parser.rb +0 -20
- data/lib/wayfarer/parsers/xml_parser.rb +0 -27
- data/lib/wayfarer/processor.rb +0 -103
- data/lib/wayfarer/routing/custom_rule.rb +0 -21
- data/lib/wayfarer/routing/filetypes_rule.rb +0 -20
- data/lib/wayfarer/routing/host_rule.rb +0 -19
- data/lib/wayfarer/routing/path_rule.rb +0 -54
- data/lib/wayfarer/routing/protocol_rule.rb +0 -21
- data/lib/wayfarer/routing/query_rule.rb +0 -59
- data/lib/wayfarer/routing/rule.rb +0 -114
- data/lib/wayfarer/routing/uri_rule.rb +0 -21
- data/spec/configuration_spec.rb +0 -26
- data/spec/crawl_spec.rb +0 -48
- data/spec/finders_spec.rb +0 -49
- data/spec/frontiers/memory_bloomfilter_spec.rb +0 -6
- data/spec/frontiers/memory_frontier_spec.rb +0 -6
- data/spec/frontiers/memory_trie_frontier_spec.rb +0 -6
- data/spec/frontiers/normalize_uris_spec.rb +0 -59
- data/spec/frontiers/redis_bloomfilter_spec.rb +0 -6
- data/spec/frontiers/redis_frontier_spec.rb +0 -6
- data/spec/http_adapters/adapter_pool_spec.rb +0 -33
- data/spec/http_adapters/net_http_adapter_spec.rb +0 -83
- data/spec/http_adapters/selenium_adapter_spec.rb +0 -53
- data/spec/integration/callbacks_spec.rb +0 -42
- data/spec/integration/locals_spec.rb +0 -106
- data/spec/integration/peeking_spec.rb +0 -61
- data/spec/job_spec.rb +0 -122
- data/spec/processor_spec.rb +0 -31
- data/spec/routing/custom_rule_spec.rb +0 -26
- data/spec/routing/host_rule_spec.rb +0 -48
- data/spec/routing/path_rule_spec.rb +0 -66
- data/spec/routing/protocol_rule_spec.rb +0 -26
- data/spec/routing/query_rule_spec.rb +0 -124
- data/spec/routing/rule_spec.rb +0 -251
- data/spec/routing/uri_rule_spec.rb +0 -24
- data/spec/shared/frontier.rb +0 -96
- data/wayfarer-jruby.gemspec +0 -49
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b6fd1a3fe8b9b259d023e8ffb125819c8663a4c5a3ead1930b46c673198276bd
|
4
|
+
data.tar.gz: e98395a58d7ab9e1062319f7ffe308056d8bfeae857463f8031e463e83aed5d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1d08a347ffc7cd54721522d7babc13ac91d50a2c06caa6bbceb13d6d633e6636e62316abd387f5c06250ed8d58802b6b766dbe2da1e8510bf638c64d05833ce
|
7
|
+
data.tar.gz: 185f44131bf7cebbb20eded4b83b4bf1bace6c3c41cc807e35bcda51191f6f18cba63b8dd63f963c3e24643c8eb772370cf4a6a36b00d19628853833324c4bae
|
@@ -0,0 +1,32 @@
|
|
1
|
+
name: ci
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- '*'
|
7
|
+
env:
|
8
|
+
CI: true
|
9
|
+
|
10
|
+
jobs:
|
11
|
+
ci:
|
12
|
+
runs-on: ubuntu-latest
|
13
|
+
steps:
|
14
|
+
- uses: actions/checkout@v2
|
15
|
+
|
16
|
+
- name: Start services
|
17
|
+
run: docker-compose up -d
|
18
|
+
|
19
|
+
- name: Run isolated tests
|
20
|
+
run: docker-compose run --rm --name test --service-ports wayfarer bundle exec rake test:isolated
|
21
|
+
|
22
|
+
- name: Run Ferrum tests
|
23
|
+
run: docker-compose run --rm --name test --service-ports wayfarer bundle exec rake test:ferrum
|
24
|
+
|
25
|
+
- name: Run Selenium tests
|
26
|
+
run: docker-compose run --rm --name test --service-ports wayfarer bundle exec rake test:selenium
|
27
|
+
|
28
|
+
- name: Run CLI tests
|
29
|
+
run: docker-compose run --rm --name test --service-ports wayfarer bundle exec rake test:cli
|
30
|
+
|
31
|
+
- name: Run RuboCop
|
32
|
+
run: docker-compose run --rm --name test --service-ports wayfarer bundle exec rake rubocop
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,21 +1,37 @@
|
|
1
1
|
AllCops:
|
2
|
+
NewCops: enable
|
2
3
|
Exclude:
|
3
|
-
- "
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
- "*.gemspec"
|
5
|
+
|
6
|
+
Layout/AccessModifierIndentation:
|
7
|
+
EnforcedStyle: outdent
|
8
|
+
|
9
|
+
Layout/LineLength:
|
10
|
+
Max: 120
|
8
11
|
|
9
12
|
Style/StringLiterals:
|
10
13
|
EnforcedStyle: double_quotes
|
11
14
|
|
12
15
|
Style/BlockDelimiters:
|
13
|
-
EnforcedStyle:
|
16
|
+
EnforcedStyle: braces_for_chaining
|
14
17
|
FunctionalMethods:
|
18
|
+
- let
|
19
|
+
- let!
|
20
|
+
- subject
|
15
21
|
- expect
|
16
22
|
|
23
|
+
Style/Documentation:
|
24
|
+
Enabled: false
|
25
|
+
|
17
26
|
Metrics/MethodLength:
|
18
|
-
Max:
|
27
|
+
Max: 20
|
28
|
+
|
29
|
+
Metrics/BlockLength:
|
30
|
+
Exclude:
|
31
|
+
- "spec/**/*"
|
32
|
+
|
33
|
+
Metrics/AbcSize:
|
34
|
+
Max: 30
|
19
35
|
|
20
|
-
Metrics/
|
21
|
-
Max:
|
36
|
+
Metrics/CyclomaticComplexity:
|
37
|
+
Max: 15
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.7.4
|
data/Dockerfile
ADDED
data/Gemfile
CHANGED
data/Gemfile.lock
ADDED
@@ -0,0 +1,221 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
wayfarer (0.4.3)
|
5
|
+
activejob (>= 6.0)
|
6
|
+
addressable (~> 2.8)
|
7
|
+
capybara (~> 3.0)
|
8
|
+
connection_pool (~> 2.2)
|
9
|
+
docile (~> 1.1)
|
10
|
+
ferrum (~> 0.9)
|
11
|
+
metainspector (~> 5.0)
|
12
|
+
mime-types (~> 3.0)
|
13
|
+
mock_redis (~> 0.29)
|
14
|
+
mustermann (~> 1.1)
|
15
|
+
net-http-persistent (~> 3.0)
|
16
|
+
nokogiri (~> 1.11)
|
17
|
+
normalize_url (~> 0.0.6)
|
18
|
+
redis (~> 4.4, < 4.5)
|
19
|
+
selenium-webdriver (~> 3.4)
|
20
|
+
thor (~> 1.0)
|
21
|
+
|
22
|
+
GEM
|
23
|
+
remote: https://rubygems.org/
|
24
|
+
specs:
|
25
|
+
activejob (6.1.4.1)
|
26
|
+
activesupport (= 6.1.4.1)
|
27
|
+
globalid (>= 0.3.6)
|
28
|
+
activesupport (6.1.4.1)
|
29
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
30
|
+
i18n (>= 1.6, < 2)
|
31
|
+
minitest (>= 5.1)
|
32
|
+
tzinfo (~> 2.0)
|
33
|
+
zeitwerk (~> 2.3)
|
34
|
+
addressable (2.8.0)
|
35
|
+
public_suffix (>= 2.0.2, < 5.0)
|
36
|
+
ast (2.4.2)
|
37
|
+
capybara (3.36.0)
|
38
|
+
addressable
|
39
|
+
matrix
|
40
|
+
mini_mime (>= 0.1.3)
|
41
|
+
nokogiri (~> 1.8)
|
42
|
+
rack (>= 1.6.0)
|
43
|
+
rack-test (>= 0.6.3)
|
44
|
+
regexp_parser (>= 1.5, < 3.0)
|
45
|
+
xpath (~> 3.2)
|
46
|
+
childprocess (3.0.0)
|
47
|
+
cliver (0.3.2)
|
48
|
+
coderay (1.1.3)
|
49
|
+
concurrent-ruby (1.1.9)
|
50
|
+
connection_pool (2.2.5)
|
51
|
+
cuprite (0.13)
|
52
|
+
capybara (>= 2.1, < 4)
|
53
|
+
ferrum (~> 0.11.0)
|
54
|
+
diff-lcs (1.4.4)
|
55
|
+
docile (1.4.0)
|
56
|
+
domain_name (0.5.20190701)
|
57
|
+
unf (>= 0.0.5, < 1.0.0)
|
58
|
+
factory_bot (6.2.0)
|
59
|
+
activesupport (>= 5.0.0)
|
60
|
+
faker (1.9.6)
|
61
|
+
i18n (>= 0.7)
|
62
|
+
faraday (1.9.3)
|
63
|
+
faraday-em_http (~> 1.0)
|
64
|
+
faraday-em_synchrony (~> 1.0)
|
65
|
+
faraday-excon (~> 1.1)
|
66
|
+
faraday-httpclient (~> 1.0)
|
67
|
+
faraday-multipart (~> 1.0)
|
68
|
+
faraday-net_http (~> 1.0)
|
69
|
+
faraday-net_http_persistent (~> 1.0)
|
70
|
+
faraday-patron (~> 1.0)
|
71
|
+
faraday-rack (~> 1.0)
|
72
|
+
faraday-retry (~> 1.0)
|
73
|
+
ruby2_keywords (>= 0.0.4)
|
74
|
+
faraday-cookie_jar (0.0.7)
|
75
|
+
faraday (>= 0.8.0)
|
76
|
+
http-cookie (~> 1.0.0)
|
77
|
+
faraday-em_http (1.0.0)
|
78
|
+
faraday-em_synchrony (1.0.0)
|
79
|
+
faraday-encoding (0.0.5)
|
80
|
+
faraday
|
81
|
+
faraday-excon (1.1.0)
|
82
|
+
faraday-http-cache (2.2.0)
|
83
|
+
faraday (>= 0.8)
|
84
|
+
faraday-httpclient (1.0.1)
|
85
|
+
faraday-multipart (1.0.3)
|
86
|
+
multipart-post (>= 1.2, < 3)
|
87
|
+
faraday-net_http (1.0.1)
|
88
|
+
faraday-net_http_persistent (1.2.0)
|
89
|
+
faraday-patron (1.0.0)
|
90
|
+
faraday-rack (1.0.0)
|
91
|
+
faraday-retry (1.0.3)
|
92
|
+
faraday_middleware (1.2.0)
|
93
|
+
faraday (~> 1.0)
|
94
|
+
fastimage (2.2.6)
|
95
|
+
ferrum (0.11)
|
96
|
+
addressable (~> 2.5)
|
97
|
+
cliver (~> 0.3)
|
98
|
+
concurrent-ruby (~> 1.1)
|
99
|
+
websocket-driver (>= 0.6, < 0.8)
|
100
|
+
globalid (1.0.0)
|
101
|
+
activesupport (>= 5.0)
|
102
|
+
http-cookie (1.0.4)
|
103
|
+
domain_name (~> 0.5)
|
104
|
+
i18n (1.8.10)
|
105
|
+
concurrent-ruby (~> 1.0)
|
106
|
+
matrix (0.4.2)
|
107
|
+
metainspector (5.11.2)
|
108
|
+
addressable (~> 2.7)
|
109
|
+
faraday (~> 1.4)
|
110
|
+
faraday-cookie_jar (~> 0.0)
|
111
|
+
faraday-encoding (~> 0.0)
|
112
|
+
faraday-http-cache (~> 2.2)
|
113
|
+
faraday_middleware (~> 1.0)
|
114
|
+
fastimage (~> 2.2)
|
115
|
+
nesty (~> 1.0)
|
116
|
+
nokogiri (~> 1.11)
|
117
|
+
method_source (1.0.0)
|
118
|
+
mime-types (3.4.1)
|
119
|
+
mime-types-data (~> 3.2015)
|
120
|
+
mime-types-data (3.2022.0105)
|
121
|
+
mini_mime (1.1.2)
|
122
|
+
mini_portile2 (2.6.1)
|
123
|
+
minitest (5.14.4)
|
124
|
+
mock_redis (0.29.0)
|
125
|
+
ruby2_keywords
|
126
|
+
multipart-post (2.1.1)
|
127
|
+
mustermann (1.1.1)
|
128
|
+
ruby2_keywords (~> 0.0.1)
|
129
|
+
nesty (1.0.2)
|
130
|
+
net-http-persistent (3.1.0)
|
131
|
+
connection_pool (~> 2.2)
|
132
|
+
nokogiri (1.12.5)
|
133
|
+
mini_portile2 (~> 2.6.1)
|
134
|
+
racc (~> 1.4)
|
135
|
+
normalize_url (0.0.6)
|
136
|
+
addressable (~> 2.3)
|
137
|
+
parallel (1.21.0)
|
138
|
+
parser (3.0.2.0)
|
139
|
+
ast (~> 2.4.1)
|
140
|
+
pry (0.14.1)
|
141
|
+
coderay (~> 1.1)
|
142
|
+
method_source (~> 1.0)
|
143
|
+
public_suffix (4.0.6)
|
144
|
+
racc (1.6.0)
|
145
|
+
rack (1.6.13)
|
146
|
+
rack-protection (1.5.5)
|
147
|
+
rack
|
148
|
+
rack-test (1.1.0)
|
149
|
+
rack (>= 1.0, < 3)
|
150
|
+
rainbow (3.0.0)
|
151
|
+
rake (10.5.0)
|
152
|
+
redis (4.4.0)
|
153
|
+
regexp_parser (2.1.1)
|
154
|
+
rexml (3.2.5)
|
155
|
+
rspec (3.10.0)
|
156
|
+
rspec-core (~> 3.10.0)
|
157
|
+
rspec-expectations (~> 3.10.0)
|
158
|
+
rspec-mocks (~> 3.10.0)
|
159
|
+
rspec-core (3.10.1)
|
160
|
+
rspec-support (~> 3.10.0)
|
161
|
+
rspec-expectations (3.10.1)
|
162
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
163
|
+
rspec-support (~> 3.10.0)
|
164
|
+
rspec-mocks (3.10.2)
|
165
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
166
|
+
rspec-support (~> 3.10.0)
|
167
|
+
rspec-support (3.10.2)
|
168
|
+
rubocop (0.93.1)
|
169
|
+
parallel (~> 1.10)
|
170
|
+
parser (>= 2.7.1.5)
|
171
|
+
rainbow (>= 2.2.2, < 4.0)
|
172
|
+
regexp_parser (>= 1.8)
|
173
|
+
rexml
|
174
|
+
rubocop-ast (>= 0.6.0)
|
175
|
+
ruby-progressbar (~> 1.7)
|
176
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
177
|
+
rubocop-ast (1.11.0)
|
178
|
+
parser (>= 3.0.1.1)
|
179
|
+
ruby-progressbar (1.11.0)
|
180
|
+
ruby2_keywords (0.0.5)
|
181
|
+
rubyzip (2.3.2)
|
182
|
+
selenium-webdriver (3.142.7)
|
183
|
+
childprocess (>= 0.5, < 4.0)
|
184
|
+
rubyzip (>= 1.2.2)
|
185
|
+
sinatra (1.4.8)
|
186
|
+
rack (~> 1.5)
|
187
|
+
rack-protection (~> 1.4)
|
188
|
+
tilt (>= 1.3, < 3)
|
189
|
+
thor (1.2.1)
|
190
|
+
tilt (2.0.10)
|
191
|
+
tzinfo (2.0.4)
|
192
|
+
concurrent-ruby (~> 1.0)
|
193
|
+
unf (0.1.4)
|
194
|
+
unf_ext
|
195
|
+
unf_ext (0.0.8)
|
196
|
+
unicode-display_width (1.8.0)
|
197
|
+
websocket-driver (0.7.5)
|
198
|
+
websocket-extensions (>= 0.1.0)
|
199
|
+
websocket-extensions (0.1.5)
|
200
|
+
xpath (3.2.0)
|
201
|
+
nokogiri (~> 1.8)
|
202
|
+
yard (0.9.26)
|
203
|
+
zeitwerk (2.4.2)
|
204
|
+
|
205
|
+
PLATFORMS
|
206
|
+
ruby
|
207
|
+
|
208
|
+
DEPENDENCIES
|
209
|
+
cuprite (~> 0.13)
|
210
|
+
factory_bot (~> 6.0)
|
211
|
+
faker (~> 1.7)
|
212
|
+
pry (~> 0.10)
|
213
|
+
rake (~> 10.4)
|
214
|
+
rspec (~> 3.4)
|
215
|
+
rubocop (~> 0.49)
|
216
|
+
sinatra (~> 1.4)
|
217
|
+
wayfarer!
|
218
|
+
yard (~> 0.9)
|
219
|
+
|
220
|
+
BUNDLED WITH
|
221
|
+
2.1.4
|
data/RELEASING.md
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# Release Procedure
|
2
|
+
|
3
|
+
1. Ensure `Wayfarer::VERSION` was bumped appropriately.
|
4
|
+
2. Ensure the version in wayfarer.gemspec matches.
|
5
|
+
3. Open a release Pull Request develop -> master branch
|
6
|
+
4. Merge the Pull Request
|
7
|
+
5. Publish RubyGem and git tag as follows:
|
8
|
+
|
9
|
+
```
|
10
|
+
git checkout master
|
11
|
+
git pull origin master --rebase
|
12
|
+
bundle exec rake build
|
13
|
+
gem push build/wayfarer-*.gem
|
14
|
+
bundle exec rake clean
|
15
|
+
git tag <VERSION>
|
16
|
+
git push origin <VERSION>
|
17
|
+
```
|
data/Rakefile
CHANGED
@@ -1,114 +1,62 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "irb"
|
3
4
|
require "rspec/core/rake_task"
|
4
5
|
require "rubocop/rake_task"
|
5
|
-
require "rack"
|
6
6
|
|
7
|
-
|
7
|
+
BUILD_DIR = "build"
|
8
8
|
|
9
|
-
task default:
|
9
|
+
task default: :build
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
desc "Run only integration tests"
|
18
|
-
RSpec::Core::RakeTask.new integration: [:test_app] do |task|
|
19
|
-
task.rspec_opts = ["--tag integration"]
|
20
|
-
end
|
21
|
-
|
22
|
-
desc "Run only Selenium tests"
|
23
|
-
RSpec::Core::RakeTask.new selenium: [:test_app] do |task|
|
24
|
-
task.rspec_opts = ["--tag selenium"]
|
25
|
-
end
|
26
|
-
|
27
|
-
desc "Run only Redis tests"
|
28
|
-
RSpec::Core::RakeTask.new redis: [:test_app] do |task|
|
29
|
-
task.rspec_opts = ["--tag redis"]
|
30
|
-
end
|
11
|
+
desc "Start an IRB session"
|
12
|
+
task :console do
|
13
|
+
require_relative "lib/wayfarer"
|
14
|
+
ARGV.clear
|
15
|
+
IRB.start
|
31
16
|
end
|
32
17
|
|
33
|
-
desc "
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
18
|
+
desc "Build gem"
|
19
|
+
task build: %i[clean] do
|
20
|
+
sh "gem build wayfarer.gemspec --verbose"
|
21
|
+
sh "mkdir #{BUILD_DIR}"
|
22
|
+
sh "mv wayfarer-*.gem #{BUILD_DIR}"
|
38
23
|
end
|
39
24
|
|
40
|
-
desc "
|
41
|
-
task :
|
42
|
-
|
43
|
-
|
44
|
-
bms.each do |bm|
|
45
|
-
sh "bundle exec ruby #{bm}"
|
46
|
-
end
|
25
|
+
desc "Remove build directory"
|
26
|
+
task :clean do
|
27
|
+
sh "rm -rf #{BUILD_DIR}"
|
47
28
|
end
|
48
29
|
|
49
|
-
desc "
|
50
|
-
task
|
30
|
+
desc "Install gem"
|
31
|
+
task install: %i[build] do
|
32
|
+
sh "gem install #{BUILD_DIR}/*.gem"
|
33
|
+
end
|
51
34
|
|
52
|
-
namespace :
|
53
|
-
desc "
|
54
|
-
|
55
|
-
|
56
|
-
sh "mkdir -p build"
|
57
|
-
sh "mv wayfarer-*.gem build"
|
35
|
+
namespace :test do
|
36
|
+
desc "Run only isolated tests"
|
37
|
+
RSpec::Core::RakeTask.new :isolated do |task|
|
38
|
+
task.rspec_opts = ["--tag ~selenium --tag ~ferrum --tag ~cli"]
|
58
39
|
end
|
59
40
|
|
60
|
-
desc "
|
61
|
-
|
62
|
-
|
63
|
-
sh "mkdir -p build"
|
64
|
-
sh "mv wayfarer-jruby-*.gem build"
|
41
|
+
desc "Run only Selenium tests"
|
42
|
+
RSpec::Core::RakeTask.new :selenium do |task|
|
43
|
+
task.rspec_opts = ["--tag selenium"]
|
65
44
|
end
|
66
|
-
end
|
67
|
-
|
68
|
-
desc "Remove build directory"
|
69
|
-
task :clean do
|
70
|
-
sh "rm -rf build"
|
71
|
-
end
|
72
45
|
|
73
|
-
desc "
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
include Wayfarer
|
78
|
-
include Wayfarer::HTTPAdapters
|
79
|
-
include Wayfarer::Routing
|
80
|
-
include Wayfarer::Frontiers
|
81
|
-
|
82
|
-
begin
|
83
|
-
require "pry"
|
84
|
-
Pry.new.repl(self)
|
85
|
-
rescue LoadError
|
86
|
-
require "irb"
|
87
|
-
ARGV.clear
|
88
|
-
IRB.start
|
46
|
+
desc "Run only Ferrum tests"
|
47
|
+
RSpec::Core::RakeTask.new :ferrum do |task|
|
48
|
+
task.rspec_opts = ["--tag ferrum"]
|
89
49
|
end
|
90
|
-
end
|
91
50
|
|
92
|
-
desc
|
93
|
-
|
94
|
-
|
51
|
+
desc "Run only CLI tests"
|
52
|
+
RSpec::Core::RakeTask.new :cli do |task|
|
53
|
+
task.rspec_opts = ["--tag cli"]
|
54
|
+
end
|
95
55
|
end
|
96
56
|
|
97
|
-
|
98
|
-
|
99
|
-
cvar = ConditionVariable.new
|
100
|
-
|
101
|
-
Thread.new do
|
102
|
-
Rack::Handler::WEBrick.run(
|
103
|
-
TestApp,
|
104
|
-
Port: 9876,
|
105
|
-
BindAddress: "localhost",
|
106
|
-
Logger: WEBrick::Log.new("/dev/null"),
|
107
|
-
AccessLog: [],
|
108
|
-
StartCallback: proc { cvar.signal }
|
109
|
-
)
|
110
|
-
end
|
57
|
+
desc "Run all tests"
|
58
|
+
RSpec::Core::RakeTask.new(:test)
|
111
59
|
|
112
|
-
|
113
|
-
|
60
|
+
RuboCop::RakeTask.new do |task|
|
61
|
+
task.formatters = %w[simple]
|
114
62
|
end
|
data/bin/wayfarer
CHANGED
@@ -1,116 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
require "logger"
|
5
|
-
require "pathname"
|
6
|
-
require "time"
|
7
|
-
require "active_support/inflector"
|
8
|
-
require "thor"
|
9
|
-
|
10
4
|
require_relative "../lib/wayfarer"
|
11
5
|
|
12
|
-
|
13
|
-
class CLI < Thor
|
14
|
-
class_option :log_level, type: :string, default: "info"
|
15
|
-
|
16
|
-
desc "exec FILE URI",
|
17
|
-
"Run the job defined in FILE starting from URI(s)"
|
18
|
-
def exec(file, uri)
|
19
|
-
set_log_level(options)
|
20
|
-
load_class_from_file(file).perform(uri)
|
21
|
-
end
|
22
|
-
|
23
|
-
option :queue_adapter, type: :string, default: "inline"
|
24
|
-
option :wait, type: :string
|
25
|
-
desc "enqueue FILE URI",
|
26
|
-
"Run the job defined in FILE starting from URI(s)"
|
27
|
-
def enqueue(file, uri)
|
28
|
-
set_log_level(options)
|
29
|
-
set_queue_adapter(options)
|
30
|
-
|
31
|
-
if wait = options[:wait]
|
32
|
-
delayed_seconds = differing_seconds_from_string(wait)
|
33
|
-
load_class_from_file(file).set(wait: delayed_seconds).perform_later(uri)
|
34
|
-
else
|
35
|
-
load_class_from_file(file).perform_later(uri)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
desc "route FILE URI",
|
40
|
-
"Output the first matching route from FILE for URI"
|
41
|
-
def route(file, uri)
|
42
|
-
set_log_level(options)
|
43
|
-
|
44
|
-
job = load_class_from_file(file)
|
45
|
-
|
46
|
-
action, params = job.router.route(URI(uri))
|
47
|
-
|
48
|
-
if action
|
49
|
-
puts "Dispatching to :#{action} with parameters: #{params}"
|
50
|
-
else
|
51
|
-
puts "No matching route"
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
desc "version", "Print the version"
|
56
|
-
def version
|
57
|
-
puts Wayfarer::VERSION
|
58
|
-
end
|
59
|
-
|
60
|
-
private
|
61
|
-
|
62
|
-
def set_log_level(options)
|
63
|
-
if level = options[:log_level]
|
64
|
-
Wayfarer.logger.level = log_level_from_string(level)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
def set_queue_adapter(options)
|
69
|
-
if adapter = options[:queue_adapter]
|
70
|
-
ActiveJob::Base.queue_adapter = adapter
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
def log_level_from_string(str)
|
75
|
-
case str.downcase
|
76
|
-
when "unknown" then Logger::UNKNOWN
|
77
|
-
when "debug" then Logger::DEBUG
|
78
|
-
when "error" then Logger::ERROR
|
79
|
-
when "fatal" then Logger::FATAL
|
80
|
-
when "info" then Logger::INFO
|
81
|
-
when "warn" then Logger::WARN
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
def differing_seconds_from_string(str)
|
86
|
-
# RuboCop turned this into an art piece
|
87
|
-
if secs = begin
|
88
|
-
Integer(secs)
|
89
|
-
rescue
|
90
|
-
nil
|
91
|
-
end
|
92
|
-
secs
|
93
|
-
elsif time = begin
|
94
|
-
Time.parse(str)
|
95
|
-
rescue
|
96
|
-
nil
|
97
|
-
end
|
98
|
-
time - Time.now
|
99
|
-
else
|
100
|
-
# TODO: Get rid of this
|
101
|
-
require "chronic"
|
102
|
-
Chronic.parse(str) - Time.now
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
def load_class_from_file(file)
|
107
|
-
path = File.join(Dir.pwd, file.chomp(".rb"))
|
108
|
-
base_name = Pathname.new(path).basename.to_s
|
109
|
-
|
110
|
-
require path
|
111
|
-
base_name.camelize.constantize
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
Wayfarer::CLI.start(ARGV)
|
6
|
+
Wayfarer::CLI::Runner.start(ARGV)
|
data/docker-compose.yml
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
version: "3"
|
2
|
+
services:
|
3
|
+
wayfarer:
|
4
|
+
build: .
|
5
|
+
volumes:
|
6
|
+
- "./:/usr/src/app"
|
7
|
+
ports:
|
8
|
+
- "9876:9876"
|
9
|
+
environment:
|
10
|
+
- CI=true
|
11
|
+
|
12
|
+
redis:
|
13
|
+
image: redis
|
14
|
+
|
15
|
+
chrome:
|
16
|
+
image: browserless/chrome
|
17
|
+
ports:
|
18
|
+
- "3000:3000"
|
19
|
+
|
20
|
+
firefox:
|
21
|
+
image: selenium/standalone-firefox:4.0.0-rc-2-prerelease-20210923
|
22
|
+
ports:
|
23
|
+
- "4444:4444"
|
24
|
+
volumes:
|
25
|
+
- "/dev/shm:/dev/shm"
|
26
|
+
|
27
|
+
docs:
|
28
|
+
image: squidfunk/mkdocs-material:7.3.0
|
29
|
+
volumes:
|
30
|
+
- "./:/docs"
|
31
|
+
ports:
|
32
|
+
- "8000:8000"
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# Batch routing
|
2
|
+
|
3
|
+
```ruby
|
4
|
+
# Create a record in an external database and store the hostname
|
5
|
+
record = Database::Row.create(hostname: "example.com")
|
6
|
+
|
7
|
+
class DummyJob < Wayfarer::Base
|
8
|
+
route do |hostname|
|
9
|
+
host hostname, to: :index
|
10
|
+
end
|
11
|
+
|
12
|
+
steer do |task|
|
13
|
+
# Pass the external record's hostname to the router
|
14
|
+
[Database::Row.find(task.batch).hostname]
|
15
|
+
end
|
16
|
+
|
17
|
+
# ...
|
18
|
+
end
|
19
|
+
|
20
|
+
# Enqueue the task and use the database record's key as batch
|
21
|
+
DummyJob.crawl_later("https://example.com", batch: record.id)
|
22
|
+
```
|