Skip to content

Commit 0a2f4a9

Browse files
author
Kirill Platonov
committed
add readme and documentation
1 parent 2e85923 commit 0a2f4a9

File tree

7 files changed

+135
-19
lines changed

7 files changed

+135
-19
lines changed

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
.bundle/
22
log/*.log
3-
pkg/
3+
pkg/
4+
Gemfile.lock
5+
tmp
6+
.yardoc/
7+
doc/

.yardopts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
--private
2+
--protected
3+
-o doc/ruby

Gemfile.lock

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
PATH
22
remote: .
33
specs:
4-
proxy_manager (0.0.1)
5-
net-ping
4+
proxy_manager (0.0.2)
5+
net-ping (~> 1.7, >= 1.7.2)
66

77
GEM
88
remote: https://rubygems.org/
@@ -51,7 +51,7 @@ GEM
5151
rspec-core (~> 2.14.0)
5252
rspec-expectations (~> 2.14.0)
5353
rspec-mocks (~> 2.14.0)
54-
rspec-core (2.14.7)
54+
rspec-core (2.14.8)
5555
rspec-expectations (2.14.5)
5656
diff-lcs (>= 1.1.3, < 2.0)
5757
rspec-mocks (2.14.6)
@@ -62,14 +62,16 @@ GEM
6262
turn (0.9.7)
6363
ansi
6464
minitest (~> 4)
65+
yard (0.8.7.4)
6566

6667
PLATFORMS
6768
ruby
6869

6970
DEPENDENCIES
70-
fuubar
71-
growl
72-
guard-rspec
71+
fuubar (>= 1.3.2)
72+
growl (>= 1.0.3)
73+
guard-rspec (>= 4.2.8)
7374
proxy_manager!
74-
rspec
75-
turn
75+
rspec (>= 2.14.1)
76+
turn (>= 0.9.7)
77+
yard (>= 0.8.7.4)

README.md

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# Ruby Proxy Manager
2+
3+
Easy manage proxy in your parsers/web-bots.
4+
5+
6+
## Installation
7+
8+
Add this line to your application's Gemfile:
9+
10+
```ruby
11+
gem 'proxy_manager'
12+
```
13+
14+
And then execute:
15+
16+
```bash
17+
$ bundle
18+
```
19+
20+
Or install it yourself as:
21+
22+
```bash
23+
$ gem install proxy_manager
24+
```
25+
26+
## Usage
27+
28+
### Load proxy list
29+
30+
From array (IP:PORT)
31+
32+
```ruby
33+
proxy = ProxyManager.load(['1.2.3.4:567', '9.8.7.6:543'])
34+
```
35+
36+
or from file
37+
38+
```ruby
39+
proxy = ProxyManager.load('proxies.txt', 'bad_proxies.txt')
40+
```
41+
42+
Files `proxies.txt` and `bad_proxies.txt` should be writable.
43+
Example of `proxies.txt` content:
44+
45+
```
46+
1.2.3.4:567
47+
9.8.7.6:543
48+
...
49+
```
50+
51+
### Get proxy
52+
53+
Get one proxy
54+
55+
```ruby
56+
proxy.get
57+
# => ["1.2.3.4", 567]
58+
```
59+
60+
Get many proxies
61+
62+
```ruby
63+
proxy.get(2)
64+
# => [["1.2.3.4", 567], ["9.8.7.6", 543]]
65+
```
66+
67+
Will be returning only pingable proxies
68+
69+
### Proxies lists
70+
71+
You also can display list of loaded proxies
72+
73+
```ruby
74+
proxy.list
75+
# => [["1.2.3.4", 567], ["9.8.7.6", 543]]
76+
```
77+
78+
and list of bad proxies
79+
80+
```ruby
81+
proxy.bad_list
82+
# => []
83+
```
84+
85+
## Documentation
86+
87+
http://rubydoc.info/gems/proxy_manager/frames
88+
89+
## Contributing
90+
91+
1. Fork it
92+
2. Create your feature branch (`git checkout -b my-new-feature`)
93+
3. Commit your changes (`git commit -am 'Add some feature'`)
94+
4. Push to the branch (`git push origin my-new-feature`)
95+
5. Create new Pull Request

README.rdoc

Lines changed: 0 additions & 3 deletions
This file was deleted.

lib/proxy_manager.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,23 @@
22
require 'net/ping'
33

44
module ProxyManager
5+
# Define gem's root path
6+
# @return [String] string path
57
def self.root
68
File.expand_path '../..', __FILE__
79
end
810

11+
# Create main object
12+
# @param proxies [Array, String] array of proxies or file with proxies
13+
# @param bad_proxies [String, nil] optional file for save bad proxies
14+
# @example
15+
# # from array
16+
# proxy = ProxyManager.load(['1.2.3.4:567', '9.8.7.6:543'])
17+
#
18+
# # or from file
19+
# proxy = ProxyManager.load('proxies.txt', 'bad_proxies.txt')
20+
# @return [Class] Main object
21+
# @see Main
922
def self.load(proxies, bad_proxies = nil)
1023
Main.new(proxies, bad_proxies)
1124
end

proxy_manager.gemspec

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ $:.push File.expand_path("../lib", __FILE__)
33
# Describe your gem and declare its dependencies:
44
Gem::Specification.new do |s|
55
s.name = "proxy_manager"
6-
s.version = '0.0.2'
6+
s.version = '0.0.3'
77
s.authors = ["Kirill Platonov"]
8+
s.licenses = ['MIT']
89
s.email = ["[email protected]"]
910
s.homepage = "https://github.com/bloodyhistory/proxy_manager"
1011
s.summary = "Ruby proxy manager. Gem for easy usage proxy in parser/web bots."
@@ -16,11 +17,12 @@ Gem::Specification.new do |s|
1617
s.files = Dir["{lib}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc", ".rspec"]
1718
s.test_files = Dir["spec/**/*"]
1819

19-
s.add_dependency 'net-ping'
20+
s.add_dependency 'net-ping', '~> 1.7', '>= 1.7.2'
2021

21-
s.add_development_dependency 'turn'
22-
s.add_development_dependency 'rspec'
23-
s.add_development_dependency 'guard-rspec'
24-
s.add_development_dependency 'growl'
25-
s.add_development_dependency 'fuubar'
22+
s.add_development_dependency 'turn', '>= 0.9.7'
23+
s.add_development_dependency 'rspec', '>= 2.14.1'
24+
s.add_development_dependency 'guard-rspec', '>= 4.2.8'
25+
s.add_development_dependency 'growl', '>= 1.0.3'
26+
s.add_development_dependency 'fuubar', '>= 1.3.2'
27+
s.add_development_dependency 'yard', '>= 0.8.7.4'
2628
end

0 commit comments

Comments
 (0)