generic 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +27 -3
- data/lib/generic/boot.rb +2 -0
- data/lib/generic/generic.rb +8 -2
- data/lib/generic/modules/template.rb +18 -0
- data/lib/generic/target.rb +1 -3
- data/lib/generic/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ea05cb7508f7b371baf4eec27ec0f435769d94a
|
4
|
+
data.tar.gz: 39c9cff33a4a37dbf04ab2e40f6623cf88c369fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8c8960d9291d547fdfb38791dd5efdf4b257e152bd66c74d2f98494baacf58c37f16dfd0286fb170808bc9e6e4c686c2d274c973bd00db9508cd4fce66de573
|
7
|
+
data.tar.gz: 7c910694a62617f4951c045447f3027ce87b3bffe0a5d035094e705b3e5425ddbb8b9576b9eae2e11fe8520cfad5cbd78ba5d6e55749064207ed9c8201e5210a
|
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# Generic
|
2
2
|
|
3
|
-
|
3
|
+
Small Web Framework
|
4
|
+
|
5
|
+
|
4
6
|
|
5
7
|
## Installation
|
6
8
|
|
@@ -20,11 +22,33 @@ Or install it yourself as:
|
|
20
22
|
|
21
23
|
## Usage
|
22
24
|
|
23
|
-
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
# myapp.rb
|
28
|
+
|
29
|
+
require 'generic'
|
30
|
+
class App < Generic::Boot
|
31
|
+
get '/' do
|
32
|
+
'Hello world!'
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
App.go!(3000)
|
37
|
+
```
|
38
|
+
|
39
|
+
Run Generic:
|
40
|
+
|
41
|
+
```bash
|
42
|
+
ruby myapp.rb
|
43
|
+
```
|
44
|
+
## TODO
|
45
|
+
1. Coffee, Sass parser
|
46
|
+
2. Application Environment
|
47
|
+
3. Small Active Records
|
24
48
|
|
25
49
|
## Contributing
|
26
50
|
|
27
|
-
1. Fork it ( https://github.com/
|
51
|
+
1. Fork it ( https://github.com/Generic-Ruby/Generic/fork )
|
28
52
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
53
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
54
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/lib/generic/boot.rb
CHANGED
data/lib/generic/generic.rb
CHANGED
@@ -4,6 +4,7 @@ require 'active_support/core_ext/object/deep_dup'
|
|
4
4
|
require 'pathname'
|
5
5
|
require 'generic/target'
|
6
6
|
require 'generic/routing'
|
7
|
+
require 'slim'
|
7
8
|
|
8
9
|
module Generic
|
9
10
|
|
@@ -93,6 +94,10 @@ module Generic
|
|
93
94
|
@app.call(env)
|
94
95
|
end
|
95
96
|
|
97
|
+
def settings
|
98
|
+
self.class.settings
|
99
|
+
end
|
100
|
+
|
96
101
|
class << self
|
97
102
|
|
98
103
|
# Methods
|
@@ -150,10 +155,11 @@ module Generic
|
|
150
155
|
end
|
151
156
|
|
152
157
|
# System Helper
|
153
|
-
def
|
158
|
+
def library(*args, &block)
|
154
159
|
if block_given?
|
155
160
|
args << Module.new(&block)
|
156
161
|
end
|
162
|
+
|
157
163
|
args.each do |m|
|
158
164
|
scope.send :include, m
|
159
165
|
end
|
@@ -173,7 +179,7 @@ module Generic
|
|
173
179
|
def after(&block)
|
174
180
|
after_actions << Proc.new(&block)
|
175
181
|
end
|
176
|
-
|
182
|
+
|
177
183
|
protected
|
178
184
|
# Define Framework Route
|
179
185
|
def define_route(path, options, &block)
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'slim'
|
2
|
+
|
3
|
+
module Generic
|
4
|
+
module Templates
|
5
|
+
module Helpers
|
6
|
+
|
7
|
+
def render(template, locals = {}, options = {}, &block)
|
8
|
+
default_path = "./views/#{template}"
|
9
|
+
Slim::Template.new(default_path, options).render(self, locals, &block)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.check(generic)
|
14
|
+
generic.library Helpers
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
data/lib/generic/target.rb
CHANGED
@@ -5,7 +5,7 @@ module Generic
|
|
5
5
|
class Target
|
6
6
|
extend Forwardable
|
7
7
|
|
8
|
-
attr_reader :request, :response
|
8
|
+
attr_reader :request, :response, :attr_reader
|
9
9
|
def_delegators :request, :session, :params
|
10
10
|
def_delegators :response, :headers
|
11
11
|
|
@@ -15,7 +15,6 @@ module Generic
|
|
15
15
|
end
|
16
16
|
|
17
17
|
private
|
18
|
-
|
19
18
|
def system_redirect(uri, status=302)
|
20
19
|
exit(status, {'Location' => uri})
|
21
20
|
end
|
@@ -33,7 +32,6 @@ module Generic
|
|
33
32
|
def system_cookies
|
34
33
|
@cookies ||= Rack::Cookies::CookieJar.new(request.cookies)
|
35
34
|
end
|
36
|
-
|
37
35
|
[:goto, :go_to].each do |keyword|
|
38
36
|
alias_method keyword, :system_redirect
|
39
37
|
end
|
data/lib/generic/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: generic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Write your name
|
@@ -52,6 +52,7 @@ files:
|
|
52
52
|
- lib/generic/boot.rb
|
53
53
|
- lib/generic/generic.rb
|
54
54
|
- lib/generic/help.rb
|
55
|
+
- lib/generic/modules/template.rb
|
55
56
|
- lib/generic/routing.rb
|
56
57
|
- lib/generic/target.rb
|
57
58
|
- lib/generic/version.rb
|