ruby-net-text 0.0.6 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +39 -0
- data/lib/net/finger.rb +39 -0
- data/lib/net/generic.rb +24 -0
- data/lib/net/gopher.rb +39 -0
- metadata +9 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 948586ccc73c2f1c60ae689e9f9a04bdfe7598affd2300501f8490a511f582c3
|
4
|
+
data.tar.gz: 0ae1eb4e3b191ffe5d506f15d981d7cb325479f9cf7fafcc9f7de63e7f13a8fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5bae93436e2d8b7985fe39e26d3bf067713e4fbf46759bc91b641bd6200e9ea8dab676868c8f89a6e89679986ceb2c96f54c7db591e28494e18d7ac5ee0a5343
|
7
|
+
data.tar.gz: 55621ad4d9bf7ea94ab1529e85acac2c279d097234eb85156027ef91fcca466bf90ab8d2cb0e3a312032fdb0248d198da5c8f8cdf11e436e2df88e5d7977758f
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# Gemini, Gopher, and Finger support for Net::* and URI::*
|
2
|
+
|
3
|
+
[![Support using Liberapay](https://img.shields.io/badge/Liberapay-Support_me-yellow?logo=liberapay)](https://liberapay.com/milouse/donate)
|
4
|
+
[![Support using Flattr](https://img.shields.io/badge/Flattr-Support_me-brightgreen?logo=flattr)](https://flattr.com/@milouse)
|
5
|
+
[![Support using Paypal](https://img.shields.io/badge/Paypal-Support_me-00457C?logo=paypal&labelColor=lightgray)](https://paypal.me/milouse)
|
6
|
+
|
7
|
+
[![Gem](https://img.shields.io/gem/v/ruby-net-text)](https://rubygems.org/gems/ruby-net-text)
|
8
|
+
[![Documentation](https://img.shields.io/badge/Documentation-ruby--net--text-CC342D?logo=rubygems)](https://www.rubydoc.info/gems/ruby-net-text/Net/Gemini)
|
9
|
+
|
10
|
+
This project aims to add connectors to well known internet text protocols
|
11
|
+
through the standard `Net::*` and `URI::*` ruby module namespaces.
|
12
|
+
|
13
|
+
## Documentation
|
14
|
+
|
15
|
+
The code is self-documented and you can browse it on rubydoc.info:
|
16
|
+
|
17
|
+
### Gemini
|
18
|
+
|
19
|
+
- [URI::Gemini](https://www.rubydoc.info/gems/ruby-net-text/URI/Gemini)
|
20
|
+
- [Net::Gemini](https://www.rubydoc.info/gems/ruby-net-text/Net/Gemini)
|
21
|
+
|
22
|
+
### Gopher
|
23
|
+
|
24
|
+
- [URI::Gopher](https://www.rubydoc.info/gems/ruby-net-text/URI/Gopher)
|
25
|
+
- [Net::Gopher](https://www.rubydoc.info/gems/ruby-net-text/Net/Gopher)
|
26
|
+
|
27
|
+
### Finger
|
28
|
+
|
29
|
+
- [URI::Finger](https://www.rubydoc.info/gems/ruby-net-text/URI/Finger)
|
30
|
+
- [Net::Finger](https://www.rubydoc.info/gems/ruby-net-text/Net/Finger)
|
31
|
+
|
32
|
+
## Helpers
|
33
|
+
|
34
|
+
This repository also includes 2 little helpers:
|
35
|
+
|
36
|
+
- `bin/heraut`: a toy client for Gemini, Gopher and Finger. Give it a URI and
|
37
|
+
it will output the remote file.
|
38
|
+
- `bin/test_thread.rb`: a toy performance test script to run against a Gemini
|
39
|
+
server
|
data/lib/net/finger.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../uri/finger'
|
4
|
+
require_relative 'generic'
|
5
|
+
|
6
|
+
module Net
|
7
|
+
# == A Finger client API for Ruby.
|
8
|
+
#
|
9
|
+
# Net::Finger provides a library which can be used to build Finger
|
10
|
+
# user-agents.
|
11
|
+
#
|
12
|
+
# Net::Finger is designed to work closely with URI.
|
13
|
+
#
|
14
|
+
# == Simple Examples
|
15
|
+
#
|
16
|
+
# All examples assume you have loaded Net::Finger with:
|
17
|
+
#
|
18
|
+
# require 'net/finger'
|
19
|
+
#
|
20
|
+
# This will also require 'uri' so you don't need to require it
|
21
|
+
# separately.
|
22
|
+
#
|
23
|
+
# The Net::Finger methods in the following section do not persist
|
24
|
+
# connections.
|
25
|
+
#
|
26
|
+
# === GET by URI
|
27
|
+
#
|
28
|
+
# uri = URI('finger://skyjake.fi/jaakko')
|
29
|
+
# Net::Finger.get(uri) # => String
|
30
|
+
#
|
31
|
+
class Finger
|
32
|
+
extend TextGeneric
|
33
|
+
|
34
|
+
def self.get(string_or_uri)
|
35
|
+
uri = build_uri string_or_uri, URI::Finger
|
36
|
+
request uri, uri.name.to_s
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/net/generic.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'socket'
|
4
|
+
|
5
|
+
# Generic interface to be used by specific network protocol implementation.
|
6
|
+
module TextGeneric
|
7
|
+
private
|
8
|
+
|
9
|
+
def build_uri(string_or_uri, uri_class)
|
10
|
+
string_or_uri = URI(string_or_uri) if string_or_uri.is_a?(String)
|
11
|
+
return string_or_uri if string_or_uri.is_a?(uri_class)
|
12
|
+
raise ArgumentError, "uri is not a String, nor an #{uri_class.name}"
|
13
|
+
end
|
14
|
+
|
15
|
+
def request(uri, query)
|
16
|
+
sock = TCPSocket.new(uri.host, uri.port)
|
17
|
+
sock.puts query
|
18
|
+
sock.read
|
19
|
+
ensure
|
20
|
+
# Stop remaining connection, even if they should be already cut
|
21
|
+
# by the server
|
22
|
+
sock&.close
|
23
|
+
end
|
24
|
+
end
|
data/lib/net/gopher.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../uri/gopher'
|
4
|
+
require_relative 'generic'
|
5
|
+
|
6
|
+
module Net
|
7
|
+
# == A Gopher client API for Ruby.
|
8
|
+
#
|
9
|
+
# Net::Gopher provides a library which can be used to build Gopher
|
10
|
+
# user-agents.
|
11
|
+
#
|
12
|
+
# Net::Gopher is designed to work closely with URI.
|
13
|
+
#
|
14
|
+
# == Simple Examples
|
15
|
+
#
|
16
|
+
# All examples assume you have loaded Net::Gopher with:
|
17
|
+
#
|
18
|
+
# require 'net/gopher'
|
19
|
+
#
|
20
|
+
# This will also require 'uri' so you don't need to require it
|
21
|
+
# separately.
|
22
|
+
#
|
23
|
+
# The Net::Gopher methods in the following section do not persist
|
24
|
+
# connections.
|
25
|
+
#
|
26
|
+
# === GET by URI
|
27
|
+
#
|
28
|
+
# uri = URI('gopher://thelambdalab.xyz/1/projects/elpher/')
|
29
|
+
# Net::Gopher.get(uri) # => String
|
30
|
+
#
|
31
|
+
class Gopher
|
32
|
+
extend TextGeneric
|
33
|
+
|
34
|
+
def self.get(string_or_uri)
|
35
|
+
uri = build_uri string_or_uri, URI::Gopher
|
36
|
+
request uri, "#{uri.selector}\r\n"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-net-text
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Étienne Deparis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-04-18 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email: etienne@depar.is
|
@@ -17,12 +17,16 @@ extensions: []
|
|
17
17
|
extra_rdoc_files: []
|
18
18
|
files:
|
19
19
|
- LICENSE
|
20
|
+
- README.md
|
21
|
+
- lib/net/finger.rb
|
20
22
|
- lib/net/gemini.rb
|
21
23
|
- lib/net/gemini/gmi_parser.rb
|
22
24
|
- lib/net/gemini/reflow_text.rb
|
23
25
|
- lib/net/gemini/request.rb
|
24
26
|
- lib/net/gemini/response.rb
|
25
27
|
- lib/net/gemini/ssl.rb
|
28
|
+
- lib/net/generic.rb
|
29
|
+
- lib/net/gopher.rb
|
26
30
|
- lib/uri/finger.rb
|
27
31
|
- lib/uri/gemini.rb
|
28
32
|
- lib/uri/gopher.rb
|
@@ -31,7 +35,8 @@ licenses:
|
|
31
35
|
- MIT
|
32
36
|
metadata:
|
33
37
|
rubygems_mfa_required: 'true'
|
34
|
-
source_code_uri: https://git.umaneti.net/ruby-net-text
|
38
|
+
source_code_uri: https://git.umaneti.net/ruby-net-text/
|
39
|
+
documentation_uri: https://www.rubydoc.info/gems/ruby-net-text
|
35
40
|
funding_uri: https://liberapay.com/milouse
|
36
41
|
post_install_message:
|
37
42
|
rdoc_options: []
|
@@ -48,7 +53,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
48
53
|
- !ruby/object:Gem::Version
|
49
54
|
version: '0'
|
50
55
|
requirements: []
|
51
|
-
rubygems_version: 3.
|
56
|
+
rubygems_version: 3.4.10
|
52
57
|
signing_key:
|
53
58
|
specification_version: 4
|
54
59
|
summary: Gemini, Gopher, and Finger support for Net::* and URI::*
|