hot-glue 0.5.16 → 0.5.17

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
2
  SHA256:
3
- metadata.gz: 61d066f183e4a0563768d26589b1fcf140c4867ea540458fea8e084ef3903b03
4
- data.tar.gz: 32361a4068d3b9808f2d9caa2a9e1c22d484e1c23d3196fdde6e0939d6b6ce60
3
+ metadata.gz: b466a03ce8d764332b3f3d8673bc29b6071308cb976706632a70713b6efb53b4
4
+ data.tar.gz: 03f8580d7266c767b1bed6a1e325c515bc09a5d9886356250ed9a4d936bab452
5
5
  SHA512:
6
- metadata.gz: 3ca1797468a13ade3f508d5fb8fc8799532bc9ec010ff0adffad7702bc569c42d6eb5926ee6682474d8b9ea3f4aeadaabe7e721a5ce3dc03996573767d04ff1c
7
- data.tar.gz: 7ec34f2f77fa45740e521ec867bec02c712cbd80f4f91a59a8011a76f10e5595ea91bdf3cb3c48770d8959606b7d9a6424ad13d0f0aa2e80fa7821000e66d272
6
+ metadata.gz: 3e0b66aa6cbab6a813a810f6bee04503c0f7437f53dc2a7a2f27aadad8b09a559a1d540f7c6ce850c5a25f641ab847edeb6c5b26fc83c6b6728bb52278bbc3bb
7
+ data.tar.gz: 5bcc706e9ad0a620c33a5815fc5160fe7afef6b9468d1d920032d1daffbfc3bc304816dc661d1c359b1002fdc854d1757869844e7afe1efa2f0eb021df408827
@@ -25,7 +25,7 @@ jobs:
25
25
  steps:
26
26
  - uses: actions/checkout@v3
27
27
  - name: Set up Ruby
28
- uses: ruby/setup-ruby@v1
28
+ uses: ruby/setup-ruby@55283cc23133118229fd3f97f9336ee23a179fcf # v1.146.0
29
29
  with:
30
30
  # Not needed with a .ruby-version file
31
31
  # runs 'bundle install' and caches installed gems automatically
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hot-glue (0.5.15)
4
+ hot-glue (0.5.16)
5
5
  ffaker (~> 2.16)
6
6
  kaminari (~> 1.2)
7
7
  rails (> 5.1)
data/README.md CHANGED
@@ -663,9 +663,22 @@ The syntax is `--modify=cost{$},price{$}`
663
663
 
664
664
  Here, the `cost` and `price` fields will be displayed as wrapped in `number_to_currency()` when displayed on the list view and when displayed as show-only.
665
665
 
666
- (You will need to separately specify them as show-only if you want them to be non-editable.)
666
+ You can also use a binary modifier, which can apply to booleans, datetimes, times, dates or anything else. When using the binary modify, a specific value is displayed if the field is truthy and another one is display if the field is falsy.
667
+ You specify it using a pipe | character like so:
667
668
 
668
- The availabel modifiers are:
669
+ `--modify=paid_at{paid|unpaid}`
670
+
671
+ here, even though `paid_at` is a datetime field, it will display as-if it is a binary -- showing either the truthy
672
+ label or the falsy label depending on if `paid_at` is or is not null in the database.
673
+ For all fields except booleans, this affects only the viewable output —
674
+ what you see on the list page and on the edit page for show-only fields.
675
+ For booleans, it affects those outputs as well as the normal edit output:
676
+ The labels you specify are used as the labels for the radio buttons that the user can select.
677
+
678
+
679
+ You will need to separately specify them as show-only if you want them to be non-editable.
680
+
681
+ The available modifiers are:
669
682
 
670
683
  | modifier | what it does | can be used on | | |
671
684
  |---------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------|---|---|
@@ -1165,7 +1178,29 @@ Always:
1165
1178
 
1166
1179
  Don't include this last line in your factory code.
1167
1180
 
1181
+ ## Nav Templates
1182
+ At the namespace level, you can have a file called `_nav.html.erb` to create tabbed bootstrap nav (you'll need to create this file manually).
1168
1183
 
1184
+ To create the default template, start by running
1185
+ ```
1186
+ bin/rails generate hot_glue:nav_template --namespace=xyz
1187
+
1188
+ ```
1189
+ this will append the file `_nav.html.erb` to the views folder at `views/xyz`
1190
+
1191
+ ```
1192
+ <ul class='nav nav-tabs'>
1193
+ </ul>
1194
+ ```
1195
+
1196
+ Once the file is present, any further builds in this namespace will:
1197
+
1198
+ 1) Append to the `_nav.html.erb` file, adding a tab for the new built scaffold
1199
+ 2) Add render to the list view of the built scaffold to include the partial:
1200
+ ```
1201
+ <%= render partial: "owner/nav", locals: {nav: "things"} %>
1202
+ ```
1203
+ (in this example `owner/` is the namespace and `things` is the name of the scaffold being built)
1169
1204
 
