Save gem root
This commit is contained in:
parent
2ec012ca31
commit
b85268434d
2 changed files with 13 additions and 3 deletions
|
@ -2,11 +2,12 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
gem_name = 'diversipub'
|
gem_name = 'diversipub'
|
||||||
|
gem_root = File.expand_path('..', __dir__).freeze
|
||||||
|
|
||||||
begin
|
begin
|
||||||
require gem_name
|
require gem_name
|
||||||
rescue LoadError
|
rescue LoadError
|
||||||
lib = File.expand_path('../lib', __dir__).freeze
|
lib = File.join(gem_root, 'lib').freeze
|
||||||
file = File.join lib, "#{gem_name}.rb"
|
file = File.join lib, "#{gem_name}.rb"
|
||||||
$LOAD_PATH.unshift lib if File.file?(file) && !$LOAD_PATH.include?(lib)
|
$LOAD_PATH.unshift lib if File.file?(file) && !$LOAD_PATH.include?(lib)
|
||||||
require gem_name
|
require gem_name
|
||||||
|
@ -56,6 +57,7 @@ $stdout.sync = true
|
||||||
$stderr.sync = true
|
$stderr.sync = true
|
||||||
|
|
||||||
main = Diversipub::Main.new(
|
main = Diversipub::Main.new(
|
||||||
|
gem_root: gem_root,
|
||||||
pwd: Pathname.pwd,
|
pwd: Pathname.pwd,
|
||||||
program_name: $PROGRAM_NAME,
|
program_name: $PROGRAM_NAME,
|
||||||
argv: ARGV,
|
argv: ARGV,
|
||||||
|
|
|
@ -5,15 +5,18 @@ module Diversipub
|
||||||
# The whole application runner.
|
# The whole application runner.
|
||||||
#
|
#
|
||||||
class Main
|
class Main
|
||||||
attr_reader :pwd, :program_name, :argv, :env, :stdin, :stdout, :stderr
|
attr_reader :gem_root, :pwd, :program_name, :argv, :env,
|
||||||
|
:stdin, :stdout, :stderr
|
||||||
|
|
||||||
def initialize(pwd:,
|
def initialize(gem_root:,
|
||||||
|
pwd:,
|
||||||
program_name:,
|
program_name:,
|
||||||
argv:,
|
argv:,
|
||||||
env:,
|
env:,
|
||||||
stdin:,
|
stdin:,
|
||||||
stdout:,
|
stdout:,
|
||||||
stderr:)
|
stderr:)
|
||||||
|
self.gem_root = gem_root
|
||||||
self.pwd = pwd
|
self.pwd = pwd
|
||||||
self.program_name = program_name
|
self.program_name = program_name
|
||||||
self.argv = argv
|
self.argv = argv
|
||||||
|
@ -25,6 +28,7 @@ module Diversipub
|
||||||
end
|
end
|
||||||
|
|
||||||
def run
|
def run
|
||||||
|
p gem_root
|
||||||
p pwd
|
p pwd
|
||||||
p program_name
|
p program_name
|
||||||
p argv
|
p argv
|
||||||
|
@ -51,6 +55,10 @@ module Diversipub
|
||||||
|
|
||||||
attr_writer :stdin, :stdout, :stderr
|
attr_writer :stdin, :stdout, :stderr
|
||||||
|
|
||||||
|
def gem_root=(gem_root)
|
||||||
|
@gem_root = Pathname.new(gem_root).freeze
|
||||||
|
end
|
||||||
|
|
||||||
def pwd=(pwd)
|
def pwd=(pwd)
|
||||||
@pwd = Pathname.new(pwd).freeze
|
@pwd = Pathname.new(pwd).freeze
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue