Rakefile in capcode-render-static-0.3.0 vs Rakefile in capcode-render-static-0.4.0

- old
+ new

@@ -1,11 +1,11 @@ require 'rubygems' require 'rake' begin require 'jeweler' - Jeweler::Tasks.new do |gem| + j = Jeweler::Tasks.new do |gem| gem.name = "capcode-render-static" gem.summary = %Q{Capcode plugin to render static file} gem.description = gem.summary gem.email = "gregoire.lejeune@free.fr" gem.homepage = "http://github.com/glejeune/Capcode.more/tree/master/%s" % gem.name @@ -14,6 +14,48 @@ gem.add_dependency('mime-types') end Jeweler::GemcutterTasks.new rescue LoadError puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler" +end + +require 'json/pure' +require 'open-uri' + +class MyGem + attr_reader :local_version + attr_reader :rubygems_version + attr_reader :name + + def initialize( version, name ) + @local_version = version + @name = name + url = "http://rubygems.org/api/v1/gems/#{@name}.json" + @rubygems_version = JSON.parse( open(url).read )["version"] + end + + def status + @rubygems_version == @local_version + end +end + +MYGEM = MyGem.new( j.jeweler.version, j.jeweler.gemspec.name ) + +namespace :gemcutter do + desc "push to gemcutter" + task :push => [:build] do + unless MYGEM.status + sh %{gem push pkg/#{MYGEM.name}-#{MYGEM.local_version}.gem}, :verbose => true + else + puts "This gem already existe in version #{MYGEM.local_version}!" + end + end + + desc "check gemcutter status" + task :status do + if MYGEM.status + puts "This gem already existe in version #{MYGEM.local_version}!" + else + puts "This gem (#{MYGEM.name}) has not been pushed! Last version at gemcutter is #{MYGEM.rubygems_version}" + end + end end