Skip to content

Commit

Permalink
v6.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ahoward committed Jan 24, 2023
1 parent 1836de0 commit 4f002e0
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 35 deletions.
8 changes: 0 additions & 8 deletions Rakefile
@@ -1,4 +1,3 @@
This.rubyforge_project = 'codeforpeople'
This.author = "Ara T. Howard"
This.email = "ara.t.howard@gmail.com"
This.homepage = "https://github.com/ahoward/#{ This.lib }"
Expand Down Expand Up @@ -145,7 +144,6 @@ task :gemspec do
spec.extensions.push(*<%= extensions.inspect %>)
spec.rubyforge_project = <%= This.rubyforge_project.inspect %>
spec.author = <%= This.author.inspect %>
spec.email = <%= This.email.inspect %>
spec.homepage = <%= This.homepage.inspect %>
Expand Down Expand Up @@ -230,12 +228,6 @@ task :release => [:clean, :gemspec, :gem] do
puts
system(cmd)
abort("cmd(#{ cmd }) failed with (#{ $?.inspect })") unless $?.exitstatus.zero?

cmd = "rubyforge login && rubyforge add_release #{ This.rubyforge_project } #{ This.lib } #{ This.version } #{ This.gem }"
puts cmd
puts
system(cmd)
abort("cmd(#{ cmd }) failed with (#{ $?.inspect })") unless $?.exitstatus.zero?
end


Expand Down
10 changes: 5 additions & 5 deletions lib/main.rb
@@ -1,7 +1,7 @@
module Main
# top level constants
#
Main::VERSION = '6.2.3' unless
Main::VERSION = '6.3.0' unless
defined? Main::VERSION
def Main.version() Main::VERSION end

Expand All @@ -21,10 +21,10 @@ def Main.description
#
def Main.dependencies
{
'chronic' => [ 'chronic', '~> 0.6', '>= 0.6.2' ] ,
'fattr' => [ 'fattr', '~> 2.2', '>= 2.2.0' ] ,
'arrayfields' => [ 'arrayfields', '~> 4.7', '>= 4.7.4' ] ,
'map' => [ 'map', '~> 6.1', '>= 6.1.0' ] ,
'chronic' => [ 'chronic', '~> 0.10', '>= 0.10.2' ] ,
'fattr' => [ 'fattr', '~> 2.4', '>= 2.4.0' ] ,
'arrayfields' => [ 'arrayfields', '~> 4.9', '>= 4.9.2' ] ,
'map' => [ 'map', '~> 6.6', '>= 6.6.0' ] ,
}
end

Expand Down
13 changes: 13 additions & 0 deletions lib/main/program/class_methods.rb
Expand Up @@ -71,13 +71,17 @@ def build(*args, &block)
define_method(:run, &block) if block
wrap_run!
end

program
end

end

def new()
instance = allocate

setup_finalizers(instance)

instance.instance_eval do
pre_initialize()
before_initialize()
Expand All @@ -86,9 +90,18 @@ def new()
after_initialize()
post_initialize()
end

instance
end

def setup_finalizers(instance)
instance.finalizers = (finalizers = [])

ObjectSpace.define_finalizer(instance) do
while((f = finalizers.pop)); f.call; end
end
end

def params
parameters
end
Expand Down
25 changes: 9 additions & 16 deletions lib/main/program/instance_methods.rb
Expand Up @@ -12,8 +12,8 @@ module InstanceMethods
fattr('stderr'){ main.stderr }
fattr('logger'){ main.logger }
fattr('script'){ main.script }
fattr('params')
fattr('finalizers')
fattr('params'){ Parameter::Table.new }
fattr('finalizers'){ [] }

%w(
program name synopsis description author version
Expand Down Expand Up @@ -51,16 +51,11 @@ def after_initialize() :hook end
def post_initialize() :hook end

def setup_finalizers
@finalizers ||= []
finalizers = @finalizers
ObjectSpace.define_finalizer(self) do
while((f = finalizers.pop)); f.call; end
end
self.class.setup_finalizers(self)
end

def finalize
@finalizers ||= []
while((f = @finalizers.pop)); f.call; end
while((f = finalizers.pop)); f.call; end
end

def setup_io_redirection
Expand Down Expand Up @@ -92,10 +87,9 @@ def logger= log
end

def setup_io_restoration
@finalizers ||= []
[STDIN, STDOUT, STDERR].each do |io|
dup = io.dup
@finalizers.push(
finalizers.push(
lambda do
io.reopen(dup)
end
Expand All @@ -111,7 +105,7 @@ def stdin= io
io
else
fd = open(io.to_s, 'r+')
@finalizers.push(lambda{ fd.close })
finalizers.push(lambda{ fd.close })
fd
end
begin
Expand All @@ -132,7 +126,7 @@ def stdout= io
io
else
fd = open(io.to_s, 'w+')
@finalizers.push(lambda{ fd.close })
finalizers.push(lambda{ fd.close })
fd
end
begin
Expand All @@ -153,7 +147,7 @@ def stderr= io
io
else
fd = open(io.to_s, 'w+')
@finalizers.push(lambda{ fd.close })
finalizers.push(lambda{ fd.close })
fd
end
begin
Expand All @@ -173,8 +167,7 @@ def parse_parameters
before_parse_parameters

self.class.parameters.parse(self)
@params = Parameter::Table.new
self.class.parameters.each{|p| @params[p.name.to_s] = p}
self.class.parameters.each{|p| params[p.name.to_s] = p}

after_parse_parameters
post_parse_parameters
Expand Down
11 changes: 5 additions & 6 deletions main.gemspec
Expand Up @@ -3,7 +3,7 @@

Gem::Specification::new do |spec|
spec.name = "main"
spec.version = "6.2.3"
spec.version = "6.3.0"
spec.platform = Gem::Platform::RUBY
spec.summary = "main"
spec.description = "a class factory and dsl for generating command line programs real quick"
Expand Down Expand Up @@ -55,18 +55,17 @@ Gem::Specification::new do |spec|
spec.test_files = nil


spec.add_dependency(*["chronic", "~> 0.6", ">= 0.6.2"])
spec.add_dependency(*["chronic", "~> 0.10", ">= 0.10.2"])

spec.add_dependency(*["fattr", "~> 2.2", ">= 2.2.0"])
spec.add_dependency(*["fattr", "~> 2.4", ">= 2.4.0"])

spec.add_dependency(*["arrayfields", "~> 4.7", ">= 4.7.4"])
spec.add_dependency(*["arrayfields", "~> 4.9", ">= 4.9.2"])

spec.add_dependency(*["map", "~> 6.1", ">= 6.1.0"])
spec.add_dependency(*["map", "~> 6.6", ">= 6.6.0"])


spec.extensions.push(*[])

spec.rubyforge_project = "codeforpeople"
spec.author = "Ara T. Howard"
spec.email = "ara.t.howard@gmail.com"
spec.homepage = "https://github.com/ahoward/main"
Expand Down

0 comments on commit 4f002e0

Please sign in to comment.