roger 0.12.5 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -30,7 +30,7 @@ module CustomGens
30
30
  end
31
31
 
32
32
  module Roger
33
- class GeneratorTest < Test::Unit::TestCase
33
+ class GeneratorTest < ::Test::Unit::TestCase
34
34
  def setup
35
35
  @cli = Cli::Base.new
36
36
  end
@@ -2,7 +2,7 @@ require "./lib/roger/release.rb"
2
2
  require "./lib/roger/release/cleaner.rb"
3
3
  require "test/unit"
4
4
 
5
- class CleanerTest < Test::Unit::TestCase
5
+ class CleanerTest < ::Test::Unit::TestCase
6
6
 
7
7
  def setup
8
8
  @base = File.dirname(__FILE__) + "/../../project"
@@ -1,7 +1,7 @@
1
1
  require "./lib/roger/release.rb"
2
2
  require "test/unit"
3
3
 
4
- class ProcessorsTest < Test::Unit::TestCase
4
+ class ProcessorsTest < ::Test::Unit::TestCase
5
5
  def setup
6
6
  Roger::Release::Processors.map.clear
7
7
  end
@@ -3,7 +3,7 @@ require "./lib/roger/release.rb"
3
3
  require "test/unit"
4
4
 
5
5
  module Roger
6
- class ReleaseTest < Test::Unit::TestCase
6
+ class ReleaseTest < ::Test::Unit::TestCase
7
7
 
8
8
  def test_get_callable
9
9
  p = lambda{}
@@ -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"])
@@ -4,7 +4,7 @@ require "./lib/roger/template.rb"
4
4
  require "test/unit"
5
5
 
6
6
  module Roger
7
- class TemplateTest < Test::Unit::TestCase
7
+ class TemplateTest < ::Test::Unit::TestCase
8
8
  def setup
9
9
  @base = Pathname.new(File.dirname(__FILE__) + "/../project")
10
10
  @config = {
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.12.5
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-19 00:00:00.000000000 Z
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.16.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.16.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: 2.5.5
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: 2.5.5
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/w3c_validator.rb
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/cli_test.rb
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/cli_test.rb
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
@@ -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
@@ -1,12 +0,0 @@
1
- require "./lib/roger/cli.rb"
2
- require "test/unit"
3
-
4
- module Roger
5
- class CliTest < Test::Unit::TestCase
6
-
7
- def test_register_generators
8
- assert_includes Cli::Base.subcommands, "generate"
9
- end
10
-
11
- end
12
- end