diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..569415f --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +.DS_Store +*.gem +coverage +pkg +tmp \ No newline at end of file diff --git a/MIT-LICENSE b/MIT-LICENSE new file mode 100644 index 0000000..92cb2aa --- /dev/null +++ b/MIT-LICENSE @@ -0,0 +1,18 @@ +Copyright (c) 2009 Winton Welsh + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.markdown b/README.markdown new file mode 100644 index 0000000..8a7d719 --- /dev/null +++ b/README.markdown @@ -0,0 +1,18 @@ +GemTemplate +=========== + +A gem template for new projects. + +Setup +----- + +
+git clone git://github.com/winton/gem_template.git my_project
+cd my_project
+rake setup
+git remote add origin git@github.com:winton/my_project.git
+
+ +A project wide find-replace occurs on file names and contents. + +Edit gemspec.rb and MIT-LICENSE, and your project is ready for its first commit. \ No newline at end of file diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..48b3814 --- /dev/null +++ b/Rakefile @@ -0,0 +1,54 @@ +require 'rubygems' +require 'rake' +require 'rake/gempackagetask' +require 'spec/rake/spectask' +require 'gemspec' + +desc "Generate gemspec" +task :gemspec do + File.open("#{Dir.pwd}/#{GEM_NAME}.gemspec", 'w') do |f| + f.write(GEM_SPEC.to_ruby) + end +end + +desc "Install gem" +task :install do + Rake::Task['gem'].invoke + `sudo gem uninstall #{GEM_NAME} -x` + `sudo gem install pkg/#{GEM_NAME}*.gem` + `rm -Rf pkg` +end + +desc "Package gem" +Rake::GemPackageTask.new(GEM_SPEC) do |pkg| + pkg.gem_spec = GEM_SPEC +end + +desc "Setup project" +task :setup do + name = File.basename(Dir.pwd) + `rm -Rf .git` + begin + dir = Dir['**/gem_template*'] + from = dir.pop + if from + rb = from.include?('.rb') + to = File.dirname(from) + "/#{name}#{'.rb' if rb}" + FileUtils.mv(from, to) + end + end while dir.length > 0 + Dir["**/*"].each do |path| + next if path.include?('Rakefile') + if File.file?(path) + `sed -i "" 's/gem_template/#{name}/g' #{path}` + end + end + `git init` +end + +desc "Run specs" +Spec::Rake::SpecTask.new do |t| + t.rcov = true + t.spec_opts = ["--format", "specdoc", "--colour"] + t.spec_files = FileList["spec/**/*_spec.rb"] +end \ No newline at end of file diff --git a/bin/gem_template b/bin/gem_template new file mode 100644 index 0000000..2ab65da --- /dev/null +++ b/bin/gem_template @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby + +$:.push File.expand_path("#{File.dirname(__FILE__)}/../lib") +require 'gem_template' diff --git a/gemspec.rb b/gemspec.rb new file mode 100644 index 0000000..76aafc7 --- /dev/null +++ b/gemspec.rb @@ -0,0 +1,19 @@ +GEM_NAME = 'gem_template' +GEM_FILES = FileList['**/*'] - FileList['coverage', 'coverage/**/*', 'pkg', 'pkg/**/*'] +GEM_SPEC = Gem::Specification.new do |s| + # == CONFIGURE == + s.author = "Winton Welsh" + s.email = "mail@wintoni.us" + s.homepage = "http://github.com/winton/#{GEM_NAME}" + s.summary = "" + # == CONFIGURE == + s.executables << GEM_NAME + s.extensions << "install" + s.extra_rdoc_files = [ "README.markdown" ] + s.files = GEM_FILES.to_a + s.has_rdoc = false + s.name = GEM_NAME + s.platform = Gem::Platform::RUBY + s.require_path = "lib" + s.version = "0.1.0" +end \ No newline at end of file diff --git a/install b/install new file mode 100644 index 0000000..a723b9e --- /dev/null +++ b/install @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby + +$:.push File.expand_path("#{File.dirname(__FILE__)}/lib") +require 'gem_template' diff --git a/lib/gem_template.rb b/lib/gem_template.rb new file mode 100644 index 0000000..159ba63 --- /dev/null +++ b/lib/gem_template.rb @@ -0,0 +1 @@ +require File.dirname(__FILE__) + "/gem_template/gem_template" diff --git a/lib/gem_template/gem_template.rb b/lib/gem_template/gem_template.rb new file mode 100644 index 0000000..e69de29 diff --git a/spec/spec.opts b/spec/spec.opts new file mode 100644 index 0000000..4e1e0d2 --- /dev/null +++ b/spec/spec.opts @@ -0,0 +1 @@ +--color diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..570449e --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,16 @@ +$TESTING=true +SPEC = File.dirname(__FILE__) +$:.unshift File.expand_path("#{SPEC}/../lib") + +require 'gem_template' +require 'pp' + +Spec::Runner.configure do |config| +end + +# For use with rspec textmate bundle +def debug(object) + puts "
"
+  puts object.pretty_inspect.gsub('<', '<').gsub('>', '>')
+  puts "
" +end