sinatra-contrib 2.0.0.rc1 → 2.0.0.rc2

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.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +2 -1
  3. data/lib/sinatra/decompile.rb +5 -0
  4. data/lib/sinatra/runner.rb +155 -0
  5. data/lib/sinatra/webdav.rb +93 -0
  6. data/sinatra-contrib.gemspec +5 -199
  7. metadata +13 -175
  8. data/spec/capture_spec.rb +0 -100
  9. data/spec/config_file/key_value.yml +0 -7
  10. data/spec/config_file/key_value.yml.erb +0 -6
  11. data/spec/config_file/key_value_override.yml +0 -2
  12. data/spec/config_file/missing_env.yml +0 -4
  13. data/spec/config_file/with_envs.yml +0 -7
  14. data/spec/config_file/with_nested_envs.yml +0 -11
  15. data/spec/config_file_spec.rb +0 -76
  16. data/spec/content_for/different_key.erb +0 -1
  17. data/spec/content_for/different_key.erubis +0 -1
  18. data/spec/content_for/different_key.haml +0 -2
  19. data/spec/content_for/different_key.slim +0 -2
  20. data/spec/content_for/footer.erb +0 -3
  21. data/spec/content_for/footer.erubis +0 -3
  22. data/spec/content_for/footer.haml +0 -2
  23. data/spec/content_for/footer.slim +0 -2
  24. data/spec/content_for/layout.erb +0 -1
  25. data/spec/content_for/layout.erubis +0 -1
  26. data/spec/content_for/layout.haml +0 -1
  27. data/spec/content_for/layout.slim +0 -1
  28. data/spec/content_for/multiple_blocks.erb +0 -4
  29. data/spec/content_for/multiple_blocks.erubis +0 -4
  30. data/spec/content_for/multiple_blocks.haml +0 -8
  31. data/spec/content_for/multiple_blocks.slim +0 -8
  32. data/spec/content_for/multiple_yields.erb +0 -3
  33. data/spec/content_for/multiple_yields.erubis +0 -3
  34. data/spec/content_for/multiple_yields.haml +0 -3
  35. data/spec/content_for/multiple_yields.slim +0 -3
  36. data/spec/content_for/passes_values.erb +0 -1
  37. data/spec/content_for/passes_values.erubis +0 -1
  38. data/spec/content_for/passes_values.haml +0 -1
  39. data/spec/content_for/passes_values.slim +0 -1
  40. data/spec/content_for/same_key.erb +0 -1
  41. data/spec/content_for/same_key.erubis +0 -1
  42. data/spec/content_for/same_key.haml +0 -2
  43. data/spec/content_for/same_key.slim +0 -2
  44. data/spec/content_for/takes_values.erb +0 -1
  45. data/spec/content_for/takes_values.erubis +0 -1
  46. data/spec/content_for/takes_values.haml +0 -3
  47. data/spec/content_for/takes_values.slim +0 -3
  48. data/spec/content_for_spec.rb +0 -241
  49. data/spec/cookies_spec.rb +0 -826
  50. data/spec/custom_logger_spec.rb +0 -43
  51. data/spec/extension_spec.rb +0 -32
  52. data/spec/json_spec.rb +0 -115
  53. data/spec/link_header_spec.rb +0 -99
  54. data/spec/multi_route_spec.rb +0 -59
  55. data/spec/namespace/foo.erb +0 -1
  56. data/spec/namespace/nested/foo.erb +0 -1
  57. data/spec/namespace_spec.rb +0 -791
  58. data/spec/okjson.rb +0 -581
  59. data/spec/reloader/app.rb.erb +0 -40
  60. data/spec/reloader_spec.rb +0 -465
  61. data/spec/required_params_spec.rb +0 -68
  62. data/spec/respond_with/bar.erb +0 -1
  63. data/spec/respond_with/bar.json.erb +0 -1
  64. data/spec/respond_with/baz.yajl +0 -1
  65. data/spec/respond_with/foo.html.erb +0 -1
  66. data/spec/respond_with/not_html.sass +0 -2
  67. data/spec/respond_with_spec.rb +0 -317
  68. data/spec/spec_helper.rb +0 -7
  69. data/spec/streaming_spec.rb +0 -415
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6d991b914291bb371442ba8031c64548acd0ed2f
4
- data.tar.gz: 87caaefbed03e5ad9b760fe37e9a855dd7b2f728
3
+ metadata.gz: 8a3837b4e5796761383a09064e40f682862a48a9
4
+ data.tar.gz: c0e347a6f786ca317d0c42d62d20e72dfffe46b6
5
5
  SHA512:
