Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Getting rid of bundler

  • Loading branch information...
commit efebcbe7435910461b524616b5f687f65dbadd56 1 parent cf1d4f1
@winton authored
View
31 Gemfile
@@ -1,31 +0,0 @@
-source "http://rubygems.org"
-
-v = {
- :bundler => '=1.0.0.beta.5',
- :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 :lib do
-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
- gem 'rspec', v[:rspec], :require => %w(
- spec/adapters/mock_frameworks/rspec
- spec/runner/formatter/progress_bar_formatter
- spec/runner/formatter/text_mate_formatter
- )
-end
View
17 Gemfile.lock
@@ -1,17 +0,0 @@
-GEM
- remote: http://rubygems.org/
- specs:
- rake (0.8.7)
- rake (0.8.7)
- rspec (1.3.0)
- rspec (1.3.0)
-
-PLATFORMS
- ruby
-
-DEPENDENCIES
- bundler (= 1.0.0.beta.2)
- rake (= 0.8.7)
- rspec (= 1.3.0)
- rspec (= 1.3.0)
- rspec (= 1.3.0)
View
45 Rakefile
@@ -1,7 +1,10 @@
-require 'rubygems'
-require 'bundler'
+require File.dirname(__FILE__) + '/lib/gem_template/gems'
-Bundler.require(:rake)
+GemTemplate::Gems.require(:rake)
+
+require 'rake'
+require 'rake/gempackagetask'
+require 'spec/rake/spectask'
def gemspec
@gemspec ||= begin
@@ -27,6 +30,41 @@ if defined?(Spec::Rake::SpecTask)
task :spec
end
+namespace :gems do
+ desc "Install gems (DEV=1|0 DOCS=1|0 SUDO=1|0)"
+ task :install do
+ file = File.dirname(__FILE__) + '/gems'
+ sudo = (ENV['SUDO'] ||= '0').to_i
+ docs = (ENV['DOCS'] ||= '0').to_i
+ sudo = sudo == 1 ? 'sudo' : ''
+ docs = docs == 1 ? '' : '--no-ri --no-rdoc'
+ gems = []
+
+ if File.exists?(file)
+ File.open(file, 'r') do |f|
+ gems = f.readlines.collect do |line|
+ line.split(' ')
+ end
+ end
+ else
+ gems = GemTemplate::Gems::TYPES[:gemspec]
+ gems = GemTemplate::Gems::TYPES[:gemspec_dev] if ENV['DEV'] == '1'
+ gems.collect! do |g|
+ [ g.to_s, GemTemplate::Gems::VERSIONS[g] ]
+ end
+ end
+
+ gems.each do |(name, version)|
+ if Gem.source_index.find_name(name, version).empty?
+ version = version ? "-v #{version}" : ''
+ system "#{sudo} gem install #{name} #{version} #{docs}"
+ else
+ puts "already installed: #{name} #{version}"
+ end
+ end
+ end
+end
+
desc "Install gem locally"
task :install => :package do
sh %{gem install pkg/#{gemspec.name}-#{gemspec.version}}
@@ -57,7 +95,6 @@ task :rename do
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}`
`sed -i '' 's/GemTemplate/#{camelize.call(name)}/g' #{path}`
View
15 gem_template.gemspec
@@ -2,9 +2,8 @@
lib = File.expand_path('../lib/', __FILE__)
$:.unshift lib unless $:.include?(lib)
+require 'gem_template/gems'
require 'gem_template/version'
-require 'rubygems'
-require 'bundler'
Gem::Specification.new do |s|
s.name = "gem_template"
@@ -16,12 +15,12 @@ Gem::Specification.new do |s|
s.summary = ""
s.description = ""
- Bundler.definition.dependencies.each do |dep|
- if dep.groups.include?(:gemspec)
- s.add_dependency dep.name, dep.requirement
- elsif dep.groups.include?(:gemspec_dev)
- s.add_development_dependency dep.name, dep.requirement
- end
+ GemTemplate::Gems::TYPES[:gemspec].each do |g|
+ s.add_dependency g.to_s, GemTemplate::Gems::VERSIONS[g]
+ end
+
+ GemTemplate::Gems::TYPES[:gemspec_dev].each do |g|
+ s.add_development_dependency g.to_s, GemTemplate::Gems::VERSIONS[g]
end
s.files = Dir.glob("{bin,lib}/**/*") + %w(LICENSE README.md)
View
5 lib/gem_template.rb
@@ -1,7 +1,6 @@
-require 'rubygems'
-require 'bundler'
+require File.dirname(__FILE__) + '/gem_template/gems'
-Bundler.require(:lib)
+GemTemplate::Gems.require(:lib)
$:.unshift File.dirname(__FILE__) + '/gem_template'
View
42 lib/gem_template/gems.rb
@@ -0,0 +1,42 @@
+unless defined?(GemTemplate::Gems)
+
+ require 'rubygems'
+
+ module GemTemplate
+ class Gems
+
+ VERSIONS = {
+ :rake => '=0.8.7',
+ :rspec => '=1.3.0'
+ }
+
+ TYPES = {
+ :gemspec => [],
+ :gemspec_dev => [ :rspec ],
+ :lib => [],
+ :rake => [ :rake, :rspec ],
+ :spec => [ :rspec ]
+ }
+
+ class <<self
+
+ def lockfile
+ file = File.expand_path('../../../gems', __FILE__)
+ unless File.exists?(file)
+ File.open(file, 'w') do |f|
+ Gem.loaded_specs.each do |key, value|
+ f.puts "#{key} #{value.version.version}"
+ end
+ end
+ end
+ end
+
+ def require(type=nil)
+ (TYPES[type] || TYPES.values.flatten.compact).each do |name|
+ gem name.to_s, VERSIONS[name]
+ end
+ end
+ end
+ end
+ end
+end
View
8 spec/spec_helper.rb
@@ -1,13 +1,11 @@
-require 'rubygems'
-require 'bundler'
+$root = File.expand_path('../../', __FILE__)
+require "#{$root}/lib/gem_template/gems"
-Bundler.require(:spec)
+GemTemplate::Gems.require(:spec)
Spec::Runner.configure do |config|
end
-SPEC = File.dirname(__FILE__)
-
require "#{Bundler.root}/lib/gem_template"
require 'pp'

0 comments on commit efebcbe

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