Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

holman

  • Loading branch information...
commit 1b8b1d0400e8db9360ee59a5f413646e032bb90c 0 parents
@holman authored
Showing with 262 additions and 0 deletions.
  1. +151 −0 Rakefile
  2. +3 −0  bin/holman
  3. +55 −0 holman.gemspec
  4. +53 −0 lib/holman.rb
151 Rakefile
@@ -0,0 +1,151 @@
+require 'rubygems'
+require 'rake'
+require 'date'
+
+#############################################################################
+#
+# Helper functions
+#
+#############################################################################
+
+def name
+ @name ||= Dir['*.gemspec'].first.split('.').first
+end
+
+def version
+ #line = File.read("lib/#{name}.rb")[/^\s*VERSION\s*=\s*.*/]
+ #line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
+ "0.0.1"
+end
+
+def date
+ Date.today.to_s
+end
+
+def rubyforge_project
+ name
+end
+
+def gemspec_file
+ "#{name}.gemspec"
+end
+
+def gem_file
+ "#{name}-#{version}.gem"
+end
+
+def replace_header(head, header_name)
+ head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{send(header_name)}'"}
+end
+
+#############################################################################
+#
+# Standard tasks
+#
+#############################################################################
+
+task :default => :test
+
+require 'rake/testtask'
+Rake::TestTask.new(:test) do |test|
+ test.libs << 'lib' << 'test'
+ test.pattern = 'test/**/test_*.rb'
+ test.verbose = true
+end
+
+desc "Generate RCov test coverage and open in your browser"
+task :coverage do
+ require 'rcov'
+ sh "rm -fr coverage"
+ sh "rcov test/test_*.rb"
+ sh "open coverage/index.html"
+end
+
+require 'rake/rdoctask'
+Rake::RDocTask.new do |rdoc|
+ rdoc.rdoc_dir = 'rdoc'
+ rdoc.title = "#{name} #{version}"
+ rdoc.rdoc_files.include('README*')
+ rdoc.rdoc_files.include('lib/**/*.rb')
+end
+
+desc "Open an irb session preloaded with this library"
+task :console do
+ sh "irb -rubygems -r ./lib/#{name}.rb"
+end
+
+#############################################################################
+#
+# Custom tasks (add your own tasks here)
+#
+#############################################################################
+
+
+
+#############################################################################
+#
+# Packaging tasks
+#
+#############################################################################
+
+desc "Create tag v#{version} and build and push #{gem_file} to Rubygems"
+task :release => :build do
+ unless `git branch` =~ /^\* master$/
+ puts "You must be on the master branch to release!"
+ exit!
+ end
+ #sh "git commit --allow-empty -a -m 'Release #{version}'"
+ #sh "git tag v#{version}"
+ sh "git push origin master"
+ #sh "git push origin v#{version}"
+ sh "gem push pkg/#{name}-#{version}.gem"
+end
+
+desc "Build #{gem_file} into the pkg directory"
+task :build => :gemspec do
+ sh "mkdir -p pkg"
+ sh "gem build #{gemspec_file}"
+ sh "mv #{gem_file} pkg"
+end
+
+desc "Generate #{gemspec_file}"
+task :gemspec => :validate do
+ # read spec file and split out manifest section
+ spec = File.read(gemspec_file)
+ head, manifest, tail = spec.split(" # = MANIFEST =\n")
+
+ # replace name version and date
+ replace_header(head, :name)
+ replace_header(head, :version)
+ replace_header(head, :date)
+ #comment this out if your rubyforge_project has a different name
+ replace_header(head, :rubyforge_project)
+
+ # determine file list from git ls-files
+ files = `git ls-files`.
+ split("\n").
+ sort.
+ reject { |file| file =~ /^\./ }.
+ reject { |file| file =~ /^(rdoc|pkg)/ }.
+ map { |file| " #{file}" }.
+ join("\n")
+
+ # piece file back together and write
+ manifest = " s.files = %w[\n#{files}\n ]\n"
+ spec = [head, manifest, tail].join(" # = MANIFEST =\n")
+ File.open(gemspec_file, 'w') { |io| io.write(spec) }
+ puts "Updated #{gemspec_file}"
+end
+
+desc "Validate #{gemspec_file}"
+task :validate do
+ libfiles = Dir['lib/*'] - ["lib/#{name}.rb", "lib/#{name}"]
+ unless libfiles.empty?
+ puts "Directory `lib` should only contain a `#{name}.rb` file and `#{name}` dir."
+ exit!
+ end
+ unless Dir['VERSION*'].empty?
+ puts "A `VERSION` file at root level violates Gem best practices."
+ exit!
+ end
+end
3  bin/holman
@@ -0,0 +1,3 @@
+#!/usr/bin/env ruby
+$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
+require 'holman'
55 holman.gemspec
@@ -0,0 +1,55 @@
+## This is the rakegem gemspec template. Make sure you read and understand
+## all of the comments. Some sections require modification, and others can
+## be deleted if you don't need them. Once you understand the contents of
+## this file, feel free to delete any comments that begin with two hash marks.
+## You can find comprehensive Gem::Specification documentation, at
+## http://docs.rubygems.org/read/chapter/20
+Gem::Specification.new do |s|
+ s.specification_version = 2 if s.respond_to? :specification_version=
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
+ s.rubygems_version = '1.3.5'
+
+ ## Leave these as is they will be modified for you by the rake gemspec task.
+ ## If your rubyforge_project name is different, then edit it and comment out
+ ## the sub! line in the Rakefile
+ s.name = 'holman'
+ s.version = '0.0.1'
+ s.date = '2011-03-17'
+ s.rubyforge_project = 'holman'
+
+ ## Make sure your summary is short. The description may be as long
+ ## as you like.
+ s.summary = "@holman"
+ s.description = "Holman."
+
+ ## List the primary authors. If there are a bunch of authors, it's probably
+ ## better to set the email to an email list or something. If you don't have
+ ## a custom homepage, consider using your GitHub URL or the like.
+ s.authors = ["Zach Holman"]
+ s.email = 'hello@zachholman.com'
+ s.homepage = 'https://github.com/holman/holman'
+
+ ## This gets added to the $LOAD_PATH so that 'lib/NAME.rb' can be required as
+ ## require 'NAME.rb' or'/lib/NAME/file.rb' can be as require 'NAME/file.rb'
+ s.require_paths = %w[lib]
+
+ ## If your gem includes any executables, list them here.
+ s.executables = ["holman"]
+ s.default_executable = 'holman'
+
+ ## Leave this section as-is. It will be automatically generated from the
+ ## contents of your Git repository via the gemspec task. DO NOT REMOVE
+ ## THE MANIFEST COMMENTS, they are used as delimiters by the task.
+ # = MANIFEST =
+ s.files = %w[
+ Rakefile
+ bin/holman
+ holman.gemspec
+ lib/holman.rb
+ ]
+ # = MANIFEST =
+
+ ## Test files will be grabbed from the file list. Make sure the path glob
+ ## matches what you actually use.
+ s.test_files = s.files.select { |path| path =~ /^test\/test_.*\.rb/ }
+end
53 lib/holman.rb
@@ -0,0 +1,53 @@
+puts "
+ G G L L f f f j j j t t L t i i i i i i t t t t t j f L L L K # # W W
+ G L L f f f j j j t t t j j t j j i i i ; i i t t j j f L L W # # W K
+ L L f f f j j t t t t t D # # # t t j t ; ; i i i t j f f f K # # # E
+ G L f f j j t t j W # # # # # # # # K L t ; ; ; i t j f f f K # # # K
+ E L f f j j j f # # # # # # # # # # # # E i ; i i t j f f f W W # # E
+ L L f j j j D # # # # # # # # # # # # # # t ; ; i t t j f D W # W # K
+ f D j j j K # # # # # # # # # # # # W W E W , ; ; i t j f K W # W # K
+ f f j j K # # # # # # K E W K E K D D D E D L ; i t f G G W W # # K K
+ f f L L # # # # K E f j G f W D D , . . i E W j G D K E D # W # W t D
+ j j L # # # # K K L i , i : t t t . # K L G D W E # W W W i L
+ j t f # # # # W D i : . E G f f L D # # W W W ; t
+ j t L # # # # W i : : . i E t j j j # K W W L ; ;
+ j t K # # W # L : : : : D i t i W # E W W ; ; ;
+ t t D # # # W L , : . i L ; G L G f # # W K W ; , ,
+ t t D # # W K G , : : i f W E j . . f G : : K j t j # # K # t i ; ;
+ i i L # # # # G ; i L E L G L i : . i ; i . # i : j # W W # ; ; ; ;
+ i ; G # # # # t i i t D W # j j . , t ; W t D : ; # W # W i ; ; i
+ i ; K # # # # i i j K t i t ; ; . : . ; : : # W # G ; ; ; i
+ i ; f E # # # i i i ; : ; ; . . : : # K K i i i i t
+ i ; ; j L # K i : . . . . W # E W K K t i i i t
+ t t i t L # W i , . . . K W W K E K t i i t t
+ i ; ; i f i j i : . . . D G # W K G t t t t j
+ t i ; i ; i i t , . . : j E D t t : . . G W W t t t t j
+ j t i ; ; , i t ; , : ; , . . , ; j i : . , G # E f G j j j j j L
+ j t i ; , t t t i ; ; : . : . . f L # K L G f j j j j j
+ j t ; ; , , , t t : ; . : L j i ; ; t f , f G # # f G L j j j L t
+ j i ; ; ; , , t t ; . . . : . . . f L # E L G L f j j j j
+ j i i ; ; , , i t i , , . . . . . . . ; t E # E f G L f f L f f
+ t t i i ; ; , , j i i , ; . . . . . : W D # # W f G L f L t j j
+ j t i ; t # # # L j i ; ; , . . . . . . , i # # # # E K D G W # # G
+ # # # # # # # # # D j i i ; , . . . . . . : . # # # # # # # # # # # #
+ # # # # # # # # # # E G j j i ; : . : : ; : . K # # # # # # # # # # #
+ # # # # # # # # # # G E E f j t i ; ; i t : : L # # # # # # # # # # #
+ # # # # # # # # # # K f L E E D G G f , , , : E # # # # # # # # # # #
+ # # # # # # # # # # # L f f L L f t ; i i , , # # # # # # # # # # # #
+"
+
+puts "
+ __ __
+ | \\ | \\
+ | $$____ ______ | $$ ______ ____ ______ _______
+ | $$ \\ / \\ | $$| \\ \\ | \\ | \\
+ | $$$$$$$\\| $$$$$$\\| $$| $$$$$$\\$$$$\\ \\$$$$$$\\| $$$$$$$\\
+ | $$ | $$| $$ | $$| $$| $$ | $$ | $$ / $$| $$ | $$
+ | $$ | $$| $$__/ $$| $$| $$ | $$ | $$| $$$$$$$| $$ | $$
+ | $$ | $$ \\$$ $$| $$| $$ | $$ | $$ \\$$ $$| $$ | $$
+ \\$$ \\$$ \\$$$$$$ \\$$ \\$$ \\$$ \\$$ \\$$$$$$$ \\$$ \\$$
+"
+
+puts ""
+puts ""
+puts " holman - http://twitter.com/holman - http://zachholman.com "
Please sign in to comment.
Something went wrong with that request. Please try again.