Skip to content

Commit 40fefe1

Browse files
committed
Added readthedocs documentation.
1 parent be0fb0b commit 40fefe1

File tree

10 files changed

+306
-0
lines changed

10 files changed

+306
-0
lines changed

.readthedocs.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# .readthedocs.yaml
2+
# Read the Docs configuration file
3+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
4+
5+
# Required
6+
version: 2
7+
8+
# Set the OS, Python version and other tools you might need
9+
build:
10+
os: ubuntu-22.04
11+
tools:
12+
python: "3.11"
13+
# You can also specify other tool versions:
14+
# nodejs: "19"
15+
# rust: "1.64"
16+
# golang: "1.19"
17+
18+
# Build documentation in the "docs/" directory with Sphinx
19+
sphinx:
20+
configuration: docs/source/conf.py
21+
22+
# Optionally build your docs in additional formats such as PDF and ePub
23+
# formats:
24+
# - pdf
25+
# - epub
26+
27+
# Optional but recommended, declare the Python requirements required
28+
# to build your documentation
29+
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
30+
python:
31+
install:
32+
- requirements: docs/requirements.txt

docs/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = source
9+
BUILDDIR = build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/make.bat

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
@ECHO OFF
2+
3+
pushd %~dp0
4+
5+
REM Command file for Sphinx documentation
6+
7+
if "%SPHINXBUILD%" == "" (
8+
set SPHINXBUILD=sphinx-build
9+
)
10+
set SOURCEDIR=source
11+
set BUILDDIR=build
12+
13+
%SPHINXBUILD% >NUL 2>NUL
14+
if errorlevel 9009 (
15+
echo.
16+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
17+
echo.installed, then set the SPHINXBUILD environment variable to point
18+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
19+
echo.may add the Sphinx directory to PATH.
20+
echo.
21+
echo.If you don't have Sphinx installed, grab it from
22+
echo.https://www.sphinx-doc.org/
23+
exit /b 1
24+
)
25+
26+
if "%1" == "" goto help
27+
28+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29+
goto end
30+
31+
:help
32+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33+
34+
:end
35+
popd

docs/requirements.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Defining the exact version will make sure things don't break
2+
sphinx-book-theme==1.0.1
3+
# sphinx-pdj-theme==0.4.0
4+
myst-parser==2.0.0
5+
markdown-it-py==3.0.0
6+
sphinx-copybutton==0.5.2

docs/source/code.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# IP2Proxy Ruby API
2+
3+
## Database Class
4+
```{py:function} open(database_file_path, file_mode)
5+
Load the IP2Proxy BIN database.
6+
7+
:param str database_file_path: (Required) The file path links to IP2Location BIN databases.
8+
:param str file_mode: (Optional) Caching mode (one of FILE_IO, MEMORY_CACHE, or SHARED_MEMORY).
9+
```
10+
11+
```{py:function} get_package_version()
12+
Return the database's type, 1 to 10 respectively for PX1 to PX11. Please visit https://www.ip2location.com/databases/ip2proxy for details.
13+
14+
:return: Returns the package version.
15+
:rtype: string
16+
```
17+
18+
```{py:function} get_module_version()
19+
Return the version of module.
20+
21+
:return: Returns the module version.
22+
:rtype: string
23+
```
24+
25+
```{py:function} get_database_version()
26+
Return the database's compilation date as a string of the form 'YYYY-MM-DD'.
27+
28+
:return: Returns the database version.
29+
:rtype: string
30+
```
31+
32+
```{py:function} get_all(ip_address)
33+
Retrieve geolocation information for an IP address.
34+
35+
:param str ip_address: (Required) The IP address (IPv4 or IPv6).
36+
:return: Returns the geolocation information in array. Refer below table for the fields avaliable in the array
37+
:rtype: array
38+
39+
**RETURN FIELDS**
40+
41+
| Field Name | Description |
42+
| ---------------- | ------------------------------------------------------------ |
43+
| countryCode | Two-character country code based on ISO 3166. |
44+
| countryName | Country name based on ISO 3166. |
45+
| regionName | Region or state name. |
46+
| cityName | City name. |
47+
| isp | Internet Service Provider or company\'s name. |
48+
| domain | Internet domain name associated with IP address range. |
49+
| usageType | Usage type classification of ISP or company. |
50+
| asn | Autonomous system number (ASN). |
51+
| as | Autonomous system (AS) name. |
52+
| lastSeen | Proxy last seen in days. |
53+
| threat | Security threat reported. |
54+
| proxyType | Type of proxy. |
55+
| provider | Name of VPN provider if available. |
56+
```

