breezy 0.12.0 → 0.13.0

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: 7d24f3b08babf09a78c371b15e95bcb9ca5cfc9d
4
- data.tar.gz: 3a0d29c9e69c63a01270739dde64031e1b0e9c1c
2
+ SHA256:
3
+ metadata.gz: fd987af4f1d0ee06d70daa8e0c0b0610a909d61dfbabdb1271e1bbe6e8b32d5d
4
+ data.tar.gz: fd191505d7d3af65c6c462f675206cbff52464bee535082498dd79bb4251f339
5
5
  SHA512:
6
- metadata.gz: 80b0cd8e3d1ef6aff04d65d9ae5a48e7b3779ea64e0352a751a0105aa6d72da71b6a4727bbe1353fc1f117c3129364beba37e8a38909a43b79c3515244394bc1
7
- data.tar.gz: 533d572c650638dfb39195ac9a302aad02c41ad956bb5ed0748e5ed05a885d4f74b8aa904d8981feaf7881834038748a07b8fed0cd389bce5c26ec7b54836021
6
+ metadata.gz: e064246ef16613bf7bbcf31e29bda96162c0bd68e9f542fbd91a5862ce0ddc35b409b1edb142668c488fbde4b7dc7d6e227ba4301ad72c7b36897bc8885a7163
7
+ data.tar.gz: de7cba9c77dcc53fad1408d0d06aab6683b4c59718d3f91e56c5672839cbe8110cf04121a3f5b9731093342b3943231252b9556055749e022f1745001364b21c
data/lib/breezy.rb CHANGED
@@ -1,14 +1,12 @@
1
1
  require 'breezy/xhr_headers'
2
2
  require 'breezy/xhr_url_for'
3
3
  require 'breezy/x_domain_blocker'
4
- require 'breezy/render'
5
4
  require 'breezy/helpers'
6
- require 'breezy/configuration'
7
- require 'breezy_template'
5
+ require 'props_template'
8
6
 
9
7
  module Breezy
10
8
  module Controller
11
- include XHRHeaders, XDomainBlocker, Render, Helpers
9
+ include XHRHeaders, XDomainBlocker, Helpers
12
10
 
13
11
  def self.included(base)
14
12
  if base.respond_to?(:before_action)
@@ -20,9 +18,8 @@ module Breezy
20
18
  end
21
19
 
22
20
  if base.respond_to?(:helper_method)
23
- base.helper_method :breezy_snippet
24
- base.helper_method :use_breezy
25
- base.helper_method :breezy_filter
21
+ base.helper_method :param_to_search_path
22
+ base.helper_method :search_path_to_camelized_param
26
23
  end
27
24
  end
28
25
  end
@@ -1,22 +1,29 @@
1
1
  module Breezy
2
2
  module Helpers
3
- def breezy_snippet
4
- if defined?(@_breezy_snippet) && @_breezy_snippet
5
- snippet = @_breezy_snippet.gsub(/\;$/, '')
6
- "#{snippet};".html_safe
3
+ def param_to_search_path(param)
4
+ if param
5
+ param.gsub(/[^\da-zA-Z\_\=\.]+/, '')
6
+ .gsub(/\.+/, '.')
7
+ .split('.')
8
+ .map do |part|
9
+ if part =~ /^-?[0-9]+$/
10
+ part.to_i
11
+ else
12
+ part
13
+ end
14
+ end
7
15
  end
8
16
  end
9
17
 
10
- def use_breezy
11
- @_use_breezy = true
12
- end
13
-
14
- def breezy_filter
15
- filter = request.params[:bzq]
16
-
17
- if filter
18
- filter.gsub(/[^\da-zA-Z\_\=\.]+/, '')
19
- end
18
+ def search_path_to_camelized_param(path)
19
+ path.map do |part|
20
+ if part.include? '='
21
+ key, rest = part.split('=')
22
+ [key.camelize(:lower), rest].join('=')
23
+ else
24
+ part.camelize(:lower)
25
+ end
26
+ end.join('.')
20
27
  end
21
28
  end
22
29
  end
