Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Move from Jeweler to RakeGem

  • Loading branch information...
commit 39853bea47b1bd79b017bd9d23c03a7e6f432064 1 parent f3cff37
@priteau authored
Showing with 190 additions and 31 deletions.
  1. +3 −0  Gemfile
  2. +134 −29 Rakefile
  3. +0 −1  VERSION
  4. +52 −0 gosen.gemspec
  5. +1 −1  lib/gosen.rb
View
3  Gemfile
@@ -0,0 +1,3 @@
+source :rubygems
+
+gemspec
View
163 Rakefile
@@ -1,25 +1,50 @@
require 'rubygems'
require 'rake'
+require 'date'
-begin
- require 'jeweler'
- Jeweler::Tasks.new do |gem|
- gem.name = "gosen"
- gem.summary = %Q{A Ruby library for the Grid'5000 RESTful API}
- gem.description = %Q{Gosen is a Ruby library providing high-level operations using the Grid'5000 RESTful API, such as Kadeploy deployments.}
- gem.email = "priteau@gmail.com"
- gem.homepage = "http://github.com/priteau/gosen"
- gem.authors = ["Pierre Riteau"]
- gem.add_dependency "restfully", ">= 0.5.1"
- gem.add_development_dependency "mocha", ">= 0.9.8"
- gem.add_development_dependency "shoulda", ">= 2.10.2"
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
- end
- Jeweler::GemcutterTasks.new
-rescue LoadError
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
+#############################################################################
+#
+# Helper functions
+#
+#############################################################################
+
+def name
+ @name ||= Dir['*.gemspec'].first.split('.').first
+end
+
+def version
+ line = File.read("lib/#{name}.rb")[/^\s*VERSION\s*=\s*.*/]
+ line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
+end
+
+def date
+ Date.today.to_s
+end
+
+def rubyforge_project
+ name
+end
+
+def gemspec_file
+ "#{name}.gemspec"
end
+def gem_file
+ "#{name}-#{version}.gem"
+end
+
+def replace_header(head, header_name)
+ head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{send(header_name)}'"}
+end
+
+#############################################################################
+#
+# Standard tasks
+#
+#############################################################################
+
+task :default => :test
+
require 'rake/testtask'
Rake::TestTask.new(:test) do |test|
test.libs << 'lib' << 'test'
@@ -27,19 +52,99 @@ Rake::TestTask.new(:test) do |test|
test.verbose = true
end
-begin
- require 'rcov/rcovtask'
- Rcov::RcovTask.new do |test|
- test.libs << 'test'
- test.pattern = 'test/**/test_*.rb'
- test.verbose = true
- end
-rescue LoadError
- task :rcov do
- abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
+desc "Generate RCov test coverage and open in your browser"
+task :coverage do
+ require 'rcov'
+ sh "rm -fr coverage"
+ sh "rcov test/test_*.rb"
+ sh "open coverage/index.html"
+end
+
+require 'rake/rdoctask'
+Rake::RDocTask.new do |rdoc|
+ rdoc.rdoc_dir = 'rdoc'
+ rdoc.title = "#{name} #{version}"
+ rdoc.rdoc_files.include('README*')
+ rdoc.rdoc_files.include('lib/**/*.rb')
+end
+
+desc "Open an irb session preloaded with this library"
+task :console do
+ sh "irb -rubygems -r ./lib/#{name}.rb"
+end
+
+#############################################################################
+#
+# Custom tasks (add your own tasks here)
+#
+#############################################################################
+
+
+
+#############################################################################
+#
+# Packaging tasks
+#
+#############################################################################
+
+desc "Create tag v#{version} and build and push #{gem_file} to Rubygems"
+task :release => :build do
+ unless `git branch` =~ /^\* master$/
+ puts "You must be on the master branch to release!"
+ exit!
end
+ sh "git commit --allow-empty -a -m 'Release #{version}'"
+ sh "git tag v#{version}"
+ sh "git push origin master"
+ sh "git push origin v#{version}"
+ sh "gem push pkg/#{name}-#{version}.gem"
end
-task :test => :check_dependencies
+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
-task :default => :test
+desc "Generate #{gemspec_file}"
+task :gemspec => :validate 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, :name)
+ replace_header(head, :version)
+ replace_header(head, :date)
+ #comment this out if your rubyforge_project has a different name
+ replace_header(head, :rubyforge_project)
+
+ # 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
+
+desc "Validate #{gemspec_file}"
+task :validate do
+ libfiles = Dir['lib/*'] - ["lib/#{name}.rb", "lib/#{name}"]
+ unless libfiles.empty?
+ puts "Directory `lib` should only contain a `#{name}.rb` file and `#{name}` dir."
+ exit!
+ end
+ unless Dir['VERSION*'].empty?
+ puts "A `VERSION` file at root level violates Gem best practices."
+ exit!
+ end
+end
View
1  VERSION
@@ -1 +0,0 @@
-0.2.0
View
52 gosen.gemspec
@@ -0,0 +1,52 @@
+Gem::Specification.new do |s|
+ s.specification_version = 2 if s.respond_to? :specification_version=
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
+ s.rubygems_version = '1.3.5'
+
+ s.name = 'gosen'
+ s.version = '0.2.1'
+ s.date = '2011-06-25'
+ s.rubyforge_project = 'gosen'
+
+ s.summary = "A Ruby library for the Grid'5000 RESTful API"
+ s.description = "Gosen is a Ruby library providing high-level operations using the Grid'5000 RESTful API, such as Kadeploy deployments."
+
+ s.authors = ["Pierre Riteau"]
+ s.email = 'priteau@gmail.com'
+ s.homepage = 'http://github.com/priteau/gosen'
+
+ s.require_paths = %w[lib]
+
+ s.executables = ["trebuchet"]
+
+ s.rdoc_options = ["--charset=UTF-8"]
+ s.extra_rdoc_files = %w[README.md LICENSE]
+
+ s.add_dependency('restfully', [">= 0.5.1"])
+
+ s.add_development_dependency('mocha', [">= 0.9.8"])
+ s.add_development_dependency('rake')
+ s.add_development_dependency('shoulda', [">= 2.10.2"])
+
+ # = MANIFEST =
+ s.files = %w[
+ LICENSE
+ README.md
+ Rakefile
+ bin/trebuchet
+ gosen.gemspec
+ lib/gosen.rb
+ lib/gosen/deployment.rb
+ lib/gosen/deployment_run.rb
+ lib/gosen/error.rb
+ test/gosen/test_deployment.rb
+ test/gosen/test_deployment_run.rb
+ test/helper.rb
+ test/test_gosen.rb
+ ]
+ # = MANIFEST =
+
+ ## Test files will be grabbed from the file list. Make sure the path glob
+ ## matches what you actually use.
+ s.test_files = s.files.select { |path| path =~ /^test\/test_.*\.rb/ }
+end
View
2  lib/gosen.rb
@@ -4,7 +4,7 @@
require 'gosen/error'
module Gosen
- VERSION = "0.2.0"
+ VERSION = "0.2.1"
# Extracts the site part of a Grid'5000 node hostname, and returns a hash indexing the nodes by their site
# Example:
Please sign in to comment.
Something went wrong with that request. Please try again.