Skip to content
Browse files

Using Bundler instead of Require

  • Loading branch information...
1 parent 50e8db9 commit c542e7faafae65e0d94d5548ea647ff23049a67d @winton committed Jun 28, 2010
View
23 Gemfile
@@ -0,0 +1,23 @@
+source "http://rubygems.org"
+
+v = {
+ :bundler => '=0.9.26',
+ :rake => '=0.8.7',
+ :rspec => '=1.3.0'
+}
+
+group :gemspec do
+ gem 'bundler', v[:bundler]
+end
+
+group :gemspec_dev do
+ gem 'rspec', v[:rspec]
+end
+
+group :rake do
+ gem 'rake', v[:rake], :require => %w(rake rake/gempackagetask)
+ gem 'rspec', v[:rspec], :require => %w(spec/rake/spectask)
+end
+
+group :spec do
+end
View
0 MIT-LICENSE → LICENSE
File renamed without changes.
View
0 README.markdown → README.md
File renamed without changes.
View
47 Rakefile
@@ -1,7 +1,46 @@
-require "#{File.dirname(__FILE__)}/require"
-Require.rakefile!
+require 'rubygems'
+require 'bundler'
-# You can delete this after you use it
+Bundler.require(:rake)
+
+def gemspec
+ @gemspec ||= begin
+ file = File.expand_path('../gem_template.gemspec', __FILE__)
+ eval(File.read(file), binding, file)
+ end
+end
+
+if defined?(Rake::GemPackageTask)
+ Rake::GemPackageTask.new(gemspec) do |pkg|
+ pkg.gem_spec = gemspec
+ end
+ task :gem => :gemspec
+end
+
+if defined?(Spec::Rake::SpecTask)
+ desc "Run specs"
+ Spec::Rake::SpecTask.new do |t|
+ t.spec_files = FileList['spec/**/*_spec.rb']
+ t.spec_opts = %w(-fs --color)
+ t.warning = true
+ end
+ task :spec
+end
+
+desc "Install gem locally"
+task :install => :package do
+ sh %{gem install pkg/#{gemspec.name}-#{gemspec.version}}
+end
+
+desc "Validate the gemspec"
+task :gemspec do
+ gemspec.validate
+end
+
+task :package => :gemspec
+task :default => :spec
+
+# DELETE AFTER USING
desc "Rename project"
task :rename do
name = ENV['NAME'] || File.basename(Dir.pwd)
@@ -17,7 +56,7 @@ task :rename do
Dir["**/*"].each do |path|
next if path.include?('Rakefile')
if File.file?(path)
- `sed -i "" 's/gem_template/#{name}/g' #{path}`
+ `sed -i 's/gem_template/#{name}/g' #{path}`
end
end
end
View
3 bin/gem_template
@@ -1,4 +1,3 @@
#!/usr/bin/env ruby
-require File.expand_path("#{File.dirname(__FILE__)}/../require")
-Require.bin!
+require File.expand_path(File.dirname(__FILE__) + "/../lib/gem_template")
View
3 lib/gem_template.rb
@@ -1,2 +1 @@
-require File.expand_path("#{File.dirname(__FILE__)}/../require")
-Require.lib!
+require 'gem_template/version'
View
0 lib/gem_template/gem_template.rb
No changes.
View
3 lib/gem_template/version.rb
@@ -0,0 +1,3 @@
+module GemTemplate
+ VERSION = "0.1.0" unless defined?(::GemTemplate::VERSION)
+end
View
36 require.rb
@@ -1,36 +0,0 @@
-require 'rubygems'
-gem 'require'
-require 'require'
-
-Require do
- gem :require, '=0.2.7'
- gem(:rake, '=0.8.7') { require 'rake' }
- gem :rspec, '=1.3.0'
-
- gemspec do
- author 'Winton Welsh'
- dependencies do
- gem :require
- end
- email 'mail@wintoni.us'
- name 'gem_template'
- homepage "http://github.com/winton/#{name}"
- summary ""
- version '0.1.0'
- end
-
- bin { require 'lib/gem_template' }
- lib { require 'lib/gem_template/gem_template' }
-
- rakefile do
- gem(:rake) { require 'rake/gempackagetask' }
- gem(:rspec) { require 'spec/rake/spectask' }
- require 'require/tasks'
- end
-
- spec_helper do
- require 'require/spec_helper'
- require 'lib/gem_template'
- require 'pp'
- end
-end
View
21 spec/spec_helper.rb
@@ -1,5 +1,20 @@
-require File.expand_path("#{File.dirname(__FILE__)}/../require")
-Require.spec_helper!
+require 'rubygems'
+require 'bundler'
+
+Bundler.require(:spec)
+
+require 'lib/gem_template'
+require 'pp'
Spec::Runner.configure do |config|
-end
+end
+
+SPEC = File.expand_path("#{Bundler.root}/spec")
+$:.unshift File.expand_path("#{Bundler.root}/lib")
+
+# For use with rspec textmate bundle
+def debug(object)
+ puts "<pre>"
+ puts object.pretty_inspect.gsub('<', '&lt;').gsub('>', '&gt;')
+ puts "</pre>"
+end

0 comments on commit c542e7f

Please sign in to comment.
Something went wrong with that request. Please try again.