hot-glue 0.2.5 → 0.2.6

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
  SHA256:
3
- metadata.gz: 31420297af512f9e5153ff91ff0b15baec2650080938b9a1def230de42dae0a3
4
- data.tar.gz: cf430cad34867b7113f48a56e06b7b195a476ae1090da28f06796b10a7eccf94
3
+ metadata.gz: 2000db5bcae078cadbe8afc0bc3d53750d0baa453ca5e627962b3a6b2b6615e1
4
+ data.tar.gz: 6ce4745eb0e6a67cd37ede9db75eca2d7bddee4bb241c236aebd12c7d0a30502
5
5
  SHA512:
6
- metadata.gz: 87ccaa42b5ab50ca222ff8c437bc348ab0f40d3c9d9c70f130ff47c2b8fea4ad51e267d6d21a377aa1f9d0bd47493a12b85296ce7b9e49081bd4ea841200ea54
7
- data.tar.gz: b64d5bd42d2f571e4a1297b36fcdebe5d65907f63ab87c9f906fcf9576b223ab434e7348023bdd91a5f84ef517cd3576ba2e97ad0ae0f2dcfe108d93a6df2bf0
6
+ metadata.gz: 126bb570bf44f4a2d3fd36731bf5eca31d416f74eda2b8e1e60ff9ceec0cfc1cff5c03cc2f185b37a354f7c7a6e7c4812fa5187286c731d5702b0d77dadc5103
7
+ data.tar.gz: 91cd67558e8910b5369886634eadc6b98a7be6d6b629e829f1cd81656579e86b015fa671f5636848f69be3af36aa0be551b19fef86117a45563d9ba35e49c2ab
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hot-glue (0.2.4)
4
+ hot-glue (0.2.5)
5
5
  ffaker (~> 2.16)
6
6
  haml-rails (~> 2.0)
7
7
  kaminari (~> 1.2)
data/README.md CHANGED
@@ -54,119 +54,163 @@ Instantly get a simple CRUD interface
54
54
 