docs/source/conf.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Configuration file for the Sphinx documentation builder.
2+
# Read https://www.sphinx-doc.org/en/master/usage/configuration.html for more options available
3+
4+
# import sphinx_pdj_theme
5+
6+
# -- Project information
7+
8+
project = 'IP2Proxy Ruby'
9+
copyright = '2023, IP2Location'
10+
author = 'IP2Location'
11+
12+
release = '0.1.0'
13+
version = '0.1.0'
14+
15+
# -- General configuration
16+
17+
extensions = [
18+
'sphinx.ext.duration',
19+
'sphinx.ext.doctest',
20+
'myst_parser',
21+
'sphinx_copybutton',
22+
]
23+
24+
# https://myst-parser.readthedocs.io/en/latest/syntax/optional.html
25+
26+
myst_enable_extensions = [
27+
"colon_fence",
28+
"deflist",
29+
"fieldlist",
30+
]
31+
32+
# https://myst-parser.readthedocs.io/en/latest/configuration.html#setting-html-metadata
33+
myst_html_meta = {
34+
"description": "IP2Proxy Ruby library enables user to query an IP address if it was being used as open proxy, web proxy, VPN anonymizer and TOR exits.",
35+
"keywords": "IP2Proxy, Proxy, IP location, Ruby",
36+
"google-site-verification": "DeW6mXDyMnMt4i61ZJBNuoADPimo5266DKob7Z7d6i4",
37+
}
38+
39+
# templates_path = ['_templates']
40+
41+
# -- Options for HTML output
42+
43+
html_theme = 'sphinx_book_theme'
44+
# html_theme_path = [sphinx_pdj_theme.get_html_theme_path()]
45+
46+
# PDJ theme options, see the list of available options here: https://github.com/jucacrispim/sphinx_pdj_theme/blob/master/sphinx_pdj_theme/theme.conf
47+
html_theme_options = {
48+
"use_edit_page_button": False,
49+
"use_source_button": False,
50+
"use_issues_button": False,
51+
"use_download_button": False,
52+
"use_sidenotes": False,
53+
}
54+
55+
# The name of an image file (relative to this directory) to place at the top
56+
# of the sidebar.
57+
html_logo = 'images/ipl-logo-square-1200.png'
58+
59+
# Favicon
60+
html_favicon = 'images/favicon.ico'
61+
62+
html_title = "IP2Proxy PHP"
63+
64+
# html_baseurl = "https://ip2proxy-ruby.readthedocs.io/en/latest/"

docs/source/images/favicon.ico

14.7 KB
Binary file not shown.
19.8 KB
Loading

