Permalink
Browse files

v1.3.1

  • Loading branch information...
1 parent 62bb76e commit 8aa094f8c906a9715059d2423dba41e54eaf0cdb @ahoward committed Jun 20, 2011
Showing with 199 additions and 49 deletions.
  1. +170 −40 Rakefile
  2. +28 −8 configuration.gemspec
  3. +1 −1 lib/configuration.rb
View
@@ -1,23 +1,66 @@
+This.rubyforge_project = 'codeforpeople'
This.author = "Ara T. Howard"
This.email = "ara.t.howard@gmail.com"
-This.homepage = "http://github.com/ahoward/#{ This.lib }/tree/master"
-This.rubyforge_project = 'codeforpeople'
+This.homepage = "https://github.com/ahoward/#{ This.lib }"
+
task :default do
- puts(Rake::Task.tasks.map{|task| task.name} - ['default'])
+ puts((Rake::Task.tasks.map{|task| task.name.gsub(/::/,':')} - ['default']).sort)
+end
+
+task :test do
+ run_tests!
+end
+
+namespace :test do
+ task(:unit){ run_tests!(:unit) }
+ task(:functional){ run_tests!(:functional) }
+ task(:integration){ run_tests!(:integration) }
end
-task :spec do
- require 'spec/rake/spectask'
- Spec::Rake::SpecTask.new do |t|
- t.spec_files = FileList['spec/*_spec.rb']
+def run_tests!(which = nil)
+ which ||= '**'
+ test_dir = File.join(This.dir, "test")
+ test_glob ||= File.join(test_dir, "#{ which }/**_test.rb")
+ test_rbs = Dir.glob(test_glob).sort
+
+ div = ('=' * 119)
+ line = ('-' * 119)
+
+ test_rbs.each_with_index do |test_rb, index|
+ testno = index + 1
+ command = "#{ This.ruby } -I ./lib -I ./test/lib #{ test_rb }"
+
+ puts
+ say(div, :color => :cyan, :bold => true)
+ say("@#{ testno } => ", :bold => true, :method => :print)
+ say(command, :color => :cyan, :bold => true)
+ say(line, :color => :cyan, :bold => true)
+
+ system(command)
+
+ say(line, :color => :cyan, :bold => true)
+
+ status = $?.exitstatus
+
+ if status.zero?
+ say("@#{ testno } <= ", :bold => true, :color => :white, :method => :print)
+ say("SUCCESS", :color => :green, :bold => true)
+ else
+ say("@#{ testno } <= ", :bold => true, :color => :white, :method => :print)
+ say("FAILURE", :color => :red, :bold => true)
+ end
+ say(line, :color => :cyan, :bold => true)
+
+ exit(status) unless status.zero?
end
end
+
task :gemspec do
- ignore_extensions = 'git', 'svn', 'tmp', /sw./, 'bak', 'gem'
- ignore_directories = 'pkg'
- ignore_files = 'test/log'
+ ignore_extensions = ['git', 'svn', 'tmp', /sw./, 'bak', 'gem']
+ ignore_directories = ['pkg']
+ ignore_files = ['test/log']
shiteless =
lambda do |list|
@@ -39,14 +82,18 @@ task :gemspec do
end
lib = This.lib
+ object = This.object
version = This.version
files = shiteless[Dir::glob("**/**")]
executables = shiteless[Dir::glob("bin/*")].map{|exe| File.basename(exe)}
- has_rdoc = true #File.exist?('doc')
+ #has_rdoc = true #File.exist?('doc')
test_files = "test/#{ lib }.rb" if File.file?("test/#{ lib }.rb")
+ summary = object.respond_to?(:summary) ? object.summary : "summary: #{ lib } kicks the ass"
+ description = object.respond_to?(:description) ? object.description : "description: #{ lib } kicks the ass"
- extensions = This.extensions
- if extensions.nil?
+ if This.extensions.nil?
+ This.extensions = []
+ extensions = This.extensions
%w( Makefile configure extconf.rb ).each do |ext|
extensions << ext if File.exists?(ext)
end
@@ -67,18 +114,17 @@ task :gemspec do
spec.version = #{ version.inspect }
spec.platform = Gem::Platform::RUBY
spec.summary = #{ lib.inspect }
+ spec.description = #{ description.inspect }
- spec.files = #{ files.inspect }
+ spec.files =\n#{ files.sort.pretty_inspect }
spec.executables = #{ executables.inspect }
- <% if test(?d, 'lib') %>
spec.require_path = "lib"
- <% end %>
- spec.has_rdoc = #{ has_rdoc.inspect }
spec.test_files = #{ test_files.inspect }
- #spec.add_dependency 'lib', '>= version'
- #spec.add_dependency 'fattr'
+
+ ### spec.add_dependency 'lib', '>= version'
+ #### spec.add_dependency 'map'
spec.extensions.push(*#{ extensions.inspect })
@@ -91,19 +137,21 @@ task :gemspec do
}
end
- open("#{ lib }.gemspec", "w"){|fd| fd.puts template}
- This.gemspec = "#{ lib }.gemspec"
+ Fu.mkdir_p(This.pkgdir)
+ gemspec = "#{ lib }.gemspec"
+ open(gemspec, "w"){|fd| fd.puts(template)}
+ This.gemspec = gemspec
end
task :gem => [:clean, :gemspec] do
- Fu.mkdir_p This.pkgdir
+ Fu.mkdir_p(This.pkgdir)
before = Dir['*.gem']
cmd = "gem build #{ This.gemspec }"
`#{ cmd }`
after = Dir['*.gem']
gem = ((after - before).first || after.first) or abort('no gem!')
- Fu.mv gem, This.pkgdir
- This.gem = File.basename(gem)
+ Fu.mv(gem, This.pkgdir)
+ This.gem = File.join(This.pkgdir, File.basename(gem))
end
task :readme do
@@ -122,7 +170,7 @@ task :readme do
cmd = "ruby #{ sample }"
samples << Util.indent(prompt + cmd, 2) << "\n\n"
- cmd = "ruby -e'STDOUT.sync=true; exec %(ruby -Ilib -Iconfig #{ sample })'"
+ cmd = "ruby -e'STDOUT.sync=true; exec %(ruby -I ./lib #{ sample })'"
samples << Util.indent(`#{ cmd } 2>&1`, 4) << "\n"
end
@@ -159,54 +207,82 @@ task :release => [:clean, :gemspec, :gem] do
gems = Dir[File.join(This.pkgdir, '*.gem')].flatten
raise "which one? : #{ gems.inspect }" if gems.size > 1
raise "no gems?" if gems.size < 1
- cmd = "rubyforge login && rubyforge add_release #{ This.rubyforge_project } #{ This.lib } #{ This.version } #{ This.pkgdir }/#{ This.gem }"
+
+ cmd = "gem push #{ This.gem }"
+ puts cmd
+ 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
- system cmd
+ puts
+ system(cmd)
+ abort("cmd(#{ cmd }) failed with (#{ $?.inspect })") unless $?.exitstatus.zero?
end
BEGIN {
+# support for this rakefile
+#
$VERBOSE = nil
require 'ostruct'
require 'erb'
require 'fileutils'
+ require 'rbconfig'
+ require 'pp'
+# fu shortcut
+#
Fu = FileUtils
+# cache a bunch of stuff about this rakefile/environment
+#
This = OpenStruct.new
This.file = File.expand_path(__FILE__)
This.dir = File.dirname(This.file)
This.pkgdir = File.join(This.dir, 'pkg')
+# grok lib
+#
lib = ENV['LIB']
unless lib
- lib = File.basename(Dir.pwd)
+ lib = File.basename(Dir.pwd).sub(/[-].*$/, '')
end
This.lib = lib
+# grok version
+#
version = ENV['VERSION']
unless version
- name = lib.capitalize
- library = "./lib/#{ lib }.rb"
- program = "./bin/#{ lib }"
- if test(?e, library)
- require library
- version = eval(name).send(:version)
- elsif test(?e, program)
- version = `#{ program } --version`.strip
- end
- abort('no version') if(version.nil? or version.empty?)
+ require "./lib/#{ This.lib }"
+ This.name = lib.capitalize
+ This.object = eval(This.name)
+ version = This.object.send(:version)
end
This.version = version
+# we need to know the name of the lib an it's version
+#
abort('no lib') unless This.lib
abort('no version') unless This.version
+# discover full path to this ruby executable
+#
+ c = Config::CONFIG
+ bindir = c["bindir"] || c['BINDIR']
+ ruby_install_name = c['ruby_install_name'] || c['RUBY_INSTALL_NAME'] || 'ruby'
+ ruby_ext = c['EXEEXT'] || ''
+ ruby = File.join(bindir, (ruby_install_name + ruby_ext))
+ This.ruby = ruby
+
+# some utils
+#
module Util
def indent(s, n = 2)
s = unindent(s)
@@ -216,7 +292,7 @@ BEGIN {
def unindent(s)
indent = nil
- s.each do |line|
+ s.each_line do |line|
next if line =~ %r/^\s*$/
indent = line[%r/^\s*/] and break
end
@@ -225,17 +301,71 @@ BEGIN {
extend self
end
+# template support
+#
class Template
def initialize(&block)
@block = block
@template = block.call.to_s
end
def expand(b=nil)
- ERB.new(Util.unindent(@template)).result(b||@block)
+ ERB.new(Util.unindent(@template)).result((b||@block).binding)
end
alias_method 'to_s', 'expand'
end
def Template(*args, &block) Template.new(*args, &block) end
+# colored console output support
+#
+ This.ansi = {
+ :clear => "\e[0m",
+ :reset => "\e[0m",
+ :erase_line => "\e[K",
+ :erase_char => "\e[P",
+ :bold => "\e[1m",
+ :dark => "\e[2m",
+ :underline => "\e[4m",
+ :underscore => "\e[4m",
+ :blink => "\e[5m",
+ :reverse => "\e[7m",
+ :concealed => "\e[8m",
+ :black => "\e[30m",
+ :red => "\e[31m",
+ :green => "\e[32m",
+ :yellow => "\e[33m",
+ :blue => "\e[34m",
+ :magenta => "\e[35m",
+ :cyan => "\e[36m",
+ :white => "\e[37m",
+ :on_black => "\e[40m",
+ :on_red => "\e[41m",
+ :on_green => "\e[42m",
+ :on_yellow => "\e[43m",
+ :on_blue => "\e[44m",
+ :on_magenta => "\e[45m",
+ :on_cyan => "\e[46m",
+ :on_white => "\e[47m"
+ }
+ def say(phrase, *args)
+ options = args.last.is_a?(Hash) ? args.pop : {}
+ options[:color] = args.shift.to_s.to_sym unless args.empty?
+ keys = options.keys
+ keys.each{|key| options[key.to_s.to_sym] = options.delete(key)}
+
+ color = options[:color]
+ bold = options.has_key?(:bold)
+
+ parts = [phrase]
+ parts.unshift(This.ansi[color]) if color
+ parts.unshift(This.ansi[:bold]) if bold
+ parts.push(This.ansi[:clear]) if parts.size > 1
+
+ method = options[:method] || :puts
+
+ Kernel.send(method, parts.join)
+ end
+
+# always run out of the project dir
+#
Dir.chdir(This.dir)
}
View
@@ -3,26 +3,46 @@
Gem::Specification::new do |spec|
spec.name = "configuration"
- spec.version = "1.3.0"
+ spec.version = "1.3.1"
spec.platform = Gem::Platform::RUBY
spec.summary = "configuration"
+ spec.description = "description: configuration kicks the ass"
+
+ spec.files =
+["LICENSE",
+ "README.rdoc",
+ "Rakefile",
+ "config",
+ "config/a.rb",
+ "config/b.rb",
+ "config/c.rb",
+ "config/d.rb",
+ "config/e.rb",
+ "config/f.rb",
+ "configuration.gemspec",
+ "lib",
+ "lib/configuration.rb",
+ "samples",
+ "samples/a.rb",
+ "samples/b.rb",
+ "samples/c.rb",
+ "samples/d.rb",
+ "samples/e.rb",
+ "samples/f.rb"]
- spec.files = ["config", "config/a.rb", "config/b.rb", "config/c.rb", "config/d.rb", "config/e.rb", "config/f.rb", "configuration.gemspec", "lib", "lib/configuration.rb", "LICENSE", "Rakefile", "README.rdoc", "samples", "samples/a.rb", "samples/b.rb", "samples/c.rb", "samples/d.rb", "samples/e.rb", "samples/f.rb"]
spec.executables = []
-
spec.require_path = "lib"
-
- spec.has_rdoc = true
spec.test_files = nil
- #spec.add_dependency 'lib', '>= version'
- #spec.add_dependency 'fattr'
+
+### spec.add_dependency 'lib', '>= version'
+#### spec.add_dependency 'map'
spec.extensions.push(*[])
spec.rubyforge_project = "codeforpeople"
spec.author = "Ara T. Howard"
spec.email = "ara.t.howard@gmail.com"
- spec.homepage = "http://github.com/ahoward/configuration/tree/master"
+ spec.homepage = "https://github.com/ahoward/configuration"
end
@@ -1,5 +1,5 @@
class Configuration
- Configuration::Version = '1.3.0'
+ Configuration::Version = '1.3.1'
def Configuration.version() Configuration::Version end
Path = [

0 comments on commit 8aa094f

Please sign in to comment.