Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

update deps and Rakefile. release 4.7.2

  • Loading branch information...
commit 2adb4ec15780128652a530942477bdf60dd1d05a 1 parent 9f52348
@ahoward authored
Showing with 164 additions and 44 deletions.
  1. +36 −20 Rakefile
  2. +55 −24 lib/main.rb
  3. +73 −0 main.gemspec
View
56 Rakefile
@@ -3,9 +3,6 @@ This.author = "Ara T. Howard"
This.email = "ara.t.howard@gmail.com"
This.homepage = "https://github.com/ahoward/#{ This.lib }"
-task :license do
- open('LICENSE', 'w'){|fd| fd.puts "same as ruby's"}
-end
task :default do
puts((Rake::Task.tasks.map{|task| task.name.gsub(/::/,':')} - ['default']).sort)
@@ -63,7 +60,7 @@ end
task :gemspec do
ignore_extensions = ['git', 'svn', 'tmp', /sw./, 'bak', 'gem']
ignore_directories = ['pkg']
- ignore_files = ['test/log', 'a.rb']
+ ignore_files = ['test/log']
shiteless =
lambda do |list|
@@ -90,7 +87,7 @@ task :gemspec do
files = shiteless[Dir::glob("**/**")]
executables = shiteless[Dir::glob("bin/*")].map{|exe| File.basename(exe)}
#has_rdoc = true #File.exist?('doc')
- test_files = "test/#{ lib }.rb" if File.file?("test/#{ lib }.rb")
+ test_files = test(?e, "test/#{ lib }.rb") ? "test/#{ lib }.rb" : nil
summary = object.respond_to?(:summary) ? object.summary : "summary: #{ lib } kicks the ass"
description = object.respond_to?(:description) ? object.description : "description: #{ lib } kicks the ass"
@@ -103,38 +100,51 @@ task :gemspec do
end
extensions = [extensions].flatten.compact
+# TODO
+ if This.dependencies.nil?
+ dependencies = []
+ else
+ case This.dependencies
+ when Hash
+ dependencies = This.dependencies.values
+ when Array
+ dependencies = This.dependencies
+ end
+ end
+
template =
if test(?e, 'gemspec.erb')
Template{ IO.read('gemspec.erb') }
else
Template {
<<-__
- ## #{ lib }.gemspec
+ ## <%= lib %>.gemspec
#
Gem::Specification::new do |spec|
- spec.name = #{ lib.inspect }
- spec.version = #{ version.inspect }
+ spec.name = <%= lib.inspect %>
+ spec.version = <%= version.inspect %>
spec.platform = Gem::Platform::RUBY
- spec.summary = #{ lib.inspect }
- spec.description = #{ description.inspect }
+ spec.summary = <%= lib.inspect %>
+ spec.description = <%= description.inspect %>
- spec.files =\n#{ files.sort.pretty_inspect }
- spec.executables = #{ executables.inspect }
+ spec.files =\n<%= files.sort.pretty_inspect %>
+ spec.executables = <%= executables.inspect %>
spec.require_path = "lib"
- spec.test_files = #{ test_files.inspect }
+ spec.test_files = <%= test_files.inspect %>
- ### spec.add_dependency 'lib', '>= version'
- #### spec.add_dependency 'map'
+ <% dependencies.each do |lib_version| %>
+ spec.add_dependency(*<%= Array(lib_version).flatten.inspect %>)
+ <% end %>
- spec.extensions.push(*#{ extensions.inspect })
+ 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 }
+ spec.rubyforge_project = <%= This.rubyforge_project.inspect %>
+ spec.author = <%= This.author.inspect %>
+ spec.email = <%= This.email.inspect %>
+ spec.homepage = <%= This.homepage.inspect %>
end
__
}
@@ -270,6 +280,12 @@ BEGIN {
end
This.version = version
+# see if dependencies are export by the module
+#
+ if This.object.respond_to?(:dependencies)
+ This.dependencies = This.object.dependencies
+ end
+
# we need to know the name of the lib an it's version
#
abort('no lib') unless This.lib
View
79 lib/main.rb
@@ -1,8 +1,7 @@
module Main
-#
# top level constants
#
- Main::VERSION = '4.7.1' unless
+ Main::VERSION = '4.7.2' unless
defined? Main::VERSION
def self.version() Main::VERSION end
@@ -14,7 +13,41 @@ def self.libdir() Main::LIBDIR end
Main::EXIT_FAILURE = 1 unless defined? Main::EXIT_FAILURE
Main::EXIT_WARN = 42 unless defined? Main::EXIT_WARN
Main::EXIT_WARNING = 42 unless defined? Main::EXIT_WARNING
+
+## deps
#
+ def Main.dependencies
+ {
+ 'chronic' => [ 'chronic' , '~> 0.6.2' ] ,
+ 'fattr' => [ 'fattr' , '~> 2.2.0' ] ,
+ 'arrayfields' => [ 'arrayfields' , '~> 4.7.4' ] ,
+ 'map' => [ 'map' , '~> 4.3.0' ]
+ }
+ end
+
+ def Main.libdir(*args, &block)
+ @libdir ||= File.expand_path(__FILE__).sub(/\.rb$/,'')
+ args.empty? ? @libdir : File.join(@libdir, *args)
+ ensure
+ if block
+ begin
+ $LOAD_PATH.unshift(@libdir)
+ block.call()
+ ensure
+ $LOAD_PATH.shift()
+ end
+ end
+ end
+
+ def Main.load(*libs)
+ libs = libs.join(' ').scan(/[^\s+]+/)
+ Main.libdir{ libs.each{|lib| Kernel.load(lib) } }
+ end
+end
+
+
+
+
# built-in
#
require 'logger'
@@ -23,7 +56,7 @@ def self.libdir() Main::LIBDIR end
require 'uri'
require 'time'
require 'date'
-#
+
# use gems to pick up dependancies
#
begin
@@ -32,27 +65,25 @@ def self.libdir() Main::LIBDIR end
42
end
- begin
- require 'chronic'
- rescue LoadError
- 42
+ if defined?(gem)
+ Main.dependencies.each do |lib, dependency|
+ gem(*dependency)
+ require(lib)
+ end
end
-
- require 'fattr'
- require 'arrayfields'
- require 'map'
-#
+
# main's own libs
#
- require libdir + 'stdext'
- require libdir + 'softspoken'
- require libdir + 'util'
- require libdir + 'logger'
- require libdir + 'usage'
- require libdir + 'cast'
- require libdir + 'parameter'
- require libdir + 'getoptlong'
- require libdir + 'mode'
- require libdir + 'program'
- require libdir + 'factories'
-end
+ Main.load %w[
+ stdext.rb
+ softspoken.rb
+ util.rb
+ logger.rb
+ usage.rb
+ cast.rb
+ parameter.rb
+ getoptlong.rb
+ mode.rb
+ program.rb
+ factories.rb
+ ]
View
73 main.gemspec
@@ -0,0 +1,73 @@
+## main.gemspec
+#
+
+Gem::Specification::new do |spec|
+ spec.name = "main"
+ spec.version = "4.7.2"
+ spec.platform = Gem::Platform::RUBY
+ spec.summary = "main"
+ spec.description = "description: main kicks the ass"
+
+ spec.files =
+["LICENSE",
+ "README",
+ "README.erb",
+ "Rakefile",
+ "TODO",
+ "a.rb",
+ "lib",
+ "lib/main",
+ "lib/main.rb",
+ "lib/main/cast.rb",
+ "lib/main/dsl.rb",
+ "lib/main/factories.rb",
+ "lib/main/getoptlong.rb",
+ "lib/main/logger.rb",
+ "lib/main/mode.rb",
+ "lib/main/parameter.rb",
+ "lib/main/program",
+ "lib/main/program.rb",
+ "lib/main/program/class_methods.rb",
+ "lib/main/program/instance_methods.rb",
+ "lib/main/softspoken.rb",
+ "lib/main/stdext.rb",
+ "lib/main/test.rb",
+ "lib/main/usage.rb",
+ "lib/main/util.rb",
+ "main.gemspec",
+ "samples",
+ "samples/a.rb",
+ "samples/b.rb",
+ "samples/c.rb",
+ "samples/d.rb",
+ "samples/e.rb",
+ "samples/f.rb",
+ "samples/g.rb",
+ "samples/h.rb",
+ "samples/j.rb",
+ "test",
+ "test/main_test.rb"]
+
+ spec.executables = []
+
+ spec.require_path = "lib"
+
+ spec.test_files = nil
+
+
+ spec.add_dependency(*["fattr", "~> 2.2.0"])
+
+ spec.add_dependency(*["map", "~> 4.3.0"])
+
+ spec.add_dependency(*["arrayfields", "~> 4.7.4"])
+
+ spec.add_dependency(*["chronic", "~> 0.3.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"
+end
Please sign in to comment.
Something went wrong with that request. Please try again.