Skip to content

Commit

Permalink
Convert to rakegem
Browse files Browse the repository at this point in the history
  • Loading branch information
darkhelmet committed Nov 18, 2010
1 parent 53ee9cf commit b6aa31d
Show file tree
Hide file tree
Showing 6 changed files with 205 additions and 167 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ doc
.yardoc

## PROJECT::SPECIFIC
.bundle/
.bundle/
.rvmrc
13 changes: 1 addition & 12 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
source 'http://rubygems.org'

gem 'rainpress'
gem 'packr'
gem 'rack', '>= 1.0'
gem 'sinatra', '~> 1.1.0'

group :development do
gem 'rspec', '~> 1.3.0'
gem 'rack-test', '>= 0.5.3'
gem 'yard'
gem 'jeweler'
gem 'ruby-debug'
end
gemspec
31 changes: 13 additions & 18 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
PATH
remote: .
specs:
sinatra-bundles (0.5.0)
packr (~> 3.1.0)
rack (~> 1.0)
rainpress (~> 1.0)
sinatra (~> 1.1.0)

GEM
remote: http://rubygems.org/
specs:
columnize (0.3.2)
git (1.2.5)
jeweler (1.5.1)
bundler (~> 1.0.0)
git (>= 1.2.5)
rake
linecache (0.43)
oyster (0.9.4)
packr (3.1.0)
oyster
rack (1.2.1)
rack-test (0.5.6)
rack (>= 1.0)
rainpress (1.0)
rake (0.8.7)
rspec (1.3.1)
ruby-debug (0.10.4)
columnize (>= 0.1)
ruby-debug-base (~> 0.10.4.0)
ruby-debug-base (0.10.4)
linecache (>= 0.3)
sinatra (1.1.0)
rack (~> 1.1)
tilt (~> 1.1)
Expand All @@ -32,12 +28,11 @@ PLATFORMS
ruby

DEPENDENCIES
jeweler
packr
rack (>= 1.0)
packr (~> 3.1.0)
rack (~> 1.0)
rack-test (>= 0.5.3)
rainpress
rainpress (~> 1.0)
rspec (~> 1.3.0)
ruby-debug
sinatra (~> 1.1.0)
sinatra-bundles!
yard
119 changes: 104 additions & 15 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,24 +1,60 @@
require 'rubygems'
require 'rake'
require 'bundler'
require 'date'

begin
require 'jeweler'
Jeweler::Tasks.new do |gem|
gem.name = "sinatra-bundles"
gem.summary = %Q{Easy asset bundling for sinatra}
gem.description = %Q{Bundle CSS and Javascript assets to a single file, compress, and cache them for snappier web experiences.}
gem.email = 'darkhelmet@darkhelmetlive.com'
gem.homepage = 'http://github.com/darkhelmet/sinatra-bundles'
gem.authors = ['Daniel Huckstep']
gem.add_bundler_dependencies
# 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/sinatra/bundles.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
#
#############################################################################

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)
#
#############################################################################

require 'spec/rake/spectask'
Spec::Rake::SpecTask.new(:spec) do |spec|
spec.libs << 'lib' << 'spec'
Expand All @@ -42,4 +78,57 @@ rescue LoadError
task :yardoc do
abort 'YARD is not available. In order to run yardoc, you must: sudo gem install yard'
end
end

#############################################################################
#
# 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

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, :name)
replace_header(head, :version)
replace_header(head, :date)

# 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
2 changes: 2 additions & 0 deletions lib/sinatra/bundles.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module Sinatra
# Main Bundles Module
module Bundles
Version = '0.5.0'

mypath = File.dirname(__FILE__)
autoload :Helpers, "#{mypath}/bundles/helpers"
autoload :Bundle, "#{mypath}/bundles/bundle"
Expand Down
Loading

0 comments on commit b6aa31d

Please sign in to comment.