Skip to content
This repository
Newer
Older
100644 68 lines (60 sloc) 1.577 kb
c542e7fa »
2010-06-28 Using Bundler instead of Require
1 require 'rubygems'
2 require 'bundler'
4ab38af8 »
2009-11-06 [gem_template] First commit
3
c542e7fa »
2010-06-28 Using Bundler instead of Require
4 Bundler.require(:rake)
5
6 def gemspec
7 @gemspec ||= begin
8 file = File.expand_path('../gem_template.gemspec', __FILE__)
9 eval(File.read(file), binding, file)
10 end
11 end
12
13 if defined?(Rake::GemPackageTask)
14 Rake::GemPackageTask.new(gemspec) do |pkg|
15 pkg.gem_spec = gemspec
16 end
17 task :gem => :gemspec
18 end
19
20 if defined?(Spec::Rake::SpecTask)
21 desc "Run specs"
22 Spec::Rake::SpecTask.new do |t|
23 t.spec_files = FileList['spec/**/*_spec.rb']
24 t.spec_opts = %w(-fs --color)
25 t.warning = true
26 end
27 task :spec
28 end
29
30 desc "Install gem locally"
31 task :install => :package do
32 sh %{gem install pkg/#{gemspec.name}-#{gemspec.version}}
33 end
34
35 desc "Validate the gemspec"
36 task :gemspec do
37 gemspec.validate
38 end
39
40 task :package => :gemspec
41 task :default => :spec
42
43 # DELETE AFTER USING
085cb142 »
2009-11-09 [gem_template] Updating README
44 desc "Rename project"
45 task :rename do
46 name = ENV['NAME'] || File.basename(Dir.pwd)
e783bde0 »
2010-06-28 Find and replace for GemTemplate as well as gem_template
47 camelize = lambda do |str|
48 str.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
49 end
4ab38af8 »
2009-11-06 [gem_template] First commit
50 begin
51 dir = Dir['**/gem_template*']
52 from = dir.pop
53 if from
e0e8a485 »
2010-06-29 Fixing file rename in rake rename
54 to = from.split('/')
55 to[-1].gsub!('gem_template', name)
ffca0152 »
2010-06-29 Fixing file rename in rake rename
56 FileUtils.mv(from, to.join('/'))
4ab38af8 »
2009-11-06 [gem_template] First commit
57 end
58 end while dir.length > 0
59 Dir["**/*"].each do |path|
60 next if path.include?('Rakefile')
61 if File.file?(path)
9c694c82 »
2010-06-29 Fixing sed call in rake rename
62 `sed -i '' 's/gem_template/#{name}/g' #{path}`
63 `sed -i '' 's/GemTemplate/#{camelize.call(name)}/g' #{path}`
eb5c8d11 »
2010-06-29 Removing end space on rake rename
64 no_space = File.read(path).gsub(/\s+\z/, '')
65 File.open(path, 'w') { |f| f.write(no_space) }
4ab38af8 »
2009-11-06 [gem_template] First commit
66 end
67 end
68 end
Something went wrong with that request. Please try again.