Skip to content

Commit

Permalink
Simplify gem handling
Browse files Browse the repository at this point in the history
  • Loading branch information
mynyml committed Jan 8, 2010
1 parent a8aedb2 commit 31876ee
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 115 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
*.gem
12 changes: 12 additions & 0 deletions Manifest
@@ -0,0 +1,12 @@
.gitignore
LICENSE
Manifest
README
Rakefile
TODO
examples/simple.rb
examples/simple2.rb
lib/unindent.rb
test/test_helper.rb
test/test_unindent.rb
unindent.gemspec
86 changes: 34 additions & 52 deletions Rakefile
@@ -1,57 +1,39 @@
# --------------------------------------------------
# tasks mostly copied from thin's Rakefile
# http://github.com/macournoyer/thin/tree/master
# --------------------------------------------------

require 'rake/gempackagetask'
require 'pathname'
require 'yaml'

RUBY_1_9 = RUBY_VERSION =~ /^1\.9/
WIN = (RUBY_PLATFORM =~ /mswin|cygwin/)
SUDO = (WIN ? "" : "sudo")

def gem
RUBY_1_9 ? 'gem19' : 'gem'
end

def all_except(paths)
Dir['**/*'] - paths.map {|path| path.strip.gsub(/^\//,'').gsub(/\/$/,'') }
end

spec = Gem::Specification.new do |s|
s.name = 'unindent'
s.version = '0.8.0'
s.summary = "Ruby method to unindent strings."
s.description = "Ruby method to unindent strings. Useful for multiline strings embeded in already indented code."
s.author = "Martin Aumont"
s.email = 'mynyml@gmail.com'
s.homepage = ''
s.has_rdoc = true
s.require_path = "lib"
s.files = Dir['**/*']
end

Rake::GemPackageTask.new(spec) do |p|
p.gem_spec = spec
end


desc "Remove package products"
task :clean => :clobber_package

desc "Update the gemspec for GitHub's gem server"
task :gemspec do
Pathname("#{spec.name}.gemspec").open('w') {|f| f << YAML.dump(spec) }
def gem_opt
defined?(Gem) ? "-rubygems" : ""
end

desc "Install gem"
task :install => [:clobber, :package] do
sh "#{SUDO} #{gem} install pkg/#{spec.full_name}.gem"
# --------------------------------------------------
# Tests
# --------------------------------------------------
task(:default => :'test:all')

namespace(:test) do
desc "Run tests"
task(:all) do
exit system("ruby #{gem_opt} -I.:lib test/test_unindent.rb")
end

desc "Run tests on multiple ruby versions (requires rvm)"
task(:portability) do
versions = %w( 1.8.6 1.8.7 1.9 1.9.2 )
versions.each do |version|
system <<-BASH
bash -c 'source ~/.rvm/scripts/rvm;
rvm use #{version};
echo "--------- #{version} ----------";
rake -s test:all'
BASH
end
end
end

desc "Uninstall gem"
task :uninstall => :clean do
sh "#{SUDO} #{gem} uninstall -v #{spec.version} -x #{spec.name}"
# --------------------------------------------------
# Docs
# --------------------------------------------------
desc "Generate YARD Documentation"
task(:yardoc) do
require 'yard'
files = %w( lib/**/*.rb )
options = %w( -o doc/yard --readme README --files LICENSE )
YARD::CLI::Yardoc.run *(options + files)
end

76 changes: 13 additions & 63 deletions unindent.gemspec
@@ -1,63 +1,13 @@
--- !ruby/object:Gem::Specification
name: unindent
version: !ruby/object:Gem::Version
version: 0.8.0
platform: ruby
authors:
- Martin Aumont
autorequire:
bindir: bin
cert_chain: []

date: 2009-03-15 00:00:00 -04:00
default_executable:
dependencies: []

description: Ruby method to unindent strings. Useful for multiline strings embeded in already indented code.
email: mynyml@gmail.com
executables: []

extensions: []

extra_rdoc_files: []

files:
- lib
- lib/unindent.rb
- examples
- examples/simple.rb
- examples/simple2.rb
- README
- Rakefile
- test
- test/test_helper.rb
- test/test_unindent.rb
- TODO
has_rdoc: true
homepage: ""
post_install_message:
rdoc_options: []

require_paths:
- lib
required_ruby_version: !ruby/object:Gem::Requirement
requirements:
- - ">="
- !ruby/object:Gem::Version
version: "0"
version:
required_rubygems_version: !ruby/object:Gem::Requirement
requirements:
- - ">="
- !ruby/object:Gem::Version
version: "0"
version:
requirements: []

rubyforge_project:
rubygems_version: 1.3.1
signing_key:
specification_version: 2
summary: Ruby method to unindent strings.
test_files: []

Gem::Specification.new do |s|
s.name = "unindent"
s.version = "0.8.0"
s.summary = "Ruby method to unindent strings."
s.description = "Ruby method to unindent strings. Useful for multiline strings embeded in already indented code."
s.author = "mynyml"
s.email = "mynyml@gmail.com"
s.homepage = "http://github.com/mynyml/unindent"
s.rubyforge_project = "unindent"
s.has_rdoc = false
s.require_path = "lib"
s.files = File.read("Manifest").strip.split("\n")
end

0 comments on commit 31876ee

Please sign in to comment.