above 0.3.0 → 0.4.0

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: 06f99a9ac81e345a4b7298476432e22a3ea0fb3d74b83009e5635037355f6f8a
4
- data.tar.gz: 7dac2bef090f98497ba0a99e59c6cabe456e2758ec7e979e8eb91a337523f959
3
+ metadata.gz: 9ea955b114b5c26d8b50b4bca80873886cd27120f93b0db78748260aee0d8be0
4
+ data.tar.gz: 3d55ce5bcb54f9e71486c18cd0f75a05d3abf5591b8dc45248b933712ce6dbb5
5
5
  SHA512:
6
- metadata.gz: d60ef771694f50e5791b8aa3a62f01f46531accabbfbcbc7df9dba0df9a09951738dccd1530c145ff470a2736c7392d51a926b2b523a1dc5669bcd30270fbbfc
7
- data.tar.gz: af53e6beffc417e0ce830bee4f80dbd5f1e9d517fad26416d9cf8fe231a83ca6faa927b12fe63437fa5430c56ccc4ba38da910c87526183de5353db0159818d2
6
+ metadata.gz: bc3bdf91d67c17ced435b2d0b40fbe1cbf922771823b97a65e565a75d7b9a7e1c470458702d3862e218eaaeda2fa6a3eaa0b99ef078c2481e2422892e276cc32
7
+ data.tar.gz: 6673f6e8a16c040e37e678cb3b0a12ca7f6effc978d19184f7a6b8c2b43ffceb077bb18148a37c419b1670e48ab4eecc6354859bcab54c02c6517e3eb55804c5
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Above Changelog
2
2
 
3
+ ## 0.4.0 - 6 September 2024
4
+
5
+ - breaking change - add ip address as a separate config value for the TCP listener
6
+ - add a Docker example
7
+ - refactor Config from a class to a module
8
+ - reconfigure Standard
9
+ - dependency updates, remove reek, add logger explicitly (leaving the standard library in 3.4)
10
+
3
11
  ## 0.3.0 - 27 August 2024
4
12
 
5
13
  - minor refactor, but includes the link to the repo from the Gemspec (sigh)
data/bin/above CHANGED
@@ -1,9 +1,10 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
4
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), "..", "lib")
5
5
 
6
- require 'bundler/setup'
7
- require 'above/cli'
6
+ require "bundler"
7
+ require "bundler/setup"
8
+ require "above/cli"
8
9
 
9
10
  Above::CLI.new.start
data/bin/console CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- require 'bundler/setup'
5
- require 'above'
4
+ require "bundler/setup"
5
+ require "above"
6
6
 
7
7
  # You can add fixtures and/or initialization code here to make experimenting
8
8
  # with your gem easier. You can also use a different console, if you like.
@@ -11,5 +11,5 @@ require 'above'
11
11
  # require "pry"
12
12
  # Pry.start
13
13
 
14
- require 'irb'
14
+ require "irb"
15
15
  IRB.start
data/lib/above/cli.rb CHANGED
@@ -4,6 +4,7 @@ require "optparse"
4
4
  require_relative "certs"
5
5
  require_relative "config"
6
6
  require_relative "server"
7
+ require_relative "version"
7
8
 
8
9
  module Above
9
10
  # CLI handled by optparse
@@ -75,8 +76,9 @@ module Above
75
76
  def start_server
76
77
  return unless @options[:server]
77
78
  dir = @options[:dir]
78
- config = Above::Config.new.read_config(dir:)
79
- config.each_pair do |server_name, server_hash|
79
+ Above::Config.init_dir unless dir
80
+ domains = Above::Config.read_config(dir:)
81
+ domains.each_pair do |server_name, server_hash|
80
82
  puts "Starting #{server_name}"
81
83
  server = Above::Server.new(config: server_hash)
82
84
  server.start
data/lib/above/config.rb CHANGED
@@ -7,21 +7,20 @@ require_relative "utils"
7
7
 
8
8
  module Above
9
9
  # Persist & use configuration
