grell 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +2 -0
- data/CHANGELOG.md +32 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +78 -0
- data/Rakefile +2 -0
- data/grell.gemspec +30 -0
- data/lib/grell.rb +10 -0
- data/lib/grell/capybara_driver.rb +34 -0
- data/lib/grell/crawler.rb +44 -0
- data/lib/grell/grell_logger.rb +10 -0
- data/lib/grell/page.rb +231 -0
- data/lib/grell/page_collection.rb +46 -0
- data/lib/grell/rawpage.rb +37 -0
- data/lib/grell/reader.rb +15 -0
- data/lib/grell/version.rb +3 -0
- data/spec/lib/crawler_spec.rb +108 -0
- data/spec/lib/page_collection_spec.rb +149 -0
- data/spec/lib/page_spec.rb +284 -0
- data/spec/lib/reader_spec.rb +43 -0
- data/spec/spec_helper.rb +64 -0
- metadata +196 -0
@@ -0,0 +1,43 @@
|
|
1
|
+
RSpec.describe Grell::Reader do
|
2
|
+
|
3
|
+
context 'Waiting time expired' do
|
4
|
+
let(:waiting_time) {0}
|
5
|
+
let(:sleeping_time) {2}
|
6
|
+
let(:condition) {false}
|
7
|
+
it 'does not sleep' do
|
8
|
+
before_time = Time.now
|
9
|
+
Grell::Reader.wait_for(->{''}, waiting_time, sleeping_time) do
|
10
|
+
condition
|
11
|
+
end
|
12
|
+
expect(Time.now - before_time).to be < 1
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'The condition is true' do
|
17
|
+
let(:waiting_time) {3}
|
18
|
+
let(:sleeping_time) {2}
|
19
|
+
let(:condition) {true}
|
20
|
+
it 'does not sleep' do
|
21
|
+
before_time = Time.now
|
22
|
+
Grell::Reader.wait_for(->{''}, waiting_time, sleeping_time) do
|
23
|
+
condition
|
24
|
+
end
|
25
|
+
expect(Time.now - before_time).to be < 1
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'The condition is false' do
|
30
|
+
let(:waiting_time) {0.2}
|
31
|
+
let(:sleeping_time) {0.2}
|
32
|
+
let(:condition) {false}
|
33
|
+
|
34
|
+
it 'waits the waiting time' do
|
35
|
+
before_time = Time.now
|
36
|
+
Grell::Reader.wait_for(->{''}, waiting_time, sleeping_time) do
|
37
|
+
condition
|
38
|
+
end
|
39
|
+
expect(Time.now - before_time).to be > waiting_time
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'grell'
|
2
|
+
require 'byebug'
|
3
|
+
require 'webmock/rspec'
|
4
|
+
require 'billy/rspec'
|
5
|
+
require 'rack'
|
6
|
+
require 'rack/server'
|
7
|
+
|
8
|
+
# This will trick Puffing-billy into using this logger instead of its own
|
9
|
+
# Puffing billy is very noisy and we do not want to see that in our output
|
10
|
+
class Rails
|
11
|
+
def self.logger
|
12
|
+
Logger.new(nil)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
WebMock.disable_net_connect!
|
17
|
+
|
18
|
+
|
19
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
20
|
+
RSpec.configure do |config|
|
21
|
+
|
22
|
+
# We do not need to wait for pages to return all the data
|
23
|
+
config.before do
|
24
|
+
stub_const("Grell::Page::WAIT_TIME", 0)
|
25
|
+
end
|
26
|
+
|
27
|
+
config.expect_with :rspec do |expectations|
|
28
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
29
|
+
end
|
30
|
+
|
31
|
+
config.mock_with :rspec do |mocks|
|
32
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
33
|
+
# a real object.
|
34
|
+
mocks.verify_partial_doubles = true
|
35
|
+
end
|
36
|
+
|
37
|
+
# Limits the available syntax to the non-monkey patched syntax that is recommended.
|
38
|
+
config.disable_monkey_patching!
|
39
|
+
|
40
|
+
# This setting enables warnings. It's recommended, but in some cases may
|
41
|
+
# be too noisy due to issues in dependencies.
|
42
|
+
# TODO: Billy puffy has lots of warnings, test this with new versions
|
43
|
+
# config.warnings = true
|
44
|
+
|
45
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
46
|
+
# file, and it's useful to allow more verbose output when running an
|
47
|
+
# individual spec file.
|
48
|
+
if config.files_to_run.one?
|
49
|
+
# Use the documentation formatter for detailed output,
|
50
|
+
# unless a formatter has already been configured
|
51
|
+
# (e.g. via a command-line flag).
|
52
|
+
config.default_formatter = 'doc'
|
53
|
+
end
|
54
|
+
|
55
|
+
config.order = :random
|
56
|
+
Kernel.srand config.seed
|
57
|
+
|
58
|
+
Capybara.javascript_driver = :poltergeist_billy
|
59
|
+
Capybara.default_driver = :poltergeist_billy
|
60
|
+
|
61
|
+
# config.profile_examples = 10
|
62
|
+
end
|
63
|
+
|
64
|
+
|
metadata
ADDED
@@ -0,0 +1,196 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: grell
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.3.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jordi Polo Carres
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-05-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: capybara
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: poltergeist
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.5'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.5'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.6'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.6'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: byebug
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '4.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '4.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: kender
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: webmock
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '1.18'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '1.18'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rspec
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '3.0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '3.0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: puffing-billy
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0.5'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0.5'
|
139
|
+
description: Ruby web crawler using PhantomJS
|
140
|
+
email:
|
141
|
+
- jcarres@mdsol.com
|
142
|
+
executables: []
|
143
|
+
extensions: []
|
144
|
+
extra_rdoc_files: []
|
145
|
+
files:
|
146
|
+
- ".rspec"
|
147
|
+
- CHANGELOG.md
|
148
|
+
- Gemfile
|
149
|
+
- LICENSE.txt
|
150
|
+
- README.md
|
151
|
+
- Rakefile
|
152
|
+
- grell.gemspec
|
153
|
+
- lib/grell.rb
|
154
|
+
- lib/grell/capybara_driver.rb
|
155
|
+
- lib/grell/crawler.rb
|
156
|
+
- lib/grell/grell_logger.rb
|
157
|
+
- lib/grell/page.rb
|
158
|
+
- lib/grell/page_collection.rb
|
159
|
+
- lib/grell/rawpage.rb
|
160
|
+
- lib/grell/reader.rb
|
161
|
+
- lib/grell/version.rb
|
162
|
+
- spec/lib/crawler_spec.rb
|
163
|
+
- spec/lib/page_collection_spec.rb
|
164
|
+
- spec/lib/page_spec.rb
|
165
|
+
- spec/lib/reader_spec.rb
|
166
|
+
- spec/spec_helper.rb
|
167
|
+
homepage: https://github.com/mdsol/grell
|
168
|
+
licenses: []
|
169
|
+
metadata: {}
|
170
|
+
post_install_message:
|
171
|
+
rdoc_options: []
|
172
|
+
require_paths:
|
173
|
+
- lib
|
174
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
175
|
+
requirements:
|
176
|
+
- - ">="
|
177
|
+
- !ruby/object:Gem::Version
|
178
|
+
version: '0'
|
179
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
180
|
+
requirements:
|
181
|
+
- - ">="
|
182
|
+
- !ruby/object:Gem::Version
|
183
|
+
version: '0'
|
184
|
+
requirements: []
|
185
|
+
rubyforge_project:
|
186
|
+
rubygems_version: 2.2.2
|
187
|
+
signing_key:
|
188
|
+
specification_version: 4
|
189
|
+
summary: Ruby web crawler
|
190
|
+
test_files:
|
191
|
+
- spec/lib/crawler_spec.rb
|
192
|
+
- spec/lib/page_collection_spec.rb
|
193
|
+
- spec/lib/page_spec.rb
|
194
|
+
- spec/lib/reader_spec.rb
|
195
|
+
- spec/spec_helper.rb
|
196
|
+
has_rdoc:
|