isomorfeus-iodine 0.7.50 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3f6d52427fb6c73c781981a09b9217b557e2da7c676578d7c726c375f8f49919
4
- data.tar.gz: 24b2b507bb66405986b947085fcc6ac65d921fb3e7775ffb00ea82909cfc74fb
3
+ metadata.gz: 5d50f8965211cbcbbd9ea83e2caf5bbe9bb2c82699fcf9f70d401ccfe436af4c
4
+ data.tar.gz: e5703c8ea79c04d5389d115e62da6bebc1c28357868fd2df47207500a7a48325
5
5
  SHA512:
6
- metadata.gz: '059aafd0ed382cc2b7446532d83a19121e19e61c8c9590bf372d074149aee2765426452c488020a2b55720fc63fbf050cc4314e26398495945957d55b9328a8c'
7
- data.tar.gz: e0e74b28d8f2c193271aa8a610298f003913e0214870ca2dd20d4c87a7358da04bd63015204788eabbe84215f4c89582f85f2d1bb4504773e8b46776d744ae3b
6
+ metadata.gz: 7b4245d04c37d3fe90dd1d88fec0aa7ecba5ce2e7b52066a2c9a8608dbc6a8d1be60b61f9c941fcf00014fd6206ff63229976a42d614262cedae5abf6c440521
7
+ data.tar.gz: e38cca54a7203adbab3d82a60e994e265f1f53e0effd1209e7b680bd042d31495e8640eba6e3f4d65322efd173262e8ffca674180b1b5fa8e329241458985fb8
data/exe/iodine CHANGED
@@ -3,208 +3,9 @@
3
3
  IODINE_PARSE_CLI = true
4
4
  require 'iodine'
5
5
 
6
- # Load Rack if available (assume it will be used).
7
- #
8
- # Remember, code costs memory. Duplicating the Rack::Builder module and functions can be avoided.
9
- begin
10
- require 'rack'
11
- module Iodine
12
- module Base
13
- module Rack
14
- Builder = ::Rack::Builder
15
- end
16
- end
17
- end
18
- rescue LoadError
19
- module Iodine
20
- module Base
21
- module Rack
22
- # The Rack::Builder code is used when Rack isn't available.
23
- #
24
- # The code was copied (with minor adjustments) from the Rack source code and is licensed under the MIT license.
25
- # Copyright (C) 2007-2019 Leah Neukirchen <http://leahneukirchen.org/infopage.html>
26
- #
27
- # ====
28
- #
29
- # Rack::Builder implements a small DSL to iteratively construct Rack
30
- # applications.
31
- #
32
- # Example:
33
- #
34
- # require 'rack/lobster'
35
- # app = Rack::Builder.new do
36
- # use Rack::CommonLogger
37
- # use Rack::ShowExceptions
38
- # map "/lobster" do
39
- # use Rack::Lint
40
- # run Rack::Lobster.new
41
- # end
42
- # end
43
- #
44
- # run app
45
- #
46
- # Or
47
- #
48
- # app = Rack::Builder.app do
49
- # use Rack::CommonLogger
50
- # run lambda { |env| [200, {'Content-Type' => 'text/plain'}, ['OK']] }
51
- # end
52
- #
53
- # run app
54
- #
55
- # +use+ adds middleware to the stack, +run+ dispatches to an application.
56
- # You can use +map+ to construct a Rack::URLMap in a convenient way.
57
- class Builder
58
- # https://stackoverflow.com/questions/2223882/whats-the-difference-between-utf-8-and-utf-8-without-bom
59
- UTF_8_BOM = '\xef\xbb\xbf'
60
-
61
- def self.parse_file(config, opts = Hash.new)
62
- if config =~ /\.ru$/
63
- return self.load_file(config, opts)
64
- else
65
- require config
66
- app = Object.const_get(::File.basename(config, '.rb').split('_').map(&:capitalize).join(''))
67
- return app, {}
68
- end
69
- end
6
+ # Load Rack if available (assume it will be used)
70
7
 
