Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Removing rake:rename in favor of putting it in separate gem, fixing r…

…ake gems:install
  • Loading branch information...
commit 3bcd4ebcca54d524449894df6d85132465683590 1 parent a94936f
@winton authored
Showing with 19 additions and 51 deletions.
  1. +19 −51 Rakefile
View
70 Rakefile
@@ -31,30 +31,24 @@ if defined?(Spec::Rake::SpecTask)
end
namespace :gems do
- desc "Install gems (DEV=1|0 DOCS=1|0 SUDO=1|0)"
+ desc "Install gems (DEV=0 DOCS=0 GEMSPEC=default SUDO=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 = []
+ dev = ENV['DEV'] == '1'
+ docs = ENV['DOCS'] == '1' ? '' : '--no-ri --no-rdoc'
+ gemset = ENV['GEMSET']
+ sudo = ENV['SUDO'] == '1' ? 'sudo' : ''
- if File.exists?(file)
- File.open(file, 'r') do |f|
- gems = f.readlines.collect do |line|
- line.split(' ')
- end
- end
+ GemTemplate::Gems.gemset = gemset if gemset
+
+ if dev
+ gems = GemTemplate::Gems.gemspec.development_dependencies
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
+ gems = GemTemplate::Gems.gemspec.dependencies
end
- gems.each do |(name, version)|
+ gems.each do |name|
+ name = name.to_s
+ version = GemTemplate::Gems.versions[name]
if Gem.source_index.find_name(name, version).empty?
version = version ? "-v #{version}" : ''
system "#{sudo} gem install #{name} #{version} #{docs}"
@@ -65,41 +59,15 @@ namespace :gems do
end
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
+desc "Install gem locally"
+task :install => :package do
+ sh %{gem install pkg/#{gemspec.name}-#{gemspec.version}}
+end
-# DELETE AFTER USING
-desc "Rename project"
-task :rename do
- name = ENV['NAME'] || File.basename(Dir.pwd)
- camelize = lambda do |str|
- str.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
- end
- dir = Dir['**/gem_template*']
- begin
- from = dir.pop
- if from
- to = from.split('/')
- to[-1].gsub!('gem_template', name)
- FileUtils.mv(from, to.join('/'))
- end
- end while dir.length > 0
- Dir["**/*"].each do |path|
- if File.file?(path)
- `sed -i '' 's/gem_template/#{name}/g' #{path}`
- `sed -i '' 's/GemTemplate/#{camelize.call(name)}/g' #{path}`
- no_space = File.read(path).gsub(/\s+\z/, '')
- File.open(path, 'w') { |f| f.write(no_space) }
- end
- end
-end
+task :default => :spec
+task :package => :gemspec
Please sign in to comment.
Something went wrong with that request. Please try again.