ruby-net-text 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c547f919d21a6cb162b2e56553a4c7d7a935d8823036bbb97ae249417be0e1ae
4
- data.tar.gz: 754907558f7a4db368b7f7cd7001bd5550dde2bb798804ee133dfee433945594
3
+ metadata.gz: de26ac5c1f8127c9d08a5430adc0cff34d266847327c6864baa903b5352ac041
4
+ data.tar.gz: d2725dab71f60b4d12be9ff0d948ae1a3f1bc6de9858499258aeedc11c801ae0
5
5
  SHA512:
6
- metadata.gz: '079107d052b63ac01d47b648966b875b7150d20db1787411f671ad5cf0fd911ded1924e9300885a0a17dea342d884482b2b4132c1b7ffdc9adb1417ecfead74a'
7
- data.tar.gz: f2894b7e387968c2d0c3f1f7a00bceb18b78351f0aa392dc53b350badccb6e5a5c17ebfb150679537cb4be344b19ca98f1c9c9ce3ecaf6b4fea2146d761eb307
6
+ metadata.gz: 79defc399e2b1e1631e153c5994ef1547d0eb9732f0153a641ba9dbf98d35ea03c176723b7bb7052ac08a61b2069eac37e158d04e213dd4c778ecb0c39af00b4
7
+ data.tar.gz: 050fecb1c2fda499404207e5cb3d49048ff5fcb9695497f35b257dc40c02e3e71ba648ffe575e044a57e282ac43f62590d147c65404005427ae8bfeeb66848d9
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
@@ -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.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Étienne Deparis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-20 00:00:00.000000000 Z
11
+ date: 2022-02-22 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.2.32
56
+ rubygems_version: 3.3.7
52
57
  signing_key:
53
58
  specification_version: 4
54
59
  summary: Gemini, Gopher, and Finger support for Net::* and URI::*