jb 0.8.1 → 0.9.0
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 +4 -4
- data/README.md +6 -0
- data/lib/generators/rails/jb_generator.rb +24 -7
- data/lib/generators/rails/templates/index.json.jb +2 -2
- data/lib/generators/rails/templates/show.json.jb +4 -1
- data/lib/jb/action_view_legacy_monkeys.rb +47 -2
- data/lib/jb/action_view_monkeys.rb +67 -29
- data/lib/jb/railtie.rb +1 -1
- data/lib/jb/version.rb +1 -1
- data/lib/jb.rb +1 -1
- metadata +61 -137
- data/.github/workflows/main.yml +0 -63
- data/.gitignore +0 -11
- data/Gemfile +0 -22
- data/Rakefile +0 -12
- data/bin/benchmark.sh +0 -5
- data/bin/console +0 -15
- data/bin/setup +0 -8
- data/gemfiles/benchmark.gemfile +0 -10
- data/jb.gemspec +0 -31
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ebc3831b6f765bbd0f306bd6772b63d5d912b981f4059d2fbf36cd6c20874e29
|
|
4
|
+
data.tar.gz: 5aef896dec1602d615c040255ad100e1ace6de28a56f25b5594c5db651a02500
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6fdb44208dd422e5e0c995a06cd948fa33b586c2dc86f75078116d8f8d04108b1db3e0be76a2552801134cc31551ccef387c692e5fb67440026cec748760854a
|
|
7
|
+
data.tar.gz: 7b40f06cb30dd60aa9ed4de0a2f930c70dd8f26abb70c383b3115054bd2b77b7cd2b3d906d537886ba52eb234e039bb180be0e50dbd3de8351376ce90d5d80b0
|
data/README.md
CHANGED
|
@@ -216,6 +216,12 @@ end
|
|
|
216
216
|
```
|
|
217
217
|
|
|
218
218
|
|
|
219
|
+
## ActionController::API
|
|
220
|
+
`ActionController::API` doesn't render view templates by default. So, in order to render `.jb` templates from API controllers, Jb includes `ActionView::Rendering`, `ActionController::Helpers`, and `ActionController::ImplicitRender` into `ActionController::API` (just like Jbuilder does).
|
|
221
|
+
|
|
222
|
+
Note that this changes the behavior of API controller actions that don't explicitly call `render`. Instead of always responding with `204 No Content`, such an action now renders its template if one exists, raises `ActionController::UnknownFormat` if templates exist only for other formats, and raises `ActionController::MissingExactTemplate` for a GET request for HTML from a browser with no template.
|
|
223
|
+
|
|
224
|
+
|
|
219
225
|
## The Generator
|
|
220
226
|
Jb extends the default Rails scaffold generator and adds some `.jb` templates. If you don't need them, please configure like so.
|
|
221
227
|
|
|
@@ -12,6 +12,8 @@ module Rails
|
|
|
12
12
|
|
|
13
13
|
argument :attributes, type: :array, default: [], banner: 'field:type field:type'
|
|
14
14
|
|
|
15
|
+
class_option :timestamps, type: :boolean, default: true
|
|
16
|
+
|
|
15
17
|
def create_root_folder
|
|
16
18
|
path = File.join('app/views', controller_file_path)
|
|
17
19
|
empty_directory path unless File.directory?(path)
|
|
@@ -22,14 +24,29 @@ module Rails
|
|
|
22
24
|
template 'show.json.jb', File.join('app/views', controller_file_path, 'show.json.jb')
|
|
23
25
|
end
|
|
24
26
|
|
|
25
|
-
|
|
26
27
|
private
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
# Pairs of the JSON key and the Ruby expression that renders the value, for each attribute of the given record
|
|
29
|
+
def json_attributes(record)
|
|
30
|
+
names = [:id] + attributes_names
|
|
31
|
+
names -= %w(password password_confirmation) if attributes.any? {|a| (a.name == 'password') && (a.type == :digest) }
|
|
32
|
+
names += %w(created_at updated_at) if options[:timestamps]
|
|
33
|
+
|
|
34
|
+
names.map do |name|
|
|
35
|
+
attribute = attributes.detect {|a| a.name == name.to_s }
|
|
36
|
+
value = "#{record}.#{name}"
|
|
37
|
+
|
|
38
|
+
case attribute && attribute.type
|
|
39
|
+
when :attachment
|
|
40
|
+
[name, "(url_for(#{value}) if #{value}.attached?)"]
|
|
41
|
+
when :attachments
|
|
42
|
+
item = name.to_s.singularize
|
|
43
|
+
[name, "#{value}.map {|#{item}| {id: #{item}.id, url: url_for(#{item})} }"]
|
|
44
|
+
when :rich_text
|
|
45
|
+
[name, "#{value}.to_s"]
|
|
46
|
+
else
|
|
47
|
+
[name, value]
|
|
48
|
+
end
|
|
49
|
+
end
|
|
33
50
|
end
|
|
34
51
|
end
|
|
35
52
|
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
@<%= plural_table_name %>.map do |<%= singular_table_name %>|
|
|
2
2
|
{
|
|
3
|
-
<%
|
|
4
|
-
<%=
|
|
3
|
+
<% json_attributes(singular_table_name).each do |name, value| -%>
|
|
4
|
+
<%= name %>: <%= value %>,
|
|
5
5
|
<% end -%>
|
|
6
6
|
url: <%= singular_table_name %>_url(<%= singular_table_name %>, format: :json)
|
|
7
7
|
}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
2
|
+
<% json_attributes("@#{singular_table_name}").each do |name, value| -%>
|
|
3
|
+
<%= name %>: <%= value %>,
|
|
4
|
+
<% end -%>
|
|
5
|
+
url: <%= singular_table_name %>_url(@<%= singular_table_name %>, format: :json)
|
|
3
6
|
}
|
|
@@ -38,17 +38,62 @@ module Jb
|
|
|
38
38
|
super
|
|
39
39
|
end
|
|
40
40
|
end
|
|
41
|
+
|
|
42
|
+
# A monkey-patch strengthening rendered collection of different kinds of objects, where the partial is found per object
|
|
43
|
+
module MixedCollectionExtension
|
|
44
|
+
private def find_template(*)
|
|
45
|
+
template = super
|
|
46
|
+
@jb_template_found = true if template.handler == Jb::Handler
|
|
47
|
+
template
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
private def collection_without_template
|
|
51
|
+
@jb_template_found = false
|
|
52
|
+
result = super
|
|
53
|
+
@jb_template_found ? result.extend(StrongArray) : result
|
|
54
|
+
end
|
|
55
|
+
end
|
|
41
56
|
end
|
|
42
57
|
|
|
43
|
-
# A monkey-patch that converts non-partial result to a JSON String
|
|
58
|
+
# A monkey-patch that converts non-partial result to a JSON String, unless it's rendered from another jb template
|
|
44
59
|
module TemplateRenderer
|
|
45
60
|
module JSONizer
|
|
46
61
|
def render_template(template, *)
|
|
47
|
-
|
|
62
|
+
from_jb = @view.instance_variable_get :@_jb_rendering_jb
|
|
63
|
+
# render_with_layout doesn't take the template in Action View 4 and 5
|
|
64
|
+
@_jb_template = jb_template?(template)
|
|
65
|
+
result = super
|
|
66
|
+
@_jb_template && !from_jb && !@_jb_yielded_to_layout ? result.to_json : result
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# Marks the view while rendering a jb template's body, and makes a non-jb layout yield a JSON String
|
|
70
|
+
private def render_with_layout(*)
|
|
71
|
+
view, jb = @view, @_jb_template
|
|
72
|
+
super do |layout|
|
|
73
|
+
from_jb = view.instance_variable_get :@_jb_rendering_jb
|
|
74
|
+
view.instance_variable_set :@_jb_rendering_jb, jb
|
|
75
|
+
begin
|
|
76
|
+
content = yield layout
|
|
77
|
+
ensure
|
|
78
|
+
view.instance_variable_set :@_jb_rendering_jb, from_jb
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
if jb && layout && !jb_template?(layout)
|
|
82
|
+
@_jb_yielded_to_layout = true
|
|
83
|
+
content.to_json
|
|
84
|
+
else
|
|
85
|
+
content
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
private def jb_template?(template)
|
|
91
|
+
template.respond_to?(:handler) && (template.handler == Jb::Handler)
|
|
48
92
|
end
|
|
49
93
|
end
|
|
50
94
|
end
|
|
51
95
|
end
|
|
52
96
|
|
|
53
97
|
::ActionView::PartialRenderer.prepend ::Jb::PartialRenderer::JbTemplateDetector
|
|
98
|
+
::ActionView::PartialRenderer.prepend ::Jb::PartialRenderer::MixedCollectionExtension
|
|
54
99
|
::ActionView::TemplateRenderer.prepend ::Jb::TemplateRenderer::JSONizer
|
|
@@ -2,63 +2,101 @@
|
|
|
2
2
|
# Monkey-patches for Action View 6+
|
|
3
3
|
|
|
4
4
|
module Jb
|
|
5
|
-
# A monkey-patch that converts non-partial result to a JSON String
|
|
5
|
+
# A monkey-patch that converts non-partial result to a JSON String, unless it's rendered from another jb template
|
|
6
6
|
module TemplateRenderer
|
|
7
7
|
module JSONizer
|
|
8
|
-
def render_template(
|
|
8
|
+
def render_template(view, template, *)
|
|
9
|
+
from_jb = view.instance_variable_get :@_jb_rendering_jb
|
|
9
10
|
rendered_template = super
|
|
10
|
-
rendered_template.instance_variable_set :@body, rendered_template.body.to_json if
|
|
11
|
+
rendered_template.instance_variable_set :@body, rendered_template.body.to_json if jb_template?(template) && !from_jb && !@_jb_yielded_to_layout
|
|
11
12
|
rendered_template
|
|
12
13
|
end
|
|
14
|
+
|
|
15
|
+
# Marks the view while rendering a jb template's body, and makes a non-jb layout yield a JSON String
|
|
16
|
+
private def render_with_layout(view, template, *)
|
|
17
|
+
jb = jb_template?(template)
|
|
18
|
+
super do |layout|
|
|
19
|
+
from_jb = view.instance_variable_get :@_jb_rendering_jb
|
|
20
|
+
view.instance_variable_set :@_jb_rendering_jb, jb
|
|
21
|
+
begin
|
|
22
|
+
content = yield layout
|
|
23
|
+
ensure
|
|
24
|
+
view.instance_variable_set :@_jb_rendering_jb, from_jb
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
if jb && layout && !jb_template?(layout)
|
|
28
|
+
@_jb_yielded_to_layout = true
|
|
29
|
+
content.to_json
|
|
30
|
+
else
|
|
31
|
+
content
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
private def jb_template?(template)
|
|
37
|
+
template.respond_to?(:handler) && (template.handler == Jb::Handler)
|
|
38
|
+
end
|
|
13
39
|
end
|
|
14
40
|
end
|
|
15
41
|
|
|
16
|
-
#
|
|
17
|
-
|
|
42
|
+
# A wrapper class for template result that makes `to_s` method do nothing. So far only used for the Rails 7.1 monkey-patch below.
|
|
43
|
+
class TemplateResult < SimpleDelegator
|
|
44
|
+
def to_s
|
|
45
|
+
__getobj__
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# Rails 7.1 (to be precise, needed only for 7.1.0..7.1.3): A monkey-patch not to stringify rendered object from JB templates
|
|
50
|
+
module TemplateResultCaster
|
|
18
51
|
def _run(method, template, *, **)
|
|
19
52
|
val = super
|
|
20
|
-
if template.respond_to?(:handler) && (template.handler == Jb::Handler)
|
|
21
|
-
def val.to_s
|
|
22
|
-
self
|
|
23
|
-
end
|
|
24
|
-
end
|
|
53
|
+
val = Jb::TemplateResult.new val if template.respond_to?(:handler) && (template.handler == Jb::Handler)
|
|
25
54
|
val
|
|
26
55
|
end
|
|
27
56
|
end
|
|
28
57
|
|
|
58
|
+
# Rendered collection result for jb templates, whose `body` returns not a String but an Array
|
|
59
|
+
class RenderedCollection < ActionView::AbstractRenderer::RenderedCollection
|
|
60
|
+
def body
|
|
61
|
+
@rendered_templates.map(&:body)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
class EmptyCollection < ActionView::AbstractRenderer::RenderedCollection::EmptyCollection
|
|
65
|
+
def body
|
|
66
|
+
[]
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# Replaces the given rendered collection with the jb version of it if it's rendered via jb template(s)
|
|
71
|
+
def self.from(obj, template)
|
|
72
|
+
if ActionView::AbstractRenderer::RenderedCollection::EmptyCollection === obj
|
|
73
|
+
template.respond_to?(:handler) && (template.handler == Jb::Handler) ? EmptyCollection.new(obj.format) : obj
|
|
74
|
+
# `template` is nil for a collection of different kinds of objects, so check each rendered template's handler
|
|
75
|
+
elsif obj.rendered_templates.any? {|rt| rt.template.respond_to?(:handler) && (rt.template.handler == Jb::Handler) }
|
|
76
|
+
new obj.rendered_templates, nil
|
|
77
|
+
else
|
|
78
|
+
obj
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
29
83
|
# Rails 6.1+: A monkey-patch for jb template collection result's `body` not to return a String but an Array
|
|
30
84
|
module CollectionRendererExtension
|
|
31
85
|
private def render_collection(_collection, _view, _path, template, _layout, _block)
|
|
32
|
-
|
|
33
|
-
if template.respond_to?(:handler) && (template.handler == Jb::Handler)
|
|
34
|
-
if ActionView::AbstractRenderer::RenderedCollection::EmptyCollection === obj
|
|
35
|
-
def obj.body; []; end
|
|
36
|
-
else
|
|
37
|
-
def obj.body; @rendered_templates.map(&:body); end
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
obj
|
|
86
|
+
Jb::RenderedCollection.from super, template
|
|
41
87
|
end
|
|
42
88
|
end
|
|
43
89
|
|
|
44
90
|
# Rails 6.0: A monkey-patch for jb template collection result's `body` not to return a String but an Array
|
|
45
91
|
module PartialRendererExtension
|
|
46
92
|
private def render_collection(_view, template)
|
|
47
|
-
|
|
48
|
-
if template.respond_to?(:handler) && (template.handler == Jb::Handler)
|
|
49
|
-
if ActionView::AbstractRenderer::RenderedCollection::EmptyCollection === obj
|
|
50
|
-
def obj.body; []; end
|
|
51
|
-
else
|
|
52
|
-
def obj.body; @rendered_templates.map(&:body); end
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
obj
|
|
93
|
+
Jb::RenderedCollection.from super, template
|
|
56
94
|
end
|
|
57
95
|
end
|
|
58
96
|
end
|
|
59
97
|
|
|
60
98
|
::ActionView::TemplateRenderer.prepend ::Jb::TemplateRenderer::JSONizer
|
|
61
|
-
::ActionView::Base.prepend ::Jb::
|
|
99
|
+
::ActionView::Base.prepend ::Jb::TemplateResultCaster if (ActionView::VERSION::MAJOR == 7) && (ActionView::VERSION::MINOR == 1) && (ActionView::VERSION::TINY < 4)
|
|
62
100
|
begin
|
|
63
101
|
# ActionView::CollectionRenderer is a newly added class since 6.1
|
|
64
102
|
::ActionView::CollectionRenderer.prepend ::Jb::CollectionRendererExtension
|
data/lib/jb/railtie.rb
CHANGED
data/lib/jb/version.rb
CHANGED
data/lib/jb.rb
CHANGED
metadata
CHANGED
|
@@ -1,162 +1,86 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: jb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.9.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
|
-
- Akira Matsuda
|
|
8
|
-
|
|
9
|
-
bindir: exe
|
|
7
|
+
- Akira Matsuda
|
|
8
|
+
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
|
-
- !ruby/object:Gem::Dependency
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
- !ruby/object:Gem::
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
- - ">="
|
|
46
|
-
- !ruby/object:Gem::Version
|
|
47
|
-
version: '0'
|
|
48
|
-
type: :development
|
|
49
|
-
prerelease: false
|
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
-
requirements:
|
|
52
|
-
- - ">="
|
|
53
|
-
- !ruby/object:Gem::Version
|
|
54
|
-
version: '0'
|
|
55
|
-
- !ruby/object:Gem::Dependency
|
|
56
|
-
name: rails
|
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
|
58
|
-
requirements:
|
|
59
|
-
- - ">="
|
|
60
|
-
- !ruby/object:Gem::Version
|
|
61
|
-
version: '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'
|
|
69
|
-
- !ruby/object:Gem::Dependency
|
|
70
|
-
name: action_args
|
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
|
72
|
-
requirements:
|
|
73
|
-
- - ">="
|
|
74
|
-
- !ruby/object:Gem::Version
|
|
75
|
-
version: '0'
|
|
76
|
-
type: :development
|
|
77
|
-
prerelease: false
|
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
-
requirements:
|
|
80
|
-
- - ">="
|
|
81
|
-
- !ruby/object:Gem::Version
|
|
82
|
-
version: '0'
|
|
83
|
-
- !ruby/object:Gem::Dependency
|
|
84
|
-
name: debug
|
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
|
86
|
-
requirements:
|
|
87
|
-
- - ">="
|
|
88
|
-
- !ruby/object:Gem::Version
|
|
89
|
-
version: '0'
|
|
90
|
-
type: :development
|
|
91
|
-
prerelease: false
|
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
-
requirements:
|
|
94
|
-
- - ">="
|
|
95
|
-
- !ruby/object:Gem::Version
|
|
96
|
-
version: '0'
|
|
97
|
-
- !ruby/object:Gem::Dependency
|
|
98
|
-
name: selenium-webdriver
|
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
|
100
|
-
requirements:
|
|
101
|
-
- - ">="
|
|
102
|
-
- !ruby/object:Gem::Version
|
|
103
|
-
version: '0'
|
|
104
|
-
type: :development
|
|
105
|
-
prerelease: false
|
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
-
requirements:
|
|
108
|
-
- - ">="
|
|
109
|
-
- !ruby/object:Gem::Version
|
|
110
|
-
version: '0'
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: railties
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
-
|
|
17
|
+
- ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: "4.2"
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
-
|
|
25
|
+
- ">="
|
|
26
|
+
- !ruby/object:Gem::Version
|
|
27
|
+
version: "4.2"
|
|
28
|
+
- !ruby/object:Gem::Dependency
|
|
29
|
+
name: actionview
|
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
|
31
|
+
requirements:
|
|
32
|
+
-
|
|
33
|
+
- ">="
|
|
34
|
+
- !ruby/object:Gem::Version
|
|
35
|
+
version: "4.2"
|
|
36
|
+
type: :runtime
|
|
37
|
+
prerelease: false
|
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
39
|
+
requirements:
|
|
40
|
+
-
|
|
41
|
+
- ">="
|
|
42
|
+
- !ruby/object:Gem::Version
|
|
43
|
+
version: "4.2"
|
|
111
44
|
description: Faster and simpler JSON renderer for Rails
|
|
112
45
|
email:
|
|
113
|
-
- ronnie@dio.jp
|
|
46
|
+
- ronnie@dio.jp
|
|
114
47
|
executables: []
|
|
115
48
|
extensions: []
|
|
116
49
|
extra_rdoc_files: []
|
|
117
50
|
files:
|
|
118
|
-
-
|
|
119
|
-
-
|
|
120
|
-
-
|
|
121
|
-
-
|
|
122
|
-
-
|
|
123
|
-
-
|
|
124
|
-
-
|
|
125
|
-
-
|
|
126
|
-
-
|
|
127
|
-
-
|
|
128
|
-
- jb.
|
|
129
|
-
- lib/
|
|
130
|
-
|
|
131
|
-
- lib/generators/rails/templates/index.json.jb
|
|
132
|
-
- lib/generators/rails/templates/show.json.jb
|
|
133
|
-
- lib/jb.rb
|
|
134
|
-
- lib/jb/action_view_legacy_monkeys.rb
|
|
135
|
-
- lib/jb/action_view_monkeys.rb
|
|
136
|
-
- lib/jb/handler.rb
|
|
137
|
-
- lib/jb/railtie.rb
|
|
138
|
-
- lib/jb/version.rb
|
|
139
|
-
homepage: https://github.com/amatsuda/jb
|
|
51
|
+
- LICENSE.txt
|
|
52
|
+
- README.md
|
|
53
|
+
- lib/generators/rails/jb_generator.rb
|
|
54
|
+
- lib/generators/rails/scaffold_controller_generator.rb
|
|
55
|
+
- lib/generators/rails/templates/index.json.jb
|
|
56
|
+
- lib/generators/rails/templates/show.json.jb
|
|
57
|
+
- lib/jb.rb
|
|
58
|
+
- lib/jb/action_view_legacy_monkeys.rb
|
|
59
|
+
- lib/jb/action_view_monkeys.rb
|
|
60
|
+
- lib/jb/handler.rb
|
|
61
|
+
- lib/jb/railtie.rb
|
|
62
|
+
- lib/jb/version.rb
|
|
63
|
+
homepage: "https://github.com/amatsuda/jb"
|
|
140
64
|
licenses:
|
|
141
|
-
- MIT
|
|
65
|
+
- MIT
|
|
142
66
|
metadata: {}
|
|
143
|
-
post_install_message:
|
|
144
67
|
rdoc_options: []
|
|
145
68
|
require_paths:
|
|
146
|
-
- lib
|
|
69
|
+
- lib
|
|
147
70
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
148
71
|
requirements:
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
72
|
+
-
|
|
73
|
+
- ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: "2.4"
|
|
152
76
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
153
77
|
requirements:
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
78
|
+
-
|
|
79
|
+
- ">="
|
|
80
|
+
- !ruby/object:Gem::Version
|
|
81
|
+
version: "0"
|
|
157
82
|
requirements: []
|
|
158
|
-
rubygems_version:
|
|
159
|
-
signing_key:
|
|
83
|
+
rubygems_version: 4.1.0.beta2
|
|
160
84
|
specification_version: 4
|
|
161
85
|
summary: Faster and simpler Jbuilder alternative
|
|
162
86
|
test_files: []
|
data/.github/workflows/main.yml
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
name: Ruby
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
pull_request:
|
|
6
|
-
schedule:
|
|
7
|
-
- cron: '26 13 * * *'
|
|
8
|
-
|
|
9
|
-
jobs:
|
|
10
|
-
build:
|
|
11
|
-
strategy:
|
|
12
|
-
matrix:
|
|
13
|
-
ruby_version: [ruby-head, '3.2', '3.1', '3.0', '2.7']
|
|
14
|
-
rails_version: [edge, '7.0', '6.1']
|
|
15
|
-
|
|
16
|
-
include:
|
|
17
|
-
- ruby_version: '3.0'
|
|
18
|
-
rails_version: '6.0'
|
|
19
|
-
|
|
20
|
-
- ruby_version: '2.7'
|
|
21
|
-
rails_version: '6.0'
|
|
22
|
-
|
|
23
|
-
- ruby_version: '2.6'
|
|
24
|
-
rails_version: '6.1'
|
|
25
|
-
- ruby_version: '2.6'
|
|
26
|
-
rails_version: '6.0'
|
|
27
|
-
- ruby_version: '2.6'
|
|
28
|
-
rails_version: '5.2'
|
|
29
|
-
- ruby_version: '2.6'
|
|
30
|
-
rails_version: '5.1'
|
|
31
|
-
- ruby_version: '2.6'
|
|
32
|
-
rails_version: '5.0'
|
|
33
|
-
- ruby_version: '2.6'
|
|
34
|
-
rails_version: '4.2'
|
|
35
|
-
bundler_version: '1'
|
|
36
|
-
|
|
37
|
-
- ruby_version: '2.5'
|
|
38
|
-
rails_version: '5.2'
|
|
39
|
-
- ruby_version: '2.5'
|
|
40
|
-
rails_version: '4.2'
|
|
41
|
-
bundler_version: '1'
|
|
42
|
-
|
|
43
|
-
- ruby_version: '2.4'
|
|
44
|
-
rails_version: '5.2'
|
|
45
|
-
- ruby_version: '2.4'
|
|
46
|
-
rails_version: '4.2'
|
|
47
|
-
bundler_version: '1'
|
|
48
|
-
|
|
49
|
-
env:
|
|
50
|
-
RAILS_VERSION: ${{ matrix.rails_version }}
|
|
51
|
-
|
|
52
|
-
runs-on: ubuntu-latest
|
|
53
|
-
|
|
54
|
-
steps:
|
|
55
|
-
- uses: actions/checkout@v4
|
|
56
|
-
- uses: ruby/setup-ruby@v1
|
|
57
|
-
with:
|
|
58
|
-
ruby-version: ${{ matrix.ruby_version }}
|
|
59
|
-
bundler: ${{ matrix.bundler_version }}
|
|
60
|
-
bundler-cache: true
|
|
61
|
-
continue-on-error: ${{ (matrix.ruby_version == 'ruby-head') || (matrix.allow_failures == 'true') }}
|
|
62
|
-
- run: bundle exec rake
|
|
63
|
-
continue-on-error: ${{ (matrix.ruby_version == 'ruby-head') || (matrix.allow_failures == 'true') }}
|
data/.gitignore
DELETED
data/Gemfile
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
source 'https://rubygems.org'
|
|
4
|
-
|
|
5
|
-
# Specify your gem's dependencies in jb.gemspec
|
|
6
|
-
gemspec
|
|
7
|
-
|
|
8
|
-
if ENV['RAILS_VERSION'] == 'edge'
|
|
9
|
-
gem 'rails', git: 'https://github.com/rails/rails.git', branch: 'main'
|
|
10
|
-
elsif ENV['RAILS_VERSION']
|
|
11
|
-
gem 'rails', "~> #{ENV['RAILS_VERSION']}.0"
|
|
12
|
-
else
|
|
13
|
-
gem 'rails'
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
gem 'nokogiri', RUBY_VERSION < '2.1' ? '~> 1.6.0' : '>= 1.7'
|
|
17
|
-
gem 'loofah', RUBY_VERSION < '2.5' ? '< 2.21.0' : '>= 0'
|
|
18
|
-
gem 'selenium-webdriver'
|
|
19
|
-
gem 'net-smtp' if RUBY_VERSION >= '3.1'
|
|
20
|
-
|
|
21
|
-
# For benchmarking
|
|
22
|
-
gem 'action_args'
|
data/Rakefile
DELETED
data/bin/benchmark.sh
DELETED
data/bin/console
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
# frozen_string_literal: true
|
|
3
|
-
|
|
4
|
-
require "bundler/setup"
|
|
5
|
-
require "jb"
|
|
6
|
-
|
|
7
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
|
8
|
-
# with your gem easier. You can also use a different console, if you like.
|
|
9
|
-
|
|
10
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
11
|
-
# require "pry"
|
|
12
|
-
# Pry.start
|
|
13
|
-
|
|
14
|
-
require "irb"
|
|
15
|
-
IRB.start
|
data/bin/setup
DELETED
data/gemfiles/benchmark.gemfile
DELETED
data/jb.gemspec
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
# coding: utf-8
|
|
2
|
-
# frozen_string_literal: true
|
|
3
|
-
|
|
4
|
-
lib = File.expand_path('../lib', __FILE__)
|
|
5
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
6
|
-
require 'jb/version'
|
|
7
|
-
|
|
8
|
-
Gem::Specification.new do |spec|
|
|
9
|
-
spec.name = "jb"
|
|
10
|
-
spec.version = Jb::VERSION
|
|
11
|
-
spec.authors = ["Akira Matsuda"]
|
|
12
|
-
spec.email = ["ronnie@dio.jp"]
|
|
13
|
-
|
|
14
|
-
spec.summary = 'Faster and simpler Jbuilder alternative'
|
|
15
|
-
spec.description = 'Faster and simpler JSON renderer for Rails'
|
|
16
|
-
spec.homepage = 'https://github.com/amatsuda/jb'
|
|
17
|
-
spec.license = "MIT"
|
|
18
|
-
|
|
19
|
-
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
20
|
-
spec.bindir = "exe"
|
|
21
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
22
|
-
spec.require_paths = ["lib"]
|
|
23
|
-
|
|
24
|
-
spec.add_development_dependency 'bundler'
|
|
25
|
-
spec.add_development_dependency 'rake'
|
|
26
|
-
spec.add_development_dependency 'test-unit-rails'
|
|
27
|
-
spec.add_development_dependency 'rails'
|
|
28
|
-
spec.add_development_dependency 'action_args'
|
|
29
|
-
spec.add_development_dependency 'debug'
|
|
30
|
-
spec.add_development_dependency 'selenium-webdriver'
|
|
31
|
-
end
|