cgi_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/LICENSE +21 -0
- data/README +46 -0
- data/Rakefile +102 -0
- data/doc/LEGAL +2 -0
- data/lib/cgi_fast_escape.rb +31 -0
- data/lib/cgi_fast_escape/version.rb +3 -0
- data/spec/helper.rb +25 -0
- data/spec/lib/cgi_fast_escape.rb +55 -0
- data/tasks/authors.rake +33 -0
- data/tasks/bacon.rake +70 -0
- data/tasks/changelog.rake +18 -0
- data/tasks/copyright.rake +41 -0
- data/tasks/gem.rake +23 -0
- data/tasks/gem_installer.rake +76 -0
- data/tasks/manifest.rake +4 -0
- data/tasks/release.rake +52 -0
- data/tasks/reversion.rake +8 -0
- data/tasks/setup.rake +15 -0
- data/tasks/yard.rake +4 -0
- metadata +88 -0
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.
|
data/README
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
== CGI Fast Escape/Unescape
|
2
|
+
----------
|
3
|
+
|
4
|
+
The CGI Fast Escape library, by The Rubyists, LLC
|
5
|
+
|
6
|
+
This library replaces the CGI.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 "cgi"
|
18
|
+
require "cgi_fast_escape"
|
19
|
+
CGI.escape("%03a" * 10000000)
|
20
|
+
|
21
|
+
Note: The above with CGI.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
|
+
CGI::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
|
+
CGI::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
|
data/Rakefile
ADDED
@@ -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 = 'CgiFastEscape'
|
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/cgi_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("cgi_fast_escape.gemspec")
|
62
|
+
|
63
|
+
GEMSPEC = Gem::Specification.new{|s|
|
64
|
+
s.name = "cgi_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/cgi_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.add_dependency "url_escape"
|
75
|
+
s.rubyforge_project = "url-escape"
|
76
|
+
|
77
|
+
|
78
|
+
s.post_install_message = <<MESSAGE
|
79
|
+
============================================================
|
80
|
+
|
81
|
+
Thank you for installing CgiFastEscape!
|
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
|
+
]
|
data/doc/LEGAL
ADDED
@@ -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{cgi url_escape}.each { |lib|
|
6
|
+
begin
|
7
|
+
require lib
|
8
|
+
rescue LoadError
|
9
|
+
require "rubygems"
|
10
|
+
require lib
|
11
|
+
end
|
12
|
+
}
|
13
|
+
|
14
|
+
class CGI
|
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
|
data/spec/helper.rb
ADDED
@@ -0,0 +1,25 @@
|
|
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{bacon rack}.each { |lib|
|
6
|
+
begin
|
7
|
+
require lib
|
8
|
+
rescue LoadError
|
9
|
+
require "rubygems"
|
10
|
+
require lib
|
11
|
+
end
|
12
|
+
}
|
13
|
+
|
14
|
+
begin
|
15
|
+
if File.file?(local_path = File.expand_path("../../lib/cgi_fast_escape.rb", __FILE__))
|
16
|
+
require File.join(File.dirname(local_path),File.basename(local_path, ".rb"))
|
17
|
+
else
|
18
|
+
require "cgi_fast_escape"
|
19
|
+
end
|
20
|
+
rescue LoadError
|
21
|
+
require "rubygems"
|
22
|
+
require "cgi_fast_escape"
|
23
|
+
end
|
24
|
+
|
25
|
+
Bacon.summary_on_exit
|
@@ -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 "CgiFastEscape" do
|
7
|
+
describe "module embedding" do
|
8
|
+
|
9
|
+
describe "escape methods" do
|
10
|
+
it "defines fast_escape on CGI" do
|
11
|
+
CGI.respond_to?(:fast_escape).should.be.true
|
12
|
+
end
|
13
|
+
|
14
|
+
it "aliases original escape on CGI to old_escape" do
|
15
|
+
CGI.respond_to?(:old_escape).should.be.true
|
16
|
+
end
|
17
|
+
|
18
|
+
it "sets CGI.fast_escape?" do
|
19
|
+
CGI.fast_escape?.should.be.true
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "unescape methods" do
|
24
|
+
it "defines fast_unescape on CGI" do
|
25
|
+
CGI.respond_to?(:fast_unescape).should.be.true
|
26
|
+
end
|
27
|
+
|
28
|
+
it "aliases original unescape on CGI to old_unescape" do
|
29
|
+
CGI.respond_to?(:old_unescape).should.be.true
|
30
|
+
end
|
31
|
+
|
32
|
+
it "sets CGI.fast_unescape?" do
|
33
|
+
CGI.fast_unescape?.should.be.true
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "CGI" do
|
42
|
+
describe "#escape" do
|
43
|
+
it "unescapes spaces in an encoded url" do
|
44
|
+
CGI.unescape("foo%20bar").should == "foo bar"
|
45
|
+
CGI.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
|
+
CGI.escape("foo bar").should == "foo+bar"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
data/tasks/authors.rake
ADDED
@@ -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
|
data/tasks/bacon.rake
ADDED
@@ -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
|
data/tasks/gem.rake
ADDED
@@ -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
|
data/tasks/manifest.rake
ADDED
data/tasks/release.rake
ADDED
@@ -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
|
data/tasks/setup.rake
ADDED
data/tasks/yard.rake
ADDED
metadata
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cgi_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
|
+
- LICENSE
|
35
|
+
- README
|
36
|
+
- Rakefile
|
37
|
+
- doc/LEGAL
|
38
|
+
- lib/cgi_fast_escape.rb
|
39
|
+
- lib/cgi_fast_escape/version.rb
|
40
|
+
- spec/helper.rb
|
41
|
+
- spec/lib/cgi_fast_escape.rb
|
42
|
+
- tasks/authors.rake
|
43
|
+
- tasks/bacon.rake
|
44
|
+
- tasks/changelog.rake
|
45
|
+
- tasks/copyright.rake
|
46
|
+
- tasks/gem.rake
|
47
|
+
- tasks/gem_installer.rake
|
48
|
+
- tasks/manifest.rake
|
49
|
+
- tasks/release.rake
|
50
|
+
- tasks/reversion.rake
|
51
|
+
- tasks/setup.rake
|
52
|
+
- tasks/yard.rake
|
53
|
+
has_rdoc: true
|
54
|
+
homepage: http://github.com/bougyman/cgi_fast_escape
|
55
|
+
licenses: []
|
56
|
+
|
57
|
+
post_install_message: |
|
58
|
+
============================================================
|
59
|
+
|
60
|
+
Thank you for installing CgiFastEscape!
|
61
|
+
|
62
|
+
============================================================
|
63
|
+
|
64
|
+
rdoc_options: []
|
65
|
+
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: "0"
|
73
|
+
version:
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: "0"
|
79
|
+
version:
|
80
|
+
requirements: []
|
81
|
+
|
82
|
+
rubyforge_project: url-escape
|
83
|
+
rubygems_version: 1.3.4
|
84
|
+
signing_key:
|
85
|
+
specification_version: 3
|
86
|
+
summary: The Rack Fast Escape library, by The Rubyists, LLC
|
87
|
+
test_files: []
|
88
|
+
|