useragents 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,28 +1,19 @@
1
- useragents-rb
2
- =============
3
- ## Usage
4
-
5
- ```ruby
6
- require 'useragents'
7
-
8
- UserAgents.list() # Default useragent list, which is commonly used
9
- # => Chrome : 27, 28, 29, 30, 31
10
- # Firefox: 23
11
- # IE : 7, 8, 9, 10, 11
12
- # Safari : xx
13
- # Opera : xx
14
- UserAgents.rand() # Generate a useragent for you
15
- ```
16
-
17
- ``` ruby
18
- require 'useragents'
19
-
20
- UserAgents.use(chrome: {gt:29}, ie: {eq: 9})
21
- UserAgents.list()
22
- # => Chrome : 29, 30, 31
23
- # IE : 9
24
-
25
- UserAgents.use(:all)
26
- UserAgents.list()
27
- # ...
28
- ```
1
+ useragents-rb
2
+ =============
3
+ [![Build Status](https://travis-ci.org/debbbbie/useragents-rb.png?branch=master)](https://travis-ci.org/debbbbie/useragents-rb)
4
+ ## Usage
5
+
6
+ ``` sh
7
+ gem install useragents
8
+ ```
9
+
10
+ ```ruby
11
+ require 'useragents'
12
+
13
+ # Generate a random useragent for you
14
+ UserAgents.rand()
15
+ ```
16
+
17
+ ``` sh
18
+
19
+ ```
data/lib/useragents.rb CHANGED
@@ -1,15 +1,23 @@
1
+ require 'core_ext/blank'
2
+
1
3
  module UserAgents
2
4
 
3
5
  class << self
4
- def list
5
6
 
7
+ def list
8
+ @@list
6
9
  end
7
10
 
8
- def use *args
9
-
10
- end
11
11
  def rand
12
+ @@list[ Kernel::rand(@@list.length) ]
13
+ end
12
14
 
15
+ def init()
16
+ @@list = File.read(File.expand_path("../useragents.txt", __FILE__)).split("\n")
13
17
  end
18
+
14
19
  end
20
+
15
21
  end
22
+
23
+ UserAgents.init()
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe UserAgents do
4
+ describe "self.list" do
5
+
6
+ it "should not be empty" do
7
+ UserAgents.list().blank?.should be(false)
8
+ end
9
+ end
10
+
11
+ describe "self.rand()" do
12
+ it "should be a String" do
13
+ UserAgents.rand().class.should be(String)
14
+ end
15
+ end
16
+
17
+ end
18
+
19
+ describe Object do
20
+ describe "[]" do
21
+ it "should be blank" do
22
+ [].blank?.should be(true)
23
+ end
24
+ end
25
+ end
data/useragents.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "useragents"
3
- s.version = "0.0.1"
3
+ s.version = "0.1.0"
4
4
 
5
5
  s.authors = "debbbbie"
6
6
  s.date = "2013-12-20"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: useragents
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: