rack_fast_escape 2009.06.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/AUTHORS ADDED
@@ -0,0 +1,5 @@
1
+ Following persons have contributed to rack_fast_escape.
2
+ (Sorted by number of submitted patches, then alphabetically)
3
+
4
+ 11 TJ Vanderpoel <tj@rubyists.com>
5
+ 1 Evan Phoenix <ephoenix@engineyard.com>
@@ -0,0 +1,50 @@
1
+ [511f98a | 2009-06-24 20:18:37 UTC] TJ Vanderpoel <TJ Vanderpoel tj@rubyists.com>
2
+
3
+ * copyrighted everything
4
+
5
+ [ed188e6 | 2009-06-23 00:57:17 UTC] bougyman <bougyman@gotdebt.nationwide-recovery.com>
6
+
7
+ * added url_escape dependency
8
+
9
+ [39e0766 | 2009-06-22 22:28:55 UTC] TJ Vanderpoel <Jayson Vaughn jv@rubyists.com>
10
+
11
+ * got reversioning for packaging working
12
+
13
+ [627a1c0 | 2009-06-22 22:23:08 UTC] TJ Vanderpoel <Jayson Vaughn jv@rubyists.com>
14
+
15
+ * made reversion handle VERSION in the lib file
16
+
17
+ [7155885 | 2009-06-22 20:14:29 UTC] Evan Phoenix <ephoenix@engineyard.com>
18
+
19
+ * Perform topiary services
20
+
21
+ [75495ef | 2009-06-22 21:50:25 UTC] TJ Vanderpoel <Jayson Vaughn jv@rubyists.com>
22
+
23
+ * back to straight text
24
+
25
+ [be475ac | 2009-06-22 21:49:45 UTC] TJ Vanderpoel <Jayson Vaughn jv@rubyists.com>
26
+
27
+ * moved to markdown
28
+
29
+ [3e63eb8 | 2009-06-22 21:48:43 UTC] TJ Vanderpoel <Jayson Vaughn jv@rubyists.com>
30
+
31
+ * filled out some README
32
+
33
+ [a389751 | 2009-06-22 21:26:39 UTC] TJ Vanderpoel <Jayson Vaughn jv@rubyists.com>
34
+
35
+ * moved version require
36
+
37
+ [5ed4a16 | 2009-06-22 21:21:34 UTC] TJ Vanderpoel <Jayson Vaughn jv@rubyists.com>
38
+
39
+ * Added initial wrapper for URLEscape to be used in Rack::Utils
40
+
41
+ * RackFastEscape::R::U contains module methods which use URLEscape
42
+ * Binds R::U to ::Rack::Utils, extending it
43
+ * Sets Rack::Utils.fast_escape? and #fast_unescape?
44
+ * Remaps original escape/unescape to old_ and binds the new fast_
45
+ versions as escape/unescape
46
+
47
+ [e6b8e04 | 2009-06-22 19:19:53 UTC] TJ Vanderpoel <Jayson Vaughn jv@rubyists.com>
48
+
49
+ * initial project skeleton
50
+
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ # Copyright (c) 2008-2009 The Rubyists, LLC (effortless systems) <rubyists@rubyists.com>
2
+ # Distributed under the terms of the MIT license.
3
+ # See the LICENSE file which accompanies this software for the full text
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in
13
+ # all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ # THE SOFTWARE.
@@ -0,0 +1,22 @@
1
+ AUTHORS
2
+ CHANGELOG
3
+ LICENSE
4
+ MANIFEST
5
+ README
6
+ Rakefile
7
+ doc/LEGAL
8
+ lib/rack_fast_escape.rb
9
+ lib/rack_fast_escape/version.rb
10
+ spec/helper.rb
11
+ spec/lib/rack_fast_escape.rb
12
+ tasks/authors.rake
13
+ tasks/bacon.rake
14
+ tasks/changelog.rake
15
+ tasks/copyright.rake
16
+ tasks/gem.rake
17
+ tasks/gem_installer.rake
18
+ tasks/manifest.rake
19
+ tasks/release.rake
20
+ tasks/reversion.rake
21
+ tasks/setup.rake
22
+ tasks/yard.rake
data/README ADDED
@@ -0,0 +1,46 @@
1
+ == Rack Fast Escape/Unescape
2
+ ----------
3
+
4
+ The Rack Fast Escape library, by The Rubyists, LLC
5
+
6
+ This library replaces the Rack::Utils.escape and #unescape methods
7
+ with the versions from URLEscape, a C extension which increases the
8
+ efficiency of these methods at least 20x.
9
+
10
+ == Download
11
+
12
+ Standard gem locations, source on github
13
+
14
+ == Usage
15
+ -------
16
+
17
+ require "rack"
18
+ require "rack_fast_escape"
19
+ Rack::Utils.escape("%03a" * 10000000)
20
+
21
+ Note: The above with Rack::Utils.escape may eat a lot of cycles.
22
+
23
+ == Tests
24
+
25
+ If you have the full source, run the specs with 'rake' in the
26
+ root of the library tree (lib/..).
27
+
28
+ == Benchmarks
29
+
30
+ |user|system|total|real
31
+ URLEscape::unescape|0.090000|0.000000|0.090000|( 0.090418)
32
+ CGI::unescape|2.920000|0.000000|2.920000|( 2.924822)
33
+
34
+ |user|system|total|real
35
+ URLEscape::unescape|0.090000|0.000000|0.090000|( 0.089071)
36
+ Rack::Utils::unescape|3.120000|0.010000|3.130000|( 3.125334)
37
+
38
+ |user|system|total|real
39
+ URLEscape::escape|0.200000|0.000000|0.200000|( 0.194290)
40
+ Rack::Utils::escape|3.960000|0.000000|3.960000|( 3.995122)|
41
+
42
+ == Support
43
+
44
+ See #rubyists on freenode or rubyists@rubyists.com
45
+
46
+ Copyright(c) 2009 by The Rubyists, LLC
@@ -0,0 +1,102 @@
1
+ # Copyright (c) 2008-2009 The Rubyists, LLC (effortless systems) <rubyists@rubyists.com>
2
+ # Distributed under the terms of the MIT license.
3
+ # See the LICENSE file which accompanies this software for the full text
4
+ #
5
+ begin; require 'rubygems'; rescue LoadError; end
6
+
7
+ require 'rake'
8
+ require 'rake/clean'
9
+ require 'rake/gempackagetask'
10
+ require 'time'
11
+ require 'date'
12
+
13
+ PROJECT_SPECS = FileList[
14
+ 'spec/*/**/*.rb'
15
+ ]
16
+
17
+ PROJECT_MODULE = 'RackFastEscape'
18
+ PROJECT_README = 'README'
19
+ #PROJECT_RUBYFORGE_GROUP_ID = 3034
20
+ PROJECT_COPYRIGHT_SUMMARY = [
21
+ "# Copyright (c) 2008-#{Time.now.year} The Rubyists, LLC (effortless systems) <rubyists@rubyists.com>",
22
+ "# Distributed under the terms of the MIT license.",
23
+ "# See the LICENSE file which accompanies this software for the full text",
24
+ "#"
25
+ ]
26
+ PROJECT_COPYRIGHT = PROJECT_COPYRIGHT_SUMMARY + [
27
+ "# Permission is hereby granted, free of charge, to any person obtaining a copy",
28
+ '# of this software and associated documentation files (the "Software"), to deal',
29
+ "# in the Software without restriction, including without limitation the rights",
30
+ "# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell",
31
+ "# copies of the Software, and to permit persons to whom the Software is",
32
+ "# furnished to do so, subject to the following conditions:",
33
+ "#",
34
+ "# The above copyright notice and this permission notice shall be included in",
35
+ "# all copies or substantial portions of the Software.",
36
+ "#",
37
+ '# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR',
38
+ "# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,",
39
+ "# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE",
40
+ "# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER",
41
+ "# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,",
42
+ "# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN",
43
+ "# THE SOFTWARE."
44
+ ]
45
+
46
+ PROJECT_VERSION =
47
+ if version = ENV['PROJECT_VERSION'] || ENV['VERSION']
48
+ version
49
+ else
50
+ begin
51
+ require "lib/rack_fast_escape/version"
52
+ RackFastEscape::VERSION
53
+ rescue
54
+ Date.today.strftime("%Y.%m.%d")
55
+ end
56
+ end
57
+
58
+ # To release the monthly version do:
59
+ # $ PROJECT_VERSION=2009.03 rake release
60
+
61
+ PROJECT_FILES = FileList[`git ls-files`.split("\n")].exclude('.gitignore').exclude("rack_fast_escape.gemspec")
62
+
63
+ GEMSPEC = Gem::Specification.new{|s|
64
+ s.name = "rack_fast_escape"
65
+ s.author = "The Rubyists, LLC"
66
+ s.summary = "The Rack Fast Escape library, by The Rubyists, LLC"
67
+ s.description = "The Rack Fast Escape library, by The Rubyists, LLC"
68
+ s.email = "The Rubyists, LLC <rubyists@rubyists.com>"
69
+ s.homepage = "http://github.com/bougyman/rack_fast_escape"
70
+ s.platform = Gem::Platform::RUBY
71
+ s.version = PROJECT_VERSION
72
+ s.files = PROJECT_FILES
73
+ s.require_path = "lib"
74
+ s.rubyforge_project = "url-escape"
75
+ s.add_dependency "url_escape"
76
+
77
+
78
+ s.post_install_message = <<MESSAGE
79
+ ============================================================
80
+
81
+ Thank you for installing RackFastEscape!
82
+
83
+ ============================================================
84
+ MESSAGE
85
+ }
86
+
87
+ Dir.glob('tasks/*.rake'){|f| import(f) }
88
+
89
+ task :default => [:bacon]
90
+
91
+ CLEAN.include %w[
92
+ **/.*.sw?
93
+ *.gem
94
+ .config
95
+ **/*~
96
+ **/{data.db,cache.yaml}
97
+ *.yaml
98
+ pkg
99
+ rdoc
100
+ ydoc
101
+ *coverage*
102
+ ]
@@ -0,0 +1,2 @@
1
+ LICENSE
2
+ lib/rack_fast_escape/version.rb
@@ -0,0 +1,31 @@
1
+ # Copyright (c) 2008-2009 The Rubyists, LLC (effortless systems) <rubyists@rubyists.com>
2
+ # Distributed under the terms of the MIT license.
3
+ # See the LICENSE file which accompanies this software for the full text
4
+ #
5
+ %w{rack url_escape}.each { |lib|
6
+ begin
7
+ require lib
8
+ rescue LoadError
9
+ require "rubygems"
10
+ require lib
11
+ end
12
+ }
13
+
14
+ module Rack::Utils
15
+ class << self
16
+ # Move the old versions
17
+ alias :old_escape :escape
18
+ alias :old_unescape :unescape
19
+
20
+ # Pull in the new versions
21
+ extend URLEscape
22
+
23
+ # Make new versions explictly available
24
+ alias :fast_escape :escape
25
+ alias :fast_unescape :unescape
26
+
27
+ # Allow for detection
28
+ def fast_escape?; true; end
29
+ def fast_unescape?; true; end
30
+ end
31
+ end
@@ -0,0 +1,3 @@
1
+ module RackFastEscape
2
+ VERSION = "2009.06.24"
3
+ end
@@ -0,0 +1,29 @@
1
+ # Copyright (c) 2008-2009 The Rubyists, LLC (effortless systems) <rubyists@rubyists.com>
2
+ # Distributed under the terms of the MIT license.
3
+ # See the LICENSE file which accompanies this software for the full text
4
+ #
5
+ require "pathname"
6
+ %w{bacon rack}.each { |lib|
7
+ begin
8
+ require lib
9
+ rescue LoadError
10
+ require "rubygems"
11
+ require lib
12
+ end
13
+ }
14
+
15
+ begin
16
+ if (local_path = Pathname.new(__FILE__).dirname.join("..", "lib", "rack_fast_escape.rb")).file?
17
+ require local_path
18
+ else
19
+ require "rack_fast_escape"
20
+ end
21
+ rescue LoadError
22
+ require "rubygems"
23
+ require "rack_fast_escape"
24
+ end
25
+
26
+ Bacon.summary_on_exit
27
+
28
+
29
+
@@ -0,0 +1,55 @@
1
+ # Copyright (c) 2008-2009 The Rubyists, LLC (effortless systems) <rubyists@rubyists.com>
2
+ # Distributed under the terms of the MIT license.
3
+ # See the LICENSE file which accompanies this software for the full text
4
+ #
5
+ require File.expand_path("../../helper", __FILE__)
6
+ describe "RackFastEscape" do
7
+ describe "module embedding" do
8
+
9
+ describe "escape methods" do
10
+ it "defines fast_escape on Rack::Utils" do
11
+ Rack::Utils.respond_to?(:fast_escape).should.be.true
12
+ end
13
+
14
+ it "aliases original escape on Rack::Utils to old_escape" do
15
+ Rack::Utils.respond_to?(:old_escape).should.be.true
16
+ end
17
+
18
+ it "sets Rack::Utils.fast_escape?" do
19
+ Rack::Utils.fast_escape?.should.be.true
20
+ end
21
+ end
22
+
23
+ describe "unescape methods" do
24
+ it "defines fast_unescape on Rack::Utils" do
25
+ Rack::Utils.respond_to?(:fast_unescape).should.be.true
26
+ end
27
+
28
+ it "aliases original unescape on Rack::Utils to old_unescape" do
29
+ Rack::Utils.respond_to?(:old_unescape).should.be.true
30
+ end
31
+
32
+ it "sets Rack::Utils.fast_unescape?" do
33
+ Rack::Utils.fast_unescape?.should.be.true
34
+ end
35
+ end
36
+
37
+ end
38
+
39
+ end
40
+
41
+ describe "Rack::Utils" do
42
+ describe "#escape" do
43
+ it "unescapes spaces in an encoded url" do
44
+ Rack::Utils.unescape("foo%20bar").should == "foo bar"
45
+ Rack::Utils.unescape("foo+bar").should == "foo bar"
46
+ end
47
+ end
48
+
49
+ describe "#escape" do
50
+ it "escapes spaces in an encoded url" do
51
+ Rack::Utils.escape("foo bar").should == "foo+bar"
52
+ end
53
+ end
54
+ end
55
+
@@ -0,0 +1,33 @@
1
+ # Once git has a fix for the glibc in handling .mailmap and another fix for
2
+ # allowing empty mail address to be mapped in .mailmap we won't have to handle
3
+ # them manually.
4
+
5
+ desc 'Update AUTHORS'
6
+ task :authors do
7
+ authors = Hash.new(0)
8
+
9
+ `git shortlog -nse`.scan(/(\d+)\s(.+)\s<(.*)>$/) do |count, name, email|
10
+ # Examples of mappping, replace with your own or comment this out/delete it
11
+ case name
12
+ when /^(?:bougyman$|TJ Vanderpoel)/
13
+ name, email = "TJ Vanderpoel", "tj@rubyists.com"
14
+ when /^(?:manveru$|Michael Fellinger)/
15
+ name, email = "Michael Fellinger", "mf@rubyists.com"
16
+ when /^(?:deathsyn$|Kevin Berry)/
17
+ name, email = "Kevin Berry", "kb@rubyists.com"
18
+ when /^(?:(?:jayson|thedonvaughn|jvaughn)$|Jayson Vaughn)/
19
+ name, email = "Jayson Vaughn", "jv@rubyists.com"
20
+ end
21
+
22
+ authors[[name, email]] += count.to_i
23
+ end
24
+
25
+ File.open('AUTHORS', 'w+') do |io|
26
+ io.puts "Following persons have contributed to #{GEMSPEC.name}."
27
+ io.puts '(Sorted by number of submitted patches, then alphabetically)'
28
+ io.puts ''
29
+ authors.sort_by{|(n,e),c| [-c, n.downcase] }.each do |(name, email), count|
30
+ io.puts("%6d %s <%s>" % [count, name, email])
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,70 @@
1
+ desc 'Run all bacon specs with pretty output'
2
+ task :bacon => :setup do
3
+ require 'open3'
4
+ require 'scanf'
5
+ require 'matrix'
6
+
7
+ specs = PROJECT_SPECS
8
+
9
+ some_failed = false
10
+ specs_size = specs.size
11
+ if specs.size == 0
12
+ $stderr.puts "You have no specs! Put a spec in spec/ before running this task"
13
+ exit 1
14
+ end
15
+ len = specs.map{|s| s.size }.sort.last
16
+ total_tests = total_assertions = total_failures = total_errors = 0
17
+ totals = Vector[0, 0, 0, 0]
18
+
19
+ red, yellow, green = "\e[31m%s\e[0m", "\e[33m%s\e[0m", "\e[32m%s\e[0m"
20
+ left_format = "%4d/%d: %-#{len + 11}s"
21
+ spec_format = "%d specifications (%d requirements), %d failures, %d errors"
22
+
23
+ specs.each_with_index do |spec, idx|
24
+ print(left_format % [idx + 1, specs_size, spec])
25
+
26
+ Open3.popen3(RUBY, spec) do |sin, sout, serr|
27
+ out = sout.read.strip
28
+ err = serr.read.strip
29
+
30
+ # this is conventional, see spec/innate/state/fiber.rb for usage
31
+ if out =~ /^Bacon::Error: (needed .*)/
32
+ puts(yellow % ("%6s %s" % ['', $1]))
33
+ else
34
+ total = nil
35
+
36
+ out.each_line do |line|
37
+ scanned = line.scanf(spec_format)
38
+
39
+ next unless scanned.size == 4
40
+
41
+ total = Vector[*scanned]
42
+ break
43
+ end
44
+
45
+ if total
46
+ totals += total
47
+ tests, assertions, failures, errors = total_array = total.to_a
48
+
49
+ if tests > 0 && failures + errors == 0
50
+ puts((green % "%6d passed") % tests)
51
+ else
52
+ some_failed = true
53
+ puts(red % " failed")
54
+ puts out unless out.empty?
55
+ puts err unless err.empty?
56
+ end
57
+ else
58
+ some_failed = true
59
+ puts(red % " failed")
60
+ puts out unless out.empty?
61
+ puts err unless err.empty?
62
+ end
63
+ end
64
+ end
65
+ end
66
+
67
+ total_color = some_failed ? red : green
68
+ puts(total_color % (spec_format % totals.to_a))
69
+ exit 1 if some_failed
70
+ end
@@ -0,0 +1,18 @@
1
+ desc 'update changelog'
2
+ task :changelog do
3
+ File.open('CHANGELOG', 'w+') do |changelog|
4
+ `git log -z --abbrev-commit`.split("\0").each do |commit|
5
+ next if commit =~ /^Merge: \d*/
6
+ ref, author, time, _, title, _, message = commit.split("\n", 7)
7
+ ref = ref[/commit ([0-9a-f]+)/, 1]
8
+ author = author[/Author: (.*)/, 1].strip
9
+ time = Time.parse(time[/Date: (.*)/, 1]).utc
10
+ title.strip!
11
+
12
+ changelog.puts "[#{ref} | #{time}] #{author}"
13
+ changelog.puts '', " * #{title}"
14
+ changelog.puts '', message.rstrip if message
15
+ changelog.puts
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,41 @@
1
+ # Copyright (c) 2008-2009 The Rubyists, LLC (effortless systems) <rubyists@rubyists.com>
2
+ # Distributed under the terms of the MIT license.
3
+ # See the LICENSE file that accompanied this software for the full MIT License text
4
+ #
5
+ require "pathname"
6
+ task :legal do
7
+ license = Pathname("LICENSE")
8
+ license.open("w+") do |f|
9
+ f.puts PROJECT_COPYRIGHT
10
+ end unless license.file? and license.read == PROJECT_COPYRIGHT
11
+ doc = Pathname("doc/LEGAL")
12
+ doc.open("w+") do |f|
13
+ f.puts "LICENSE"
14
+ end unless doc.file?
15
+ end
16
+
17
+ desc "add copyright summary to all .rb files in the distribution"
18
+ task :copyright => [:legal] do
19
+ doc = Pathname("doc/LEGAL")
20
+ ignore = doc.readlines.
21
+ select { |line| line.strip!; Pathname(line).file? }.
22
+ map { |file| Pathname(file).expand_path }
23
+
24
+ puts "adding copyright summary to files that don't have it currently"
25
+ puts PROJECT_COPYRIGHT_SUMMARY
26
+ puts
27
+
28
+ (Pathname.glob('{controller,model,app,lib,test,spec}/**/*{.rb}') +
29
+ Pathname.glob("Rakefile")).each do |file|
30
+ next if ignore.include? file.expand_path
31
+ lines = file.readlines.map{ |l| l.chomp }
32
+ if lines.first.match(/^# \* \w.*/)
33
+ @f = lines.shift
34
+ end
35
+ unless lines.first(PROJECT_COPYRIGHT_SUMMARY.size) == PROJECT_COPYRIGHT_SUMMARY
36
+ oldlines = file.readlines
37
+ oldlines.shift if @f
38
+ file.open("w+") { |f| f.puts @f if @f;f.puts PROJECT_COPYRIGHT_SUMMARY + oldlines }
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,23 @@
1
+ require 'rake/gempackagetask'
2
+
3
+ desc "make a gemspec"
4
+ task :gemspec => [:manifest, :changelog, :authors] do
5
+ gemspec_file = "#{GEMSPEC.name}.gemspec"
6
+ File.open(gemspec_file, 'w+'){|gs| gs.puts(GEMSPEC.to_ruby) }
7
+ end
8
+
9
+ desc "package and install from gemspec"
10
+ task :install => [:gemspec] do
11
+ sh "gem build #{GEMSPEC.name}.gemspec"
12
+ sh "gem install #{GEMSPEC.name}-#{GEMSPEC.version}.gem"
13
+ end
14
+
15
+ desc "uninstall the gem"
16
+ task :uninstall => [:clean] do
17
+ sh %{gem uninstall -x #{GEMSPEC.name}}
18
+ end
19
+
20
+ Rake::GemPackageTask.new(GEMSPEC) do |p|
21
+ p.need_tar = true
22
+ p.need_zip = true
23
+ end
@@ -0,0 +1,76 @@
1
+ task :gem_installer do
2
+ class GemInstaller
3
+ def initialize(options = {}, &block)
4
+ @gems = []
5
+ @options = options
6
+
7
+ run(&block)
8
+ end
9
+
10
+ def run(&block)
11
+ instance_eval(&block) if block_given?
12
+ end
13
+
14
+ def gem(name, version = nil, options = {})
15
+ if version.respond_to?(:merge!)
16
+ options = version
17
+ else
18
+ options[:version] = version
19
+ end
20
+
21
+ @gems << [name, options]
22
+ end
23
+
24
+ def setup_gemspec(gemspec)
25
+ gemspec.dependencies.each do |dependency|
26
+ dependency.version_requirements.as_list.each do |version|
27
+ gem(dependency.name, version)
28
+ end
29
+ end
30
+
31
+ setup
32
+ end
33
+
34
+ def setup
35
+ require 'rubygems'
36
+ require 'rubygems/dependency_installer'
37
+
38
+ @gems.each do |name, options|
39
+ setup_gem(name, options)
40
+ end
41
+ end
42
+
43
+ def setup_gem(name, options, try_install = true)
44
+ print "activating #{name} ... "
45
+ Gem.activate(name, *[options[:version]].compact)
46
+ require(options[:lib] || name)
47
+ puts "success."
48
+ rescue LoadError => error
49
+ puts error
50
+ install_gem(name, options) if try_install
51
+ setup_gem(name, options, try_install = false)
52
+ end
53
+
54
+ def install_gem(name, options)
55
+ installer = Gem::DependencyInstaller.new(options)
56
+
57
+ temp_argv(options[:extconf]) do
58
+ print "Installing #{name} ... "
59
+ installer.install(name, options[:version])
60
+ puts "done."
61
+ end
62
+ end
63
+
64
+ def temp_argv(extconf)
65
+ if extconf ||= @options[:extconf]
66
+ old_argv = ARGV.clone
67
+ ARGV.replace(extconf.split(' '))
68
+ end
69
+
70
+ yield
71
+
72
+ ensure
73
+ ARGV.replace(old_argv) if extconf
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,4 @@
1
+ desc 'update manifest'
2
+ task :manifest do
3
+ File.open('MANIFEST', 'w+'){|io| io.puts(*GEMSPEC.files) }
4
+ end
@@ -0,0 +1,52 @@
1
+ namespace :release do
2
+ task :all => [:release_github, :release_rubyforge]
3
+
4
+ desc 'Display instructions to release on github'
5
+ task :github => [:reversion, :gemspec] do
6
+ name, version = GEMSPEC.name, GEMSPEC.version
7
+
8
+ puts <<INSTRUCTIONS
9
+ First add the relevant files:
10
+
11
+ git add AUTHORS MANIFEST CHANGELOG #{name}.gemspec lib/#{name}/version.rb
12
+
13
+ Then commit them, tag the commit, and push:
14
+
15
+ git commit -m 'Version #{version}'
16
+ git tag -a -m '#{version}' '#{version}'
17
+ git push
18
+
19
+ INSTRUCTIONS
20
+
21
+ end
22
+
23
+ # TODO: Not tested
24
+ desc 'Display instructions to release on rubyforge'
25
+ task :rubyforge => [:reversion, :gemspec, :package] do
26
+ rf_project, name, version = GEMSPEC.rubyforge_project, GEMSPEC.name, GEMSPEC.version.to_s
27
+
28
+ puts <<INSTRUCTIONS
29
+ To publish to rubyforge do following:
30
+
31
+ rubyforge login
32
+ rubyforge add_release #{rf_project} #{name} #{version.dump} -n README pkg/#{name}-#{version}.gem
33
+
34
+ After you have done these steps, see:
35
+
36
+ VERSION=#{version.dump} rake release:rubyforge_archives
37
+
38
+ INSTRUCTIONS
39
+ end
40
+
41
+ desc 'Display instructions to add archives after release:rubyforge'
42
+ task :rubyforge_archives do
43
+ rf_project, name, version = GEMSPEC.rubyforge_project, GEMSPEC.name, GEMSPEC.version.to_s
44
+ puts "Adding archives for distro packagers is:", ""
45
+
46
+ Dir["pkg/#{name}-#{version}.{tgz,zip}"].each do |file|
47
+ puts "rubyforge add_file %s %s %p %p" % [rf_project, name, version, file]
48
+ end
49
+
50
+ puts
51
+ end
52
+ end
@@ -0,0 +1,8 @@
1
+ desc "update version.rb"
2
+ task :reversion do
3
+ File.open("lib/#{GEMSPEC.name}/version.rb", 'w+') do |file|
4
+ file.puts("module #{PROJECT_MODULE}")
5
+ file.puts(' VERSION = %p' % GEMSPEC.version.to_s)
6
+ file.puts('end')
7
+ end
8
+ end
@@ -0,0 +1,15 @@
1
+ desc 'install all possible dependencies'
2
+ task :setup => :gem_installer do
3
+ GemInstaller.new do
4
+ # core
5
+ gem 'url_escape'
6
+
7
+ # spec
8
+ gem 'bacon'
9
+
10
+ # doc
11
+ gem 'yard'
12
+
13
+ setup
14
+ end
15
+ end
@@ -0,0 +1,4 @@
1
+ desc 'Generate YARD documentation'
2
+ task :yard => :clean do
3
+ sh("yardoc -o ydoc --protected -r #{PROJECT_README} lib/**/*.rb tasks/*.rake")
4
+ end
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rack_fast_escape
3
+ version: !ruby/object:Gem::Version
4
+ version: 2009.06.24
5
+ platform: ruby
6
+ authors:
7
+ - The Rubyists, LLC
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-06-24 00:00:00 -05:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: url_escape
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ description: The Rack Fast Escape library, by The Rubyists, LLC
26
+ email: The Rubyists, LLC <rubyists@rubyists.com>
27
+ executables: []
28
+
29
+ extensions: []
30
+
31
+ extra_rdoc_files: []
32
+
33
+ files:
34
+ - AUTHORS
35
+ - CHANGELOG
36
+ - LICENSE
37
+ - MANIFEST
38
+ - README
39
+ - Rakefile
40
+ - doc/LEGAL
41
+ - lib/rack_fast_escape.rb
42
+ - lib/rack_fast_escape/version.rb
43
+ - spec/helper.rb
44
+ - spec/lib/rack_fast_escape.rb
45
+ - tasks/authors.rake
46
+ - tasks/bacon.rake
47
+ - tasks/changelog.rake
48
+ - tasks/copyright.rake
49
+ - tasks/gem.rake
50
+ - tasks/gem_installer.rake
51
+ - tasks/manifest.rake
52
+ - tasks/release.rake
53
+ - tasks/reversion.rake
54
+ - tasks/setup.rake
55
+ - tasks/yard.rake
56
+ has_rdoc: true
57
+ homepage: http://github.com/bougyman/rack_fast_escape
58
+ licenses: []
59
+
60
+ post_install_message: |
61
+ ============================================================
62
+
63
+ Thank you for installing RackFastEscape!
64
+
65
+ ============================================================
66
+
67
+ rdoc_options: []
68
+
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: "0"
76
+ version:
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: "0"
82
+ version:
83
+ requirements: []
84
+
85
+ rubyforge_project: url-escape
86
+ rubygems_version: 1.3.4
87
+ signing_key:
88
+ specification_version: 3
89
+ summary: The Rack Fast Escape library, by The Rubyists, LLC
90
+ test_files: []
91
+