coolCrawler 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ce0e8b8ba2b209fbe9060b3d00744aaaf574c2b2ada771f1fe4f4bc63665bc4f
4
- data.tar.gz: 89f98f2b07274e0d3f4217aa9303899d20a7395ebe3a133980f920087aaa48e4
3
+ metadata.gz: e927853d47dec36f11557336b9a7c1f2d986b1a9933b78878f2cef18f585cf54
4
+ data.tar.gz: 67a189af1c21a32650b4cd58573aac781cf2f2a43ce6b20a88eb04a3298fbb79
5
5
  SHA512:
6
- metadata.gz: 4612e0d29277b25c6e0621efc2b4cfaa0f2d5dbabd94445beef520a3b0d912c78942b73f80731d1394e5a5f9ef5aab51d274188f758bd099a680e2b45297be0f
7
- data.tar.gz: 6c06f1eb22dfafbccc8dde7ce245c4d9ed7777ff575742c12a07c88cce1d3bde9b97efc18761bca1a4f2f6d86432cbf74fdbfb8f5ef9b23c69524129449a8236
6
+ metadata.gz: 6f3e9b7ff0b17807160670456b7d1bf49079760accef770620e0689e66234f6737dd90c973178f1bc600d22c2bc114e95d198fd756a656f006c2d9f35e2b7167
7
+ data.tar.gz: 2e03b27c2142c7eb389df2e4955070924c843e92d2a167e6aa1b5411e2698bcfbc551999542575b46eda561a949eaca2a3445a1e7db2ba6304700b58ed8a35b7
data/.rspec CHANGED
@@ -1,3 +1,3 @@
1
- --format documentation
2
- --color
3
- --require spec_helper
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml CHANGED
@@ -1,13 +1,13 @@
1
- AllCops:
2
- TargetRubyVersion: 3.0.0
3
-
4
- Style/StringLiterals:
5
- Enabled: true
6
- EnforcedStyle: double_quotes
7
-
8
- Style/StringLiteralsInInterpolation:
9
- Enabled: true
10
- EnforcedStyle: double_quotes
11
-
12
- Layout/LineLength:
13
- Max: 120
1
+ AllCops:
2
+ TargetRubyVersion: 3.0.0
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
data/CHANGELOG.md CHANGED
@@ -1,6 +1,11 @@
1
- ## [Unreleased]
2
-
3
- ## [0.1.0] - 2022-09-24
4
-
5
- - Initial release
6
- - Supports basic crawling with BFS algorithm
1
+ ## [0.3.0] - 2022-09-24
2
+
3
+ - Removed Crawler class
4
+ - CrawlerServer has been renamed to CrawlerPool
5
+ - added attr_reader to get site.
6
+ - Crawler still ignores outgoing links for now
7
+
8
+ ## [0.1.0] - 2022-09-24
9
+
10
+ - Initial release
11
+ - Supports basic crawling with BFS algorithm
data/CODE_OF_CONDUCT.md CHANGED
@@ -1,84 +1,84 @@
1
- # Contributor Covenant Code of Conduct
2
-
3
- ## Our Pledge
4
-
5
- We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
-
7
- We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
-
9
- ## Our Standards
10
-
11
- Examples of behavior that contributes to a positive environment for our community include:
12
-
13
- * Demonstrating empathy and kindness toward other people
14
- * Being respectful of differing opinions, viewpoints, and experiences
15
- * Giving and gracefully accepting constructive feedback
16
- * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
- * Focusing on what is best not just for us as individuals, but for the overall community
18
-
19
- Examples of unacceptable behavior include:
20
-
21
- * The use of sexualized language or imagery, and sexual attention or
22
- advances of any kind
23
- * Trolling, insulting or derogatory comments, and personal or political attacks
24
- * Public or private harassment
25
- * Publishing others' private information, such as a physical or email
26
- address, without their explicit permission
27
- * Other conduct which could reasonably be considered inappropriate in a
28
- professional setting
29
-
30
- ## Enforcement Responsibilities
31
-
32
- Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
-
34
- Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
-
36
- ## Scope
37
-
38
- This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
-
40
- ## Enforcement
41
-
42
- Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at williamwright3@cmail.carleton.ca. All complaints will be reviewed and investigated promptly and fairly.
43
-
44
- All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
-
46
- ## Enforcement Guidelines
47
-
48
- Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
-
50
- ### 1. Correction
51
-
52
- **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
-
54
- **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
-
56
- ### 2. Warning
57
-
58
- **Community Impact**: A violation through a single incident or series of actions.
59
-
60
- **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
-
62
- ### 3. Temporary Ban
63
-
64
- **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
-
66
- **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
-
68
- ### 4. Permanent Ban
69
-
70
- **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
-
72
- **Consequence**: A permanent ban from any sort of public interaction within the community.
73
-
74
- ## Attribution
75
-
76
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
- available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
-
79
- Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
-
81
- [homepage]: https://www.contributor-covenant.org
82
-
83
- For answers to common questions about this code of conduct, see the FAQ at
84
- https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at williamwright3@cmail.carleton.ca. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile CHANGED
@@ -1,12 +1,12 @@
1
- # frozen_string_literal: true
2
-
3
- source "https://rubygems.org"
4
-
5
- # Specify your gem's dependencies in coolCrawler.gemspec
6
- gemspec
7
-
8
- gem "rake", "~> 13.0"
9
-
10
- gem "rspec", "~> 3.0"
11
-
12
- gem "rubocop", "~> 1.21"
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in coolCrawler.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rspec", "~> 3.0"
11
+
12
+ gem "rubocop", "~> 1.21"
data/Gemfile.lock CHANGED
@@ -1,102 +1,102 @@
1
- PATH
2
- remote: .
3
- specs:
4
- coolCrawler (0.1.0)
5
- async-http
6
- nokogiri
7
- open-uri
8
- uri
9
-
10
- GEM
11
- remote: https://rubygems.org/
12
- specs:
13
- ast (2.4.2)
14
- async (2.1.0)
15
- console (~> 1.10)
16
- io-event (~> 1.0.0)
17
- timers (~> 4.1)
18
- async-http (0.59.2)
19
- async (>= 1.25)
20
- async-io (>= 1.28)
21
- async-pool (>= 0.2)
22
- protocol-http (~> 0.23.1)
23
- protocol-http1 (~> 0.14.0)
24
- protocol-http2 (~> 0.14.0)
25
- traces (>= 0.4.0)
26
- async-io (1.34.0)
27
- async
28
- async-pool (0.3.12)
29
- async (>= 1.25)
30
- console (1.15.3)
31
- fiber-local
32
- date (3.2.2)
33
- diff-lcs (1.5.0)
34
- fiber-local (1.0.0)
35
- io-event (1.0.9)
36
- json (2.6.2)
37
- nokogiri (1.13.8-x86_64-linux)
38
- racc (~> 1.4)
39
- open-uri (0.2.0)
40
- stringio
41
- time
42
- uri
43
- parallel (1.22.1)
44
- parser (3.1.2.1)
45
- ast (~> 2.4.1)
46
- protocol-hpack (1.4.2)
47
- protocol-http (0.23.12)
48
- protocol-http1 (0.14.6)
49
- protocol-http (~> 0.22)
50
- protocol-http2 (0.14.2)
51
- protocol-hpack (~> 1.4)
52
- protocol-http (~> 0.18)
53
- racc (1.6.0)
54
- rainbow (3.1.1)
55
- rake (13.0.6)
56
- regexp_parser (2.6.0)
57
- rexml (3.2.5)
58
- rspec (3.11.0)
59
- rspec-core (~> 3.11.0)
60
- rspec-expectations (~> 3.11.0)
61
- rspec-mocks (~> 3.11.0)
62
- rspec-core (3.11.0)
63
- rspec-support (~> 3.11.0)
64
- rspec-expectations (3.11.1)
65
- diff-lcs (>= 1.2.0, < 2.0)
66
- rspec-support (~> 3.11.0)
67
- rspec-mocks (3.11.1)
68
- diff-lcs (>= 1.2.0, < 2.0)
69
- rspec-support (~> 3.11.0)
70
- rspec-support (3.11.1)
71
- rubocop (1.36.0)
72
- json (~> 2.3)
73
- parallel (~> 1.10)
74
- parser (>= 3.1.2.1)
75
- rainbow (>= 2.2.2, < 4.0)
76
- regexp_parser (>= 1.8, < 3.0)
77
- rexml (>= 3.2.5, < 4.0)
78
- rubocop-ast (>= 1.20.1, < 2.0)
79
- ruby-progressbar (~> 1.7)
80
- unicode-display_width (>= 1.4.0, < 3.0)
81
- rubocop-ast (1.21.0)
82
- parser (>= 3.1.1.0)
83
- ruby-progressbar (1.11.0)
84
- stringio (3.0.2)
85
- time (0.2.0)
86
- date
87
- timers (4.3.4)
88
- traces (0.7.0)
89
- unicode-display_width (2.3.0)
90
- uri (0.11.0)
91
-
92
- PLATFORMS
93
- x86_64-linux
94
-
95
- DEPENDENCIES
96
- coolCrawler!
97
- rake (~> 13.0)
98
- rspec (~> 3.0)
99
- rubocop (~> 1.21)
100
-
101
- BUNDLED WITH
102
- 2.3.7
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ coolCrawler (0.1.0)
5
+ async-http
6
+ nokogiri
7
+ open-uri
8
+ uri
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ ast (2.4.2)
14
+ async (2.1.0)
15
+ console (~> 1.10)
16
+ io-event (~> 1.0.0)
17
+ timers (~> 4.1)
18
+ async-http (0.59.2)
19
+ async (>= 1.25)
20
+ async-io (>= 1.28)
21
+ async-pool (>= 0.2)
22
+ protocol-http (~> 0.23.1)
23
+ protocol-http1 (~> 0.14.0)
24
+ protocol-http2 (~> 0.14.0)
25
+ traces (>= 0.4.0)
26
+ async-io (1.34.0)
27
+ async
28
+ async-pool (0.3.12)
29
+ async (>= 1.25)
30
+ console (1.15.3)
31
+ fiber-local
32
+ date (3.2.2)
33
+ diff-lcs (1.5.0)
34
+ fiber-local (1.0.0)
35
+ io-event (1.0.9)
36
+ json (2.6.2)
37
+ nokogiri (1.13.8-x86_64-linux)
38
+ racc (~> 1.4)
39
+ open-uri (0.2.0)
40
+ stringio
41
+ time
42
+ uri
43
+ parallel (1.22.1)
44
+ parser (3.1.2.1)
45
+ ast (~> 2.4.1)
46
+ protocol-hpack (1.4.2)
47
+ protocol-http (0.23.12)
48
+ protocol-http1 (0.14.6)
49
+ protocol-http (~> 0.22)
50
+ protocol-http2 (0.14.2)
51
+ protocol-hpack (~> 1.4)
52
+ protocol-http (~> 0.18)
53
+ racc (1.6.0)
54
+ rainbow (3.1.1)
55
+ rake (13.0.6)
56
+ regexp_parser (2.6.0)
57
+ rexml (3.2.5)
58
+ rspec (3.11.0)
59
+ rspec-core (~> 3.11.0)
60
+ rspec-expectations (~> 3.11.0)
61
+ rspec-mocks (~> 3.11.0)
62
+ rspec-core (3.11.0)
63
+ rspec-support (~> 3.11.0)
64
+ rspec-expectations (3.11.1)
65
+ diff-lcs (>= 1.2.0, < 2.0)
66
+ rspec-support (~> 3.11.0)
67
+ rspec-mocks (3.11.1)
68
+ diff-lcs (>= 1.2.0, < 2.0)
69
+ rspec-support (~> 3.11.0)
70
+ rspec-support (3.11.1)
71
+ rubocop (1.36.0)
72
+ json (~> 2.3)
73
+ parallel (~> 1.10)
74
+ parser (>= 3.1.2.1)
75
+ rainbow (>= 2.2.2, < 4.0)
76
+ regexp_parser (>= 1.8, < 3.0)
77
+ rexml (>= 3.2.5, < 4.0)
78
+ rubocop-ast (>= 1.20.1, < 2.0)
79
+ ruby-progressbar (~> 1.7)
80
+ unicode-display_width (>= 1.4.0, < 3.0)
81
+ rubocop-ast (1.21.0)
82
+ parser (>= 3.1.1.0)
83
+ ruby-progressbar (1.11.0)
84
+ stringio (3.0.2)
85
+ time (0.2.0)
86
+ date
87
+ timers (4.3.4)
88
+ traces (0.7.0)
89
+ unicode-display_width (2.3.0)
90
+ uri (0.11.0)
91
+
92
+ PLATFORMS
93
+ x86_64-linux
94
+
95
+ DEPENDENCIES
96
+ coolCrawler!
97
+ rake (~> 13.0)
98
+ rspec (~> 3.0)
99
+ rubocop (~> 1.21)
100
+
101
+ BUNDLED WITH
102
+ 2.3.7
data/LICENSE.txt CHANGED
@@ -1,21 +1,21 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2022 William Wright
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 William Wright
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md CHANGED
@@ -1,65 +1,66 @@
1
- # CoolCrawler
2
-
3
- Cool Crawler is a light weight crawler for the purpose of that one university assignment.
4
-
5
- ## Installation
6
-
7
- Add this line to your application's Gemfile:
8
-
9
- ```ruby
10
- gem 'coolCrawler'
11
- ```
12
-
13
- And then execute:
14
-
15
- $ bundle install
16
-
17
- Or install it yourself as:
18
-
19
- $ gem install coolCrawler
20
-
21
- ## Usage
22
-
23
-
24
-
25
- ```ruby
26
- # create a set of 10 crawlers with a delay of 0.01 seconds between each group of crawl
27
- crawler = CoolCrawler::CrawlerServer.new("https://github.com", 10, 0.01)
28
-
29
- # set the callback function. This will be called everytime an individual crawler finishes its crawling. page is current path the crawler is on, links is an array
30
- # of all links found
31
- crawler.set_callback(Proc.new {|page, links| p page, links})
32
-
33
- # starts the crawl (ends when thare no more page in queue)
34
- crawler.run
35
- end
36
- ```
37
-
38
- ## TO-DO
39
-
40
- ### For version 0.1.x:
41
-
42
- * Implement method to scan and apply the rules of robots.txt
43
- * add a way to limit the number of links in the queue
44
- * Sleep period can be specified in the start block, but it would be good to have it supplied as configuration
45
- * Test and adapt for concurrency
46
-
47
- I will implement pageranking in 0.2.x
48
-
49
- ## Development
50
-
51
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
52
-
53
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
54
-
55
- ## Contributing
56
-
57
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/coolCrawler. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/coolCrawler/blob/master/CODE_OF_CONDUCT.md).
58
-
59
- ## License
60
-
61
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
62
-
63
- ## Code of Conduct
64
-
65
- Everyone interacting in the CoolCrawler project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/coolCrawler/blob/master/CODE_OF_CONDUCT.md).
1
+ # CoolCrawler
2
+
3
+ Cool Crawler is a light weight crawler for the purpose of that one university assignment.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'coolCrawler'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle install
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install coolCrawler
20
+
21
+ ## Usage
22
+
23
+
24
+
25
+ ```ruby
26
+ require 'cool_crawler'
27
+ # create a set of 10 crawlers with a delay of 0.01 seconds between each group of crawl
28
+ crawler = CoolCrawler::CrawlerServer.new("https://github.com", 10, 0.01)
29
+
30
+ # set the callback function. This will be called everytime an individual crawler finishes its crawling. page is current path the crawler is on, links is an array
31
+ # of all links found
32
+ crawler.set_callback(Proc.new {|page, links| p page, links})
33
+
34
+ # starts the crawl (ends when thare no more page in queue)
35
+ crawler.run
36
+ end
37
+ ```
38
+
39
+ ## TO-DO
40
+
41
+ ### For version 0.1.x:
42
+
43
+ * Implement method to scan and apply the rules of robots.txt
44
+ * add a way to limit the number of links in the queue
45
+ * Sleep period can be specified in the start block, but it would be good to have it supplied as configuration
46
+ * Test and adapt for concurrency
47
+
48
+ I will implement pageranking in 0.2.x
49
+
50
+ ## Development
51
+
52
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
53
+
54
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
55
+
56
+ ## Contributing
57
+
58
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/coolCrawler. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/coolCrawler/blob/master/CODE_OF_CONDUCT.md).
59
+
60
+ ## License
61
+
62
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
63
+
64
+ ## Code of Conduct
65
+
66
+ Everyone interacting in the CoolCrawler project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/coolCrawler/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile CHANGED
@@ -1,12 +1,12 @@
1
- # frozen_string_literal: true
2
-
3
- require "bundler/gem_tasks"
4
- require "rspec/core/rake_task"
5
-
6
- RSpec::Core::RakeTask.new(:spec)
7
-
8
- require "rubocop/rake_task"
9
-
10
- RuboCop::RakeTask.new
11
-
12
- task default: %i[spec rubocop]
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
@@ -1,5 +1,5 @@
1
- # frozen_string_literal: true
2
-
3
- module CoolCrawler
4
- VERSION = "0.2.1"
5
- end
1
+ # frozen_string_literal: true
2
+
3
+ module CoolCrawler
4
+ VERSION = "0.3.0"
5
+ end
data/lib/cool_crawler.rb CHANGED
@@ -1,126 +1,109 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "coolCrawler/version"
4
- require 'async'
5
- require 'async/http/internet'
6
- require 'async/barrier'
7
- require 'nokogiri'
8
-
9
- # Module Controller
10
- module CoolCrawler
11
- class Error < StandardError; end
12
-
13
- # This is the class that handles the queue and async requests
14
- class CrawlerServer
15
-
16
- def initialize(start, max_connections, delay)
17
- uri = URI(start)
18
- @site = "#{uri.scheme}://#{uri.host}"
19
- @max_connections = max_connections
20
- @delay = delay
21
- visited[uri.path] = 1
22
- queue << uri.path
23
- end
24
-
25
- attr_reader :max_connections, :delay, :callback
26
-
27
- def set_callback(proc)
28
- @callback=proc
29
- end
30
-
31
- def run
32
- until queue.empty?
33
- send_crawlers
34
- sleep(delay)
35
- end
36
- end
37
-
38
- def after(page, links)
39
- callback.call(page, links) unless callback.nil?
40
- end
41
-
42
- def send_crawlers
43
- pages = []
44
- until queue.empty? || pages.size >= max_connections
45
- pages << queue.pop
46
- end
47
- Async do
48
- internet = Async::HTTP::Internet.new
49
- barrier = Async::Barrier.new
50
-
51
- pages.each do |page|
52
- barrier.async do
53
- response = internet.get URI.join(@site, page).to_s
54
- links = Crawler.new(URI.join(@site, page), response.read).gather_links_uri
55
- after(page, links)
56
- links.each do |link|
57
- enqueue(link)
58
- add_to_visited(link)
59
- end
60
- end
61
- end
62
- barrier.wait
63
- ensure
64
- internet&.close
65
- end
66
- end
67
-
68
- def queue
69
- @queue ||= Queue.new
70
- end
71
-
72
- def visited
73
- @visited ||= {}
74
- end
75
-
76
- def visited?(path)
77
- visited.include?(path)
78
- end
79
-
80
- def add_to_visited(path)
81
- if visited?(path)
82
- visited[path] += 1
83
- else
84
- visited[path] = 1
85
- end
86
- end
87
-
88
- def sorted_visited
89
- visited.sort_by { |_k, v| v }
90
- end
91
-
92
- def enqueue(path)
93
- queue << path unless visited.include?(path)
94
- end
95
-
96
- end
97
-
98
-
99
- # This is the individual crawler
100
- class Crawler
101
- include CoolCrawler
102
- def initialize(current, response)
103
- @current = URI(current)
104
- @response = response
105
- end
106
-
107
- attr_reader :current, :response
108
-
109
- def gather_links_uri
110
- links = []
111
- doc = Nokogiri::HTML(response)
112
- doc.xpath("//a").each do |a|
113
- next if a["href"].nil?
114
- uri_a = URI(a["href"].strip.split('#')[0].sub(/\\|(\s+$)/, ""))
115
- begin
116
- link = URI.join(current, uri_a).path if (uri_a.host == current.host || uri_a.host.nil?) && uri_a.path
117
- links << URI.join(current, uri_a).path if (uri_a.host == current.host || uri_a.host.nil?) && uri_a.path
118
- rescue
119
- # do nothing
120
- end
121
- end
122
- links
123
- end
124
-
125
- end
126
- end
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "coolCrawler/version"
4
+ require 'async'
5
+ require 'async/http/internet'
6
+ require 'async/barrier'
7
+ require 'nokogiri'
8
+
9
+ # Module Controller
10
+ module CoolCrawler
11
+ class Error < StandardError; end
12
+
13
+ # This is the class that handles the queue and async requests
14
+ class CrawlerPool
15
+
16
+ def initialize(start, max_connections, delay)
17
+ @uri = URI(start)
18
+ @site = "#{uri.scheme}://#{uri.host}"
19
+ @max_connections = max_connections
20
+ @delay = delay
21
+ visited[uri.path] = 1
22
+ queue << uri.path
23
+ end
24
+
25
+ attr_reader :max_connections, :uri, :delay, :callback, :site
26
+
27
+ def set_callback(proc)
28
+ @callback=proc
29
+ end
30
+
31
+ def run
32
+ until queue.empty?
33
+ send_crawlers
34
+ sleep(delay)
35
+ end
36
+ end
37
+
38
+ def after(page, links)
39
+ callback.call(page, links) unless callback.nil?
40
+ end
41
+
42
+ def send_crawlers
43
+ pages = []
44
+ pages << queue.pop until queue.empty? || pages.size >= max_connections
45
+ Async do
46
+ internet = Async::HTTP::Internet.new
47
+ barrier = Async::Barrier.new
48
+
49
+ pages.each do |page|
50
+ barrier.async do
51
+ response = internet.get URI.join(@site, page).to_s
52
+ links = gather_links_uri(response.read, URI.join(uri, page))
53
+ after(page, links)
54
+ links.each do |link|
55
+ enqueue(link)
56
+ add_to_visited(link)
57
+ end
58
+ end
59
+ end
60
+ barrier.wait
61
+ ensure
62
+ internet&.close
63
+ end
64
+ end
65
+
66
+ def gather_links_uri(body, page)
67
+ links = []
68
+ doc = Nokogiri::HTML(body)
69
+ doc.xpath("//a").each do |a|
70
+ next if a["href"].nil?
71
+ uri_a = URI(a["href"].strip.split('#')[0].sub(/\\|(\s+$)/, ""))
72
+ begin
73
+ links << URI.join(page, uri_a).path if (uri_a.host == uri.host || uri_a.host.nil?) && uri_a.path
74
+ rescue
75
+ # do nothing
76
+ end
77
+ end
78
+ links
79
+ end
80
+
81
+ def queue
82
+ @queue ||= Queue.new
83
+ end
84
+
85
+ def visited
86
+ @visited ||= {}
87
+ end
88
+
89
+ def visited?(path)
90
+ visited.include?(path)
91
+ end
92
+
93
+ def add_to_visited(path)
94
+ if visited?(path)
95
+ visited[path] += 1
96
+ else
97
+ visited[path] = 1
98
+ end
99
+ end
100
+
101
+ def sorted_visited
102
+ visited.sort_by { |_k, v| v }
103
+ end
104
+
105
+ def enqueue(path)
106
+ queue << path unless visited.include?(path)
107
+ end
108
+ end
109
+ end
data/sig/coolCrawler.rbs CHANGED
@@ -1,4 +1,4 @@
1
- module CoolCrawler
2
- VERSION: String
3
- # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
- end
1
+ module CoolCrawler
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coolCrawler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Wright
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-10-04 00:00:00.000000000 Z
11
+ date: 2022-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -96,8 +96,6 @@ files:
96
96
  - LICENSE.txt