6
- metadata.gz: 187c5077d865228cef464aab890399b53c2c9f299b0c91710f64d74342307ddefcb0c20e03cf72cedd831243535d199b327cb92245345cf6e5dff7a0caaa897d
7
- data.tar.gz: 021b1a649f15e0eb78a92fe70b9a88e771103e6b4736baf62ba2da088b14c1dcc1fc87448b18e9c3dbf06c7dc2d44fb2a0f9d3f06cfbde7562dacef5502ce138
6
+ metadata.gz: 0eed9a63680ab183eb8b2ed3161eed6b38280c668196a9052225e86ebea07b2af4aaa3c9c6a5cb87ada74146b30f4efee7eca66815cd2f5f1c8ee63e611ec192
7
+ data.tar.gz: e5a2555a09268cb5c1c96dd023ad764c1758da22e01751cdc40adc1c14ee42df05306375bec6606131d512ab795d1fc656d6e6e3c2b591b5999ae14397c5c3fb
data/LICENSE CHANGED
@@ -1,6 +1,7 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2008-2011 Nicolas Sanguinetti, entp.com, Konstantin Haase
3
+ Copyright (c) 2008-2017 Nicolas Sanguinetti, entp.com, Konstantin Haase
4
+ Copyright (c) 2015-2017 Zachary Scott
4
5
 
5
6
  Permission is hereby granted, free of charge, to any person obtaining
