Add attribute Diversipub::Main#pwd

This commit is contained in:
Alex Kotov 2023-05-03 16:29:58 +04:00
parent fa9e28fd66
commit 6d26cc6e39
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08
3 changed files with 16 additions and 2 deletions

View file

@ -59,6 +59,7 @@ $stdout.sync = true
$stderr.sync = true
main = Diversipub::Main.new(
pwd: Pathname.pwd,
program_name: $PROGRAM_NAME,
argv: ARGV,
env: ENV,

View file

@ -5,6 +5,7 @@
####################
require 'logger'
require 'pathname'
########
# Gems #

View file

@ -5,9 +5,16 @@ module Diversipub
# The whole application runner.
#
class Main
attr_reader :program_name, :argv, :env, :stdin, :stdout, :stderr
attr_reader :pwd, :program_name, :argv, :env, :stdin, :stdout, :stderr
def initialize(program_name:, argv:, env:, stdin:, stdout:, stderr:)
def initialize(pwd:,
program_name:,
argv:,
env:,
stdin:,
stdout:,
stderr:)
self.pwd = pwd
self.program_name = program_name
self.argv = argv
self.env = env
@ -18,6 +25,7 @@ module Diversipub
end
def run
p pwd
p program_name
p argv
p env
@ -40,6 +48,10 @@ module Diversipub
attr_writer :stdin, :stdout, :stderr
def pwd=(pwd)
@pwd = Pathname.new(pwd).freeze
end
def program_name=(program_name)
@program_name = String(program_name).freeze
end