97
97
  - README.md
98
98
  - Rakefile
99
- - coolCrawler-0.2.0.gem
100
- - coolCrawler.gemspec
101
99
  - lib/coolCrawler/version.rb
102
100
  - lib/cool_crawler.rb
103
101
  - sig/coolCrawler.rbs
Binary file
data/coolCrawler.gemspec DELETED
@@ -1,40 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "lib/coolCrawler/version"
4
-
5
- Gem::Specification.new do |spec|
6
- spec.name = "coolCrawler"
7
- spec.version = CoolCrawler::VERSION
8
- spec.authors = ["William Wright"]
9
- spec.email = ["williamwright3@cmail.carleton.ca"]
10
-
11
- spec.summary = "Simple Web Crawler"
12
- spec.homepage = "https://github.com/willwright1213/coolCrawler"
13
- spec.license = "MIT"
14
- spec.required_ruby_version = ">= 3.0.0"
15
-
16
- spec.metadata["homepage_uri"] = spec.homepage
17
- spec.metadata["source_code_uri"] = "https://github.com/willwright1213/coolCrawler"
18
- spec.metadata["changelog_uri"] = "https://github.com/willwright1213/coolCrawler/blob/main/CHANGELOG.md"
19
-
20
- # Specify which files should be added to the gem when it is released.
21
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
- spec.files = Dir.chdir(File.expand_path(__dir__)) do
23
- `git ls-files -z`.split("\x0").reject do |f|
24
- (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
25
- end
26
- end
27
- spec.bindir = "exe"
28
- spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
29
- spec.require_paths = ["lib"]
30
-
31
- # Uncomment to register a new dependency of your gem
32
- # spec.add_dependency "example-gem", "~> 1.0"
33
- spec.add_development_dependency "rspec", "~> 3.11"
34
- spec.add_dependency 'async-http'
35
- spec.add_dependency "nokogiri"
36
- spec.add_dependency "open-uri"
37
- spec.add_dependency "uri"
38
- # For more information and examples about making a new gem, check out our
39
- # guide at: https://bundler.io/guides/creating_gem.html
40
- end