rack-app-front_end 0.21.0 → 0.22.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
- SHA1:
3
- metadata.gz: 1d90fa0a6d8b2ac46cbb6c8b412794ec196bd6b3
4
- data.tar.gz: fee7347ba0ee77b07f12faf74e5865a2bca743fa
2
+ SHA256:
3
+ metadata.gz: 74853f0132c7d0f14f46bfe65e1bd2debb0664e3ece9c14dd18aa3f1892963fb
4
+ data.tar.gz: a549153a7c959a58b0de6fb80e3e24199f205f7bc31feacb8c74844ac1b333a1
5
5
  SHA512:
6
- metadata.gz: 17d63a3268e88615a6f7df1e68dae6910cbcab079229eb9efefeab6045a51a642362ef8a385f86ee7991571080614e8809a44651fb47b686a962051c1592c130
7
- data.tar.gz: 41333b68d01a4adbbb3627fbdef332fb4053a27306add4ce9f40464e7ceec1b31856b83f580d4c3276332c6ae6c292ad0b97246dfb569c1d3555c79acc5469d4
6
+ metadata.gz: 6a9311a32c3043154f08f3c509a348380d6d32024f1cf971282d1d84f8eeb0dbecb8e4b1ecea25e600ce4f11728871096a422265ce7030e2cbb6e9a5e58c2fea
7
+ data.tar.gz: 671e084d48dba708891e18e5caf232f5cc000a04ba99278c0559225e2062e4b9fc8ade9e8279afbd2d5f425fae32395d62e632edeba0f61a6b0e12544bf48041
data/README.md CHANGED
@@ -20,20 +20,22 @@ Or install it yourself as:
20
20
  ## Usage
21
21
 
22
22
  ```ruby
23
+ require 'rack/app'
24
+ require 'rack/app/front_end'
23
25
 
24
26
  class App < Rack::App
25
-
26
- extend Rack::App::FrontEnd
27
-
27
+
28
+ apply_extensions :front_end
29
+
28
30
  mount_folder '/from/project/root/path'
29
-
31
+
30
32
  mount_folder 'relative/folder/from/this/file/to/folder'
31
-
33
+
32
34
  get '/some_url' do
33
35
  @items = []
34
36
  render 'some.html.erb'
35
37
  end
36
-
38
+
37
39
  end
38
40
 
39
41
  ```
@@ -48,4 +50,3 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
48
50
  ## Contributing
49
51
 
50
52
  Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/rack-app-mvc. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
51
-
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.21.0
1
+ 0.22.1
@@ -2,7 +2,7 @@ module Rack::App::FrontEnd::Helpers::Table
2
2
  module Builder
3
3
  extend(self)
4
4
 
5
- def from_array_of_hash(array_of_hash)
5
+ def from_array_of_hash(array_of_hash, attributes)
6
6
  headers = array_of_hash.each_with_object([]) do |hash, trs|
7
7
  trs.push(*hash.keys)
8
8
  trs.uniq!
@@ -11,7 +11,7 @@ module Rack::App::FrontEnd::Helpers::Table
11
11
  o = Object.new
12
12
  o.extend(Rack::App::FrontEnd::Helpers::HtmlDsl)
13
13
 
14
- table_html = o.__send__ :table_tag do
14
+ table_html = o.__send__ :table_tag, attributes do
15
15
  tr_tag do
16
16
  headers.each do |header|
17
17
  td_tag String(header)
@@ -30,11 +30,11 @@ module Rack::App::FrontEnd::Helpers::Table
30
30
  table_html
31
31
  end
32
32
 
33
- def from_hash(hash)
33
+ def from_hash(hash, attributes)
34
34
  o = Object.new
35
35
  o.extend(Rack::App::FrontEnd::Helpers::HtmlDsl)
36
36
 
37
- table_html = o.__send__ :table_tag do
37
+ table_html = o.__send__ :table_tag, attributes do
38
38
  hash.each do |key, value|
39
39
  tr_tag do
40
40
  td_tag String(key)
@@ -47,11 +47,11 @@ module Rack::App::FrontEnd::Helpers::Table
47
47
  end
48
48
  end
49
49
 
50
- def table_by(object)
50
+ def table_by(object, attributes={})
51
51
  if object.is_a?(Array) && object.all? { |e| e.is_a?(Hash) }
52
- Builder.from_array_of_hash(object)
52
+ Builder.from_array_of_hash(object, attributes)
53
53
  elsif object.is_a?(Hash)
54
- Builder.from_hash(object)
54
+ Builder.from_hash(object, attributes)
55
55
  else
56
56
  raise("don't know how to build table from this: #{object}")
57
57
  end
@@ -0,0 +1,22 @@
1
+ class Rack::App::FrontEnd::Template::Cache
2
+ def initialize
3
+ @cache = {}
4
+ end
5
+
6
+ # Caches a value for key, or returns the previously cached value.
7
+ # If a value has been previously cached for key then it is
8
+ # returned. Otherwise, block is yielded to and its return value
9
+ # which may be nil, is cached under key and returned.
10
+ # @yield
11
+ # @yieldreturn the value to cache for key
12
+ def fetch(*key)
13
+ @cache.fetch(key) do
14
+ @cache[key] = yield
15
+ end
16
+ end
17
+
18
+ # Clears the cache.
19
+ def clear
20
+ @cache = {}
21
+ end
22
+ end
@@ -2,11 +2,12 @@ require 'tilt'
2
2
  class Rack::App::FrontEnd::Template
3
3
 
4
4
  require 'rack/app/front_end/template/scope'
5
+ require 'rack/app/front_end/template/cache'
5
6
  require 'rack/app/front_end/template/default_layout'
6
7
  require 'rack/app/front_end/template/default_template'
7
8
 
8
9
  def self.cache
9
- @cache ||= Tilt::Cache.new
10
+ @cache ||= Rack::App::FrontEnd::Template::Cache.new
10
11
  end
11
12
 
12
13
  def self.template?(file_path)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-app-front_end
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.21.0
4
+ version: 0.22.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Luzsi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-03-30 00:00:00.000000000 Z
11
+ date: 2023-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -113,6 +113,7 @@ files:
113
113
  - lib/rack/app/front_end/syntax_sugar.rb
114
114
  - lib/rack/app/front_end/syntax_sugar/dsl.rb
115
115
  - lib/rack/app/front_end/template.rb
116
+ - lib/rack/app/front_end/template/cache.rb
116
117
  - lib/rack/app/front_end/template/default_layout.rb
117
118
  - lib/rack/app/front_end/template/default_template.rb
118
119
  - lib/rack/app/front_end/template/scope.rb
@@ -138,8 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
139
  - !ruby/object:Gem::Version
139
140
  version: '0'
140
141
  requirements: []
141
- rubyforge_project:
142
- rubygems_version: 2.5.1
142
+ rubygems_version: 3.0.3.1
143
143
  signing_key:
144
144
  specification_version: 4
145
145
  summary: Rack::App FrontEnd framework to create beautiful website with style