10
- class Config
11
- attr_reader :domains
12
-
13
- def self.config_dir
10
+ module Config
11
+ def config_dir
14
12
  File.join(Utils.home_dir, ".config/above")
15
13
  end
16
14
 
17
- def self.domains_dir
15
+ def domains_dir
18
16
  File.join(Config.config_dir, "domains")
19
17
  end
20
18
 
21
- def self.exemplar
19
+ def exemplar
22
20
  {
23
21
  "server" => {
24
22
  "domain" => "localhost",
23
+ "ip" => "0.0.0.0",
25
24
  "max_fibers" => 20,
26
25
  "port" => 1965,
27
26
  "tls_cert" => "/home/above/localhost.crt",
@@ -56,12 +55,8 @@ module Above
56
55
  }
57
56
  end
58
57
 
59
- def initialize
60
- init_dir
61
- end
62
-
63
58
  def init_dir
64
- if !File.exist?(Config.domains_dir)
59
+ unless File.exist?(Config.domains_dir)
65
60
  FileUtils.mkdir_p(Config.domains_dir)
66
61
  File.write(File.join(Config.config_dir, "example.yml"), Config.exemplar.to_yaml)
67
62
  puts "Configuration directory created"
@@ -74,7 +69,7 @@ module Above
74
69
 
75
70
  def read_config(dir: nil)
76
71
  dir ||= Config.domains_dir
77
- files = Dir[File.join(dir, "**/*.yml")]
72
+ files = Dir[File.join(dir, "*.yml")] # not subfolders
78
73
  domains = {}
79
74
  files.each do |file|
80
75
  hash = YAML.safe_load_file(file, permitted_classes: [Hash])
@@ -89,5 +84,7 @@ module Above
89
84
  end
90
85
  domains
91
86
  end
87
+
88
+ module_function :config_dir, :domains_dir, :exemplar, :init_dir, :read_config
92
89
  end
93
90
  end
@@ -60,7 +60,7 @@ module Above
60
60
  end
61
61
 
62
62
  def write(msg)
63
- # Standard library logger doesn't support write but it supports << which actually
63
+ # Standard library logger (to be removed in 3.4) doesn't support write but it supports << which actually
64
64
  # calls to write on the log device without formatting
65
65
  if @logger.respond_to?(:write)
66
66
  @logger.write(msg)
data/lib/above/server.rb CHANGED
@@ -128,7 +128,7 @@ module Above
128
128
  end
129
129
 
130
130
  def tls_server
131
- tcp_server = TCPServer.new(@server_config["domain"], @server_config["port"])
131
+ tcp_server = TCPServer.new(@server_config["ip"], @server_config["port"])
132
132
  ssl_ctx = OpenSSL::SSL::SSLContext.new.tap do |ctx|
133
133
  ctx.key = OpenSSL::PKey::EC.new(
134
134
  File.read(
data/lib/above/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Above
4
- VERSION = "0.3.0"
4
+ VERSION = "0.4.0"
5
5
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: above
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Kreuzer
@@ -35,7 +35,7 @@ cert_chain:
35
35
  YgqTixCwts6cQYIdYNFtJbzKvRNqyviKKxPaum7UWAv6Uy80gxgJ8p+fG81FsxbZ
36
36
  0ULnXrHlhf/CHs550TxRlXalgxBCImGdHzWjhdJeC1dZP3olgNtjO23ywtw=
37
37
  -----END CERTIFICATE-----
38
- date: 2024-08-27 00:00:00.000000000 Z
38
+ date: 2024-09-06 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: async
@@ -51,6 +51,26 @@ dependencies:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
53
  version: '2.15'
54
+ - !ruby/object:Gem::Dependency
55
+ name: logger
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '1.6'
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: 1.6.1
64
+ type: :runtime
65
+ prerelease: false
66
+ version_requirements: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - "~>"
69
+ - !ruby/object:Gem::Version
70
+ version: '1.6'
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: 1.6.1
54
74
  - !ruby/object:Gem::Dependency
55
75
  name: marcel
56
76
  requirement: !ruby/object:Gem::Requirement
metadata.gz.sig CHANGED
Binary file