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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e8009597e2e41965f0ad078918d629c4b88eaf2536d9c001053079cdfd24705a
4
- data.tar.gz: 44386071847fd8a44299d967a8d8605b615a3fc865afd21a4f555410c10b3cba
3
+ metadata.gz: ef685ddc4ab38b92f223ce779b2e57b27473556cdbdcb8a93bdf8269f7cb27ff
4
+ data.tar.gz: f89e2a1d07968d32b50ac56fe1aa7669d7f02c31ede5d7e7d0ccb09deb48c36d
5
5
  SHA512:
6
- metadata.gz: 505e79eee033484f4ecd2eb08daca91521e2d93f5b780051fe82968d9a5510b0ac5152d4cc61aee77827e85d1e40d053451881e623e9f0f713fc1e0f0e03b1fa
7
- data.tar.gz: 842210c79e38f9c984018c38377f704d235bd4f795ce3753cd89fdcddceb9c2d93db654c94d68dec23a4de818ade9719a08d382f5b6abb4fed5d29b5259cf8a1
6
+ metadata.gz: 8bad4c17c6e830f8c2897112375da39947326a8f204db2a52dd41d99ed7c963a31f8f0b2ad05228bd50226cb4d82e995e5752c2be73f0ede1306e24b79f48ead
7
+ data.tar.gz: 32ee2f926d51b6324427f295bcebfd46958da7f364d7dbbdf80270777a486e5513ce75f50725fbe1c466ac304271fb2edbef0e864e3b5441a7af8b225bca30bf
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## [0.4.3] - 2021-07-24
2
+
3
+ - Updated the method for changing the Content-Type
4
+ - Interaction with headers has been improved
5
+
1
6
  ## [0.4.2] - 2021-07-24
2
7
 
3
8
  - DB module removed
data/Gemfile CHANGED
@@ -5,5 +5,4 @@ source "https://rubygems.org"
5
5
  gemspec
6
6
 
7
7
  gem "minitest", "~> 5.0"
8
- gem "pg", "~> 1.2", ">= 1.2.3"
9
8
  gem "rack", "~> 2.2", ">= 2.2.3"
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- yaframework (0.4.1)
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 (~> 2.1.4)
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.1.4
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/sinatra)
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
@@ -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["Content-Length"] = @length.to_s unless (100..199).include?(status) || status == 204
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
- self.status = status
30
- headers["Location"] = target
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Yaframework
4
- VERSION = "0.4.2"
4
+ VERSION = "0.4.3"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yaframework
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - maxbarsukov