6
7
  a copy of this software and associated documentation files (the
@@ -0,0 +1,5 @@
1
+ warn "Sinatra::Decompile is deprecated without replacement."
2
+
3
+ def warn(message)
4
+ super "#{caller.first[/^[^:]:\d+:/]} warning: #{message}"
5
+ end
@@ -0,0 +1,155 @@
1
+ require 'open-uri'
2
+ require 'net/http'
3
+ require 'timeout'
4
+
5
+ # NOTE: This feature is experimental, and missing tests!
6
+ #
7
+ # Helps you spinning up and shutting down your own sinatra app. This is especially helpful for running
8
+ # real network tests against a sinatra backend.
9
+ #
10
+ # The backend server could look like the following (in test/server.rb).
11
+ #
12
+ # require "sinatra"
13
+ #
14
+ # get "/" do
15
+ # "Cheers from test server"
16
+ # end
17
+ #
18
+ # get "/ping" do
19
+ # "1"
20
+ # end
21
+ #
22
+ # Note that you need to implement a ping action for internal use.
23
+ #
24
+ # Next, you need to write your runner.
25
+ #
26
+ # require 'sinatra/runner'
27
+ #
28
+ # class Runner < Sinatra::Runner
29
+ # def app_file
30
+ # File.expand_path("../server.rb", __FILE__)
31
+ # end
32
+ # end
33
+ #
34
+ # Override Runner#app_file, #command, #port, #protocol and #ping_path for customization.
35
+ #
36
+ # **Don't forget to override #app_file specific to your application!**
37
+ #
38
+ # Whereever you need this test backend, here's how you manage it. The following example assumes you
39
+ # have a test in your app that needs to be run against your test backend.
40
+ #
41
+ # runner = ServerRunner.new
42
+ # runner.run
43
+ #
44
+ # # ..tests against localhost:4567 here..
45
+ #
46
+ # runner.kill
47
+ #
48
+ # For an example, check https://github.com/apotonick/roar/blob/master/test/integration/runner.rb
49
+ module Sinatra
50
+ class Runner
51
+ def app_file
52
+ File.expand_path("../server.rb", __FILE__)
53
+ end
54
+
55
+ def run
56
+ @pipe = start
57
+ @started = Time.now
58
+ warn "#{server} up and running on port #{port}" if ping
59
+ end
60
+
61
+ def kill
62
+ return unless pipe
63
+ Process.kill("KILL", pipe.pid)
64
+ rescue NotImplementedError
65
+ system "kill -9 #{pipe.pid}"
66
+ rescue Errno::ESRCH
67
+ end
68
+
69
+ def get(url)
70
+ Timeout.timeout(1) { get_url("#{protocol}://127.0.0.1:#{port}#{url}") }
71
+ end
72
+
73
+ def get_stream(url = "/stream", &block)
74
+ Net::HTTP.start '127.0.0.1', port do |http|
75
+ request = Net::HTTP::Get.new url
76
+ http.request request do |response|
77
+ response.read_body(&block)
78
+ end
79
+ end
80
+ end
81
+
82
+ def get_response(url)
83
+ Net::HTTP.start '127.0.0.1', port do |http|
84
+ request = Net::HTTP::Get.new url
85
+ http.request request do |response|
86
+ response
87
+ end
88
+ end
89
+ end
90
+
91
+ def log
92
+ @log ||= ""
93
+ loop { @log << pipe.read_nonblock(1) }
94
+ rescue Exception
95
+ @log
96
+ end
97
+
98
+ private
99
+ attr_accessor :pipe
100
+
101
+ def start
102
+ IO.popen(command)
103
+ end
104
+
105
+ def command # to be overwritten
106
+ "bundle exec ruby #{app_file} -p #{port} -e production"
107
+ end
108
+
109
+ def ping(timeout=30)
110
+ loop do
111
+ return if alive?
112
+ if Time.now - @started > timeout
113
+ $stderr.puts command, log
114
+ fail "timeout"
115
+ else
116
+ sleep 0.1
117
+ end
118
+ end
119
+ end
120
+
121
+ def alive?
122
+ 3.times { get(ping_path) }
123
+ true
124
+ rescue Errno::ECONNREFUSED, Errno::ECONNRESET, EOFError, SystemCallError, OpenURI::HTTPError, Timeout::Error
125
+ false
126
+ end
127
+
128
+ def ping_path # to be overwritten
129
+ '/ping'
130
+ end
131
+
132
+ def port # to be overwritten
133
+ 4567
134
+ end
135
+
136
+ def protocol
137
+ "http"
138
+ end
139
+
140
+ def get_url(url)
141
+ uri = URI.parse(url)
142
+
143
+ return uri.read unless protocol == "https"
144
+ get_https_url(uri)
145
+ end
146
+
147
+ def get_https_url(uri)
148
+ http = Net::HTTP.new(uri.host, uri.port)
149
+ http.use_ssl = true
150
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
151
+ request = Net::HTTP::Get.new(uri.request_uri)
152
+ http.request(request).body
153
+ end
154
+ end
155
+ end
@@ -0,0 +1,93 @@
1
+ require 'sinatra/base'
2
+
3
+ module Sinatra
4
+
5
+ # = Sinatra::WebDAV
6
+ #
7
+ # This extensions provides WebDAV verbs, as defined by RFC 4918
8
+ # (https://tools.ietf.org/html/rfc4918). To use this in your app,
9
+ # just +register+ it:
10
+ #
11
+ # require 'sinatra/base'
12
+ # require 'sinatra/webdav'
13
+ #
14
+ # class Application < Sinatra::Base
15
+ # register Sinatra::WebDAV
16
+ #
17
+ # # Now you can use any WebDAV verb:
18
+ # propfind '/2014/january/21' do
19
+ # 'I have a lunch at 9 PM'
20
+ # end
21
+ # end
22
+ #
23
+ # You can use it in classic application just by requring the extension:
24
+ #
25
+ # require 'sinatra'
26
+ # require 'sinatra/webdav'
27
+ #
28
+ # mkcol '/2015' do
29
+ # 'You started 2015!'
30
+ # end
31
+ #
32
+ module WebDAV
33
+ def self.registered(_)
34
+ Sinatra::Request.include WebDAV::Request
35
+ end
36
+
37
+ module Request
38
+ def self.included(base)
39
+ base.class_eval do
40
+ alias _safe? safe?
41
+ alias _idempotent? idempotent?
42
+
43
+ def safe?
44
+ _safe? or propfind?
45
+ end
46
+
47
+ def idempotent?
48
+ _idempotent? or propfind? or move? or unlock? # or lock?
49
+ end
50
+ end
51
+ end
52
+
53
+ def propfind?
54
+ request_method == 'PROPFIND'
55
+ end
56
+
57
+ def proppatch?
58
+ request_method == 'PROPPATCH'
59
+ end
60
+
61
+ def mkcol?
62
+ request_method == 'MKCOL'
63
+ end
64
+
65
+ def copy?
66
+ request_method == 'COPY'
67
+ end
68
+
69
+ def move?
70
+ request_method == 'MOVE'
71
+ end
72
+
73
+ #def lock?
74
+ # request_method == 'LOCK'
75
+ #end
76
+
77
+ def unlock?
78
+ request_method == 'UNLOCK'
79
+ end
80
+ end
81
+
82
+ def propfind(path, opts = {}, &bk) route 'PROPFIND', path, opts, &bk end
83
+ def proppatch(path, opts = {}, &bk) route 'PROPPATCH', path, opts, &bk end
84
+ def mkcol(path, opts = {}, &bk) route 'MKCOL', path, opts, &bk end
85
+ def copy(path, opts = {}, &bk) route 'COPY', path, opts, &bk end
86
+ def move(path, opts = {}, &bk) route 'MOVE', path, opts, &bk end
87
+ #def lock(path, opts = {}, &bk) route 'LOCK', path, opts, &bk end
88
+ def unlock(path, opts = {}, &bk) route 'UNLOCK', path, opts, &bk end
89
+ end
90
+
91
+ register WebDAV
92
+ Delegator.delegate :propfind, :proppatch, :mkcol, :copy, :move, :unlock # :lock
93
+ end
@@ -7,211 +7,17 @@ Gem::Specification.new do |s|
7
7
  s.name = "sinatra-contrib"
8
8
  s.version = Sinatra::VERSION
9
9
  s.description = "Collection of useful Sinatra extensions"
10
- s.homepage = "http://github.com/sinatra/sinatra-contrib"
10
+ s.homepage = "http://github.com/sinatra/sinatra/tree/master/sinatra-contrib"
11
11
  s.license = "MIT"
12
12
  s.summary = s.description
13
-
14
- # generated from git shortlog -sn
15
- s.authors = [
16
- "Konstantin Haase",
17
- "Zachary Scott",
18
- "Gabriel Andretta",
19
- "Trevor Bramble",
20
- "Katrina Owen",
21
- "Ashley Williams",
22
- "Nicolas Sanguinetti",
23
- "Hrvoje Šimić",
24
- "Masahiro Fujiwara",
25
- "Rafael Magana",
26
- "Vipul A M",
27
- "ashley williams",
28
- "Jack Chu",
29
- "Sumeet Singh",
30
- "Ilya Shindyapin",
31
- "lest",
32
- "Jake Worth",
33
- "Kashyap",
34
- "Matt Lyon",
35
- "Matthew Conway",
36
- "Meck",
37
- "Michi Huber",
38
- "Nic Benders",
39
- "Patricio Mac Adden",
40
- "Reed Lipman",
41
- "Samy Dindane",
42
- "Sergey Nartimov",
43
- "Thibaut Sacreste",
44
- "Uchio KONDO",
45
- "Will Bailey",
46
- "mono",
47
- "Adrian Pacała",
48
- "undr",
49
- "Aish",
50
- "Alexey Chernenkov",
51
- "Andrew Crump",
52
- "Anton Davydov",
53
- "Bo Jeanes",
54
- "David Asabina",
55
- "Eliot Shepard",
56
- "Eric Marden",
57
- "Gray Manley",
58
- "Guillaume Bouteille",
59
- "Jamie Hodge",
60
- "Julie Ng",
61
- "Koichi Sasada",
62
- "Kyle Lacy",
63
- "Lars Vonk",
64
- "Martin Frost",
65
- "Mathieu Allaire"
66
- ]
67
-
68
- # generated from git shortlog -sne
69
- s.email = [
70
- "konstantin.mailinglists@googlemail.com",
71
- "ohhgabriel@gmail.com",
72
- "inbox@trevorbramble.com",
73
- "e@zzak.io",
74
- "zachary@zacharyscott.net",
75
- "katrina.owen@gmail.com",
76
- "ashley@bocoup.com",
77
- "contacto@nicolassanguinetti.info",
78
- "shime.ferovac@gmail.com",
79
- "raf.magana@gmail.com",
80
- "m-fujiwara@axsh.net",
81
- "vipulnsward@gmail.com",
82
- "konstantin.haase@gmail.com",
83
- "jack@jackchu.com",
84
- "ashley666ashley@gmail.com",
85
- "ilya@shindyapin.com",
86
- "just.lest@gmail.com",
87
- "kashyap.kmbc@gmail.com",
88
- "ortuna@gmail.com",
89
- "tbramble@chef.io",
90
- "jworth@prevailhs.com",
91
- "mail@zzak.io",
92
- "nic@newrelic.com",
93
- "patriciomacadden@gmail.com",
94
- "rmlipman@gmail.com",
95
- "samy@dindane.com",
96
- "just.lest@gmail.com",
97
- "thibaut.sacreste@gmail.com",
98
- "udzura@udzura.jp",
99
- "will.bailey@gmail.com",
100
- "mono@mono0x.net",
101
- "altpacala@gmail.com",
102
- "undr@yandex.ru",
103
- "aisha.fenton@visfleet.com",
104
- "laise@pisem.net",
105
- "andrew.crump@ieee.org",
106
- "antondavydov.o@gmail.com",
107
- "me@bjeanes.com",
108
- "david@supr.nu",
109
- "eshepard@slower.net",
110
- "eric.marden@gmail.com",
111
- "g.manley@tukaiz.com",
112
- "duffman@via.ecp.fr",
113
- "jamiehodge@me.com",
114
- "uxjulie@gmail.com",
115
- "ko1@atdot.net",
116
- "kylewlacy@me.com",
117
- "lars.vonk@gmail.com",
118
- "blame@kth.se",
119
- "mathieuallaire@gmail.com",
120
- "matt@flowerpowered.com",
121
- "himself@mattonrails.com",
122
- "yesmeck@gmail.com",
123
- "michi.huber@gmail.com"
124
- ]
125
-
126
- # generated from git ls-files
127
- s.files = [
13
+ s.authors = ["https://github.com/sinatra/sinatra/graphs/contributors"]
14
+ s.email = "sinatrarb@googlegroups.com"
15
+ s.files = Dir["lib/**/*.rb"] + [
128
16
  "LICENSE",
129
17
  "README.md",
130
18
  "Rakefile",
131
19
  "ideas.md",
132
- "lib/sinatra/capture.rb",
133
- "lib/sinatra/config_file.rb",
134
- "lib/sinatra/content_for.rb",
135
- "lib/sinatra/contrib.rb",
136
- "lib/sinatra/contrib/all.rb",
137
- "lib/sinatra/contrib/setup.rb",
138
- "lib/sinatra/contrib/version.rb",
139
- "lib/sinatra/cookies.rb",
140
- "lib/sinatra/custom_logger.rb",
141
- "lib/sinatra/engine_tracking.rb",
142
- "lib/sinatra/extension.rb",
143
- "lib/sinatra/json.rb",
144
- "lib/sinatra/link_header.rb",
145
- "lib/sinatra/multi_route.rb",
146
- "lib/sinatra/namespace.rb",
147
- "lib/sinatra/reloader.rb",
148
- "lib/sinatra/respond_with.rb",
149
- "lib/sinatra/streaming.rb",
150
- "lib/sinatra/required_params.rb",
151
- "lib/sinatra/test_helpers.rb",
152
- "sinatra-contrib.gemspec",
153
- "spec/capture_spec.rb",
154
- "spec/config_file/key_value.yml",
155
- "spec/config_file/key_value.yml.erb",
156
- "spec/config_file/key_value_override.yml",
157
- "spec/config_file/missing_env.yml",
158
- "spec/config_file/with_envs.yml",
159
- "spec/config_file/with_nested_envs.yml",
160
- "spec/config_file_spec.rb",
161
- "spec/content_for/different_key.erb",
162
- "spec/content_for/different_key.erubis",
163
- "spec/content_for/different_key.haml",
164
- "spec/content_for/different_key.slim",
165
- "spec/content_for/footer.erb",
166
- "spec/content_for/footer.erubis",
167
- "spec/content_for/footer.haml",
168
- "spec/content_for/footer.slim",
169
- "spec/content_for/layout.erb",
170
- "spec/content_for/layout.erubis",
171
- "spec/content_for/layout.haml",
172
- "spec/content_for/layout.slim",
173
- "spec/content_for/multiple_blocks.erb",
174
- "spec/content_for/multiple_blocks.erubis",
175
- "spec/content_for/multiple_blocks.haml",
176
- "spec/content_for/multiple_blocks.slim",
177
- "spec/content_for/multiple_yields.erb",
178
- "spec/content_for/multiple_yields.erubis",
179
- "spec/content_for/multiple_yields.haml",
180
- "spec/content_for/multiple_yields.slim",
181
- "spec/content_for/passes_values.erb",
182
- "spec/content_for/passes_values.erubis",
183
- "spec/content_for/passes_values.haml",
184
- "spec/content_for/passes_values.slim",
185
- "spec/content_for/same_key.erb",
186
- "spec/content_for/same_key.erubis",
187
- "spec/content_for/same_key.haml",
188
- "spec/content_for/same_key.slim",
189
- "spec/content_for/takes_values.erb",
190
- "spec/content_for/takes_values.erubis",
191
- "spec/content_for/takes_values.haml",
192
- "spec/content_for/takes_values.slim",
193
- "spec/content_for_spec.rb",
194
- "spec/cookies_spec.rb",
195
- "spec/custom_logger_spec.rb",
196
- "spec/extension_spec.rb",
197
- "spec/json_spec.rb",
198
- "spec/link_header_spec.rb",
199
- "spec/multi_route_spec.rb",
200
- "spec/namespace/foo.erb",
201
- "spec/namespace/nested/foo.erb",
202
- "spec/namespace_spec.rb",
203
- "spec/okjson.rb",
204
- "spec/reloader/app.rb.erb",
205
- "spec/reloader_spec.rb",
206
- "spec/respond_with/bar.erb",
207
- "spec/respond_with/bar.json.erb",
208
- "spec/respond_with/baz.yajl",
209
- "spec/respond_with/foo.html.erb",
210
- "spec/respond_with/not_html.sass",
211
- "spec/respond_with_spec.rb",
212
- "spec/spec_helper.rb",
213
- "spec/streaming_spec.rb",
214
- "spec/required_params_spec.rb",
20
+ "sinatra-contrib.gemspec"
215
21
  ]
216
22
 
217
23
  s.required_ruby_version = '>= 2.2.0'