@@ -48,7 +48,7 @@ module Rails
48
48
  "\nimport #{component_name} from 'views/#{controller_file_path}/#{action}'"
49
49
  end
50
50
 
51
- inject_into_file app_js, after: 'const screenToComponentMapping = {' do
51
+ inject_into_file app_js, after: 'const identifierToComponentMapping = {' do
52
52
  "\n '#{[controller_file_path, action].join('/')}': #{component_name},"
53
53
  end
54
54
  end
@@ -62,7 +62,7 @@ module Rails
62
62
  end
63
63
 
64
64
  def filename_with_extensions(name)
65
- [name, :js, :props] * '.'
65
+ [name, :json, :props] * '.'
66
66
  end
67
67
 
68
68
  def filename_with_jsx_extensions(name)
@@ -5,26 +5,51 @@ require_dependency "<%= namespaced_path %>/application_controller"
5
5
  <% module_namespacing do -%>
6
6
  class <%= controller_class_name %>Controller < ApplicationController
7
7
  before_action :set_<%= singular_table_name %>, only: [:show, :edit, :update, :destroy]
8
- # `use_breezy` enables breezy functionality
9
- # on application.html.erb
10
- before_action :use_breezy
11
8
 
12
9
  # GET <%= route_url %>
13
10
  def index
14
11
  @<%= plural_table_name %> = <%= orm_class.all(class_name) %>
12
+ respond_to do |format|
13
+ format.html {
14
+ @initial_state = render_to_string(formats: [:json], layout: true)
15
+ render inline: '', layout: true
16
+ }
17
+ format.json { render layout: true }
18
+ end
15
19
  end
16
20
 
17
21
  # GET <%= route_url %>/1
18
22
  def show
23
+ respond_to do |format|
24
+ format.html {
25
+ @initial_state = render_to_string(formats: [:json], layout: true)
26
+ render inline: '', layout: true
27
+ }
28
+ format.json { render layout: true }
29
+ end
19
30
  end
20
31
 
21
32
  # GET <%= route_url %>/new
22
33
  def new
23
34
  @<%= singular_table_name %> = <%= orm_class.build(class_name) %>
35
+ respond_to do |format|
36
+ format.html {
37
+ @initial_state = render_to_string(formats: [:json], layout: true)
38
+ render inline: '', layout: true
39
+ }
40
+ format.json { render layout: true }
41
+ end
24
42
  end
25
43
 
26
44
  # GET <%= route_url %>/1/edit
27
45
  def edit
46
+ respond_to do |format|
47
+ format.html {
48
+ @initial_state = render_to_string(formats: [:json], layout: true)
49
+ render inline: '', layout: true
50
+ }
51
+ format.json { render layout: true }
52
+ end
28
53
  end
29
54
 
30
55
  # POST <%= route_url %>
@@ -1,5 +1,8 @@
1
1
  json.flash flash.to_h
2
- json.errors @<%= singular_table_name %>.errors.to_h
2
+
3
+ if @<%= singular_table_name %>.errors
4
+ json.errors @<%= singular_table_name %>.errors.to_h
5
+ end
3
6
 
4
7
  <%- attributes_list_with_timestamps.each do |attr| -%>
5
8
  json.<%=attr%> @<%= singular_table_name %>.<%=attr%>
@@ -0,0 +1,6 @@
1
+ json.flash flash.to_h
2
+ if @<%= singular_table_name %>.errors
3
+ json.errors @<%= singular_table_name %>.errors.to_h
4
+ end
5
+
6
+ json.<%= plural_table_name %>_path <%= plural_table_name %>_path
@@ -12,7 +12,7 @@ import applicationReducer from './reducer'
12
12
 
13
13
  // Mapping between your props template to Component
14
14
  // e.g {'posts/new': PostNew}
