roger 0.12.5 → 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/CHANGELOG.md +9 -0
- data/lib/roger/cli.rb +12 -44
- data/lib/roger/cli/command.rb +5 -1
- data/lib/roger/cli/generate.rb +3 -1
- data/lib/roger/cli/test.rb +16 -0
- data/lib/roger/helpers/get_callable.rb +28 -0
- data/lib/roger/helpers/logging.rb +30 -0
- data/lib/roger/mockupfile.rb +10 -3
- data/lib/roger/project.rb +19 -8
- data/lib/roger/release.rb +9 -51
- data/lib/roger/release/finalizers/rsync.rb +2 -56
- data/lib/roger/server.rb +0 -3
- data/lib/roger/test.rb +134 -0
- data/roger.gemspec +3 -3
- data/test/Mockupfile-syntax.rb +18 -10
- data/test/project/Mockupfile +7 -2
- data/test/project/html/formats/index.html +10 -1
- data/test/project/lib/tests/fail/fail.rb +17 -0
- data/test/project/lib/tests/noop/lib/cli.rb +8 -0
- data/test/project/lib/tests/noop/lib/test.rb +15 -0
- data/test/project/lib/tests/noop/noop.rb +7 -0
- data/test/project/lib/tests/succeed/succeed.rb +17 -0
- data/test/unit/cli/cli_base_test.rb +24 -0
- data/test/unit/cli/cli_test_test.rb +142 -0
- data/test/unit/generators_test.rb +1 -1
- data/test/unit/release/cleaner_test.rb +1 -1
- data/test/unit/release/processors_test.rb +1 -1
- data/test/unit/release_test.rb +1 -1
- data/test/unit/resolver_test.rb +2 -2
- data/test/unit/template_test.rb +1 -1
- metadata +24 -10
- data/lib/roger/rack/html_validator.rb +0 -26
- data/lib/roger/w3c_validator.rb +0 -129
- data/test/unit/cli_test.rb +0 -12
data/test/unit/release_test.rb
CHANGED
data/test/unit/resolver_test.rb
CHANGED
@@ -3,7 +3,7 @@ require "./lib/roger/resolver.rb"
|
|
3
3
|
require "test/unit"
|
4
4
|
|
5
5
|
module Roger
|
6
|
-
class ResolverTest < Test::Unit::TestCase
|
6
|
+
class ResolverTest < ::Test::Unit::TestCase
|
7
7
|
def setup
|
8
8
|
@base = Pathname.new(File.dirname(__FILE__) + "/../project/html")
|
9
9
|
@resolver = Roger::Resolver.new(@base)
|
@@ -58,7 +58,7 @@ module Roger
|
|
58
58
|
|
59
59
|
end
|
60
60
|
|
61
|
-
class ResolverMultipleTest < Test::Unit::TestCase
|
61
|
+
class ResolverMultipleTest < ::Test::Unit::TestCase
|
62
62
|
def setup
|
63
63
|
@base = Pathname.new(File.dirname(__FILE__) + "/../project")
|
64
64
|
@resolver = Roger::Resolver.new([@base + "html", @base + "partials"])
|
data/test/unit/template_test.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: roger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Flurin Egger
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-12-
|
13
|
+
date: 2014-12-22 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: thor
|
@@ -18,14 +18,14 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0.
|
21
|
+
version: 0.19.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
26
|
- - ~>
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
version: 0.
|
28
|
+
version: 0.19.0
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: rack
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
@@ -102,14 +102,14 @@ dependencies:
|
|
102
102
|
requirements:
|
103
103
|
- - ~>
|
104
104
|
- !ruby/object:Gem::Version
|
105
|
-
version:
|
105
|
+
version: 3.0.0
|
106
106
|
type: :development
|
107
107
|
prerelease: false
|
108
108
|
version_requirements: !ruby/object:Gem::Requirement
|
109
109
|
requirements:
|
110
110
|
- - ~>
|
111
111
|
- !ruby/object:Gem::Version
|
112
|
-
version:
|
112
|
+
version: 3.0.0
|
113
113
|
- !ruby/object:Gem::Dependency
|
114
114
|
name: mocha
|
115
115
|
requirement: !ruby/object:Gem::Requirement
|
@@ -156,14 +156,16 @@ files:
|
|
156
156
|
- lib/roger/cli/generate.rb
|
157
157
|
- lib/roger/cli/release.rb
|
158
158
|
- lib/roger/cli/serve.rb
|
159
|
+
- lib/roger/cli/test.rb
|
159
160
|
- lib/roger/extractor.rb
|
160
161
|
- lib/roger/generators.rb
|
161
162
|
- lib/roger/generators/generator.rb
|
162
163
|
- lib/roger/generators/new.rb
|
163
164
|
- lib/roger/generators/templates/generator.tt
|
165
|
+
- lib/roger/helpers/get_callable.rb
|
166
|
+
- lib/roger/helpers/logging.rb
|
164
167
|
- lib/roger/mockupfile.rb
|
165
168
|
- lib/roger/project.rb
|
166
|
-
- lib/roger/rack/html_validator.rb
|
167
169
|
- lib/roger/rack/roger.rb
|
168
170
|
- lib/roger/rack/sleep.rb
|
169
171
|
- lib/roger/release.rb
|
@@ -182,7 +184,7 @@ files:
|
|
182
184
|
- lib/roger/resolver.rb
|
183
185
|
- lib/roger/server.rb
|
184
186
|
- lib/roger/template.rb
|
185
|
-
- lib/roger/
|
187
|
+
- lib/roger/test.rb
|
186
188
|
- roger.gemspec
|
187
189
|
- test/Mockupfile-syntax.rb
|
188
190
|
- test/project/.rvmrc
|
@@ -205,6 +207,11 @@ files:
|
|
205
207
|
- test/project/layouts/test.html.erb
|
206
208
|
- test/project/layouts/yield.html.erb
|
207
209
|
- test/project/lib/generators/test.rb
|
210
|
+
- test/project/lib/tests/fail/fail.rb
|
211
|
+
- test/project/lib/tests/noop/lib/cli.rb
|
212
|
+
- test/project/lib/tests/noop/lib/test.rb
|
213
|
+
- test/project/lib/tests/noop/noop.rb
|
214
|
+
- test/project/lib/tests/succeed/succeed.rb
|
208
215
|
- test/project/partials/formats/erb.html.erb
|
209
216
|
- test/project/partials/partials-test.html.erb
|
210
217
|
- test/project/partials/test/erb.html.erb
|
@@ -214,7 +221,8 @@ files:
|
|
214
221
|
- test/project/partials/test/simple.html.erb
|
215
222
|
- test/project/partials/test/yield.html.erb
|
216
223
|
- test/project/partials2/partials2-test.html.erb
|
217
|
-
- test/unit/
|
224
|
+
- test/unit/cli/cli_base_test.rb
|
225
|
+
- test/unit/cli/cli_test_test.rb
|
218
226
|
- test/unit/generators_test.rb
|
219
227
|
- test/unit/release/cleaner_test.rb
|
220
228
|
- test/unit/release/finalizers/git_branch_test.rb
|
@@ -269,6 +277,11 @@ test_files:
|
|
269
277
|
- test/project/layouts/test.html.erb
|
270
278
|
- test/project/layouts/yield.html.erb
|
271
279
|
- test/project/lib/generators/test.rb
|
280
|
+
- test/project/lib/tests/fail/fail.rb
|
281
|
+
- test/project/lib/tests/noop/lib/cli.rb
|
282
|
+
- test/project/lib/tests/noop/lib/test.rb
|
283
|
+
- test/project/lib/tests/noop/noop.rb
|
284
|
+
- test/project/lib/tests/succeed/succeed.rb
|
272
285
|
- test/project/partials/formats/erb.html.erb
|
273
286
|
- test/project/partials/partials-test.html.erb
|
274
287
|
- test/project/partials/test/erb.html.erb
|
@@ -278,7 +291,8 @@ test_files:
|
|
278
291
|
- test/project/partials/test/simple.html.erb
|
279
292
|
- test/project/partials/test/yield.html.erb
|
280
293
|
- test/project/partials2/partials2-test.html.erb
|
281
|
-
- test/unit/
|
294
|
+
- test/unit/cli/cli_base_test.rb
|
295
|
+
- test/unit/cli/cli_test_test.rb
|
282
296
|
- test/unit/generators_test.rb
|
283
297
|
- test/unit/release/cleaner_test.rb
|
284
298
|
- test/unit/release/finalizers/git_branch_test.rb
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'rack/request'
|
2
|
-
require 'rack/response'
|
3
|
-
|
4
|
-
module Roger
|
5
|
-
module Rack
|
6
|
-
class HtmlValidator
|
7
|
-
def initialize(app)
|
8
|
-
@app = app
|
9
|
-
end
|
10
|
-
|
11
|
-
def call(env)
|
12
|
-
resp = @app.call(env)
|
13
|
-
if resp[1]["Content-Type"].to_s.include?("html")
|
14
|
-
str = ""
|
15
|
-
resp[2].each{|c| str << c}
|
16
|
-
validator = W3CValidator.new(str)
|
17
|
-
validator.validate!
|
18
|
-
if !validator.valid
|
19
|
-
env["rack.errors"].puts "Validation failed on #{env["PATH_INFO"]}: (errors: #{validator.errors}, warnings: #{validator.warnings})"
|
20
|
-
end
|
21
|
-
end
|
22
|
-
resp
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
data/lib/roger/w3c_validator.rb
DELETED
@@ -1,129 +0,0 @@
|
|
1
|
-
require 'cgi'
|
2
|
-
require 'net/http'
|
3
|
-
require 'uri'
|
4
|
-
require 'yaml'
|
5
|
-
|
6
|
-
module Roger
|
7
|
-
class W3CValidator
|
8
|
-
|
9
|
-
ValidationUri = "http://validator.w3.org/check"
|
10
|
-
|
11
|
-
class RequestError < StandardError; end
|
12
|
-
|
13
|
-
attr_reader :valid,:response,:errors,:warnings,:status
|
14
|
-
|
15
|
-
class << self
|
16
|
-
def validation_uri
|
17
|
-
@uri ||= URI.parse(ValidationUri)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def initialize(html)
|
22
|
-
@html = html
|
23
|
-
end
|
24
|
-
|
25
|
-
def validate!
|
26
|
-
@status = @warnings = @errors = @response = @valid = nil
|
27
|
-
options = {"output" => "json"}
|
28
|
-
query,headers = build_post_query(options)
|
29
|
-
response = self.request(:post,self.class.validation_uri.path,query,headers)
|
30
|
-
@status,@warnings,@errors = response["x-w3c-validator-status"],response["x-w3c-validator-warnings"].to_i,response["x-w3c-validator-errors"].to_i
|
31
|
-
|
32
|
-
if @status == "Valid" && @warnings == 0 && @errors == 0
|
33
|
-
return @valid = true
|
34
|
-
else
|
35
|
-
begin
|
36
|
-
@response = YAML.load(response.body)
|
37
|
-
rescue
|
38
|
-
end
|
39
|
-
return (@valid = (@errros == 0))
|
40
|
-
end
|
41
|
-
|
42
|
-
end
|
43
|
-
|
44
|
-
protected
|
45
|
-
|
46
|
-
def build_post_query(options)
|
47
|
-
boundary = "validate-this-content-please"
|
48
|
-
headers = {"Content-type" => "multipart/form-data, boundary=" + boundary + " "}
|
49
|
-
|
50
|
-
parts = []
|
51
|
-
options.each do |k,v|
|
52
|
-
parts << post_param(k,v)
|
53
|
-
end
|
54
|
-
parts << file_param("uploaded_file","index.html",@html,"text/html")
|
55
|
-
|
56
|
-
q = parts.map{|p| "--#{boundary}\r\n#{p}"}.join("") + "--#{boundary}--"
|
57
|
-
[q,headers]
|
58
|
-
end
|
59
|
-
|
60
|
-
def post_param(k,v)
|
61
|
-
"Content-Disposition: form-data; name=\"#{CGI::escape(k)}\"\r\n\r\n#{v}\r\n"
|
62
|
-
end
|
63
|
-
|
64
|
-
def file_param(k,filename,content,mime_type)
|
65
|
-
out = []
|
66
|
-
out << "Content-Disposition: form-data; name=\"#{CGI::escape(k)}\"; filename=\"#{filename}\""
|
67
|
-
out << "Content-Transfer-Encoding: binary"
|
68
|
-
out << "Content-Type: #{mime_type}"
|
69
|
-
out.join("\r\n") + "\r\n\r\n" + content + "\r\n"
|
70
|
-
end
|
71
|
-
|
72
|
-
# Makes request to remote service.
|
73
|
-
def request(method, path, *arguments)
|
74
|
-
perform_request(method, path, arguments, 3)
|
75
|
-
end
|
76
|
-
|
77
|
-
def perform_request(method, path, arguments, tries=3)
|
78
|
-
result = nil
|
79
|
-
result = http.send(method, path, *arguments)
|
80
|
-
handle_response(result)
|
81
|
-
rescue RequestError => e
|
82
|
-
if tries > 0
|
83
|
-
perform_request(method, path, arguments, tries-1)
|
84
|
-
else
|
85
|
-
raise
|
86
|
-
end
|
87
|
-
rescue Timeout::Error => e
|
88
|
-
raise
|
89
|
-
end
|
90
|
-
|
91
|
-
# Handles response and error codes from remote service.
|
92
|
-
def handle_response(response)
|
93
|
-
case response.code.to_i
|
94
|
-
when 301,302
|
95
|
-
raise "Redirect"
|
96
|
-
when 200...400
|
97
|
-
response
|
98
|
-
when 400
|
99
|
-
raise "Bad Request"
|
100
|
-
when 401
|
101
|
-
raise "Unauthorized Access"
|
102
|
-
when 403
|
103
|
-
raise "Forbidden Access"
|
104
|
-
when 404
|
105
|
-
raise "Rescoure not found"
|
106
|
-
when 405
|
107
|
-
raise "Method not allowed"
|
108
|
-
when 409
|
109
|
-
raise RequestError.new("Rescource conflict")
|
110
|
-
when 422
|
111
|
-
raise RequestError.new("Resource invalid")
|
112
|
-
when 401...500
|
113
|
-
raise "Client error"
|
114
|
-
when 500...600
|
115
|
-
raise RequestError.new("Server error")
|
116
|
-
else
|
117
|
-
raise "Unknown response: #{response.code.to_i}"
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
def http
|
122
|
-
site = self.class.validation_uri
|
123
|
-
http = Net::HTTP.new(site.host, site.port)
|
124
|
-
# http.use_ssl = site.is_a?(URI::HTTPS)
|
125
|
-
# http.verify_mode = OpenSSL::SSL::VERIFY_NONE if http.use_ssl
|
126
|
-
http
|
127
|
-
end
|
128
|
-
end
|
129
|
-
end
|