viu 0.0.0 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +11 -0
- data/.travis.yml +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +144 -0
- data/LICENSE.txt +21 -0
- data/README.md +26 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/viu.rb +14 -1
- data/lib/viu/html.rb +86 -0
- data/lib/viu/layout.rb +24 -0
- data/lib/viu/railtie.rb +19 -0
- data/lib/viu/rendering_helpers.rb +17 -0
- data/lib/viu/test_case.rb +12 -0
- data/lib/viu/test_helpers.rb +30 -0
- data/lib/viu/version.rb +5 -0
- data/viu.gemspec +43 -0
- metadata +115 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7fcf443dc32a50462eb147063436581b225a066e1368a51132eb485379bd4891
|
4
|
+
data.tar.gz: 18ba17c3be19f4562447374e2b65c2dba7bba3acf3acb6d91c1f6412a3a4b5bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e4f28c552311fa43527a3cc0c59e18f22f172848f0c28b7eb05fe0dea8fa3bd8c3ab943f14018bfae347877632071b71c12a916645ec222ae22b74ac096ee78
|
7
|
+
data.tar.gz: 0b00071e7a91eb93f75c933f6ed0c5e56178afae13ad66027911a20bf582b715c59d061b98b639ce83c730242ebd5ea37ac2dd4c4fc2d37b44726ab1a62e8a67
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at mrbongiolo@hey.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,144 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
viu (0.0.1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
actioncable (5.2.4.3)
|
10
|
+
actionpack (= 5.2.4.3)
|
11
|
+
nio4r (~> 2.0)
|
12
|
+
websocket-driver (>= 0.6.1)
|
13
|
+
actionmailer (5.2.4.3)
|
14
|
+
actionpack (= 5.2.4.3)
|
15
|
+
actionview (= 5.2.4.3)
|
16
|
+
activejob (= 5.2.4.3)
|
17
|
+
mail (~> 2.5, >= 2.5.4)
|
18
|
+
rails-dom-testing (~> 2.0)
|
19
|
+
actionpack (5.2.4.3)
|
20
|
+
actionview (= 5.2.4.3)
|
21
|
+
activesupport (= 5.2.4.3)
|
22
|
+
rack (~> 2.0, >= 2.0.8)
|
23
|
+
rack-test (>= 0.6.3)
|
24
|
+
rails-dom-testing (~> 2.0)
|
25
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
26
|
+
actionview (5.2.4.3)
|
27
|
+
activesupport (= 5.2.4.3)
|
28
|
+
builder (~> 3.1)
|
29
|
+
erubi (~> 1.4)
|
30
|
+
rails-dom-testing (~> 2.0)
|
31
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
32
|
+
activejob (5.2.4.3)
|
33
|
+
activesupport (= 5.2.4.3)
|
34
|
+
globalid (>= 0.3.6)
|
35
|
+
activemodel (5.2.4.3)
|
36
|
+
activesupport (= 5.2.4.3)
|
37
|
+
activerecord (5.2.4.3)
|
38
|
+
activemodel (= 5.2.4.3)
|
39
|
+
activesupport (= 5.2.4.3)
|
40
|
+
arel (>= 9.0)
|
41
|
+
activestorage (5.2.4.3)
|
42
|
+
actionpack (= 5.2.4.3)
|
43
|
+
activerecord (= 5.2.4.3)
|
44
|
+
marcel (~> 0.3.1)
|
45
|
+
activesupport (5.2.4.3)
|
46
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
47
|
+
i18n (>= 0.7, < 2)
|
48
|
+
minitest (~> 5.1)
|
49
|
+
tzinfo (~> 1.1)
|
50
|
+
arel (9.0.0)
|
51
|
+
builder (3.2.4)
|
52
|
+
concurrent-ruby (1.1.7)
|
53
|
+
crass (1.0.6)
|
54
|
+
docile (1.3.2)
|
55
|
+
erubi (1.9.0)
|
56
|
+
globalid (0.4.2)
|
57
|
+
activesupport (>= 4.2.0)
|
58
|
+
haml (5.1.2)
|
59
|
+
temple (>= 0.8.0)
|
60
|
+
tilt
|
61
|
+
i18n (1.8.5)
|
62
|
+
concurrent-ruby (~> 1.0)
|
63
|
+
loofah (2.6.0)
|
64
|
+
crass (~> 1.0.2)
|
65
|
+
nokogiri (>= 1.5.9)
|
66
|
+
mail (2.7.1)
|
67
|
+
mini_mime (>= 0.1.1)
|
68
|
+
marcel (0.3.3)
|
69
|
+
mimemagic (~> 0.3.2)
|
70
|
+
method_source (1.0.0)
|
71
|
+
mimemagic (0.3.5)
|
72
|
+
mini_mime (1.0.2)
|
73
|
+
mini_portile2 (2.4.0)
|
74
|
+
minitest (5.14.1)
|
75
|
+
nio4r (2.5.2)
|
76
|
+
nokogiri (1.10.10)
|
77
|
+
mini_portile2 (~> 2.4.0)
|
78
|
+
rack (2.2.3)
|
79
|
+
rack-test (1.1.0)
|
80
|
+
rack (>= 1.0, < 3)
|
81
|
+
rails (5.2.4.3)
|
82
|
+
actioncable (= 5.2.4.3)
|
83
|
+
actionmailer (= 5.2.4.3)
|
84
|
+
actionpack (= 5.2.4.3)
|
85
|
+
actionview (= 5.2.4.3)
|
86
|
+
activejob (= 5.2.4.3)
|
87
|
+
activemodel (= 5.2.4.3)
|
88
|
+
activerecord (= 5.2.4.3)
|
89
|
+
activestorage (= 5.2.4.3)
|
90
|
+
activesupport (= 5.2.4.3)
|
91
|
+
bundler (>= 1.3.0)
|
92
|
+
railties (= 5.2.4.3)
|
93
|
+
sprockets-rails (>= 2.0.0)
|
94
|
+
rails-dom-testing (2.0.3)
|
95
|
+
activesupport (>= 4.2.0)
|
96
|
+
nokogiri (>= 1.6)
|
97
|
+
rails-html-sanitizer (1.3.0)
|
98
|
+
loofah (~> 2.3)
|
99
|
+
railties (5.2.4.3)
|
100
|
+
actionpack (= 5.2.4.3)
|
101
|
+
activesupport (= 5.2.4.3)
|
102
|
+
method_source
|
103
|
+
rake (>= 0.8.7)
|
104
|
+
thor (>= 0.19.0, < 2.0)
|
105
|
+
rake (12.3.3)
|
106
|
+
simplecov (0.18.5)
|
107
|
+
docile (~> 1.1)
|
108
|
+
simplecov-html (~> 0.11)
|
109
|
+
simplecov-html (0.12.2)
|
110
|
+
slim (4.1.0)
|
111
|
+
temple (>= 0.7.6, < 0.9)
|
112
|
+
tilt (>= 2.0.6, < 2.1)
|
113
|
+
sprockets (4.0.2)
|
114
|
+
concurrent-ruby (~> 1.0)
|
115
|
+
rack (> 1, < 3)
|
116
|
+
sprockets-rails (3.2.1)
|
117
|
+
actionpack (>= 4.0)
|
118
|
+
activesupport (>= 4.0)
|
119
|
+
sprockets (>= 3.0.0)
|
120
|
+
temple (0.8.2)
|
121
|
+
thor (1.0.1)
|
122
|
+
thread_safe (0.3.6)
|
123
|
+
tilt (2.0.10)
|
124
|
+
tzinfo (1.2.7)
|
125
|
+
thread_safe (~> 0.1)
|
126
|
+
websocket-driver (0.7.3)
|
127
|
+
websocket-extensions (>= 0.1.0)
|
128
|
+
websocket-extensions (0.1.5)
|
129
|
+
|
130
|
+
PLATFORMS
|
131
|
+
ruby
|
132
|
+
|
133
|
+
DEPENDENCIES
|
134
|
+
bundler (~> 1.17)
|
135
|
+
haml (~> 5)
|
136
|
+
minitest (~> 5.0)
|
137
|
+
rails (~> 5.2)
|
138
|
+
rake (~> 12.3)
|
139
|
+
simplecov (~> 0.18.0)
|
140
|
+
slim (~> 4)
|
141
|
+
viu!
|
142
|
+
|
143
|
+
BUNDLED WITH
|
144
|
+
1.17.2
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 Ralf Schmitz Bongiolo
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# Viu
|
2
|
+
|
3
|
+
Currently this is a POC (proof of concept), on the usage of `ActionView` as a "real" view layer. Inspired on
|
4
|
+
`view_component`, `cells` and others, `viu` is just a small wrapper around `AV`. It aims to work with the least amount
|
5
|
+
of surprise with Rails, but with a few boundaries, like a View won't be able to automatically access `@ivars` defined
|
6
|
+
in the controller, those have to explicitly be passed to them.
|
7
|
+
|
8
|
+
The project is already been tested on a small scale in our production environment.
|
9
|
+
|
10
|
+
## Your first View
|
11
|
+
|
12
|
+
`app/views/my_view.rb`:
|
13
|
+
```ruby
|
14
|
+
class MyView < Viu::Html
|
15
|
+
def initialize(name)
|
16
|
+
@name = name
|
17
|
+
end
|
18
|
+
end
|
19
|
+
```
|
20
|
+
|
21
|
+
`app/views/my_view.html.erb`:
|
22
|
+
```erb
|
23
|
+
<h1><%= @name %></h1>
|
24
|
+
```
|
25
|
+
|
26
|
+
Unless a template is given directly, a view will try to find a template with it's name.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "viu"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/viu.rb
CHANGED
@@ -1,2 +1,15 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "viu/version"
|
4
|
+
|
5
|
+
require "viu/html"
|
6
|
+
require "viu/layout"
|
7
|
+
require "viu/test_case"
|
8
|
+
|
9
|
+
require 'viu/railtie' if defined?(Rails)
|
10
|
+
|
11
|
+
module Viu
|
12
|
+
EMPTY_HASH = {}.freeze
|
13
|
+
|
14
|
+
class Error < StandardError; end
|
2
15
|
end
|
data/lib/viu/html.rb
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "action_view"
|
4
|
+
|
5
|
+
module Viu
|
6
|
+
class Html < ActionView::Base
|
7
|
+
|
8
|
+
def initialize(*); end
|
9
|
+
|
10
|
+
def render_in(view_context, options = EMPTY_HASH)
|
11
|
+
__setup!(view_context)
|
12
|
+
|
13
|
+
layout = options.fetch(:layout, self.class.layout)
|
14
|
+
|
15
|
+
if layout.is_a?(Class)
|
16
|
+
__render_layout_class(layout)
|
17
|
+
elsif layout.is_a?(Proc)
|
18
|
+
__render_layout_proc(layout)
|
19
|
+
else
|
20
|
+
@view_renderer.render(self, template: __fetch_template!, layout: layout)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
attr_reader :controller, :request
|
27
|
+
|
28
|
+
delegate :protect_against_forgery?, :form_authenticity_token, :content_security_policy?, to: :helpers
|
29
|
+
|
30
|
+
def helpers
|
31
|
+
@helpers ||= controller.view_context
|
32
|
+
end
|
33
|
+
|
34
|
+
def __setup!(view_context)
|
35
|
+
@view_context = view_context
|
36
|
+
@lookup_context ||= view_context.lookup_context
|
37
|
+
@view_renderer ||= view_context.view_renderer
|
38
|
+
@controller ||= view_context.controller
|
39
|
+
@request ||= controller.request
|
40
|
+
_prepare_context
|
41
|
+
end
|
42
|
+
|
43
|
+
def __fetch_template!
|
44
|
+
return self.class.template if self.class.template.present?
|
45
|
+
|
46
|
+
self.class.template!(self.class.name.underscore)
|
47
|
+
end
|
48
|
+
|
49
|
+
def __render_layout_class(layout)
|
50
|
+
layout.new.render_in(@view_context) do
|
51
|
+
@view_renderer.render(self, template: __fetch_template!, layout: nil)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def __render_layout_proc(layout)
|
56
|
+
self.instance_exec(&layout).render_in(@view_context) do
|
57
|
+
@view_renderer.render(self, template: __fetch_template!, layout: nil)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
class << self
|
62
|
+
|
63
|
+
def inherited(child)
|
64
|
+
if defined?(Rails) && child != Viu::Layout
|
65
|
+
child.include Rails.application.routes.url_helpers unless child < Rails.application.routes.url_helpers
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def layout!(value)
|
70
|
+
@__layout = value
|
71
|
+
end
|
72
|
+
|
73
|
+
def layout
|
74
|
+
@__layout ||= nil
|
75
|
+
end
|
76
|
+
|
77
|
+
def template!(value)
|
78
|
+
@__template = value
|
79
|
+
end
|
80
|
+
|
81
|
+
def template
|
82
|
+
@__template ||= nil
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
data/lib/viu/layout.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "viu/html"
|
4
|
+
|
5
|
+
module Viu
|
6
|
+
class Layout < Html
|
7
|
+
|
8
|
+
class Renderer < ActionView::PartialRenderer
|
9
|
+
|
10
|
+
# https://github.com/rails/rails/blob/v5.2.4.3/actionview/lib/action_view/renderer/partial_renderer.rb#L421
|
11
|
+
def find_template(path, locals)
|
12
|
+
prefixes = path.include?(?/) ? [] : @lookup_context.prefixes
|
13
|
+
# override partial arg to false, so that it will look for templates without a prefixed _
|
14
|
+
@lookup_context.find_template(path, prefixes, false, locals, @details)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def render_in(view_context, &block)
|
19
|
+
__setup!(view_context)
|
20
|
+
|
21
|
+
Renderer.new(@lookup_context).render(self, { partial: __fetch_template!, layout: nil }, block)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/viu/railtie.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rails"
|
4
|
+
require "viu/rendering_helpers"
|
5
|
+
|
6
|
+
module Viu
|
7
|
+
class Railtie < Rails::Railtie
|
8
|
+
|
9
|
+
initializer "viu.include_rendering_helpers" do |app|
|
10
|
+
ActiveSupport.on_load(:action_view) do
|
11
|
+
ActionView::Base.include Viu::RenderingHelpers::ActionViewHelpers
|
12
|
+
end
|
13
|
+
|
14
|
+
ActiveSupport.on_load(:action_controller) do
|
15
|
+
ActionController::Base.include Viu::RenderingHelpers::ActionControllerHelpers
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Viu
|
4
|
+
module RenderingHelpers
|
5
|
+
module ActionViewHelpers
|
6
|
+
def render_view(view, options = EMPTY_HASH)
|
7
|
+
view.render_in(@view_context, options)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
module ActionControllerHelpers
|
12
|
+
def render_view(view, options = EMPTY_HASH)
|
13
|
+
self.response_body = view.render_in(view_context, options)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_support/test_case"
|
4
|
+
require "rails/dom/testing/assertions"
|
5
|
+
require "viu/test_helpers"
|
6
|
+
|
7
|
+
module Viu
|
8
|
+
class TestCase < ActiveSupport::TestCase
|
9
|
+
include Rails::Dom::Testing::Assertions
|
10
|
+
include Viu::TestHelpers
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Viu
|
4
|
+
module TestHelpers
|
5
|
+
|
6
|
+
attr_reader :rendered_view
|
7
|
+
|
8
|
+
def render_view(view, **args)
|
9
|
+
@rendered_view = Nokogiri::HTML::Document.parse(
|
10
|
+
view.render_in(controller.view_context, args)
|
11
|
+
)
|
12
|
+
end
|
13
|
+
|
14
|
+
def controller
|
15
|
+
# TODO: make ApplicationController usage here configurable
|
16
|
+
@controller ||= ApplicationController.new.tap { |c| c.request = request }
|
17
|
+
.extend(Rails.application.routes.url_helpers)
|
18
|
+
end
|
19
|
+
|
20
|
+
def request
|
21
|
+
@request ||= ActionDispatch::TestRequest.create
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def document_root_element
|
27
|
+
@rendered_view.root
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/viu/version.rb
ADDED
data/viu.gemspec
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path("../lib", __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require "viu/version"
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = "viu"
|
9
|
+
spec.version = Viu::VERSION
|
10
|
+
spec.authors = ["Ralf Schmitz Bongiolo"]
|
11
|
+
spec.email = ["mrbongiolo@hey.com"]
|
12
|
+
|
13
|
+
spec.summary = %q{Rails' missing View layer.}
|
14
|
+
spec.description = %q{Rails' missing View layer.}
|
15
|
+
spec.homepage = "https://github.com/mrbongiolo/viu"
|
16
|
+
spec.license = "MIT"
|
17
|
+
|
18
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
19
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
20
|
+
if spec.respond_to?(:metadata)
|
21
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
22
|
+
|
23
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
24
|
+
spec.metadata["source_code_uri"] = "https://github.com/mrbongiolo/viu"
|
25
|
+
spec.metadata["changelog_uri"] = "https://github.com/mrbongiolo/viu/CHANGELOG.md"
|
26
|
+
else
|
27
|
+
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
28
|
+
end
|
29
|
+
|
30
|
+
# Specify which files should be added to the gem when it is released.
|
31
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
32
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
33
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
34
|
+
end
|
35
|
+
spec.require_paths = ["lib"]
|
36
|
+
|
37
|
+
spec.add_development_dependency "bundler", "~> 1.17"
|
38
|
+
spec.add_development_dependency "rake", "~> 12.3"
|
39
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
40
|
+
spec.add_development_dependency "simplecov", "~> 0.18.0"
|
41
|
+
spec.add_development_dependency "haml", "~> 5"
|
42
|
+
spec.add_development_dependency "slim", "~> 4"
|
43
|
+
end
|
metadata
CHANGED
@@ -1,26 +1,133 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: viu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ralf Schmitz Bongiolo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
12
|
-
dependencies:
|
13
|
-
|
14
|
-
|
11
|
+
date: 2020-08-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.17'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.17'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '12.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '12.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: simplecov
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.18.0
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.18.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: haml
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '5'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '5'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: slim
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '4'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '4'
|
97
|
+
description: Rails' missing View layer.
|
98
|
+
email:
|
99
|
+
- mrbongiolo@hey.com
|
15
100
|
executables: []
|
16
101
|
extensions: []
|
17
102
|
extra_rdoc_files: []
|
18
103
|
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- ".travis.yml"
|
106
|
+
- CODE_OF_CONDUCT.md
|
107
|
+
- Gemfile
|
108
|
+
- Gemfile.lock
|
109
|
+
- LICENSE.txt
|
110
|
+
- README.md
|
111
|
+
- Rakefile
|
112
|
+
- bin/console
|
113
|
+
- bin/setup
|
19
114
|
- lib/viu.rb
|
20
|
-
|
115
|
+
- lib/viu/html.rb
|
116
|
+
- lib/viu/layout.rb
|
117
|
+
- lib/viu/railtie.rb
|
118
|
+
- lib/viu/rendering_helpers.rb
|
119
|
+
- lib/viu/test_case.rb
|
120
|
+
- lib/viu/test_helpers.rb
|
121
|
+
- lib/viu/version.rb
|
122
|
+
- viu.gemspec
|
123
|
+
homepage: https://github.com/mrbongiolo/viu
|
21
124
|
licenses:
|
22
125
|
- MIT
|
23
|
-
metadata:
|
126
|
+
metadata:
|
127
|
+
allowed_push_host: https://rubygems.org
|
128
|
+
homepage_uri: https://github.com/mrbongiolo/viu
|
129
|
+
source_code_uri: https://github.com/mrbongiolo/viu
|
130
|
+
changelog_uri: https://github.com/mrbongiolo/viu/CHANGELOG.md
|
24
131
|
post_install_message:
|
25
132
|
rdoc_options: []
|
26
133
|
require_paths:
|
@@ -39,5 +146,5 @@ requirements: []
|
|
39
146
|
rubygems_version: 3.0.3
|
40
147
|
signing_key:
|
41
148
|
specification_version: 4
|
42
|
-
summary:
|
149
|
+
summary: Rails' missing View layer.
|
43
150
|
test_files: []
|