faraday-uafaker 0.0.1 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/data/uass.txt +17 -9420
- data/lib/faraday_middleware/request/user_agent_faker.rb +6 -2
- data/spec/user_agent_faker_spec.rb +3 -3
- metadata +3 -3
|
@@ -2,7 +2,7 @@ require 'faraday'
|
|
|
2
2
|
|
|
3
3
|
module FaradayMiddleware
|
|
4
4
|
class UserAgentFaker < Faraday::Middleware
|
|
5
|
-
VERSION = '0.0.
|
|
5
|
+
VERSION = '0.0.4'
|
|
6
6
|
|
|
7
7
|
UASS_FILE = File.expand_path(File.dirname(__FILE__) + '/../../../data/uass.txt')
|
|
8
8
|
|
|
@@ -12,8 +12,12 @@ module FaradayMiddleware
|
|
|
12
12
|
UASS[rand UASS.length].chomp
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
+
def uas
|
|
16
|
+
@uas ||= self.class.uas
|
|
17
|
+
end
|
|
18
|
+
|
|
15
19
|
def call(env)
|
|
16
|
-
env[:request_headers]['User-Agent'] =
|
|
20
|
+
env[:request_headers]['User-Agent'] = uas
|
|
17
21
|
@app.call(env)
|
|
18
22
|
end
|
|
19
23
|
end
|
|
@@ -9,7 +9,7 @@ describe FaradayMiddleware::UserAgentFaker do
|
|
|
9
9
|
it 'must choose one of known UA string' do
|
|
10
10
|
uas = FaradayMiddleware::UserAgentFaker::uas
|
|
11
11
|
expect(FaradayMiddleware::UserAgentFaker::UASS.include?("#{uas}\n")).to eq true
|
|
12
|
-
end
|
|
12
|
+
end
|
|
13
13
|
|
|
14
14
|
it 'must choose each time new UA string' do
|
|
15
15
|
uas1 = FaradayMiddleware::UserAgentFaker::uas
|
|
@@ -33,10 +33,10 @@ describe FaradayMiddleware::UserAgentFaker do
|
|
|
33
33
|
expect(FaradayMiddleware::UserAgentFaker::UASS.include?("#{uas}\n")).to eq true
|
|
34
34
|
end
|
|
35
35
|
|
|
36
|
-
it 'must
|
|
36
|
+
it 'must keep one random UA string during whole connection' do
|
|
37
37
|
uas1 = Nokogiri::HTML(conn.get().body).css('#uas_textfeld').text
|
|
38
38
|
uas2 = Nokogiri::HTML(conn.get().body).css('#uas_textfeld').text
|
|
39
|
-
expect(uas1).
|
|
39
|
+
expect(uas1).to eq uas2
|
|
40
40
|
end
|
|
41
41
|
end
|
|
42
42
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: faraday-uafaker
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Shem Ming
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2016-03-09 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -124,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
124
124
|
version: '0'
|
|
125
125
|
requirements: []
|
|
126
126
|
rubyforge_project:
|
|
127
|
-
rubygems_version: 2.
|
|
127
|
+
rubygems_version: 2.4.8
|
|
128
128
|
signing_key:
|
|
129
129
|
specification_version: 4
|
|
130
130
|
summary: Faraday middleware for faking UA string.
|