erio 0.0.0.pre.1 → 0.0.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 00eb0cee6fec9de55efa247ae2bf261dbb6b004089d36ba28092401fa1fb6486
4
- data.tar.gz: 8c648b04718f3a01aa36704d202fdcec29f7d8363cb724ce0b6c3c418be0e7f5
3
+ metadata.gz: fb828e54c82c4a578580e448efa8f9c1b3a7d928b858797c6ff3705008248c98
4
+ data.tar.gz: 25a70971f006b187f6c2e51a3a4cde352e06fc4568e608c73afd104c38fe48bb
5
5
  SHA512:
6
- metadata.gz: 27ec96297130e59d89c861746d670174f58a891fbbfa4cead2c014dc4582366cf537e57fd07683660c2a1eac15c5b929cf0ffa303e37466a421b59f4ec7f9d05
7
- data.tar.gz: 6c14ac81103188a5ac334ac777c3a6f7dc412382100dacb96392c8f0713f086d4a08aa40a3d9fd7c91bd7d362777ac95234ddb86b5f35d6e77992af26758ebf3
6
+ metadata.gz: 2bb0f55713455608bbeac5330c338af7bef85fb84b12120c55b5e73bca76fdccf58e0e8e16d49402cd18b9913f3b5efde59b032c957f3a1091b1489c8245f93c
7
+ data.tar.gz: 91251f5e922e0d3a3e9f62127420aae508206db07de666c10995330e8500038a61cec9ed5abd92cf59bd1e7144b4b65c3c3c51227feff1d7101f0c338bf74ba1
@@ -0,0 +1,7 @@
1
+ {
2
+ "workbench.colorCustomizations": {
3
+ "activityBar.background": "#0B3600",
4
+ "titleBar.activeBackground": "#104B01",
5
+ "titleBar.activeForeground": "#EDFFE8"
6
+ }
7
+ }
data/README.md CHANGED
@@ -14,30 +14,20 @@ gem install erio
14
14
  require 'erio'
15
15
 
16
16
  class App < Erio
17
- enter do
18
- status 200
19
- header content_type: 'html'
20
- if accept? 'image'
21
- send_file '/public'+path
22
- elsif path? '/'
23
- '<h1>Hello, Erio!</h1>'
24
- elsif query? id: 1
25
- header content_type: 'json'
26
- { id: 1, name: 'Touwa Erio', country: 'Japan' }.to_json
17
+ middle do
18
+ if path? '/'
19
+ status 200
20
+ header content_type: 'html'
21
+ body '<h1>Hello, Erio!</h1>'
27
22
  else
28
- status 404
29
- "<h1><b>404</b> - not found page</h1><hr><h2>\"#{path}\"</h2>"
30
- end
31
23
  end
32
24
  end
33
25
 
34
- App.run!
35
-
36
26
  ```
37
27
 
38
28
  ## Contributing
39
29
 
40
- Bug reports and pull requests are welcome on GitHub at https://github.com/saisui/erio-rb. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/saisui/erio-rb/blob/master/CODE_OF_CONDUCT.md).
30
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/erio. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/erio/blob/master/CODE_OF_CONDUCT.md).
41
31
 
42
32
  ## License
43
33
 
data/lib/erio/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class Erio
4
- VERSION = "0.0.0-1"
3
+ module Erio
4
+ VERSION = "0.0.0"
5
5
  end
data/lib/erio.rb CHANGED
@@ -1,35 +1,40 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "erio/version"
4
- require'rack'
5
- require'rack/handler/puma'
6
4
 
7
5
  class Erio
8
- @_enter = -> { @status=200; 'set `enter do ... end\' to set routes.'}
9
-
6
+ @_before = -> {}
7
+ @_after = -> {}
8
+ @_middle = -> { @status=200; 'set `middle do ... end\' to set routes.'}
10
9
  def self.inherited(subclass)
11
10
  instance_variables.map { |k| subclass.instance_variable_set(k, instance_variable_get(k)) }
12
11
  end
13
12
  end
14
13
 
15
14
  class << Erio
16
- def enter &blk; blk ? @_enter = blk : @_enter.arity == 1 ? @_enter.call(self) : class_exec(&@_enter) end
15
+ def middle &blk; blk ? @_middle = blk : @_middle.call(*[self][0,@_middle.arity]) end
16
+ def before &blk; blk ? @_before = blk : @_before.arity == 1 ? @_before.call(self) : @_before.call end
17
+ def after &blk; blk ? @_after = blk : @_after.arity == 1 ? @_after.call(self) : @_after.call end
18
+ def logger
19
+ puts "#{@_env['REMOTE_ADDR']} - [#{Time.now}] \"#{@_env['REQUEST_METHOD']} #{@_env['PATH_INFO']}?#{@_env['QUERY_STRING']} #{@_env['rack.url_scheme']}\" [#{@_env['HTTP_ACCEPT']}] #{"%.4fs" % @_spent.to_f}"
20
+ end
17
21
 
18
- def _call env
22
+ def main env
19
23
  @_env = env
20
24
  @header = {}
21
25
  @status = nil
22
26
  @body = nil
23
- @body ||= enter || ''
27
+ @_t0 = Time.now
28
+ before
29
+ @body ||= middle || ''
30
+ @_spent = Time.now - @_t0
31
+ logger
32
+ after
24
33
  [@status,@header,[@body]]
25
34
  end
26
35
 
27
36
  def call env
28
- dup._call(env)
29
- end
30
-
31
- def run!
32
- Rack::Handler::Puma.run(self)
37
+ self.dup.main(env)
33
38
  end
34
39
 
35
40
  def [] key; instance_variable_get :"@#{key}" end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: erio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0.pre.1
4
+ version: 0.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - kozmozEnjel
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-03-13 00:00:00.000000000 Z
10
+ date: 2025-03-12 00:00:00.000000000 Z
11
11
  dependencies: []
12
12
  description: For Education but powerful and useful.
13
13
  email:
@@ -18,12 +18,12 @@ extra_rdoc_files: []
18
18
  files:
19
19
  - ".rspec"
20
20
  - ".standard.yml"
21
+ - ".vscode/settings.json"
21
22
  - CHANGELOG.md
22
23
  - CODE_OF_CONDUCT.md
23
24
  - LICENSE.txt
24
25
  - README.md
25
26
  - Rakefile
26
- - config.ru
27
27
  - lib/erio.rb
28
28
  - lib/erio/version.rb
29
29
  - sig/erio.rbs
data/config.ru DELETED
@@ -1,3 +0,0 @@
1
- require './lib/erio'
2
-
3
- run Erio