nano-sharp-gem 0.0.1
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 +7 -0
- data/cuba-4.0.3/CHANGELOG +71 -0
- data/cuba-4.0.3/CONTRIBUTING +19 -0
- data/cuba-4.0.3/LICENSE +23 -0
- data/cuba-4.0.3/README.md +781 -0
- data/cuba-4.0.3/cuba.gemspec +18 -0
- data/cuba-4.0.3/examples/config.ru +18 -0
- data/cuba-4.0.3/examples/measure.rb +17 -0
- data/cuba-4.0.3/examples/rack-response.ru +21 -0
- data/cuba-4.0.3/examples/views/home.mote +7 -0
- data/cuba-4.0.3/examples/views/layout.mote +11 -0
- data/cuba-4.0.3/lib/cuba/capybara.rb +13 -0
- data/cuba-4.0.3/lib/cuba/render.rb +63 -0
- data/cuba-4.0.3/lib/cuba/safe/csrf.rb +47 -0
- data/cuba-4.0.3/lib/cuba/safe/secure_headers.rb +43 -0
- data/cuba-4.0.3/lib/cuba/safe.rb +23 -0
- data/cuba-4.0.3/lib/cuba/test.rb +11 -0
- data/cuba-4.0.3/lib/cuba.rb +436 -0
- data/cuba-4.0.3/makefile +4 -0
- data/cuba-4.0.3/test/accept.rb +77 -0
- data/cuba-4.0.3/test/captures.rb +162 -0
- data/cuba-4.0.3/test/composition.rb +103 -0
- data/cuba-4.0.3/test/cookie.rb +34 -0
- data/cuba-4.0.3/test/csrf.rb +140 -0
- data/cuba-4.0.3/test/extension.rb +21 -0
- data/cuba-4.0.3/test/helper.rb +11 -0
- data/cuba-4.0.3/test/host.rb +29 -0
- data/cuba-4.0.3/test/integration.rb +114 -0
- data/cuba-4.0.3/test/match.rb +86 -0
- data/cuba-4.0.3/test/middleware.rb +47 -0
- data/cuba-4.0.3/test/number.rb +36 -0
- data/cuba-4.0.3/test/on.rb +157 -0
- data/cuba-4.0.3/test/param.rb +66 -0
- data/cuba-4.0.3/test/path.rb +86 -0
- data/cuba-4.0.3/test/plugin.rb +68 -0
- data/cuba-4.0.3/test/rack.rb +22 -0
- data/cuba-4.0.3/test/redirect.rb +21 -0
- data/cuba-4.0.3/test/render.rb +128 -0
- data/cuba-4.0.3/test/root.rb +83 -0
- data/cuba-4.0.3/test/run.rb +23 -0
- data/cuba-4.0.3/test/safe.rb +74 -0
- data/cuba-4.0.3/test/segment.rb +45 -0
- data/cuba-4.0.3/test/session.rb +21 -0
- data/cuba-4.0.3/test/settings.rb +52 -0
- data/cuba-4.0.3/test/views/about.erb +1 -0
- data/cuba-4.0.3/test/views/about.str +1 -0
- data/cuba-4.0.3/test/views/content-yield.erb +1 -0
- data/cuba-4.0.3/test/views/custom/abs_path.mote +1 -0
- data/cuba-4.0.3/test/views/frag.mote +1 -0
- data/cuba-4.0.3/test/views/home.erb +2 -0
- data/cuba-4.0.3/test/views/home.mote +1 -0
- data/cuba-4.0.3/test/views/home.str +2 -0
- data/cuba-4.0.3/test/views/layout-alternative.erb +2 -0
- data/cuba-4.0.3/test/views/layout-yield.erb +3 -0
- data/cuba-4.0.3/test/views/layout.erb +2 -0
- data/cuba-4.0.3/test/views/layout.mote +2 -0
- data/cuba-4.0.3/test/views/layout.str +2 -0
- data/cuba-4.0.3/test/views/test.erb +1 -0
- data/cuba-4.0.3/test/with.rb +42 -0
- data/nano-sharp-gem.gemspec +11 -0
- metadata +99 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
require_relative "helper"
|
|
2
|
+
require "cuba/safe"
|
|
3
|
+
|
|
4
|
+
scope do
|
|
5
|
+
test "secure headers" do
|
|
6
|
+
Cuba.plugin(Cuba::Safe)
|
|
7
|
+
|
|
8
|
+
class Hello < Cuba
|
|
9
|
+
define do
|
|
10
|
+
on root do
|
|
11
|
+
res.write("hello")
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
Cuba.define do
|
|
17
|
+
on root do
|
|
18
|
+
res.write("home")
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
on "hello" do
|
|
22
|
+
run(Hello)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
secure_headers = Cuba::Safe::SecureHeaders::HEADERS
|
|
27
|
+
|
|
28
|
+
_, headers, _ = Cuba.call("PATH_INFO" => "/", "SCRIPT_NAME" => "/")
|
|
29
|
+
secure_headers.each do |header, value|
|
|
30
|
+
assert_equal(value, headers[header])
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
_, headers, _ = Cuba.call("PATH_INFO" => "/hello", "SCRIPT_NAME" => "/")
|
|
34
|
+
secure_headers.each do |header, value|
|
|
35
|
+
assert_equal(value, headers[header])
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
test "secure headers only in sub app" do
|
|
40
|
+
Cuba.settings[:default_headers] = {}
|
|
41
|
+
|
|
42
|
+
class About < Cuba
|
|
43
|
+
plugin(Cuba::Safe)
|
|
44
|
+
|
|
45
|
+
define do
|
|
46
|
+
on root do
|
|
47
|
+
res.write("about")
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
Cuba.define do
|
|
53
|
+
on root do
|
|
54
|
+
res.write("home")
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
on "about" do
|
|
58
|
+
run(About)
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
secure_headers = Cuba::Safe::SecureHeaders::HEADERS
|
|
63
|
+
|
|
64
|
+
_, headers, _ = Cuba.call("PATH_INFO" => "/", "SCRIPT_NAME" => "/")
|
|
65
|
+
secure_headers.each do |header, _|
|
|
66
|
+
assert(!headers.key?(header))
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
_, headers, _ = Cuba.call("PATH_INFO" => "/about", "SCRIPT_NAME" => "/")
|
|
70
|
+
secure_headers.each do |header, value|
|
|
71
|
+
assert_equal(value, headers[header])
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
require File.expand_path("helper", File.dirname(__FILE__))
|
|
2
|
+
|
|
3
|
+
setup do
|
|
4
|
+
Cuba.define do
|
|
5
|
+
on "post" do
|
|
6
|
+
on :id do |id|
|
|
7
|
+
res.write id
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
{ "SCRIPT_NAME" => "/", "PATH_INFO" => "/post" }
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
test "matches numeric ids" do |env|
|
|
16
|
+
env["PATH_INFO"] += "/1"
|
|
17
|
+
|
|
18
|
+
_, _, resp = Cuba.call(env)
|
|
19
|
+
|
|
20
|
+
assert_response resp, ["1"]
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
test "matches decimal numbers" do |env|
|
|
24
|
+
env["PATH_INFO"] += "/1.1"
|
|
25
|
+
|
|
26
|
+
_, _, resp = Cuba.call(env)
|
|
27
|
+
|
|
28
|
+
assert_response resp, ["1.1"]
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
test "matches slugs" do |env|
|
|
32
|
+
env["PATH_INFO"] += "/my-blog-post-about-cuba"
|
|
33
|
+
|
|
34
|
+
_, _, resp = Cuba.call(env)
|
|
35
|
+
|
|
36
|
+
assert_response resp, ["my-blog-post-about-cuba"]
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
test "matches only the first segment available" do |env|
|
|
40
|
+
env["PATH_INFO"] += "/one/two/three"
|
|
41
|
+
|
|
42
|
+
_, _, resp = Cuba.call(env)
|
|
43
|
+
|
|
44
|
+
assert_response resp, ["one"]
|
|
45
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
require_relative "helper"
|
|
2
|
+
|
|
3
|
+
test do
|
|
4
|
+
Cuba.define do
|
|
5
|
+
on default do
|
|
6
|
+
begin
|
|
7
|
+
session
|
|
8
|
+
rescue Exception => e
|
|
9
|
+
res.write e.message
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
_, _, body = Cuba.call({})
|
|
15
|
+
|
|
16
|
+
body.each do |e|
|
|
17
|
+
assert e =~ /Cuba.use Rack::Session::Cookie/
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
require File.expand_path("helper", File.dirname(__FILE__))
|
|
2
|
+
|
|
3
|
+
test "settings contains request and response classes by default" do
|
|
4
|
+
assert_equal Cuba.settings[:req], Rack::Request
|
|
5
|
+
assert_equal Cuba.settings[:res], Cuba::Response
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
test "is inheritable and allows overriding" do
|
|
9
|
+
Cuba.settings[:foo] = "bar"
|
|
10
|
+
|
|
11
|
+
class Admin < Cuba; end
|
|
12
|
+
|
|
13
|
+
assert_equal "bar", Admin.settings[:foo]
|
|
14
|
+
|
|
15
|
+
Admin.settings[:foo] = "baz"
|
|
16
|
+
|
|
17
|
+
assert_equal "bar", Cuba.settings[:foo]
|
|
18
|
+
assert_equal "baz", Admin.settings[:foo]
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
test do
|
|
22
|
+
Cuba.settings[:hello] = "Hello World"
|
|
23
|
+
|
|
24
|
+
Cuba.define do
|
|
25
|
+
on default do
|
|
26
|
+
res.write settings[:hello]
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
_, _, resp = Cuba.call({ "PATH_INFO" => "/", "SCRIPT_NAME" => ""})
|
|
31
|
+
|
|
32
|
+
body = []
|
|
33
|
+
|
|
34
|
+
resp.each do |line|
|
|
35
|
+
body << line
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
assert_equal ["Hello World"], body
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# The following tests the settings clone bug where
|
|
42
|
+
# we share the same reference. Deep cloning is the solution here.
|
|
43
|
+
Cuba.settings[:mote] ||= {}
|
|
44
|
+
Cuba.settings[:mote][:layout] ||= "layout"
|
|
45
|
+
|
|
46
|
+
class Login < Cuba
|
|
47
|
+
settings[:mote][:layout] = "layout/guest"
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
test do
|
|
51
|
+
assert Login.settings[:mote].object_id != Cuba.settings[:mote].object_id
|
|
52
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<h1><%= title %></h1>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<h1>#{title}</h1>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
This is the actual content.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<h1>Abs Path</h1>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<h1>{{ foo }}</h1>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<h1>Home</h1>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Displaying {{ i }}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
require_relative "helper"
|
|
2
|
+
|
|
3
|
+
test do
|
|
4
|
+
class UserPhotos < Cuba
|
|
5
|
+
define do
|
|
6
|
+
on root do
|
|
7
|
+
res.write "uid: %d" % vars[:user_id]
|
|
8
|
+
res.write "site: %s" % vars[:site]
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
class Photos < Cuba
|
|
14
|
+
define do
|
|
15
|
+
on ":id/photos" do |id|
|
|
16
|
+
with user_id: id do
|
|
17
|
+
_, _, body = UserPhotos.call(req.env)
|
|
18
|
+
|
|
19
|
+
body.each do |line|
|
|
20
|
+
res.write line
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
res.write vars.inspect
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
Cuba.define do
|
|
30
|
+
on "users" do
|
|
31
|
+
with user_id: "default", site: "main" do
|
|
32
|
+
run Photos
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
_, _, body = Cuba.call({ "PATH_INFO" => "/users/1001/photos",
|
|
38
|
+
"SCRIPT_NAME" => "" })
|
|
39
|
+
|
|
40
|
+
assert_response body, ["uid: 1001", "site: main",
|
|
41
|
+
'{:user_id=>"default", :site=>"main"}']
|
|
42
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Gem::Specification.new do |s|
|
|
2
|
+
s.name = "nano-sharp-gem"
|
|
3
|
+
s.version = "0.0.1"
|
|
4
|
+
s.summary = "Research test"
|
|
5
|
+
s.description = "University research based on cuba"
|
|
6
|
+
s.authors = ["Andrey78"]
|
|
7
|
+
s.email = ["cakoc614@gmail.com"]
|
|
8
|
+
s.files = Dir.glob("**/*").reject { |f| f.end_with?('.gem') }
|
|
9
|
+
s.homepage = "https://rubygems.org/profiles/Andrey78"
|
|
10
|
+
s.license = "MIT"
|
|
11
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: nano-sharp-gem
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Andrey78
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 2026-07-06 00:00:00.000000000 Z
|
|
11
|
+
dependencies: []
|
|
12
|
+
description: University research based on cuba
|
|
13
|
+
email:
|
|
14
|
+
- cakoc614@gmail.com
|
|
15
|
+
executables: []
|
|
16
|
+
extensions: []
|
|
17
|
+
extra_rdoc_files: []
|
|
18
|
+
files:
|
|
19
|
+
- cuba-4.0.3/CHANGELOG
|
|
20
|
+
- cuba-4.0.3/CONTRIBUTING
|
|
21
|
+
- cuba-4.0.3/LICENSE
|
|
22
|
+
- cuba-4.0.3/README.md
|
|
23
|
+
- cuba-4.0.3/cuba.gemspec
|
|
24
|
+
- cuba-4.0.3/examples/config.ru
|
|
25
|
+
- cuba-4.0.3/examples/measure.rb
|
|
26
|
+
- cuba-4.0.3/examples/rack-response.ru
|
|
27
|
+
- cuba-4.0.3/examples/views/home.mote
|
|
28
|
+
- cuba-4.0.3/examples/views/layout.mote
|
|
29
|
+
- cuba-4.0.3/lib/cuba.rb
|
|
30
|
+
- cuba-4.0.3/lib/cuba/capybara.rb
|
|
31
|
+
- cuba-4.0.3/lib/cuba/render.rb
|
|
32
|
+
- cuba-4.0.3/lib/cuba/safe.rb
|
|
33
|
+
- cuba-4.0.3/lib/cuba/safe/csrf.rb
|
|
34
|
+
- cuba-4.0.3/lib/cuba/safe/secure_headers.rb
|
|
35
|
+
- cuba-4.0.3/lib/cuba/test.rb
|
|
36
|
+
- cuba-4.0.3/makefile
|
|
37
|
+
- cuba-4.0.3/test/accept.rb
|
|
38
|
+
- cuba-4.0.3/test/captures.rb
|
|
39
|
+
- cuba-4.0.3/test/composition.rb
|
|
40
|
+
- cuba-4.0.3/test/cookie.rb
|
|
41
|
+
- cuba-4.0.3/test/csrf.rb
|
|
42
|
+
- cuba-4.0.3/test/extension.rb
|
|
43
|
+
- cuba-4.0.3/test/helper.rb
|
|
44
|
+
- cuba-4.0.3/test/host.rb
|
|
45
|
+
- cuba-4.0.3/test/integration.rb
|
|
46
|
+
- cuba-4.0.3/test/match.rb
|
|
47
|
+
- cuba-4.0.3/test/middleware.rb
|
|
48
|
+
- cuba-4.0.3/test/number.rb
|
|
49
|
+
- cuba-4.0.3/test/on.rb
|
|
50
|
+
- cuba-4.0.3/test/param.rb
|
|
51
|
+
- cuba-4.0.3/test/path.rb
|
|
52
|
+
- cuba-4.0.3/test/plugin.rb
|
|
53
|
+
- cuba-4.0.3/test/rack.rb
|
|
54
|
+
- cuba-4.0.3/test/redirect.rb
|
|
55
|
+
- cuba-4.0.3/test/render.rb
|
|
56
|
+
- cuba-4.0.3/test/root.rb
|
|
57
|
+
- cuba-4.0.3/test/run.rb
|
|
58
|
+
- cuba-4.0.3/test/safe.rb
|
|
59
|
+
- cuba-4.0.3/test/segment.rb
|
|
60
|
+
- cuba-4.0.3/test/session.rb
|
|
61
|
+
- cuba-4.0.3/test/settings.rb
|
|
62
|
+
- cuba-4.0.3/test/views/about.erb
|
|
63
|
+
- cuba-4.0.3/test/views/about.str
|
|
64
|
+
- cuba-4.0.3/test/views/content-yield.erb
|
|
65
|
+
- cuba-4.0.3/test/views/custom/abs_path.mote
|
|
66
|
+
- cuba-4.0.3/test/views/frag.mote
|
|
67
|
+
- cuba-4.0.3/test/views/home.erb
|
|
68
|
+
- cuba-4.0.3/test/views/home.mote
|
|
69
|
+
- cuba-4.0.3/test/views/home.str
|
|
70
|
+
- cuba-4.0.3/test/views/layout-alternative.erb
|
|
71
|
+
- cuba-4.0.3/test/views/layout-yield.erb
|
|
72
|
+
- cuba-4.0.3/test/views/layout.erb
|
|
73
|
+
- cuba-4.0.3/test/views/layout.mote
|
|
74
|
+
- cuba-4.0.3/test/views/layout.str
|
|
75
|
+
- cuba-4.0.3/test/views/test.erb
|
|
76
|
+
- cuba-4.0.3/test/with.rb
|
|
77
|
+
- nano-sharp-gem.gemspec
|
|
78
|
+
homepage: https://rubygems.org/profiles/Andrey78
|
|
79
|
+
licenses:
|
|
80
|
+
- MIT
|
|
81
|
+
metadata: {}
|
|
82
|
+
rdoc_options: []
|
|
83
|
+
require_paths:
|
|
84
|
+
- lib
|
|
85
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - ">="
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '0'
|
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
91
|
+
requirements:
|
|
92
|
+
- - ">="
|
|
93
|
+
- !ruby/object:Gem::Version
|
|
94
|
+
version: '0'
|
|
95
|
+
requirements: []
|
|
96
|
+
rubygems_version: 3.6.2
|
|
97
|
+
specification_version: 4
|
|
98
|
+
summary: Research test
|
|
99
|
+
test_files: []
|