1170
1205
  ## Automatic Base Controller
1171
1206
 
@@ -1271,6 +1306,37 @@ end
1271
1306
 
1272
1307
  # VERSION HISTORY
1273
1308
 
1309
+ #### 2023-08-18 - v0.5.17
1310
+
1311
+ • Nav templates (`_nav.html.erb`) are now automatically appended to if they exist. Remember nav template live in the views folder at the root of the *namespace*, which is one folder up from whatever folder is being built.
1312
+ If a file exists `_nav.html.erb`, it will get appnded to with content like this:
1313
+
1314
+ ```
1315
+ <li class="nav-item">
1316
+ <%= link_to "Domains", domains_path, class: "nav-link #{'active' if nav == 'domains'}" %>
1317
+ </li>
1318
+ ```
1319
+
1320
+ This append to the `_nav.html.erb` template happens in addition to the partial itself being included from the layout.
1321
+ (Also only if it exists, so be sure create it before running the scaffold generators for the namespace. Of course, you only need to create it once for each namespace)
1322
+
1323
+ • To create a new `_nav.html.erb` template use
1324
+
1325
+ ```
1326
+ bin/rails generate hot_glue:nav_template --namespace=xyz
1327
+ ```
1328
+
1329
+ Here, you give only the namespace. It will create an empty nav template:
1330
+ ```
1331
+ <ul class='nav nav-tabs'>
1332
+ </ul>
1333
+ ```
1334
+
1335
+ • Fixes to specs for datetimes
1336
+
1337
+ • Fixes way the flash notices where created that violated frozen string literal
1338
+
1339
+
1274
1340
  #### 2023-08-17 - v0.5.16
1275
1341
 
1276
1342
  - Adds `--modidy` flag to turn numbers into currency and apply binary labels (see docs for `--modify` flag)
@@ -30,7 +30,7 @@ class DateTimeField < Field
30
30
  end
31
31
 
32
32
  def spec_list_view_natural_assertion
33
- "expect(page).to have_content(#{singular}#{1}.#{name}.in_time_zone(current_timezone).strftime('%m/%d/%Y @ %l:%M %p ').gsub(' ', ' ') + timezonize(current_timezone) )"
33
+ "expect(page).to have_content(#{singular}#{1}.#{name}.in_time_zone(current_timezone).strftime('%m/%d/%Y @ %l:%M %p ').gsub(' ', ' ') + timezonize(current_timezone) )"
34
34
  end
35
35
 
36
36
  def form_field_output
@@ -5,7 +5,7 @@ class UUIDField < AssociationField
5
5
 
6
6
  def spec_list_view_assertion
7
7
  assoc_name = name.to_s.gsub('_id','')
8
- association = eval("#{singular_class}.reflect_on_association(:#{assoc_name})")
8
+ association = eval("#{class_name}.reflect_on_association(:#{assoc_name})")
9
9
  "expect(page).to have_content(#{singular}#{1}.#{assoc_name}.#{HotGlue.derrive_reference_name(association.class_name)})"
10
10
  end
11
11
  end
@@ -0,0 +1,22 @@
1
+ module HotGlue
2
+ class NavTemplateGenerator < Rails::Generators::Base
3
+ source_root File.expand_path('templates', __dir__)
4
+ class_option :namespace, type: :string, default: nil
5
+
6
+ def filepath_prefix
7
+ # todo: inject the context
8
+ 'spec/dummy/' if $INTERNAL_SPECS
9
+ end
10
+
11
+
12
+ def initialize(*args) #:nodoc:
13
+ super
14
+ @namespace = options['namespace']
15
+ copy_file "erb/_nav.html.erb", "#{'spec/dummy/' if $INTERNAL_SPECS}app/views/#{@namespace ? @namespace + "/" : ""}_nav.html.erb"
16
+
17
+ end
18
+ end
19
+ end
20
+
21
+
22
+
@@ -761,9 +761,14 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
761
761
  res
762
762
  end
763
763
 
764
+ def nested_path
765
+ @nested_set.collect{| arg| arg[:plural] + "/\#{#{arg[:singular]}.id}/" }.join("/")
766
+ end
767
+
768
+
764
769
  def objest_nest_params_by_id_for_specs
765
770
  @nested_set.map { |arg|
766
- "#{arg[:singular]}_id: #{arg[:singular]}.id"
771
+ "#{arg[:singular]}_id: #{arg[:singular] }.id"
767
772
  }.join(",\n ")
768
773
  end
769
774
 
@@ -1023,6 +1028,29 @@ class HotGlue::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
1023
1028
  end
