yaframework 0.5.0 → 0.5.1

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: 374739919ee6fdbc46ee3fc95f5604c162a358d21d593b6709cefa1add1af42a
4
- data.tar.gz: 1a021b3a32f2358f5444759b30316e6670cd300121a265e95787889e58fdcc70
3
+ metadata.gz: b01d1643e6921880fd3630c0b5898c502a0b3ff54c602f63ac54f9d32e263b36
4
+ data.tar.gz: 602742bc864f51d7151d946710d47583e2b3a7abfe257ffb74c2f2d48418ff89
5
5
  SHA512:
6
- metadata.gz: cdca19d28dfdbc2e980357242811bda91e685b383f859e19b0aafdb2e9f66d69eab5c2201f5a9da751648bf6b667b33ffef6a494555a6258bd4dd36ed4efc914
7
- data.tar.gz: 2029fec4b50c8c9039f7b4449c7ad09198a07e4f979cd36b5b197e8523846c5a3155038b4e7aa8d13e012397003b3822a1f630ceecf2d941f5c412f86f726114
6
+ metadata.gz: 80d9262cc6a0206ecbd058c3bb6d65c78b4abe0192924dd27685d61fd91ec90c60e85d3a3f7792e8ce6f45d4c6d1b6e30309fa6d66f3988debd0a8fa450bd1b6
7
+ data.tar.gz: 9d95222a443494ca862a16499f42662053515765c3cd2dbb06050b469b333f852c7097c1de16904704bc731a18c653a3980cd199b2dfe8738e5a1424148ce6ce
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [0.5.1] - 2021-07-26
2
+
3
+ - `helpers` and `configure` methods added
4
+
1
5
  ## [0.5.0] - 2021-07-25
2
6
 
3
7
  - Templates rendering added
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- yaframework (0.5.0)
4
+ yaframework (0.5.1)
5
5
  rack (~> 2.2, >= 2.2.3)
6
6
  tilt (~> 2.0)
7
7
 
data/examples/README.md CHANGED
@@ -42,6 +42,20 @@ Here are some examples of applications created with Yaframework:
42
42
  How to use `before` and `after` hooks
43
43
 
44
44
 
45
+ 9. [**Rendering**](https://github.com/maxbarsukov/yaframework/tree/master/examples/rendering)
46
+
47
+ Rendering your `.erb` (or any else) files and partials using tilt.
48
+
49
+
50
+ 10. [**Helpers**](https://github.com/maxbarsukov/yaframework/blob/master/examples/helpers.rb)
51
+
52
+ Example of using helpers
53
+
54
+
55
+ 11. [**Configure**](https://github.com/maxbarsukov/yaframework/blob/master/examples/configure.rb)
56
+
57
+ How to configure your application
58
+
45
59
  ## Installation
46
60
 
47
61
  Clone this repo and go to this folder.
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "yaframework"
4
+ app = Yaframework::Application
5
+
6
+ app.configure do
7
+ @app_name
8
+ end
9
+
10
+ app.get "/" do
11
+ "Hey, that's #{@app_name}"
12
+ end
13
+
14
+ app.listen(9292)
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "yaframework"
4
+ app = Yaframework::Application
5
+
6
+ app.helpers do
7
+ def hello
8
+ "Hello"
9
+ end
10
+
11
+ def colon
12
+ ", "
13
+ end
14
+ end
15
+
16
+ app.helpers do
17
+ def world
18
+ "world!"
19
+ end
20
+ end
21
+
22
+ app.get "/" do
23
+ hello + colon + world
24
+ end
25
+
26
+ app.listen(9292)
@@ -3,6 +3,11 @@
3
3
  require "yaframework"
4
4
  app = Yaframework::Application
5
5
 
6
+ app.before do
7
+ @number = Random.rand
8
+ puts @number
9
+ end
10
+
6
11
  app.get "/" do
7
12
  render "index"
8
13
  end
@@ -1,3 +1,6 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "yaframework"
4
+ require "./app"
2
5
 
3
6
  run app
@@ -0,0 +1,4 @@
1
+ <h1>Look me in index.erb file</h1>
2
+
3
+ <p>It works!</p>
4
+ <%= partial "partial", number: @number %>
@@ -0,0 +1,10 @@
1
+ <html lang="en">
2
+ <head>
3
+ <meta charset="utf-8">
4
+ <title>Example app</title>
5
+ </head>
6
+
7
+ <body>
8
+ <%= content %>
9
+ </body>
10
+ </html>
@@ -0,0 +1 @@
1
+ <p>Yout number was <b><%= number %></b></p>
@@ -25,6 +25,14 @@ module Yaframework
25
25
  end
26
26
  end
27
27
 
28
+ def helpers(&block)
29
+ exec(block) if block_given?
30
+ end
31
+
32
+ def configure(&block)
33
+ exec(block) if block_given?
34
+ end
35
+
28
36
  def call(env)
29
37
  @env = env
30
38
  @request = Yaframework::Request.new @env
@@ -36,9 +36,7 @@ module Yaframework
36
36
  private
37
37
 
38
38
  def _render(template, locals = {}, options = {}, &block)
39
- _cache.fetch(template) {
40
- Tilt.new(template, 1, options.merge(outvar: "@_output"))
41
- }.render(self, locals, &block)
39
+ _cache.fetch(template) { Tilt.new(template, 1, options.merge(outvar: "@_output")) }.render(self, locals, &block)
42
40
  end
43
41
 
44
42
  def _cache
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Yaframework
4
- VERSION = "0.5.0"
4
+ VERSION = "0.5.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yaframework
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - maxbarsukov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-07-25 00:00:00.000000000 Z
11
+ date: 2021-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -122,17 +122,20 @@ files:
122
122
  - examples/Gemfile
123
123
  - examples/README.md
124
124
  - examples/before_after_hooks.rb
125
+ - examples/configure.rb
125
126
  - examples/content_types.rb
126
127
  - examples/cookies.rb
127
128
  - examples/error_handling.rb
128
129
  - examples/halts_and_redirects.rb
129
130
  - examples/headers.rb
130
131
  - examples/hello_world.rb
132
+ - examples/helpers.rb
131
133
  - examples/params.rb
132
134
  - examples/rendering/app.rb
133
135
  - examples/rendering/config.ru
134
136
  - examples/rendering/views/index.erb
135
137
  - examples/rendering/views/layout.erb
138
+ - examples/rendering/views/partial.erb
136
139
  - lib/yaframework.rb
137
140
  - lib/yaframework/base.rb
138
141
  - lib/yaframework/render.rb