Sha256: a0e12a9231ff0d745d1a6034085671b4ba6d6b4d8c91f3faf0c134cc32f6bda5
Contents?: true
Size: 1.91 KB
Versions: 1
Compression:
Stored size: 1.91 KB
Contents
require 'date' require 'rake/testtask' task :default => :test ## helper functions def name @name ||= Dir['*.gemspec'].first.split('.').first end def gem_name 'avdi-faraday' end def version line = File.read("lib/#{name}.rb")[/^\s*VERSION\s*=\s*.*/] line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1] end def gemspec_file "#{name}.gemspec" end def gem_file "#{gem_name}-#{version}.gem" end def replace_header(head, header_name) head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{send(header_name)}'"} end ## standard tasks desc "Run all tests" task :test do exec 'script/test' end desc "Open an irb session preloaded with this library" task :console do sh "irb -rubygems -r ./lib/#{name}.rb" end ## release management tasks desc "Commit, create tag v#{version} and build and push #{gem_file} to Rubygems" task :release => :build do sh "git commit --allow-empty -a -m 'Release #{version}'" sh "git tag v#{version}-avdi" sh "git push avdi" sh "git push avdi v#{version}" sh "gem push pkg/#{gem_file}" end desc "Build #{gem_file} into the pkg directory" task :build => :gemspec do sh "mkdir -p pkg" sh "gem build #{gemspec_file}" sh "mv #{gem_file} pkg" end desc "Generate #{gemspec_file}" task :gemspec do # read spec file and split out manifest section spec = File.read(gemspec_file) head, manifest, tail = spec.split(" # = MANIFEST =\n") # replace name version and date replace_header(head, :gem_name) replace_header(head, :version) # determine file list from git ls-files files = `git ls-files`. split("\n"). sort. reject { |file| file =~ /^\./ }. reject { |file| file =~ /^(rdoc|pkg)/ }. map { |file| " #{file}" }. join("\n") # piece file back together and write manifest = " s.files = %w[\n#{files}\n ]\n" spec = [head, manifest, tail].join(" # = MANIFEST =\n") File.open(gemspec_file, 'w') { |io| io.write(spec) } puts "Updated #{gemspec_file}" end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
avdi-faraday-0.8.1 | Rakefile |