user_agent_randomizer 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/user_agent.rb ADDED
@@ -0,0 +1,20 @@
1
+ require 'yaml'
2
+
3
+ class UserAgent
4
+
5
+ attr_accessor :type, :string
6
+
7
+ def initialize(type)
8
+ @type = type
9
+ ua_types = ["crawler", "desktop_browser", "mobile_browser", "console",
10
+ "offline_browser", "email_client", "link_checker", "email_collector",
11
+ "validator", "feed_reader", "library", "cloud_platform", "other"]
12
+ ua_h = YAML.load_file(File.expand_path("../data/user_agents.yml", __FILE__))
13
+ if ua_types.include?(type)
14
+ @string = ua_h[type].sample.to_s
15
+ else
16
+ @string = ua_h.values.flatten.sample
17
+ end
18
+ end
19
+
20
+ end
@@ -0,0 +1,4 @@
1
+ module UserAgentRandomizer
2
+ VERSION = "0.1.0"
3
+ end
4
+
@@ -0,0 +1 @@
1
+ require File.expand_path('../../lib/user_agent', __FILE__)
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe UserAgent do
4
+
5
+ it "is a String" do
6
+ ua = UserAgent.new("desktop_browser").string
7
+ expect(ua).to be_a String
8
+ end
9
+
10
+ it "has a type" do
11
+ ua = UserAgent.new("desktop_browser").type
12
+ expect(ua).to eq("desktop_browser")
13
+ end
14
+
15
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'user_agent_randomizer/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "user_agent_randomizer"
8
+ spec.version = UserAgentRandomizer::VERSION
9
+ spec.date = "2014-06-27"
10
+ spec.authors = ["Christoph Pilka"]
11
+ spec.email = ["c.pilka@asconix.com"]
12
+ spec.summary = %q{Random HTTP User-Agent string generator}
13
+ spec.description = %q{In few cases random HTTP User-Agent strings are required that are generated by this gem.}
14
+ spec.homepage = "https://github.com/asconix/user_agent_randomizer"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0")
18
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.6"
23
+ spec.add_development_dependency "rake", "~> 10.3"
24
+ spec.add_development_dependency "rspec", "~> 3.0"
25
+ spec.add_development_dependency "nokogiri", "~> 1.6"
26
+ end
metadata ADDED
@@ -0,0 +1,115 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: user_agent_randomizer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Christoph Pilka
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-06-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: nokogiri
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.6'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.6'
69
+ description: In few cases random HTTP User-Agent strings are required that are generated
70
+ by this gem.
71
+ email:
72
+ - c.pilka@asconix.com
73
+ executables: []
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - ".travis.yml"
79
+ - Gemfile
80
+ - LICENSE
81
+ - README.md
82
+ - Rakefile
83
+ - lib/data/user_agents.yml
84
+ - lib/user_agent.rb
85
+ - lib/user_agent_randomizer/version.rb
86
+ - spec/spec_helper.rb
87
+ - spec/useragent-randomizer_spec.rb
88
+ - user_agent_randomizer.gemspec
89
+ homepage: https://github.com/asconix/user_agent_randomizer
90
+ licenses:
91
+ - MIT
92
+ metadata: {}
93
+ post_install_message:
94
+ rdoc_options: []
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ requirements: []
108
+ rubyforge_project:
109
+ rubygems_version: 2.2.2
110
+ signing_key:
111
+ specification_version: 4
112
+ summary: Random HTTP User-Agent string generator
113
+ test_files:
114
+ - spec/spec_helper.rb
115
+ - spec/useragent-randomizer_spec.rb