docs/source/index.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[![Latest Stable Version](https://img.shields.io/gem/v/ip2proxy_ruby.svg)](https://rubygems.org/gems/ip2proxy_ruby)
2+
[![Total Downloads](https://img.shields.io/gem/dt/ip2proxy_ruby.svg)](https://rubygems.org/gems/ip2proxy_ruby)
3+
4+
# IP2Proxy Ruby Library
5+
This module allows user to reverse search of IP address to detect VPN servers, open proxies, web proxies, Tor exit nodes, search engine robots, data center ranges and residential proxies using IP2Proxy BIN database. Other information available includes proxy type, country, state, city, ISP, domain name, usage type, AS number, AS name, threats, last seen date and provider names. It lookup the proxy IP address from **IP2Proxy BIN Data** file or web service.
6+
7+
For more details, please visit:
8+
[https://www.ip2location.com/ip2proxy/developers/ruby](https://www.ip2location.com/ip2proxy/developers/ruby)
9+
10+
11+
## Table of contents
12+
```{eval-rst}
13+
.. toctree::
14+
15+
self
16+
quickstart
17+
code
18+
```

docs/source/quickstart.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Quickstart
2+
3+
## Dependencies
4+
5+
This library requires IP2Proxy BIN database to function. You may download the BIN database at
6+
7+
- IP2Proxy LITE BIN Data (Free): <https://lite.ip2location.com>
8+
- IP2Proxy Commercial BIN Data (Comprehensive):
9+
<https://www.ip2location.com>
10+
11+
:::{note}
12+
An outdated BIN database was provided in the data folder for your testing. You are recommended to visit the above links to download the latest BIN database.
13+
:::
14+
15+
## Installation
16+
17+
Install this package using the command as below:
18+
19+
```
20+
gem install ip2proxy_ruby
21+
```
22+
23+
## Sample Codes
24+
25+
### Query geolocation information from BIN database
26+
27+
You can query the geolocation information from the IP2Proxy BIN database as below:
28+
29+
```ruby
30+
require 'ip2proxy_ruby'
31+
32+
# open IP2Proxy BIN database for proxy lookup
33+
i2p = Ip2proxy.new.open("./data/PX11.SAMPLE.BIN")
34+
35+
# get versioning information
36+
print 'Module Version: ' + i2p.get_module_version + "\n"
37+
print 'Package Version: ' + i2p.get_package_version + "\n"
38+
print 'Database Version: ' + i2p.get_database_version + "\n"
39+
40+
# individual proxy data check
41+
print 'Is Proxy: ' + i2p.is_proxy('1.2.3.4').to_s + "\n"
42+
print 'Proxy Type: ' + i2p.get_proxytype('1.2.3.4') + "\n"
43+
print 'Country Code: ' + i2p.get_country_short('1.2.3.4') + "\n"
44+
print 'Country Name: ' + i2p.get_country_long('1.2.3.4') + "\n"
45+
print 'Region Name: ' + i2p.get_region('1.2.3.4') + "\n"
46+
print 'City Name: ' + i2p.get_city('1.2.3.4') + "\n"
47+
print 'ISP: ' + i2p.get_isp('1.2.3.4') + "\n"
48+
print 'Domain: ' + i2p.get_domain('1.2.3.4') + "\n"
49+
print 'Usage Type: ' + i2p.get_usagetype('1.2.3.4') + "\n"
50+
print 'ASN: ' + i2p.get_asn('1.2.3.4') + "\n"
51+
print 'AS: ' + i2p.get_as('1.2.3.4') + "\n"
52+
print 'Last Seen: ' + i2p.get_last_seen('1.2.3.4') + "\n"
53+
print 'Threat: ' + i2p.get_threat('1.2.3.4') + "\n"
54+
print 'Provider: ' + i2p.get_provider('1.2.3.4') + "\n"
55+
56+
# single function to get all proxy data returned in array
57+
record = i2p.get_all('1.2.3.4')
58+
print 'is Proxy: ' + record['is_proxy'].to_s + "\n"
59+
print 'Proxy Type: ' + record['proxy_type'] + "\n"
60+
print 'Country Code: ' + record['country_short'] + "\n"
61+
print 'Country Name: ' + record['country_long'] + "\n"
62+
print 'Region Name: ' + record['region'] + "\n"
63+
print 'City Name: ' + record['city'] + "\n"
64+
print 'ISP: ' + record['isp'] + "\n"
65+
print 'Domain: ' + record['domain'] + "\n"
66+
print 'Usage Type: ' + record['usagetype'] + "\n"
67+
print 'ASN: ' + record['asn'] + "\n"
68+
print 'AS: ' + record['as'] + "\n"
69+
print 'Last Seen: ' + record['last_seen'] + "\n"
70+
print 'Threat: ' + record['threat'] + "\n"
71+
print 'Provider: ' + record['provider'] + "\n"
72+
73+
# close IP2Proxy BIN database
74+
i2p.close()
75+
```

0 commit comments

Comments
 (0)