Skip to content

Commit

Permalink
Using Bundler instead of Require
Browse files Browse the repository at this point in the history
  • Loading branch information
winton committed Jun 28, 2010
1 parent 50e8db9 commit c542e7f
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 47 deletions.
23 changes: 23 additions & 0 deletions 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
File renamed without changes.
File renamed without changes.
47 changes: 43 additions & 4 deletions 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)
Expand All @@ -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
3 changes: 1 addition & 2 deletions 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")
3 changes: 1 addition & 2 deletions lib/gem_template.rb
@@ -1,2 +1 @@
require File.expand_path("#{File.dirname(__FILE__)}/../require")
Require.lib!
require 'gem_template/version'
Empty file removed lib/gem_template/gem_template.rb
Empty file.
3 changes: 3 additions & 0 deletions lib/gem_template/version.rb
@@ -0,0 +1,3 @@
module GemTemplate
VERSION = "0.1.0" unless defined?(::GemTemplate::VERSION)
end
36 changes: 0 additions & 36 deletions require.rb

This file was deleted.

21 changes: 18 additions & 3 deletions 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.