1024
1029
  end
1025
1030
 
1031
+ def insert_into_nav_template
1032
+ # how does this get called(?)
1033
+ nav_file = "#{Rails.root}/app/views/#{namespace_with_trailing_dash}_nav.html.#{@markup}"
1034
+ if include_nav_template
1035
+ append_text = " <li class='nav-item'>
1036
+ <%= link_to '#{@list_label_heading}', #{path_helper_plural}, class: \"nav-link \#{'active' if nav == '#{plural_name}'}\" %>
1037
+ </li>"
1038
+
1039
+ text = File.read(nav_file)
1040
+ if text.include?(append_text)
1041
+ puts "SKIPPING: Nav link for #{singular_name} already exists in #{nav_file}"
1042
+ else
1043
+ puts "APPENDING: nav link for #{singular_name} #{nav_file}"
1044
+
1045
+ replace = text.gsub(/\<\/ul\>/, append_text + "\n</ul>")
1046
+
1047
+ File.open("#{Rails.root}/app/views/#{namespace_with_trailing_dash}_nav.html.#{@markup}", "w") { |file|
1048
+ file.puts replace
1049
+ }
1050
+ end
1051
+ end
1052
+ end
1053
+
1026
1054
  def namespace_with_dash
1027
1055
  if @namespace
1028
1056
  "/#{@namespace}"
@@ -125,11 +125,11 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
125
125
  }.join("/n") %><% end %><%= controller_attachment_orig_filename_pickup_syntax %>
126
126
  if @<%= singular_name %>.update(modified_params)
127
127
  <% if @display_list_after_update %> load_all_<%= plural %><% end %>
128
- flash[:notice] = (flash[:notice] || "") << "Saved #{@<%= singular %>.<%= display_class %>}"
128
+ flash[:notice] = "#{flash[:notice]} Saved \#{@<%= singular %>.<%= display_class %>}"
129
129
  flash[:alert] = @hawk_alarm if @hawk_alarm
130
130
  render :update
131
131
  else
132
- flash[:alert] = (flash[:alert] || "") << "<%= singular_name.titlecase %> could not be saved. #{@hawk_alarm}"
132
+ flash[:alert] = "#{flash[:notice]} <%= singular_name.titlecase %> could not be saved. #{@hawk_alarm}"
133
133
  render :update, status: :unprocessable_entity
134
134
  end
135
135
  end
@@ -0,0 +1,3 @@
1
+ <ul class='nav nav-tabs'>
2
+
3
+ </ul>
@@ -91,7 +91,7 @@ describe 'interaction for <%= controller_class_name %>' do
91
91
  it "should destroy" do
92
92
  visit <%= path_helper_plural %>
93
93
  accept_alert do
94
- find("form[action='<%= namespace_with_dash %>/<%= plural %>/#{<%= singular %>1.id}'] > input.delete-<%= singular %>-button").click
94
+ find("form[action='<%= namespace_with_dash %>/<%= nested_path %><%= plural %>/#{<%= singular %>1.id}'] > input.delete-<%= singular %>-button").click
95
95
  end
96
96
  expect(page).to_not have_content(<%= singular %>1.<%= @display_class %>)
97
97
  expect(<%= singular_class %>.where(id: <%= singular %>1.id).count).to eq(0)
@@ -1,5 +1,5 @@
1
1
  module HotGlue
2
2
  class Version
3
- CURRENT = '0.5.16'
3
+ CURRENT = '0.5.17'
4
4
  end
5
5
  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.5.16
4
+ version: 0.5.17
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: 2023-08-17 00:00:00.000000000 Z
11
+ date: 2023-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -104,6 +104,7 @@ files:
104
104
  - lib/generators/hot_glue/layout_strategy/tailwind.rb
105
105
  - lib/generators/hot_glue/markup_templates/base.rb
106
106
  - lib/generators/hot_glue/markup_templates/erb.rb
107
+ - lib/generators/hot_glue/nav_template_generator.rb
107
108
  - lib/generators/hot_glue/scaffold_generator.rb
108
109
  - lib/generators/hot_glue/templates/base_controller.rb.erb
109
110
  - lib/generators/hot_glue/templates/capybara_login.rb
@@ -114,6 +115,7 @@ files:
114
115
  - lib/generators/hot_glue/templates/erb/_form.erb
115
116
  - lib/generators/hot_glue/templates/erb/_line.erb
116
117
  - lib/generators/hot_glue/templates/erb/_list.erb
118
+ - lib/generators/hot_glue/templates/erb/_nav.html.erb
117
119
  - lib/generators/hot_glue/templates/erb/_new_button.erb
118
120
  - lib/generators/hot_glue/templates/erb/_new_form.erb
119
121
  - lib/generators/hot_glue/templates/erb/_show.erb