55
55
  ![hot-glue-4](https://user-images.githubusercontent.com/59002/116405517-c2b2e300-a7fd-11eb-8423-d43e3afc9fa6.gif)
56
56
 
57
- ## TO INSTALL (RAILS 7)
58
57
 
59
- - Install Turbo `rails turbo:install` (?)
60
-
61
- - Add `gem 'hot-glue'` to your Gemfile
62
- - `bundle install`
63
- - `rails generate hot_glue:install --markup=erb` for ERB
64
- - or `rails generate hot_glue:install --markup=haml` for HAML
65
-
66
- - Add to your `application.html.erb`
58
+ ## ADD HOTWIRE
67
59
  ```
68
- <%= render partial: 'layouts/flash_notices' %>
60
+ yarn add @hotwired/turbo-rails
69
61
  ```
70
- - Or for Haml add to your `application.haml`
62
+ or `npm install @hotwired/turbo-rails`
63
+
64
+ ## ADD HOT-GLUE GEM
65
+ - Add `gem 'hot-glue'` to your Gemfile & `bundle install`
66
+
67
+ ## ADD RSPEC, FACTORY-BOT, AND FFAKER
68
+
69
+ add these 3 gems to your gemfile inside :development and :test groups
71
70
  ```
72
- = render partial: 'layouts/flash_notices'
71
+ gem 'rspec-rails'
72
+ gem 'factory_bot_rails'
73
+ gem 'ffaker'
73
74
  ```
74
75
 
75
- ## TO INSTALL (RAILS 6)
76
76
 
77
+ ## RUN THE RSPEC INSTALLER
78
+ - run `rails generate rspec:install`
79
+
80
+ ## RUN HOT-GLUE INSTALL
81
+ ### FOR ERB:
82
+ `rails generate hot_glue:install --markup=erb`
83
+
84
+ ### FOR HAML:
85
+ `rails generate hot_glue:install --markup=haml`
86
+
87
+
88
+ ## FOR RAILS 6 ONLY: SWITCH FROM TurblLinks to Turbo-Rails (SKIP THIS STEP FOR RAILS 7)
89
+ (THIS WAS AUTOMATICALLY DONE BY THE HOT GLUE INSTALLATION -- CONFIRM CHANGES ONLY)
77
90
  - Add `gem 'turbo-rails'` to your Gemfile & `bundle install`
78
-
79
91
  - Then install it with `rails turbo:install`
80
-
81
92
  - The Turbo install has switched your action cable settings from 'async' to Redis, so be sure to start a redis server
82
-
83
- - Add `gem 'hot-glue'` to your Gemfile & `bundle install`
84
-
85
- - in `javascript/packs/application.js` remove this line:
86
- `import Turbolinks from "turbolinks"`
93
+ - in `app/javascript/packs/application.js` remove this line
94
+ ```
95
+ import Turbolinks from "turbolinks"
96
+ ```
97
+ and replace it with
98
+ ```
99
+ import { Turbo } from "@hotwired/turbo-rails"
100
+ ```
87
101
 
88
- - in the same file (`javascript/packs/application.js`) add this line:
89
- `import { Turbo } from "@hotwired/turbo-rails"`
90
102
 
91
- - Run the hot-glue install generator
103
+ Also replace
104
+ ```
105
+ Turbolinks.start()
106
+ ```
107
+ with:
108
+ ```
109
+ Turbo.start()
110
+ ```
92
111
 
93
- FOR ERB:
94
- `rails generate hot_glue:install --markup=erb`
95
112
 
96
- FOR HAML:
97
- `rails generate hot_glue:install --markup=haml`
113
+ ## Modify `application.html.erb`
114
+ (THIS WAS AUTOMATICALLY DONE BY THE HOT GLUE INSTALLATION -- CONFIRM CHANGES ONLY)
115
+ Note: if you have some kind of non-standard application layout, like one at a different file
116
+ or if you have modified your opening <body> tag, this may not have been automatically applied by the installer.
98
117
 
99
- - Add to your `application.html.erb`
118
+ - This was added to your `application.html.erb`
100
119
  ```
101
120
  <%= render partial: 'layouts/flash_notices' %>
102
121
  ```
103
122
 
123
+ ## Modify `rails_helper.rb`
124
+ (THIS WAS AUTOMATICALLY DONE BY THE HOT GLUE INSTALLATION)
125
+ Note: if you have some kind of non-standard rails_helper.rb, like one that does not use the standard ` do |config|` syntax after your `RSpec.configure`
126
+ this may not have been automatically applied by the installer.
104
127
 
105
- ## Rspec setup
106
- - add `gem 'rspec-rails'` to your gemfile inside :development and :test
107
- - add `gem 'factory_bot_rails'` to your gemfile inside :development and :test
108
- - more info:
109
- https://github.com/thoughtbot/factory_bot/blob/master/GETTING_STARTED.md#rspec
128
+ - configure Rspec to work with Factory Bot inside of `rails_helper.rb`
129
+ ```
130
+ RSpec.configure do |config|
131
+ // ... more rspec configuration (not shown)
132
+ config.include FactoryBot::Syntax::Methods
133
+ end
134
+ ```
110
135
 
111
- - add `gem 'ffaker'` to your Gemfile inside the :development and :test groups
112
- -
113
- - run `rails generate rspec:install`
114
- - configure Rspec to work with Factory Bot inside of `rails_helper.rb`
115
- ```
116
- RSpec.configure do |config|
117
- // ... more rspec configuration (not shown)
118
- config.include FactoryBot::Syntax::Methods
119
- end
120
- ```
121
-
122
- - add to rails_helper.rb (inside the existing Rspec.configure block)
123
- - ````
124
- config.include FactoryBot::Syntax::Methods
125
- ````
126
- - also add to rails_helper.rb (outside of the Rspec.configure block)
127
- ```
128
- Capybara.register_driver :headless_chrome_desktop do |app|
129
- options = Selenium::WebDriver::Chrome::Options.new
130
- options.add_argument('--headless')
131
- options.add_argument('--disable-gpu')
132
- options.add_argument('--window-size=1280,1200')
136
+
137
+ ## CAPYBARA: SWITCH FROM RACK-TEST TO HEADLESS CHROME
138
+ (THIS WAS AUTOMATICALLY DONE BY THE HOT GLUE INSTALLATION)
139
+
140
+ - By default Capybara is installed with :rack_test as its driver.
141
+ - This does not support Javascript, and the code from Hot Glue IS NOT fallback compatible-- it will not work on non-Javascript browsers.
142
+ - From the [Capybara docs](https://github.com/teamcapybara/capybara#drivers):
143
+ ```
144
+ By default, Capybara uses the :rack_test driver, which is fast but limited: it does not support JavaScript
145
+ ```
146
+
147
+ - To fix this, you must switch to a Javascript-supporting Capybara driver. You can choose one of:
148
+ -
149
+ ```
150
+ Capybara.default_driver = :selenium
151
+ ```
152
+
153
+ ```
154
+ Capybara.default_driver = :selenium_chrome
155
+ ```
156
+ By default, the installer should have added this option to your `rails_helper.rb` file:
157
+
158
+ ```
159
+ Capybara.default_driver = :selenium_chrome_headless
160
+ ```
161
+
162
+ Alternatively, can define your own driver like so:
163
+
164
+ ```
165
+ Capybara.register_driver :my_headless_chrome_desktop do |app|
166
+ options = Selenium::WebDriver::Chrome::Options.new
167
+ options.add_argument('--headless')
168
+ options.add_argument('--disable-gpu')
169
+ options.add_argument('--window-size=1280,1200')
133
170
 
134
- driver = Capybara::Selenium::Driver.new(app,
135
- browser: :chrome,
136
- options: options)
171
+ driver = Capybara::Selenium::Driver.new(app,
172
+ browser: :chrome,
173
+ options: options)
137
174
 
138
- driver
139
- end
140
- Capybara.default_driver = :headless_chrome_desktop
175
+ driver
176
+ end
177
+ Capybara.default_driver = :my_headless_chrome_desktop
141
178
 
142
- ```
179
+ ```
143
180
 
181
+ ## Add User Authentication if you are using Access Control
182
+ (THIS WAS AUTOMATICALLY DONE BY THE HOT GLUE INSTALLATION)
144
183
 
145
184
  - for a quick Capybara login, create a support helper in `spec/support/` and log-in as your user
146
- ```
147
- def login_as(account)
148
- visit '/accounts/sign_in'
149
- within("#new_account") do
150
- fill_in 'Email', with: account.email
151
- fill_in 'Password', with: 'password'
152
- end
153
- click_button 'Log in'
154
- end
155
- ```
185
+ - in the default code, the devise login would be for an object called account and lives at the route `/accounts/sign_in`
186
+ - modify the generated code (it was installed by the installed) for your devise login
187
+ ```
188
+ def login_as(account)
189
+ visit '/accounts/sign_in'
190
+ within("#new_account") do
191
+ fill_in 'Email', with: account.email
192
+ fill_in 'Password', with: 'password'
193
+ end
194
+ click_button 'Log in'
195
+ end
196
+ ```
197
+
198
+ ## Install Bootstrap using Sprockets (IMPORTANT: YOU DO NOT NEED JQUERY)
156
199
 
157
- ## Install Bootstrap using Sprockets (IMPORTANT: YOU DO NOT NEED JQUERY*)
158
200
  Bootstrap with Sprockets for Rails 5 or 7 default — Rails 6 custom
159
- - use twbs/bootstrap-rubygem gem
160
- - see README for bootstrap-rubygem to install
161
- Bootstrap with Webpack for FOR RAILS 7 :
162
-
163
- - add to Gemfile
164
- - gem 'bootstrap', '~> 5.1.0'
201
+ - add `gem 'bootstrap-rubygem'` to your gemfile
202
+ - replace `application.css` with a new file (delete old contents) `application.scss`
203
+ ```
204
+ @import "bootstrap";
205
+ ```
206
+ - see README at github.com/twbs/bootstrap-rubygem to install
165
207
 
166
208
 
209
+ ## Bootstrap with Webpack for FOR RAILS 7 ONLY :
210
+ - add to Gemfile
211
+ - gem 'bootstrap', '~> 5.1.0'
167
212
  - completely delete the file `app/assets/application.css`
168
213
  - create new file where it was `app/assets/application.scss` with this contents (do not keep the contents of the old application.css file):
169
-
170
214
  ```
171
215
  // Custom bootstrap variables must be set or imported *before* bootstrap.
172
216
  @import "bootstrap";
@@ -174,7 +218,7 @@ Bootstrap with Webpack for FOR RAILS 7 :
174
218
 
175
219
  * You do not need jQuery for HotGlue to work *
176
220
 
177
- ### Bootstrap with Webpack RAILS 6 ONLY:
221
+ ## Bootstrap with Webpack RAILS 6 ONLY:
178
222
  - change `stylesheet_link_tag` to `stylesheet_pack_tag` in your application layout
179
223
  - run `yarn add bootstrap`
180
224
  - create a new file at `app/javascript/require_bootstrap.scss` with this content
@@ -186,14 +230,53 @@ Bootstrap with Webpack for FOR RAILS 7 :
186
230
  ```
187
231
  import 'require_bootstrap'
188
232
  ```
189
-
190
233
 
234
+ ## RAILS 6 ONLY : Install Devise or implement your own authentication
235
+ (or only use --gd mode, see below)
191
236
 
237
+ Add to your Gemfile `gem 'devise'`
238
+
239
+ ```
240
+ rails generate devise:install
241
+ ```
242
+
243
+ IMPORTNAT: Follow the instructions the Devise installer gives you, *Except Step 3*, you can skip this step:
244
+ ```
245
+ 3. Ensure you have flash messages in app/views/layouts/application.html.erb.
246
+ For example:
247
+
248
+ <p class="notice"><%= notice %></p>
249
+ <p class="alert"><%= alert %></p>
250
+
251
+ ```
252
+
253
+
254
+ You can also skip Devise Step 4, which is optional:
255
+ ```
256
+ 4. You can copy Devise views (for customization) to your app by running:
257
+
258
+ rails g devise:views
259
+
260
+ * Not required *
261
+ ```
262
+
263
+
264
+ ## RAILS 7: Devise is not yet supported on Rails 7
265
+
266
+
267
+ ## install font-awesome
268
+
269
+ I recommend https://github.com/tomkra/font_awesome5_rails
270
+ or https://github.com/FortAwesome/font-awesome-sass
271
+
272
+
273
+
274
+ ## For Enum support, I recommend activerecord-pgenum
275
+
276
+ Instructions for Rails are here:
277
+ https://jasonfleetwoodboldt.com/courses/stepping-up-rails/enumerated-types-in-rails-and-postgres/
192
278
 
193
- ## Install Devise or implement your own authentication
194
- (or only use --gd mode, see below)
195
279
 
196
- ## install font-awesome. I recommend https://github.com/tomkra/font_awesome5_rails or https://github.com/FortAwesome/font-awesome-sass
197
280
 
198
281
 
199
282
  ### First Argument
@@ -492,7 +575,10 @@ Obviously, the created controller will always have this base controller as its s
492
575
 
493
576
  # VERSION HISTORY
494
577
 
495
- #### 2021-10-09 - v-0.2.5 - this version is all about developer happyness:
578
+ #### 2021-10-11 - v0.2.6 - many additional automatic fixes for default Rails installation 6 or 7 for the generate hot_glue:install command
579
+
580
+
581
+ #### 2021-10-10 - v0.2.5 - this version is all about developer happyness:
496
582
  - significant fixes for the behavioral (system) specs. they now create new & update interactions
497
583
  for (almost) all field types
498
584
  - the install generator now checks your layouts/application.html.erb for `render partial: 'layouts/flash_messages' ` and adds it if it isn't there already
@@ -0,0 +1,12 @@
1
+ <%= turbo_frame_tag "flash_notices" do %>
2
+ <% unless notice.nil? %>
3
+ <div class="alert alert-notice alert-dismissible">
4
+ <%= notice %>
5
+ </div>
6
+ <% end %>
7
+ <% unless alert.nil? %>
8
+ <div class="alert alert-danger alert-dismissible">
9
+ <%= alert %>
10
+ </div>
11
+ <% end %>
12
+ <% end %>
@@ -23,33 +23,56 @@ module HotGlue
23
23
  copy_file "confirmable.js", "#{'spec/dummy/' if Rails.env.test?}app/javascript/controllers/confirmable.js"
24
24
  end
25
25
 
26
+ if Rails.version.split(".")[0].to_i == 6
27
+ app_js_contents = File.read("app/javascript/packs/application.js")
28
+ if app_js_contents.include?("import Turbolinks from \"turbolinks\"")
29
+ app_js_contents.gsub!("import Turbolinks from \"turbolinks\"", "import { Turbo } from \"@hotwired/turbo-rails\"")
30
+ puts " HOTGLUE --> fixed packs/application.js: swapping old Turbolinks syntas for new Turbo-Rails syntax [ import { Turbo } from \"@hotwired/turbo-rails\" ] "
31
+ end
32
+
33
+ if app_js_contents.include?("Turbolinks.start()")
34
+ app_js_contents.gsub!("Turbolinks.start()", "Turbo.start()")
35
+ puts " HOTGLUE --> fixed packs/application.js: swapping old Turbolinks syntas for new Turbo-Rails syntax[ Turbolinks.start() ] "
36
+ end
37
+ File.write("app/javascript/packs/application.js", app_js_contents)
38
+
39
+ end
40
+
41
+
26
42
  rails_helper_contents = File.read("spec/rails_helper.rb")
43
+ if !rails_helper_contents.include?("Capybara.default_driver =")
44
+ rails_helper_contents << "\nCapybara.default_driver = :selenium_chrome_headless "
45
+ puts " HOTGLUE --> added to spec/rails_helper.rb: `Capybara.default_driver = :selenium_chrome_headless` "
46
+ end
47
+
27
48
  if !rails_helper_contents.include?("include FactoryBot::Syntax::Methods")
28
49
  rails_helper_contents.gsub!("RSpec.configure do |config|", "RSpec.configure do |config| \n
29
50
  config.include FactoryBot::Syntax::Methods
30
51
  ")
31
- File.write("spec/rails_helper.rb", rails_helper_contents)
32
- puts " HOTGLUE --> add to spec/rails_helper.rb: `config.include FactoryBot::Syntax::Methods` "
52
+ puts " HOTGLUE --> added to spec/rails_helper.rb: `config.include FactoryBot::Syntax::Methods` "
53
+ end
54
+
55
+ if ! rails_helper_contents.include?("require 'support/capybara_login.rb'")
56
+ rails_helper_contents.gsub!("require 'rspec/rails'","require 'rspec/rails' \nrequire 'support/capybara_login.rb'")
57
+ puts " HOTGLUE --> added to spec/rails_helper.rb: `require 'support/capybara_login.rb'` "
33
58
  end
59
+ File.write("spec/rails_helper.rb", rails_helper_contents)
60
+
34
61
 
35
62
  application_layout_contents = File.read("app/views/layouts/application.html.erb")
36
63
 
37
64
  if !application_layout_contents.include?("render partial: 'layouts/flash_notices'")
38
65
  application_layout_contents.gsub!("<body>", "<body>\n
39
- <%= render partial: 'flash_notices' %>
66
+ <%= render partial: 'layouts/flash_notices' %>
40
67
  ")
41
68
  File.write("app/views/layouts/application.html.erb", application_layout_contents)
42
- puts " HOTGLUE --> add to app/views/layouts/application.html.erb: `<%= render partial: 'layouts/flash_notices' %>` "
69
+ puts " HOTGLUE --> added to app/views/layouts/application.html.erb: `<%= render partial: 'layouts/flash_notices' %>` "
43
70
  end
44
71
 
45
- #
46
-
47
- # TODO>: look for config.include FactoryBot::Syntax::Methods
48
- # inside of spec/rails_Helper.rb and inject it if it is not there
49
- # rspec_file = File.read("spec/rails_helper.rb")
50
- #
51
- # "RSpec.configure do |config|"
52
72
 
73
+ if !File.exists?("spec/support/capybara_login.rb")
74
+ copy_file "capybara_login.rb", "#{'spec/dummy/' if Rails.env.test?}spec/support/capybara_login.rb"
75
+ end
53
76
  end
54
77
  end
55
78
  end
@@ -0,0 +1,8 @@
1
+ def login_as(account)
2
+ visit '/accounts/sign_in'
3
+ within("#new_account") do
4
+ fill_in 'Email', with: account.email
5
+ fill_in 'Password', with: 'password'
6
+ end
7
+ click_button 'Log in'
8
+ end
@@ -7,6 +7,8 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
7
7
  before_action :<%= arg %>
8
8
  <% } %><% end %>
9
9
  before_action :load_<%= singular_name %>, only: [:show, :edit, :update, :destroy]
10
+ after_action -> { flash.discard }, if: -> { request.format.symbol == :turbo_stream }
11
+
10
12
  helper :hot_glue
11
13
  include HotGlue::ControllerHelper
12
14
 
@@ -1,3 +1,3 @@
1
1
  module HotGlue
2
- VERSION = '0.2.5'
2
+ VERSION = '0.2.6'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hot-glue
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Fleetwood-Boldt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-09 00:00:00.000000000 Z
11
+ date: 2021-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -118,6 +118,7 @@ files:
118
118
  - app/assets/config/manifest.js
119
119
  - app/helpers/hot_glue/controller_helper.rb
120
120
  - app/helpers/hot_glue_helper.rb
121
+ - app/views/layouts/_flash_notices.erb
121
122
  - bin/rails
122
123
  - config/database.yml
123
124
  - db/migrate/20210306212711_create_abcs.rb
@@ -134,6 +135,7 @@ files:
134
135
  - lib/generators/hot_glue/markup_templates/slim.rb
135
136
  - lib/generators/hot_glue/scaffold_generator.rb
136
137
  - lib/generators/hot_glue/templates/base_controller.rb.erb
138
+ - lib/generators/hot_glue/templates/capybara_login.rb
137
139
  - lib/generators/hot_glue/templates/confirmable.js
138
140
  - lib/generators/hot_glue/templates/controller.rb.erb
139
141
  - lib/generators/hot_glue/templates/erb/_errors.erb