yaframework 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile +0 -1
- data/Gemfile.lock +3 -3
- data/README.md +1 -1
- data/lib/yaframework/response.rb +35 -4
- data/lib/yaframework/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef685ddc4ab38b92f223ce779b2e57b27473556cdbdcb8a93bdf8269f7cb27ff
|
4
|
+
data.tar.gz: f89e2a1d07968d32b50ac56fe1aa7669d7f02c31ede5d7e7d0ccb09deb48c36d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8bad4c17c6e830f8c2897112375da39947326a8f204db2a52dd41d99ed7c963a31f8f0b2ad05228bd50226cb4d82e995e5752c2be73f0ede1306e24b79f48ead
|
7
|
+
data.tar.gz: 32ee2f926d51b6324427f295bcebfd46958da7f364d7dbbdf80270777a486e5513ce75f50725fbe1c466ac304271fb2edbef0e864e3b5441a7af8b225bca30bf
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
yaframework (0.4.
|
4
|
+
yaframework (0.4.2)
|
5
5
|
rack (~> 2.2)
|
6
6
|
|
7
7
|
GEM
|
@@ -36,7 +36,7 @@ PLATFORMS
|
|
36
36
|
ruby
|
37
37
|
|
38
38
|
DEPENDENCIES
|
39
|
-
bundler (
|
39
|
+
bundler (>= 2.2.10)
|
40
40
|
minitest (~> 5.0)
|
41
41
|
pg (~> 1.2, >= 1.2.3)
|
42
42
|
rack (~> 2.2, >= 2.2.3)
|
@@ -45,4 +45,4 @@ DEPENDENCIES
|
|
45
45
|
yaframework!
|
46
46
|
|
47
47
|
BUNDLED WITH
|
48
|
-
2.
|
48
|
+
2.2.16
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Yaframework
|
2
2
|
|
3
|
-
[![Gem Version](https://badge.fury.io/rb/yaframework.svg)](https://badge.fury.io/rb/
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/yaframework.svg)](https://badge.fury.io/rb/yaframework)
|
4
4
|
[![Build Status](https://app.travis-ci.com/maxbarsukov/yaframework.svg?token=T4CL2EqKG6FY816F3W3F&branch=master)](https://app.travis-ci.com/maxbarsukov/yaframework)
|
5
5
|
|
6
6
|
Yaframework is a [DSL](https://en.wikipedia.org/wiki/Domain-specific_language) for
|
data/lib/yaframework/response.rb
CHANGED
@@ -2,6 +2,14 @@
|
|
2
2
|
|
3
3
|
module Yaframework
|
4
4
|
class Response
|
5
|
+
LOCATION = "Location"
|
6
|
+
|
7
|
+
module ContentType
|
8
|
+
HTML = "text/html"
|
9
|
+
TEXT = "text/plain"
|
10
|
+
JSON = "application/json"
|
11
|
+
end
|
12
|
+
|
5
13
|
attr_accessor :status
|
6
14
|
attr_reader :headers, :body
|
7
15
|
|
@@ -21,19 +29,42 @@ module Yaframework
|
|
21
29
|
end
|
22
30
|
|
23
31
|
def finish
|
24
|
-
headers[
|
32
|
+
@headers[Rack::CONTENT_LENGTH] = @length.to_s unless (100..199).include?(status) || status == 204
|
25
33
|
[status, headers, body]
|
26
34
|
end
|
27
35
|
|
28
36
|
def redirect(target, status = 302)
|
29
|
-
|
30
|
-
headers[
|
37
|
+
@status = status
|
38
|
+
@headers[LOCATION] = target
|
31
39
|
end
|
32
40
|
|
33
41
|
def write(string)
|
34
42
|
s = string.to_s
|
35
43
|
@length += s.bytesize
|
36
|
-
body << s
|
44
|
+
@body << s
|
45
|
+
end
|
46
|
+
|
47
|
+
def [](key)
|
48
|
+
@headers[key]
|
49
|
+
end
|
50
|
+
|
51
|
+
def []=(key, value)
|
52
|
+
@headers[key] = value
|
53
|
+
end
|
54
|
+
|
55
|
+
def html(str)
|
56
|
+
@headers[Rack::CONTENT_TYPE] = ContentType::HTML
|
57
|
+
write(str)
|
58
|
+
end
|
59
|
+
|
60
|
+
def text(str)
|
61
|
+
@headers[Rack::CONTENT_TYPE] = ContentType::TEXT
|
62
|
+
write(str)
|
63
|
+
end
|
64
|
+
|
65
|
+
def json(str)
|
66
|
+
@headers[Rack::CONTENT_TYPE] = ContentType::JSON
|
67
|
+
write(str)
|
37
68
|
end
|
38
69
|
end
|
39
70
|
end
|
data/lib/yaframework/version.rb
CHANGED