15
- const screenToComponentMapping = {
15
+ const identifierToComponentMapping = {
16
16
  }
17
17
 
18
18
  const history = createHistory({})
@@ -60,5 +60,5 @@ class App extends React.Component {
60
60
  }
61
61
 
62
62
  document.addEventListener("DOMContentLoaded", function() {
63
- render(<App mapping={screenToComponentMapping}/>, document.getElementById('app'))
63
+ render(<App mapping={identifierToComponentMapping}/>, document.getElementById('app'))
64
64
  })
@@ -0,0 +1,23 @@
1
+ path = param_to_search_path(params[:bzq])
2
+
3
+ json.data(search: path) do
4
+ yield json
5
+ end
6
+
7
+ json.component_identifier "#{params[:controller]}/#{params[:action]}"
8
+ json.defers json.deferred!
9
+ json.fragments json.fragments!
10
+ json.assets [
11
+ asset_pack_path('application.js'),
12
+ asset_path('application.css')
13
+ ]
14
+
15
+ if protect_against_forgery?
16
+ json.csrf_token form_authenticity_token
17
+ end
18
+
19
+ if path
20
+ json.action 'graft'
21
+ json.path search_path_to_camelized_param(path)
22
+ end
23
+
data/lib/install/web.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  require "webpacker/configuration"
2
2
 
3
- babelrc = Rails.root.join(".babelrc")
4
3
  babel_config = Rails.root.join("babel.config.js")
5
4
 
6
5
  def append_js_tags
@@ -8,7 +7,7 @@ def append_js_tags
8
7
  js_tag = <<-JS_TAG
9
8
 
10
9
  <script type="text/javascript">
11
- window.BREEZY_INITIAL_PAGE_STATE=<%= breezy_snippet %>;
10
+ window.BREEZY_INITIAL_PAGE_STATE=<%= @initial_state.html_safe %>;
12
11
  </script>
13
12
  JS_TAG
14
13
 
@@ -21,6 +20,7 @@ def append_js_tags
21
20
  end
22
21
  end
23
22
 
23
+ #TODO: add member_key
24
24
  def add_member_methods
25
25
  inject_into_file "app/models/application_record.rb", after: "class ApplicationRecord < ActiveRecord::Base\n" do
26
26
  <<-RUBY
@@ -29,51 +29,31 @@ def add_member_methods
29
29
  end
30
30
 
31
31
  def self.member_by(attr, value)
32
- find_by(Hash[attr, val])
32
+ find_by(Hash[attr, value])
33
+ end
34
+
35
+ def self.member_key
36
+ "id"
33
37
  end
34
38
 
35
39
  RUBY
36
40
  end
37
41
  end
38
42
 
39
- if File.exist?(babelrc)
40
- react_babelrc = JSON.parse(File.read(babelrc))
41
- react_babelrc["presets"] ||= []
42
- react_babelrc["plugins"] ||= []
43
-
44
- react_babelrc["plugins"].push(["module-resolver", {
45
- "root": ["./app"],
46
- "alias": {
47
- "views": "./app/views",
48
- "components": "./app/components",
49
- "javascript": "./app/javascript"
43
+ say "Copying module-resolver preset to your babel.config.js"
44
+ resolver_snippet = <<~JAVASCRIPT
45
+ [
46
+ require('babel-plugin-module-resolver').default, {
47
+ "root": ["./app"],
48
+ "alias": {
49
+ "views": "./app/views",
50
+ "components": "./app/components",
51
+ "javascript": "./app/javascript"
52
+ }
50
53
  }
51
- }])
52
-
53
- say "Copying module-resolver preset to your .babelrc file"
54
-
55
- File.open(babelrc, "w") do |f|
56
- f.puts JSON.pretty_generate(react_babelrc)
57
- end
58
- elsif File.exist?(babel_config)
59
- say "Copying module-resolver preset to your babel.config.js"
60
- resolver_snippet = <<~PLUGIN
61
- [
62
- require('babel-plugin-module-resolver').default, {
63
- "root": ["./app"],
64
- "alias": {
65
- "views": "./app/views",
66
- "components": "./app/components",
67
- "javascript": "./app/javascript"
68
- }
69
- }
70
- ],
71
- PLUGIN
72
- insert_into_file "babel.config.js", resolver_snippet, after: /plugins: \[\n/
73
- else
74
- say "Copying .babelrc to app root directory"
75
- copy_file "#{__dir__}/templates/web/babelrc", ".babelrc"
76
- end
54
+ ],
55
+ JAVASCRIPT
56
+ insert_into_file "babel.config.js", resolver_snippet, after: /plugins: \[\n/
77
57
 
78
58
  say "Copying application.js file to #{Webpacker.config.source_entry_path}"
79
59
  copy_file "#{__dir__}/templates/web/application.js", "#{Webpacker.config.source_entry_path}/application.js"
@@ -87,8 +67,8 @@ copy_file "#{__dir__}/templates/web/action_creators.js", "#{Webpacker.config.sou
87
67
  say "Copying actions.js file to #{Webpacker.config.source_entry_path}"
88
68
  copy_file "#{__dir__}/templates/web/actions.js", "#{Webpacker.config.source_entry_path}/actions.js"
89
69
 
90
- say "Copying Breezy initializer"
91
- copy_file "#{__dir__}/templates/web/initializer.rb", "config/initializers/breezy.rb"
70
+ say "Copying application.json.props"
71
+ copy_file "#{__dir__}/templates/web/application.json.props", "app/views/layouts/application.json.props"
92
72
 
93
73
  say "Appending js tags to your application.html.erb"
94
74
  append_js_tags
@@ -10,6 +10,16 @@ namespace :breezy do
10
10
  end
11
11
  end
12
12
 
13
+ desc "Verifies if any version of react is in package.json"
14
+ task :verify_react do
15
+ package_json = JSON.parse(File.read(Rails.root.join("package.json")))
16
+
17
+ if package_json['dependencies']['react'].nil?
18
+ $stderr.puts "React not installed. Did you run `rails webpacker:install:react`?"
19
+ $stderr.puts "Exiting!" && exit!
20
+ end
21
+ end
22
+
13
23
  desc "Verifies webpacker has been installed"
14
24
  task "verify_webpacker" do
15
25
  begin
@@ -23,7 +33,7 @@ namespace :breezy do
23
33
 
24
34
  namespace :install do
25
35
  desc "Install everything needed for breezy web"
26
- task 'web' => ["breezy:verify_webpacker", "webpacker:verify_install"] do
36
+ task 'web' => ["breezy:verify_webpacker", "webpacker:verify_install", "breezy:verify_react"] do
27
37
  template = File.expand_path("../install/web.rb", __dir__)
28
38
  exec "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{template}"
29
39
  end
data/test/breezy_test.rb CHANGED
@@ -1,12 +1,8 @@
1
1
  require 'test_helper'
2
2
 
3
3
  class BreezyController < TestController
4
- before_action do
5
- @_use_breezy = false
6
- end
7
-
8
4
  def simple_action
9
- render plain: ''
5
+ render inline: ''
10
6
  end
11
7
 
12
8
  def redirect_to_same_origin
data/test/helpers_test.rb CHANGED
@@ -2,30 +2,22 @@ require 'test_helper'
2
2
 
3
3
  class HelpersTest < ActiveSupport::TestCase
4
4
  include Breezy::Helpers
5
- attr_reader :request
6
5
 
7
- class Request
8
- attr_reader :params
9
- def initialize(params = {})
10
- @params = params
11
- end
12
- end
13
-
14
- test 'breezy_filter returns a valid bzq param' do
15
- @request = Request.new({:bzq => 'foo.bar.baz_baz'})
6
+ test 'clean_bzq returns nil if qry is nil' do
7
+ qry = nil
16
8
 
17
- assert_equal breezy_filter, 'foo.bar.baz_baz'
9
+ assert_nil param_to_search_path(qry)
18
10
  end
19
11
 
20
- test 'breezy_filter removes invalid bzq param chars' do
21
- @request = Request.new({:bzq => 'foo.bar/?)()-'})
12
+ test 'clean_bzq returns a refined qry' do
13
+ qry = 'foo...bar/?)()-'
22
14
 
23
- assert_equal breezy_filter, 'foo.bar'
15
+ assert_equal param_to_search_path(qry), ['foo', 'bar']
24
16
  end
25
17
 
26
- test 'breezy_filter return nil when no params are present' do
27
- @request = Request.new({})
18
+ test 'camelize_path' do
19
+ path = ['foo_bar', 'foo_bar=1', 'foo_baz_roo']
28
20
 
29
- assert_nil breezy_filter
21
+ assert_equal search_path_to_camelized_param(path), 'fooBar.fooBar=1.fooBazRoo'
30
22
  end
31
23
  end
data/test/render_test.rb CHANGED
@@ -4,14 +4,14 @@ class RenderController < TestController
4
4
  require 'action_view/testing/resolvers'
5
5
 
6
6
  append_view_path(ActionView::FixtureResolver.new(
7
- 'render/action.js.breezy' => 'json.author "john smith"',
8
- 'render/action.html.erb' => 'john smith',
9
- 'render/implied_render_with_breezy.js.breezy' => 'json.author "john smith"',
10
- 'render/implied_render_with_breezy.html.erb' => 'john smith',
7
+ 'render/simple_render_with_breezy.json.props' => 'json.author "john smith"',
8
+ 'render/simple_render_with_breezy_with_bad_layout.json.props' => 'json.author "john smith"',
9
+ 'layouts/application.json.props' => 'json.data {yield json}',
10
+ 'layouts/does_not_exist.html.erb' => '',
11
11
  'layouts/application.html.erb' => <<~HTML
12
12
  <html>
13
13
  <head>
14
- <script><%= breezy_snippet %></script>
14
+ <script><%= @initial_state.strip.html_safe %></script>
15
15
  </head>
16
16
  <body><%=yield%></body>
17
17
  </html>
@@ -20,21 +20,18 @@ class RenderController < TestController
20
20
 
21
21
  layout 'application'
22
22
 
23
- before_action :use_breezy, only: [:simple_render_with_breezy, :implied_render_with_breezy]
24
-
25
23
  def render_action
26
24
  render :action
27
25
  end
28
26
 
29
27
  def simple_render_with_breezy
30
- render :action
31
- end
32
-
33
- def implied_render_with_breezy
28
+ @initial_state = render_to_string(formats: [:json], layout: true)
29
+ render inline: '', layout: true
34
30
  end
35
31
 
36
- def render_action_with_breezy_false
37
- render :action
32
+ def simple_render_with_breezy_with_bad_layout
33
+ @initial_state = render_to_string(formats: [:json], layout: 'does_not_exist')
34
+ render inline: '', layout: true
38
35
  end
39
36
 
40
37
  def form_authenticity_token
@@ -50,108 +47,35 @@ class RenderTest < ActionController::TestCase
50
47
  if Rails.version >= '6'
51
48
  # In rails 6, the fixture orders the templates based on their appearance in the handler
52
49
  # This doesn't happen IRL, so I'm going to explicitly set the handler here.
53
- #
50
+ #
54
51
  # Note that the original is the following
55
52
  # @controller.lookup_context.handlers = [:raw, :breezy, :erb, :js, :html, :builder, :ruby]
56
- @controller.lookup_context.handlers = [:breezy, :erb]
53
+ @controller.lookup_context.handlers = [:props, :erb]
57
54
  end
58
-
59
- Breezy.configuration.track_sprockets_assets = ['app.js']
60
- Breezy.configuration.track_pack_assets = ['app.js']
61
- end
62
-
63
- teardown do
64
- Breezy.configuration.track_sprockets_assets = []
65
- Breezy.configuration.track_pack_assets = []
66
- end
67
-
68
- test "render action via get" do
69
- get :render_action
70
- assert_normal_render 'john smith'
71
55
  end
72
56
 
73
57
  test "simple render with breezy" do
74
58
  get :simple_render_with_breezy
75
- assert_breezy_html({author: "john smith"}, screen: 'render/action')
76
- end
77
-
78
- test "implied render with breezy" do
79
- get :implied_render_with_breezy
80
- assert_breezy_html({author: "john smith"}, screen: 'render/implied_render_with_breezy')
81
- end
82
-
83
- test "simple render with breezy via get js" do
84
- @request.accept = 'application/javascript'
85
- get :simple_render_with_breezy
86
- assert_breezy_js({author: "john smith"})
87
- end
88
-
89
- test "render action via xhr and get js" do
90
- @request.accept = 'application/javascript'
91
- get :simple_render_with_breezy, xhr: true
92
- assert_breezy_js({author: "john smith"})
93
- end
94
-
95
- test "render with breezy false" do
96
- get :render_action_with_breezy_false
97
- assert_normal_render("john smith")
98
- end
99
-
100
- test "render with breezy false via xhr get" do
101
- @request.accept = 'text/html'
102
- get :render_action_with_breezy_false, xhr: true
103
- assert_normal_render("john smith")
104
- end
105
-
106
- test "render action via xhr and put" do
107
- @request.accept = 'text/html'
108
- put :render_action, xhr: true
109
- assert_normal_render 'john smith'
110
- end
111
59
 
112
- private
113
-
114
- def assert_breezy_html(content, opts={})
115
60
  assert_response 200
116
-
117
61
  rendered = <<~HTML
118
62
  <html>
119
63
  <head>
120
- <script>(function(){var fragments={};var lastFragmentName;var lastFragmentPath;var cache={};var defers=[];return ({"data":#{content.to_json},"screen":"#{opts[:screen]}","fragments":fragments,"privateOpts":{"csrfToken":"secret","assets":["/app.js"],"lastFragmentName":lastFragmentName,"lastFragmentPath":lastFragmentPath,"defers":defers}});})();</script>
64
+ <script>{"data":{"author":"john smith"}}</script>
121
65
  </head>
122
66
  <body></body>
123
67
  </html>
124
68
  HTML
125
69
 
126
70
  assert_equal rendered, @response.body
127
- assert_equal 'text/html', @response.content_type
128
- end
129
-
130
- def assert_breezy_js(content)
131
- assert_response 200
132
- assert_equal '(function(){var fragments={};var lastFragmentName;var lastFragmentPath;var cache={};var defers=[];return ({"data":' + content.to_json + ',"screen":"render/action","fragments":fragments,"privateOpts":{"csrfToken":"secret","assets":["/app.js"],"lastFragmentName":lastFragmentName,"lastFragmentPath":lastFragmentPath,"defers":defers}});})()', @response.body
133
- assert_equal 'text/javascript', @response.content_type
134
- end
135
-
136
- def assert_breezy_replace_js(content)
137
- assert_response 200
138
- assert_equal 'Breezy.replace((function(){return ({"data":' + content.to_json + ',"csrfToken":"secret","assets":["/app.js"]});})());', @response.body
139
- assert_equal 'text/javascript', @response.content_type
71
+ assert_equal 'text/html', @response.media_type
140
72
  end
141
73
 
142
- def assert_normal_render(content)
143
- assert_response 200
144
-
145
- rendered = <<~HTML
146
- <html>
147
- <head>
148
- <script></script>
149
- </head>
150
- <body>#{content}</body>
151
- </html>
152
- HTML
74
+ test "simple render when the layout doesn't exist" do
75
+ err = assert_raise ActionView::MissingTemplate do |e|
76
+ get :simple_render_with_breezy_with_bad_layout
77
+ end
153
78
 
154
- assert_equal rendered, @response.body
155
- assert_equal 'text/html', @response.content_type
79
+ assert_equal(true, err.message.starts_with?('Missing template layouts/does_not_exist with {:locale=>[:en], :formats=>[:json], :variants=>[], :handlers=>[:props, :erb]}.'))
156
80
  end
157
81
  end
data/test/test_helper.rb CHANGED
@@ -8,7 +8,7 @@ require 'active_record'
8
8
  require 'active_support/testing/autorun'
9
9
  require 'active_support/test_case'
10
10
 
11
- require 'breezy_template'
11
+ require 'props_template'
12
12
 
13
13
  ActiveSupport::TestCase.test_order = :random if ActiveSupport::TestCase.respond_to?(:test_order=)
14
14
  ActiveRecord::Base.establish_connection adapter: "sqlite3", database: ":memory:"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: breezy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.0
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Johny Ho
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-31 00:00:00.000000000 Z
11
+ date: 2020-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 5.0.0
19
+ version: 6.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 5.0.0
26
+ version: 6.0.0
27
27
  - !ruby/object:Gem::Dependency
28
- name: breezy_template
28
+ name: props_template
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 0.12.0
33
+ version: 0.13.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 0.12.0
40
+ version: 0.13.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: webpacker
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '5.0'
61
+ version: '6.0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: '5.0'
68
+ version: '6.0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rake
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -158,19 +158,17 @@ extra_rdoc_files: []
158
158
  files:
159
159
  - app/views/breezy/response.html.erb
160
160
  - lib/breezy.rb
161
- - lib/breezy/configuration.rb
162
161
  - lib/breezy/helpers.rb
163
- - lib/breezy/render.rb
164
162
  - lib/breezy/x_domain_blocker.rb
165
163
  - lib/breezy/xhr_headers.rb
166
164
  - lib/breezy/xhr_url_for.rb
167
165
  - lib/generators/rails/breezy_generator.rb
168
166
  - lib/generators/rails/scaffold_controller_generator.rb
169
167
  - lib/generators/rails/templates/controller.rb.tt
170
- - lib/generators/rails/templates/edit.js.props
171
- - lib/generators/rails/templates/index.js.props
172
- - lib/generators/rails/templates/new.js.props
173
- - lib/generators/rails/templates/show.js.props
168
+ - lib/generators/rails/templates/edit.json.props
169
+ - lib/generators/rails/templates/index.json.props
170
+ - lib/generators/rails/templates/new.json.props
171
+ - lib/generators/rails/templates/show.json.props
174
172
  - lib/generators/rails/templates/web/base.jsx
175
173
  - lib/generators/rails/templates/web/edit.jsx
176
174
  - lib/generators/rails/templates/web/form.jsx
@@ -180,13 +178,11 @@ files:
180
178
  - lib/install/templates/web/action_creators.js
181
179
  - lib/install/templates/web/actions.js
182
180
  - lib/install/templates/web/application.js
183
- - lib/install/templates/web/babelrc
184
- - lib/install/templates/web/initializer.rb
181
+ - lib/install/templates/web/application.json.props
185
182
  - lib/install/templates/web/reducer.js
186
183
  - lib/install/web.rb
187
184
  - lib/tasks/install.rake
188
185
  - test/breezy_test.rb
189
- - test/configuration_test.rb
190
186
  - test/engine_test.rb
191
187
  - test/helpers_test.rb
192
188
  - test/render_test.rb
@@ -210,14 +206,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
210
206
  - !ruby/object:Gem::Version
211
207
  version: '0'
212
208
  requirements: []
213
- rubyforge_project:
214
- rubygems_version: 2.6.11
209
+ rubygems_version: 3.0.3
215
210
  signing_key:
216
211
  specification_version: 4
217
212
  summary: Rails integration for BreezyJS
218
213
  test_files:
219
214
  - test/render_test.rb
220
- - test/configuration_test.rb
221
215
  - test/helpers_test.rb
222
216
  - test/engine_test.rb
223
217
  - test/test_helper.rb
@@ -1,35 +0,0 @@
1
- module Breezy
2
- class Configuration
3
- def initialize
4
- BreezyTemplate.configuration = nil
5
- end
6
-
7
- def track_sprockets_assets=(assets)
8
- BreezyTemplate.configuration.track_sprockets_assets = assets
9
- end
10
-
11
- def track_sprockets_assets
12
- BreezyTemplate.configuration.track_sprockets_assets
13
- end
14
-
15
- def track_pack_assets=(assets)
16
- BreezyTemplate.configuration.track_pack_assets = assets
17
- end
18
-
19
- def track_pack_assets
20
- BreezyTemplate.configuration.track_pack_assets
21
- end
22
- end
23
-
24
- def self.configuration
25
- @configuration ||= Configuration.new
26
- end
27
-
28
- def self.configuration=(config)
29
- @configuration = config
30
- end
31
-
32
- def self.configure
33
- yield configuration
34
- end
35
- end
data/lib/breezy/render.rb DELETED
@@ -1,37 +0,0 @@
1
- module Breezy
2
- module Render
3
- def default_render(*args)
4
- if @_use_breezy
5
- render(*args)
6
- else
7
- super
8
- end
9
- end
10
-
11
- def render(*args, &block)
12
- if !@_use_breezy
13
- return super
14
- end
15
-
16
- render_options = args.extract_options!
17
- breezy_options = render_options.delete(:breezy)
18
-
19
- if !breezy_options
20
- breezy = {}
21
- end
22
-
23
- render_options[:locals] ||= {}
24
- render_options[:locals][:breezy] = breezy
25
-
26
- if request.format == :html
27
- original_formats = self.formats
28
- @_breezy_snippet = render_to_string(*args, render_options.merge(formats: [:js]))
29
- self.formats = original_formats
30
-
31
- render_options.reverse_merge!(formats: original_formats, template: 'breezy/response')
32
- end
33
-
34
- super(*args, render_options, &block)
35
- end
36
- end
37
- end
@@ -1,4 +0,0 @@
1
- json.flash flash.to_h
2
- json.errors @<%= singular_table_name %>.errors.to_h
3
-
4
- json.<%= plural_table_name %>_path <%= plural_table_name %>_path
@@ -1,35 +0,0 @@
1
- {
2
- "presets": [
3
- [
4
- "env",
5
- {
6
- "modules": false,
7
- "targets": {
8
- "browsers": "> 1%",
9
- "uglify": true
10
- },
11
- "useBuiltIns": true
12
- }
13
- ],
14
- "react"
15
- ],
16
- "plugins": [
17
- "syntax-dynamic-import",
18
- ["module-resolver", {
19
- "root": ["./app"],
20
- "alias": {
21
- "views": "./app/views",
22
- "components": "./app/components",
23
- "javascript": "./app/javascript"
24
- }
25
- }],
26
- "transform-object-rest-spread",
27
- [
28
- "transform-class-properties",
29
- {
30
- "spec": true
31
- }
32
- ]
33
- ]
34
- }
35
-
@@ -1,15 +0,0 @@
1
- require 'breezy_template/core_ext'
2
-
3
- Breezy.configure do |config|
4
- # Configure breezy.js to refresh the browser when sprockets or
5
- # webpacker asset fingerpint changes. This is similar to Turbolink's
6
- # `data-turbolinks-track`.
7
- #
8
- # Note that this file was generated without sprockets JS tracking.
9
- # If you need to change this behavior, add it like so:
10
- #
11
- # config.track_sprockets_assets = ['application.js', 'application.css']
12
- config.track_sprockets_assets = ['application.css']
13
-
14
- config.track_pack_assets = ['application.js']
15
- end
@@ -1,36 +0,0 @@
1
- require 'test_helper'
2
-
3
- class ConfigurationTest < ActiveSupport::TestCase
4
- def restore_default_config
5
- Breezy.configuration = nil
6
- Breezy.configure {}
7
- end
8
-
9
- setup do
10
- restore_default_config
11
- end
12
-
13
- test 'configuration with an empty block defaults to application.js and application.css' do
14
- Breezy.configure do |config|
15
- end
16
-
17
- track_sprockets_assets = ['application.js', 'application.css']
18
- track_pack_assets = ['application.js']
19
-
20
- assert_equal track_sprockets_assets, Breezy.configuration.track_sprockets_assets
21
- assert_equal track_pack_assets, Breezy.configuration.track_pack_assets
22
- end
23
-
24
- test 'configuration with track_assets specified' do
25
- Breezy.configure do |config|
26
- config.track_sprockets_assets = ['app.js']
27
- config.track_pack_assets = ['pack.js']
28
- end
29
-
30
- track_sprockets_assets = ['app.js']
31
- track_pack_assets = ['pack.js']
32
-
33
- assert_equal track_sprockets_assets, Breezy.configuration.track_sprockets_assets
34
- assert_equal track_pack_assets, Breezy.configuration.track_pack_assets
35
- end
36
- end