-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
230 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
tmp | ||
pkg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Copyright (c) 2008-2009 Bryan Helmkamp | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
module GemHelpers | ||
|
||
def generate_gemspec | ||
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), "lib"))) | ||
require "asset_trip" | ||
|
||
Gem::Specification.new do |s| | ||
s.name = "asset-trip" | ||
s.version = AssetTrip::VERSION | ||
s.author = "Bryan Helmkamp" | ||
s.email = "bryan@brynary.com" | ||
s.homepage = "http://github.com/brynary/asset-trip" | ||
s.summary = "Rails asset bundling plugin that will expand your mind" | ||
# s.description = <<-EOS.strip | ||
# TODO | ||
# EOS | ||
|
||
require "git" | ||
repo = Git.open(".") | ||
|
||
s.files = normalize_files(repo.ls_files.keys - repo.lib.ignored_files) | ||
s.test_files = normalize_files(Dir['spec/**/*.rb'] - repo.lib.ignored_files) | ||
|
||
s.has_rdoc = true | ||
s.extra_rdoc_files = %w[README.rdoc MIT-LICENSE.txt] | ||
end | ||
end | ||
|
||
def normalize_files(array) | ||
# only keep files, no directories, and sort | ||
array.select do |path| | ||
File.file?(path) | ||
end.sort | ||
end | ||
|
||
# Adds extra space when outputting an array. This helps create better version | ||
# control diffs, because otherwise it is all on the same line. | ||
def prettyify_array(gemspec_ruby, array_name) | ||
gemspec_ruby.gsub(/s\.#{array_name.to_s} = \[.+?\]/) do |match| | ||
leadin, files = match[0..-2].split("[") | ||
leadin + "[\n #{files.split(",").join(",\n ")}\n ]" | ||
end | ||
end | ||
|
||
def read_gemspec | ||
@read_gemspec ||= eval(File.read("asset-trip.gemspec")) | ||
end | ||
|
||
def sh(command) | ||
puts command | ||
system command | ||
end | ||
end | ||
|
||
class Default < Thor | ||
include GemHelpers | ||
|
||
desc "gemspec", "Regenerate asset-trip.gemspec" | ||
def gemspec | ||
File.open("asset-trip.gemspec", "w") do |file| | ||
gemspec_ruby = generate_gemspec.to_ruby | ||
gemspec_ruby = prettyify_array(gemspec_ruby, :files) | ||
gemspec_ruby = prettyify_array(gemspec_ruby, :test_files) | ||
gemspec_ruby = prettyify_array(gemspec_ruby, :extra_rdoc_files) | ||
|
||
file.write gemspec_ruby | ||
end | ||
|
||
puts "Wrote gemspec to asset-trip.gemspec" | ||
read_gemspec.validate | ||
end | ||
|
||
desc "build", "Build a asset-trip gem" | ||
def build | ||
sh "gem build asset-trip.gemspec" | ||
FileUtils.mkdir_p "pkg" | ||
FileUtils.mv read_gemspec.file_name, "pkg" | ||
end | ||
|
||
desc "install", "Install the latest built gem" | ||
def install | ||
sh "gem install --local pkg/#{read_gemspec.file_name}" | ||
end | ||
|
||
desc "release", "Release the current branch to GitHub and Gemcutter" | ||
def release | ||
gemspec | ||
build | ||
Release.new.tag | ||
Release.new.gem | ||
end | ||
end | ||
|
||
class Release < Thor | ||
include GemHelpers | ||
|
||
desc "tag", "Tag the gem on the origin server" | ||
def tag | ||
release_tag = "v#{read_gemspec.version}" | ||
sh "git tag -a #{release_tag} -m 'Tagging #{release_tag}'" | ||
sh "git push origin #{release_tag}" | ||
end | ||
|
||
desc "gem", "Push the gem to Gemcutter" | ||
def gem | ||
sh "gem push pkg/#{read_gemspec.file_name}" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
# -*- encoding: utf-8 -*- | ||
|
||
Gem::Specification.new do |s| | ||
s.name = %q{asset-trip} | ||
s.version = "0.1.0.pre" | ||
|
||
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version= | ||
s.authors = ["Bryan Helmkamp"] | ||
s.date = %q{2009-11-05} | ||
s.email = %q{bryan@brynary.com} | ||
s.extra_rdoc_files = [ | ||
"README.rdoc", | ||
"MIT-LICENSE.txt" | ||
] | ||
s.files = [ | ||
".gitignore", | ||
"README.rdoc", | ||
"Rakefile", | ||
"init.rb", | ||
"lib/asset_trip.rb", | ||
"lib/asset_trip/asset.rb", | ||
"lib/asset_trip/compressor.rb", | ||
"lib/asset_trip/config.rb", | ||
"lib/asset_trip/file_writer.rb", | ||
"lib/asset_trip/helper.rb", | ||
"lib/asset_trip/javascript.rb", | ||
"lib/asset_trip/load_path.rb", | ||
"lib/asset_trip/manifest.rb", | ||
"lib/asset_trip/manifest_writer.rb", | ||
"lib/asset_trip/memoizable.rb", | ||
"lib/asset_trip/middleware.rb", | ||
"lib/asset_trip/ssl_stylesheet.rb", | ||
"lib/asset_trip/stylesheet.rb", | ||
"lib/asset_trip/url_rewriter.rb", | ||
"spec/asset_trip/asset_spec.rb", | ||
"spec/asset_trip/compressor_spec.rb", | ||
"spec/asset_trip/config_spec.rb", | ||
"spec/asset_trip/helper_spec.rb", | ||
"spec/asset_trip/javascript_spec.rb", | ||
"spec/asset_trip/load_path_spec.rb", | ||
"spec/asset_trip/manifest_writer_spec.rb", | ||
"spec/asset_trip/middleware_spec.rb", | ||
"spec/asset_trip/stylesheet_spec.rb", | ||
"spec/asset_trip/url_rewriter_spec.rb", | ||
"spec/asset_trip_spec.rb", | ||
"spec/fixtures/app/javascripts/main.js", | ||
"spec/fixtures/app/javascripts/main/new.js", | ||
"spec/fixtures/app/javascripts/signup.js", | ||
"spec/fixtures/app/stylesheets/new.css", | ||
"spec/fixtures/config/asset_trip/assets.rb", | ||
"spec/integration/bundle_spec.rb", | ||
"spec/integration/prune_spec.rb", | ||
"spec/spec.opts", | ||
"spec/spec_helper.rb", | ||
"spec/support/core_extensions.rb", | ||
"spec/support/helpers.rb", | ||
"spec/support/matchers.rb", | ||
"spec/support/path_utils.rb", | ||
"spec/support/sandbox_helper.rb", | ||
"tasks/asset_trip.rake", | ||
"vendor/yuicompressor-2.4.2.jar", | ||
"MIT-LICENSE.txt" | ||
] | ||
s.homepage = %q{http://github.com/brynary/asset-trip} | ||
s.require_paths = ["lib"] | ||
s.rubygems_version = %q{1.3.5} | ||
s.summary = %q{Rails asset bundling plugin that will expand your mind} | ||
s.test_files = [ | ||
"spec/asset_trip/asset_spec.rb", | ||
"spec/asset_trip/compressor_spec.rb", | ||
"spec/asset_trip/config_spec.rb", | ||
"spec/asset_trip/helper_spec.rb", | ||
"spec/asset_trip/javascript_spec.rb", | ||
"spec/asset_trip/load_path_spec.rb", | ||
"spec/asset_trip/manifest_writer_spec.rb", | ||
"spec/asset_trip/middleware_spec.rb", | ||
"spec/asset_trip/stylesheet_spec.rb", | ||
"spec/asset_trip/url_rewriter_spec.rb", | ||
"spec/asset_trip_spec.rb", | ||
"spec/fixtures/config/asset_trip/assets.rb", | ||
"spec/integration/bundle_spec.rb", | ||
"spec/integration/prune_spec.rb", | ||
"spec/spec_helper.rb", | ||
"spec/support/core_extensions.rb", | ||
"spec/support/helpers.rb", | ||
"spec/support/matchers.rb", | ||
"spec/support/path_utils.rb", | ||
"spec/support/sandbox_helper.rb" | ||
] | ||
|
||
if s.respond_to? :specification_version then | ||
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION | ||
s.specification_version = 3 | ||
|
||
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then | ||
else | ||
end | ||
else | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters