rack-mason 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/CHANGELOG +24 -0
- data/Gemfile +16 -0
- data/LICENSE +21 -0
- data/README.rdoc +54 -0
- data/Rakefile +23 -0
- data/examples/middlewares/initial.rb +27 -0
- data/examples/middlewares/intro.rb +16 -0
- data/examples/middlewares/l337.rb +21 -0
- data/examples/middlewares/stylizer.rb +15 -0
- data/examples/rackapp/app.rb +105 -0
- data/examples/rackapp/config.ru +16 -0
- data/examples/railsapp/README +243 -0
- data/examples/railsapp/Rakefile +10 -0
- data/examples/railsapp/app/controllers/application_controller.rb +10 -0
- data/examples/railsapp/app/controllers/tommy_boy_controller.rb +9 -0
- data/examples/railsapp/app/helpers/application_helper.rb +3 -0
- data/examples/railsapp/app/helpers/tommy_boy_helper.rb +2 -0
- data/examples/railsapp/app/views/layouts/application.html.erb +13 -0
- data/examples/railsapp/app/views/tommy_boy/index.html.erb +44 -0
- data/examples/railsapp/app/views/tommy_boy/more.html.erb +12 -0
- data/examples/railsapp/config/boot.rb +110 -0
- data/examples/railsapp/config/database.yml +22 -0
- data/examples/railsapp/config/environment.rb +50 -0
- data/examples/railsapp/config/environments/development.rb +17 -0
- data/examples/railsapp/config/environments/production.rb +28 -0
- data/examples/railsapp/config/environments/test.rb +28 -0
- data/examples/railsapp/config/initializers/backtrace_silencers.rb +7 -0
- data/examples/railsapp/config/initializers/inflections.rb +10 -0
- data/examples/railsapp/config/initializers/mime_types.rb +5 -0
- data/examples/railsapp/config/initializers/new_rails_defaults.rb +21 -0
- data/examples/railsapp/config/initializers/session_store.rb +15 -0
- data/examples/railsapp/config/locales/en.yml +5 -0
- data/examples/railsapp/config/routes.rb +4 -0
- data/examples/railsapp/db/development.sqlite3 +0 -0
- data/examples/railsapp/db/seeds.rb +7 -0
- data/examples/railsapp/doc/README_FOR_APP +2 -0
- data/examples/railsapp/public/404.html +30 -0
- data/examples/railsapp/public/422.html +30 -0
- data/examples/railsapp/public/500.html +30 -0
- data/examples/railsapp/public/favicon.ico +0 -0
- data/examples/railsapp/public/images/rails.png +0 -0
- data/examples/railsapp/public/javascripts/application.js +2 -0
- data/examples/railsapp/public/javascripts/controls.js +963 -0
- data/examples/railsapp/public/javascripts/dragdrop.js +973 -0
- data/examples/railsapp/public/javascripts/effects.js +1128 -0
- data/examples/railsapp/public/javascripts/prototype.js +4320 -0
- data/examples/railsapp/public/robots.txt +5 -0
- data/examples/railsapp/script/about +4 -0
- data/examples/railsapp/script/console +3 -0
- data/examples/railsapp/script/dbconsole +3 -0
- data/examples/railsapp/script/destroy +3 -0
- data/examples/railsapp/script/generate +3 -0
- data/examples/railsapp/script/performance/benchmarker +3 -0
- data/examples/railsapp/script/performance/profiler +3 -0
- data/examples/railsapp/script/plugin +3 -0
- data/examples/railsapp/script/runner +3 -0
- data/examples/railsapp/script/server +3 -0
- data/examples/railsapp/test/functional/tommy_boy_controller_test.rb +8 -0
- data/examples/railsapp/test/performance/browsing_test.rb +9 -0
- data/examples/railsapp/test/test_helper.rb +38 -0
- data/examples/railsapp/test/unit/helpers/tommy_boy_helper_test.rb +4 -0
- data/examples/sinatraapp/app.rb +107 -0
- data/gem.yml +17 -0
- data/lib/mason_helper.rb +76 -0
- data/lib/mason_test_helper.rb +99 -0
- data/lib/rack-mason.rb +70 -0
- data/test/rack-mason_test.rb +21 -0
- data/test/test_helper.rb +13 -0
- data/vex/gem.rake +36 -0
- data/vex/gem.rb +95 -0
- metadata +197 -0
@@ -0,0 +1,21 @@
|
|
1
|
+
$:.unshift(File.expand_path(File.dirname(__FILE__)))
|
2
|
+
require "test_helper"
|
3
|
+
|
4
|
+
module Rack
|
5
|
+
class TestMiddleware < Mason
|
6
|
+
def update_body(doc)
|
7
|
+
h1 = create_node(doc, "h1", "Inserted a heading!")
|
8
|
+
add_first_child(doc.at_css("body"), h1)
|
9
|
+
doc
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class RackMasonTest < Test::Unit::TestCase
|
15
|
+
|
16
|
+
def test_modifies_document
|
17
|
+
after_html = process_html("<html><body><h1>heading</h1></body></html>", Rack::TestMiddleware)
|
18
|
+
assert_html_equal "<html><body><h1>Inserted a heading!</h1><h1>heading</h1></body></html>", after_html
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'test/unit'
|
3
|
+
$:.unshift(File.expand_path(File.dirname(__FILE__) + "/../lib"))
|
4
|
+
require 'rack-mason'
|
5
|
+
require 'mason_test_helper'
|
6
|
+
|
7
|
+
module Test
|
8
|
+
module Unit
|
9
|
+
class TestCase
|
10
|
+
include MasonTestHelper
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/vex/gem.rake
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
def sys(*args)
|
2
|
+
STDERR.puts "#{args.join(" ")}"
|
3
|
+
system *args
|
4
|
+
end
|
5
|
+
|
6
|
+
namespace :gem do
|
7
|
+
task :build => :spec do
|
8
|
+
options = []
|
9
|
+
sys "gem build .gemspec #{options.join(" ")} && mkdir -p pkg && mv *.gem pkg"
|
10
|
+
end
|
11
|
+
|
12
|
+
task :spec do
|
13
|
+
File.open ".gemspec", "w" do |file|
|
14
|
+
file.write <<-TXT
|
15
|
+
require "vex/gem"
|
16
|
+
Gem.spec File.dirname(__FILE__)
|
17
|
+
TXT
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
task :install => :build do
|
22
|
+
file = Dir.glob("pkg/*.gem").sort.last
|
23
|
+
sys "gem install #{file}"
|
24
|
+
end
|
25
|
+
|
26
|
+
task :push => :build do
|
27
|
+
file = Dir.glob("pkg/*.gem").sort.last
|
28
|
+
puts "To push the gem to gemcutter please run"
|
29
|
+
puts
|
30
|
+
puts "\tgem push #{file}"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
desc "Build gem"
|
35
|
+
# task :gem => %w(test gem:install)
|
36
|
+
task :gem => %w(gem:install gem:push)
|
data/vex/gem.rb
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
module Gem
|
2
|
+
(class << self; self; end).class_eval do
|
3
|
+
def default_attributes
|
4
|
+
%w(name version date files executables)
|
5
|
+
end
|
6
|
+
|
7
|
+
def set_root(root)
|
8
|
+
@root = File.expand_path(root)
|
9
|
+
@name = File.basename(@root)
|
10
|
+
@conf ||= YAML.load File.read("#{@root}/gem.yml")
|
11
|
+
@attributes ||= (default_attributes + @conf.keys.map(&:to_s)).uniq
|
12
|
+
end
|
13
|
+
|
14
|
+
# attr_reader :root, :conf, :attributes,
|
15
|
+
attr_reader :name
|
16
|
+
|
17
|
+
def attribute(name)
|
18
|
+
if @conf.key?(name) && !%w(dependencies).include?(name)
|
19
|
+
@conf[name]
|
20
|
+
else
|
21
|
+
self.send(name)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
#
|
26
|
+
# create a new Gem::Specification object for this gem.
|
27
|
+
def spec(root)
|
28
|
+
self.set_root root
|
29
|
+
|
30
|
+
Gem::Specification.new do |s|
|
31
|
+
@attributes.each do |attr|
|
32
|
+
v = attribute(attr)
|
33
|
+
next if v.nil?
|
34
|
+
|
35
|
+
log attr, v
|
36
|
+
|
37
|
+
s.send attr + "=", v
|
38
|
+
end
|
39
|
+
|
40
|
+
%w(pre_uninstall post_install).each do |hook|
|
41
|
+
next unless File.exists?("#{root}/hooks/#{hook}.rb")
|
42
|
+
log hook, "yes"
|
43
|
+
Gem.send(hook) {
|
44
|
+
load "hooks/#{hook}.rb"
|
45
|
+
}
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def log(attr, v)
|
51
|
+
v = case attr
|
52
|
+
when "files" then "#{v.length} files"
|
53
|
+
else v.inspect
|
54
|
+
end
|
55
|
+
|
56
|
+
STDERR.puts "#{"%20s" % attr}:\t#{v}"
|
57
|
+
end
|
58
|
+
|
59
|
+
def dependencies
|
60
|
+
return nil unless @conf["dependencies"]
|
61
|
+
|
62
|
+
@conf["dependencies"].map do |d|
|
63
|
+
Gem::Dependency.new d, ">= 0"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def head(file)
|
68
|
+
File.open(file) do |f|
|
69
|
+
f.readline
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def executables
|
74
|
+
r = Dir.glob("#{@root}/bin/**/*").map do |file|
|
75
|
+
next unless head(file) =~ /^#!/
|
76
|
+
file[@root.length + 5 .. -1]
|
77
|
+
end.compact
|
78
|
+
|
79
|
+
return nil if r.empty?
|
80
|
+
r
|
81
|
+
end
|
82
|
+
|
83
|
+
#
|
84
|
+
# get files from git
|
85
|
+
def files
|
86
|
+
r = `git ls-files`.split("\n")
|
87
|
+
end
|
88
|
+
|
89
|
+
#
|
90
|
+
# return the date
|
91
|
+
def date
|
92
|
+
Date.today.to_s
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
metadata
ADDED
@@ -0,0 +1,197 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rack-mason
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 31
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 2
|
10
|
+
version: 0.1.2
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- radiospiel
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-06-21 00:00:00 +02:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: nokogiri
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: rack
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 3
|
44
|
+
segments:
|
45
|
+
- 0
|
46
|
+
version: "0"
|
47
|
+
type: :runtime
|
48
|
+
version_requirements: *id002
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: diffy
|
51
|
+
prerelease: false
|
52
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
hash: 3
|
58
|
+
segments:
|
59
|
+
- 0
|
60
|
+
version: "0"
|
61
|
+
type: :runtime
|
62
|
+
version_requirements: *id003
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: colored
|
65
|
+
prerelease: false
|
66
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
hash: 3
|
72
|
+
segments:
|
73
|
+
- 0
|
74
|
+
version: "0"
|
75
|
+
type: :runtime
|
76
|
+
version_requirements: *id004
|
77
|
+
description: |-
|
78
|
+
If you are creating Rack middleware that changes the HTML response, use Rack::Mason to get a head start. Rack::Mason takes care of the boilerplate Rack glue so that you can focus on simply changing the HTML.
|
79
|
+
Notethis is a fork from https://github.com/techiferous/rack-mason (c) techiferous@gmail.com
|
80
|
+
email: radiospiel@open-lab.org
|
81
|
+
executables: []
|
82
|
+
|
83
|
+
extensions: []
|
84
|
+
|
85
|
+
extra_rdoc_files: []
|
86
|
+
|
87
|
+
files:
|
88
|
+
- .gitignore
|
89
|
+
- CHANGELOG
|
90
|
+
- Gemfile
|
91
|
+
- LICENSE
|
92
|
+
- README.rdoc
|
93
|
+
- Rakefile
|
94
|
+
- examples/middlewares/initial.rb
|
95
|
+
- examples/middlewares/intro.rb
|
96
|
+
- examples/middlewares/l337.rb
|
97
|
+
- examples/middlewares/stylizer.rb
|
98
|
+
- examples/rackapp/app.rb
|
99
|
+
- examples/rackapp/config.ru
|
100
|
+
- examples/railsapp/README
|
101
|
+
- examples/railsapp/Rakefile
|
102
|
+
- examples/railsapp/app/controllers/application_controller.rb
|
103
|
+
- examples/railsapp/app/controllers/tommy_boy_controller.rb
|
104
|
+
- examples/railsapp/app/helpers/application_helper.rb
|
105
|
+
- examples/railsapp/app/helpers/tommy_boy_helper.rb
|
106
|
+
- examples/railsapp/app/views/layouts/application.html.erb
|
107
|
+
- examples/railsapp/app/views/tommy_boy/index.html.erb
|
108
|
+
- examples/railsapp/app/views/tommy_boy/more.html.erb
|
109
|
+
- examples/railsapp/config/boot.rb
|
110
|
+
- examples/railsapp/config/database.yml
|
111
|
+
- examples/railsapp/config/environment.rb
|
112
|
+
- examples/railsapp/config/environments/development.rb
|
113
|
+
- examples/railsapp/config/environments/production.rb
|
114
|
+
- examples/railsapp/config/environments/test.rb
|
115
|
+
- examples/railsapp/config/initializers/backtrace_silencers.rb
|
116
|
+
- examples/railsapp/config/initializers/inflections.rb
|
117
|
+
- examples/railsapp/config/initializers/mime_types.rb
|
118
|
+
- examples/railsapp/config/initializers/new_rails_defaults.rb
|
119
|
+
- examples/railsapp/config/initializers/session_store.rb
|
120
|
+
- examples/railsapp/config/locales/en.yml
|
121
|
+
- examples/railsapp/config/routes.rb
|
122
|
+
- examples/railsapp/db/development.sqlite3
|
123
|
+
- examples/railsapp/db/seeds.rb
|
124
|
+
- examples/railsapp/doc/README_FOR_APP
|
125
|
+
- examples/railsapp/log/production.log
|
126
|
+
- examples/railsapp/log/server.log
|
127
|
+
- examples/railsapp/log/test.log
|
128
|
+
- examples/railsapp/public/404.html
|
129
|
+
- examples/railsapp/public/422.html
|
130
|
+
- examples/railsapp/public/500.html
|
131
|
+
- examples/railsapp/public/favicon.ico
|
132
|
+
- examples/railsapp/public/images/rails.png
|
133
|
+
- examples/railsapp/public/javascripts/application.js
|
134
|
+
- examples/railsapp/public/javascripts/controls.js
|
135
|
+
- examples/railsapp/public/javascripts/dragdrop.js
|
136
|
+
- examples/railsapp/public/javascripts/effects.js
|
137
|
+
- examples/railsapp/public/javascripts/prototype.js
|
138
|
+
- examples/railsapp/public/robots.txt
|
139
|
+
- examples/railsapp/script/about
|
140
|
+
- examples/railsapp/script/console
|
141
|
+
- examples/railsapp/script/dbconsole
|
142
|
+
- examples/railsapp/script/destroy
|
143
|
+
- examples/railsapp/script/generate
|
144
|
+
- examples/railsapp/script/performance/benchmarker
|
145
|
+
- examples/railsapp/script/performance/profiler
|
146
|
+
- examples/railsapp/script/plugin
|
147
|
+
- examples/railsapp/script/runner
|
148
|
+
- examples/railsapp/script/server
|
149
|
+
- examples/railsapp/test/functional/tommy_boy_controller_test.rb
|
150
|
+
- examples/railsapp/test/performance/browsing_test.rb
|
151
|
+
- examples/railsapp/test/test_helper.rb
|
152
|
+
- examples/railsapp/test/unit/helpers/tommy_boy_helper_test.rb
|
153
|
+
- examples/sinatraapp/app.rb
|
154
|
+
- gem.yml
|
155
|
+
- lib/mason_helper.rb
|
156
|
+
- lib/mason_test_helper.rb
|
157
|
+
- lib/rack-mason.rb
|
158
|
+
- test/rack-mason_test.rb
|
159
|
+
- test/test_helper.rb
|
160
|
+
- vex/gem.rake
|
161
|
+
- vex/gem.rb
|
162
|
+
has_rdoc: true
|
163
|
+
homepage: http://github.com/radiospiel/rack-mason
|
164
|
+
licenses: []
|
165
|
+
|
166
|
+
post_install_message:
|
167
|
+
rdoc_options: []
|
168
|
+
|
169
|
+
require_paths:
|
170
|
+
- lib
|
171
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
172
|
+
none: false
|
173
|
+
requirements:
|
174
|
+
- - ">="
|
175
|
+
- !ruby/object:Gem::Version
|
176
|
+
hash: 3
|
177
|
+
segments:
|
178
|
+
- 0
|
179
|
+
version: "0"
|
180
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
181
|
+
none: false
|
182
|
+
requirements:
|
183
|
+
- - ">="
|
184
|
+
- !ruby/object:Gem::Version
|
185
|
+
hash: 3
|
186
|
+
segments:
|
187
|
+
- 0
|
188
|
+
version: "0"
|
189
|
+
requirements: []
|
190
|
+
|
191
|
+
rubyforge_project:
|
192
|
+
rubygems_version: 1.6.2
|
193
|
+
signing_key:
|
194
|
+
specification_version: 3
|
195
|
+
summary: Helps you write Rack middleware using Nokogiri.
|
196
|
+
test_files: []
|
197
|
+
|