71
- def self.load_file(path, options = Hash.new)
72
- cfgfile = ::File.read(path)
73
- cfgfile.slice!(/\A#{UTF_8_BOM}/) if cfgfile.encoding == Encoding::UTF_8
74
-
75
- cfgfile.sub!(/^__END__\n.*\Z/m, '')
76
- app = new_from_string cfgfile, path
77
-
78
- return app, options
79
- end
80
-
81
- def self.new_from_string(builder_script, file = "(rackup)")
82
- eval "Iodine::Base::Rack::Builder.new {\n" + builder_script + "\n}.to_app",
83
- TOPLEVEL_BINDING, file, 0
84
- end
85
-
86
- def initialize(default_app = nil, &block)
87
- @use, @map, @run, @warmup, @freeze_app = [], nil, default_app, nil, false
88
- instance_eval(&block) if block_given?
89
- end
90
-
91
- def self.app(default_app = nil, &block)
92
- self.new(default_app, &block).to_app
93
- end
94
-
95
- # Specifies middleware to use in a stack.
96
- #
97
- # class Middleware
98
- # def initialize(app)
99
- # @app = app
100
- # end
101
- #
102
- # def call(env)
103
- # env["rack.some_header"] = "setting an example"
104
- # @app.call(env)
105
- # end
106
- # end
107
- #
108
- # use Middleware
109
- # run lambda { |env| [200, { "Content-Type" => "text/plain" }, ["OK"]] }
110
- #
111
- # All requests through to this application will first be processed by the middleware class.
112
- # The +call+ method in this example sets an additional environment key which then can be
113
- # referenced in the application if required.
114
- def use(middleware, *args, &block)
115
- if @map
116
- mapping, @map = @map, nil
117
- @use << proc { |app| generate_map(app, mapping) }
118
- end
119
- @use << proc { |app| middleware.new(app, *args, &block) }
120
- end
121
-
122
- # Takes an argument that is an object that responds to #call and returns a Rack response.
123
- # The simplest form of this is a lambda object:
124
- #
125
- # run lambda { |env| [200, { "Content-Type" => "text/plain" }, ["OK"]] }
126
- #
127
- # However this could also be a class:
128
- #
129
- # class Heartbeat
130
- # def self.call(env)
131
- # [200, { "Content-Type" => "text/plain" }, ["OK"]]
132
- # end
133
- # end
134
- #
135
- # run Heartbeat
136
- def run(app)
137
- @run = app
138
- end
139
-
140
- # Takes a lambda or block that is used to warm-up the application.
141
- #
142
- # warmup do |app|
143
- # client = Rack::MockRequest.new(app)
144
- # client.get('/')
145
- # end
146
- #
147
- # use SomeMiddleware
148
- # run MyApp
149
- def warmup(prc = nil, &block)
150
- @warmup = prc || block
151
- end
152
-
153
- # Creates a route within the application.
154
- #
155
- # Rack::Builder.app do
156
- # map '/' do
157
- # run Heartbeat
158
- # end
159
- # end
160
- #
161
- # The +use+ method can also be used here to specify middleware to run under a specific path:
162
- #
163
- # Rack::Builder.app do
164
- # map '/' do
165
- # use Middleware
166
- # run Heartbeat
167
- # end
168
- # end
169
- #
170
- # This example includes a piece of middleware which will run before requests hit +Heartbeat+.
171
- #
172
- def map(path, &block)
173
- @map ||= {}
174
- @map[path] = block
175
- end
176
-
177
- # Freeze the app (set using run) and all middleware instances when building the application
178
- # in to_app.
179
- def freeze_app
180
- @freeze_app = true
181
- end
182
-
183
- def to_app
184
- app = @map ? generate_map(@run, @map) : @run
185
- fail "missing run or map statement" unless app
186
- app.freeze if @freeze_app
187
- app = @use.reverse.inject(app) { |a, e| e[a].tap { |x| x.freeze if @freeze_app } }
188
- @warmup.call(app) if @warmup
189
- app
190
- end
191
-
192
- def call(env)
193
- to_app.call(env)
194
- end
195
-
196
- private
197
-
198
- def generate_map(default_app, mapping)
199
- mapped = default_app ? { '/' => default_app } : {}
200
- mapping.each { |r, b| mapped[r] = self.class.new(default_app, &b).to_app }
201
- URLMap.new(mapped)
202
- end
203
- end
204
- end
205
- end
206
- end
207
- end
8
+ require 'rack'
208
9
 
209
10
  module Iodine
210
11
  # The Iodine::Base namespace is reserved for internal use and is NOT part of the public API.
@@ -214,37 +15,23 @@ module Iodine
214
15
 
215
16
  def self.try_file filename
216
17
  return nil unless File.exist? filename
217
- return Iodine::Base::Rack::Builder.parse_file filename
18
+ ::Rack::Builder.parse_file filename
218
19
  end
219
20
 
220
- def self.get_app_opts
221
- app, opt = nil, nil
21
+ def self.get_app
22
+ app = nil
222
23
  filename = Iodine::DEFAULT_SETTINGS[:filename_]
223
24
  if filename
224
- app, opt = try_file filename
225
- app, opt = try_file "#{filename}.ru" unless opt
226
- unless opt
25
+ app = try_file filename
26
+ app = try_file "#{filename}.ru" unless app
27
+ unless app
227
28
  puts "* Couldn't find #{filename}\n testing for config.ru\n"
228
- app, opt = try_file "config.ru"
29
+ app = try_file "config.ru"
229
30
  end
230
31
  else
231
- app, opt = try_file "config.ru";
232
- end
233
-
234
- unless opt
235
- puts "WARNING: Ruby application not found#{ filename ? " - missing both #{filename} and config.ru" : " - missing config.ru"}."
236
- if Iodine::DEFAULT_SETTINGS[:public]
237
- puts " Running only static file service."
238
- opt = Hash.new
239
- app = Proc.new { [404, {}, "Not Found!"] }
240
- else
241
- puts "\nERROR: Couldn't run Ruby application, check command line arguments."
242
- ARGV << "-?"
243
- Iodine::Base::CLI.parse
244
- exit(0);
245
- end
32
+ app = try_file "config.ru";
246
33
  end
247
- return app, opt
34
+ app
248
35
  end
249
36
 
250
37
  def self.perform_warmup(app)
@@ -256,7 +43,7 @@ module Iodine
256
43
  rescue StandardError => _e
257
44
  end
258
45
  end
259
- Iodine::Base::Rack::Builder.new(app) do |r|
46
+ ::Rack::Builder.new(app) do |r|
260
47
  r.warmup do |a|
261
48
  client = ::Rack::MockRequest.new(a)
262
49
  client.get('/')
@@ -266,9 +53,9 @@ module Iodine
266
53
  end
267
54
 
268
55
  def self.call
269
- app, opt = get_app_opts
56
+ app = get_app
270
57
  perform_warmup(app) if Iodine::DEFAULT_SETTINGS[:warmup_]
271
- Iodine::Rack.run(app, opt)
58
+ Iodine::Rack.run(app)
272
59
  end
273
60
  end
274
61
  end
@@ -34,6 +34,8 @@ Gem::Specification.new do |spec|
34
34
  spec.requirements << 'TLS requires OpenSSL >= 1.1.0.'
35
35
  spec.requirements << 'Or Windows with Ruby >= 3.0.0 build with MingW and MingW as compiler.'
36
36
 
37
+ spec.add_dependency 'rackup', '~> 0.2.2'
38
+ spec.add_dependency 'rack', '~> 3.0.0'
37
39
  spec.add_development_dependency 'rake', '~> 13.0', '< 14.0'
38
40
  spec.add_development_dependency 'minitest', '>=5', '< 6.0'
39
41
  spec.add_development_dependency 'rspec', '>=3.9.0', '< 4.0'
@@ -1,3 +1,3 @@
1
1
  module Iodine
2
- VERSION = '0.7.50'.freeze
2
+ VERSION = '0.8.0'.freeze
3
3
  end
@@ -27,7 +27,9 @@ end
27
27
  ENV['RACK_HANDLER'] ||= 'iodine'
28
28
 
29
29
  begin
30
- ::Rack::Handler.register('iodine', 'Iodine::Rack') if defined?(::Rack::Handler)
31
- ::Rack::Handler.register('Iodine', 'Iodine::Rack') if defined?(::Rack::Handler)
30
+ if defined?(::Rackup::Handler)
31
+ ::Rackup::Handler.register('iodine', Iodine::Rack)
32
+ ::Rackup::Handler.register('Iodine', Iodine::Rack)
33
+ end
32
34
  rescue StandardError
33
35
  end
metadata CHANGED
@@ -1,15 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: isomorfeus-iodine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.50
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Biedermann
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-05-28 00:00:00.000000000 Z
11
+ date: 2022-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rackup
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.2.2
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.2.2
27
+ - !ruby/object:Gem::Dependency
28
+ name: rack
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 3.0.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 3.0.0
13
41
  - !ruby/object:Gem::Dependency
14
42
  name: rake
15
43
  requirement: !ruby/object:Gem::Requirement
@@ -247,7 +275,7 @@ metadata:
247
275
  github_repo: ssh://github.com/isomorfeus/gems
248
276
  source_code_uri: https://github.com/isomorfeus/isomorfeus-iodine
249
277
  post_install_message: |-
250
- Thank you for installing Iodine 0.7.50.
278
+ Thank you for installing Iodine 0.8.0.
251
279
  Remember: if iodine supports your business, it's only fair to give value back (code contributions / donations) to Bo, see https://github.com/boazsegev/iodine
252
280
  rdoc_options: []
253
281
  require_paths: