Skip to content
Newer
Older
100644 88 lines (76 sloc) 2.13 KB
efebcbe @winton Getting rid of bundler
authored
1 require File.dirname(__FILE__) + '/lib/gem_template/gems'
4ab38af @winton [gem_template] First commit
authored
2
eca33a4 @winton New system for specifying gem versions, gemspec info, activating gems
authored
3 GemTemplate::Gems.activate %w(rake rspec)
efebcbe @winton Getting rid of bundler
authored
4
5 require 'rake'
6 require 'spec/rake/spectask'
c542e7f @winton Using Bundler instead of Require
authored
7
8 def gemspec
9 @gemspec ||= begin
10 file = File.expand_path('../gem_template.gemspec', __FILE__)
11 eval(File.read(file), binding, file)
12 end
13 end
14
15 if defined?(Spec::Rake::SpecTask)
16 desc "Run specs"
17 Spec::Rake::SpecTask.new do |t|
18 t.spec_files = FileList['spec/**/*_spec.rb']
19 t.spec_opts = %w(-fs --color)
20 t.warning = true
21 end
22 task :spec
b3f7765 @winton Adding ability to build a gem for every gemset (dependencies change b…
authored
23 task :default => :spec
24 end
25
26 desc "Build gem(s)"
27 task :gem do
28 old_gemset = ENV['GEMSET']
29 pkg = "#{File.dirname(__FILE__)}/pkg"
30 system "rm -Rf #{pkg}"
31 (GemTemplate::Gems.gemspecs.keys + %w(default nodep)).each do |gemset|
32 ENV['GEMSET'] = gemset
33 system "mkdir -p #{pkg} && cd #{pkg} && gem build ../gem_template.gemspec"
34 end
35 ENV['GEMSET'] = old_gemset
36 end
37
38 namespace :gem do
39 desc "Install gem(s)"
40 task :install do
41 Rake::Task['gem'].invoke
42 Dir["#{File.dirname(__FILE__)}/pkg/*.gem"].each do |pkg|
43 system "gem install #{pkg} --no-ri --no-rdoc"
44 end
45 end
46
47 desc "Push gem(s)"
48 task :push do
49 Rake::Task['gem'].invoke
50 Dir["#{File.dirname(__FILE__)}/pkg/*.gem"].each do |pkg|
51 system "gem push #{pkg}"
52 end
53 end
c542e7f @winton Using Bundler instead of Require
authored
54 end
55
efebcbe @winton Getting rid of bundler
authored
56 namespace :gems do
b3f7765 @winton Adding ability to build a gem for every gemset (dependencies change b…
authored
57 desc "Install gem dependencies (DEV=0 DOCS=0 GEMSPEC=default SUDO=0)"
efebcbe @winton Getting rid of bundler
authored
58 task :install do
3bcd4eb @winton Removing rake:rename in favor of putting it in separate gem, fixing r…
authored
59 dev = ENV['DEV'] == '1'
60 docs = ENV['DOCS'] == '1' ? '' : '--no-ri --no-rdoc'
61 gemset = ENV['GEMSET']
62 sudo = ENV['SUDO'] == '1' ? 'sudo' : ''
efebcbe @winton Getting rid of bundler
authored
63
3bcd4eb @winton Removing rake:rename in favor of putting it in separate gem, fixing r…
authored
64 GemTemplate::Gems.gemset = gemset if gemset
65
66 if dev
67 gems = GemTemplate::Gems.gemspec.development_dependencies
efebcbe @winton Getting rid of bundler
authored
68 else
3bcd4eb @winton Removing rake:rename in favor of putting it in separate gem, fixing r…
authored
69 gems = GemTemplate::Gems.gemspec.dependencies
efebcbe @winton Getting rid of bundler
authored
70 end
71
3bcd4eb @winton Removing rake:rename in favor of putting it in separate gem, fixing r…
authored
72 gems.each do |name|
73 name = name.to_s
74 version = GemTemplate::Gems.versions[name]
efebcbe @winton Getting rid of bundler
authored
75 if Gem.source_index.find_name(name, version).empty?
76 version = version ? "-v #{version}" : ''
77 system "#{sudo} gem install #{name} #{version} #{docs}"
78 else
79 puts "already installed: #{name} #{version}"
80 end
81 end
82 end
83 end
84
c542e7f @winton Using Bundler instead of Require
authored
85 desc "Validate the gemspec"
86 task :gemspec do
87 gemspec.validate
b3f7765 @winton Adding ability to build a gem for every gemset (dependencies change b…
authored
88 end
Something went wrong with that request. Please try again.