generic 0.0.3 → 0.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dd6950356e997c63545003fcfdb3009fc75159b1
4
- data.tar.gz: e75f52114b5311e2b398eb3a5ede128ae36caf74
3
+ metadata.gz: 8ea05cb7508f7b371baf4eec27ec0f435769d94a
4
+ data.tar.gz: 39c9cff33a4a37dbf04ab2e40f6623cf88c369fb
5
5
  SHA512:
6
- metadata.gz: 3dd444b799993ef39d8516d4cc917b7db0f7996d7f12dbae047d25056bd5cc9075d35bd928e89bdee1ff34e326d3644c5c2cdec5f00cf34843960f8b0981bb9e
7
- data.tar.gz: ba594f139687a12ebdbc3118eb07f26e8c21ce7c083d9cf9b2462e465ee0a5de1fec2f1e56488b7a83e2f6cb74771fb53d9979719a6812ff654b44bcdb28d794
6
+ metadata.gz: c8c8960d9291d547fdfb38791dd5efdf4b257e152bd66c74d2f98494baacf58c37f16dfd0286fb170808bc9e6e4c686c2d274c973bd00db9508cd4fce66de573
7
+ data.tar.gz: 7c910694a62617f4951c045447f3027ce87b3bffe0a5d035094e705b3e5425ddbb8b9576b9eae2e11fe8520cfad5cbd78ba5d6e55749064207ed9c8201e5210a
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # Generic
2
2
 
3
- TODO: Write a gem description
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
- TODO: Write usage instructions here
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/[my-github-username]/generic/fork )
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`)
@@ -1,4 +1,6 @@
1
1
  require "generic/generic"
2
+ require "generic/modules/template"
3
+
2
4
  module Generic
3
5
  class Boot < Base
4
6
  class << self
@@ -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 helpers(*args, &block)
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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Generic
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
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.3
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