Skip to content
Browse files

Merge branch 'master' into rails

  • Loading branch information...
2 parents 5f45d78 + 3bcd4eb commit bafdf8353a6838ac0e9fc75395de82a96b8c8f3e @winton committed Dec 29, 2010
Showing with 25 additions and 53 deletions.
  1. +19 −51 Rakefile
  2. +6 −0 gem_template.gemspec
  3. +0 −1 lib/gem_template/gems.rb
  4. +0 −1 spec/gem_template/gems_spec.rb
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
View
6 gem_template.gemspec
@@ -1,4 +1,10 @@
# -*- encoding: utf-8 -*-
+lib = File.expand_path('../lib/', __FILE__)
+$:.unshift lib unless $:.include?(lib)
+
+require 'gem_template/gems'
+GemTemplate::Gems.gemset ||= :default
+
Gem::Specification.new do |s|
GemTemplate::Gems.gemspec.hash.each do |key, value|
unless %w(dependencies development_dependencies).include?(key)
View
1 lib/gem_template/gems.rb
@@ -23,7 +23,6 @@ def initialize(hash)
Gems.config = SimpleStruct.new(
:gemsets => [ "#{File.expand_path('../../../', __FILE__)}/config/gemsets.yml" ],
:gemspec => "#{File.expand_path('../../../', __FILE__)}/config/gemspec.yml",
- :testing => false,
:warn => true
)
View
1 spec/gem_template/gems_spec.rb
@@ -9,7 +9,6 @@
GemTemplate::Gems.config.gemsets = [
"#{$root}/spec/fixtures/gemsets.yml"
]
- GemTemplate::Gems.config.testing = true
GemTemplate::Gems.config.warn = true
GemTemplate::Gems.gemspec true

0 comments on commit bafdf83

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