Skip to content

Commit

Permalink
Use Bundler gem conventions.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabe Berke-Williams committed Nov 11, 2011
1 parent e9dc22b commit 43f0a68
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 136 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -3,3 +3,5 @@ pkg
test_project
.rake_tasks
tmp/aruba
*.gem
.bundle
93 changes: 3 additions & 90 deletions Rakefile
@@ -1,98 +1,11 @@
require 'rubygems'
require 'rake'
require 'bundler/gem_helper'
require 'cucumber/rake/task'
require 'date'

TEST_PROJECT = 'test_project'
SUSPENDERS_GEM_VERSION = '0.3.1'
Bundler::GemHelper.install_tasks

#############################################################################
#
# Testing functions
#
#############################################################################
TEST_PROJECT = 'test_project'

Cucumber::Rake::Task.new

desc 'Run the test suite'
task :default => ['cucumber']

#############################################################################
#
# Helper functions
#
#############################################################################

def name
@name ||= Dir['*.gemspec'].first.split('.').first
end

def version
SUSPENDERS_GEM_VERSION
end

def date
Date.today.to_s
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

#############################################################################
#
# Packaging tasks
#
#############################################################################

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 --tags"
sh "gem push pkg/#{name}-#{version}.gem"
end

task :build => :gemspec do
sh "mkdir -p pkg"
sh "gem build #{gemspec_file}"
sh "mv #{gem_file} pkg"
end

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
3 changes: 3 additions & 0 deletions lib/suspenders/version.rb
@@ -0,0 +1,3 @@
module Suspenders
VERSION = '0.3.1'
end
63 changes: 17 additions & 46 deletions suspenders.gemspec
@@ -1,11 +1,14 @@
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'
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "suspenders/version"

s.name = 'suspenders'
s.version = '0.3.1'
s.date = '2011-10-28'
Gem::Specification.new do |s|
s.name = 'suspenders'
s.version = Suspenders::VERSION
s.date = Date.today.strftime('%Y-%m-%d')
s.authors = ["thoughtbot"]
s.email = 'support@thoughtbot.com'
s.homepage = 'http://github.com/thoughtbot/suspenders'

s.summary = "Generate a Rails app using thoughtbot's best practices."
s.description = <<-HERE
Expand All @@ -14,51 +17,19 @@ thoughtbot to get a jump start on a working app. Use Suspenders if you're in a
rush to build something amazing; don't use it if you like missing deadlines.
HERE

s.authors = ["thoughtbot"]
s.email = 'support@thoughtbot.com'
s.homepage = 'http://github.com/thoughtbot/suspenders'

s.executables = ["suspenders"]
s.default_executable = 'suspenders'
s.files = `git ls-files`.split("\n").
reject { |file| file =~ /^\./ }.
reject { |file| file =~ /^(rdoc|pkg)/ }
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]

s.rdoc_options = ["--charset=UTF-8"]
s.extra_rdoc_files = %w[README.md LICENSE]

s.add_dependency('rails', '3.1.1')
s.add_dependency('bundler', '>= 1.0.7')

s.add_development_dependency('cucumber', '~> 1.1.0')
s.add_development_dependency('aruba', '~> 0.4.6')

# = MANIFEST =
s.files = %w[
CONTRIBUTING.md
Gemfile
Gemfile.lock
LICENSE
README.md
Rakefile
bin/suspenders
features/rake_clean.feature
features/step_definitions/shell.rb
lib/suspenders/actions.rb
lib/suspenders/app_builder.rb
lib/suspenders/generators/app_generator.rb
suspenders.gemspec
templates/Gemfile_additions
templates/Procfile
templates/README_FOR_SUSPENDERS
templates/_flashes.html.erb
templates/_javascript.html.erb
templates/errors.rb
templates/factory_girl_steps.rb
templates/import_scss_styles
templates/javascripts/prefilled_input.js
templates/postgresql_database.yml.erb
templates/suspenders_gitignore
templates/suspenders_layout.html.erb.erb
templates/time_formats.rb
]
# = MANIFEST =

s.test_files = s.files.select {|path| path =~ /^features/ }
end

0 comments on commit 43f0a68

Please sign in to comment.