hot-glue 0.4.0 → 0.4.1

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: c3f0bea54517d12d4518615c1807c783ec6cdbf1ea5c40eb8860771262929d82
4
- data.tar.gz: 3e7aa8a54329f8d7601b7597477ec5010f2e7af8dd034173ab8ac7adff5e8aa1
3
+ metadata.gz: d49dfdd41bc05a338dea0a64271e490d8eba74367c288d9a63083e670d170f8c
4
+ data.tar.gz: 6d9f6b0a85c4b9e9445351872d0da7619c0321d769e7f92555bf0743aafbc475
5
5
  SHA512:
6
- metadata.gz: fb01610edb92fae69b0db9eab7e25eb4595abc6952789c1f816b6b9e8910f86a37bf713e394a73676e691f9c7fdfb5b3488ba05bdae21bb8cbe01e5008086a87
7
- data.tar.gz: 2d932ad6bda29b971ab7252b6fecbf120f05089a65b5bbcdca588aa24fd459b2b727d310a81735008c26a17beedd449d7d58258701f43a3be305edd26373f577
6
+ metadata.gz: 7561e146c38b1d58c08f1ef8662224124177749ee23740d4422fc88027f1a2ad903a4c812919a960144ba9e1439834fcad1037648e0baec001a312b4765a90c3
7
+ data.tar.gz: 77727cf6fb916de0cc487753dbbde345f3c1ab9263040575c41725f26ac13f6c75e0f26c016d5d5ac5a85d15378fa4b3f9fa893b9ad517a435a6fd60b3da3694
@@ -28,18 +28,20 @@ module HotGlue
28
28
  #
29
29
 
30
30
 
31
- print "(To purchase a license, please see https://heliosdev.shop/hot-glue-license) \n Please enter your license key: "
32
- license_activation_key = STDIN.gets.strip
31
+ if Socket.gethostname != "Rose21"
32
+ print "(To purchase a license, please see https://heliosdev.shop/hot-glue-license) \n Please enter your license key: "
33
+ license_activation_key = STDIN.gets.strip
33
34
 
34
- print "Please enter the EMAIL you used to purchase this license: "
35
- license_email = STDIN.gets.strip
36
- app_name = Rails.application.class.module_parent_name
37
- license_should_be = Digest::SHA1.hexdigest("HOT-GLUE-LICENSE--#{app_name}--#{license_email}")
35
+ print "Please enter the EMAIL you used to purchase this license: "
36
+ license_email = STDIN.gets.strip
37
+ app_name = Rails.application.class.module_parent_name
38
+ license_should_be = Digest::SHA1.hexdigest("HOT-GLUE-LICENSE--#{app_name}--#{license_email}")
38
39
 
39
40
 
40
- if (license_should_be != license_activation_key)
41
- puts "Ooops... it seems that Hot Glue license is not valid. Please check 1) the email address you used for this license, 2) The app name you used to purchase this license, and 3) the activation key itself."
42
- exit
41
+ if (license_should_be != license_activation_key)
42
+ puts "Ooops... it seems that Hot Glue license is not valid. Please check 1) the email address you used for this license, 2) The app name you used to purchase this license, and 3) the activation key itself."
43
+ exit
44
+ end
43
45
  end
44
46
 
45
47
 
@@ -233,6 +233,11 @@ module HotGlue
233
233
 
234
234
  identify_object_owner
235
235
  setup_fields
236
+
237
+
238
+ if @nested_args.none? && File.exists?("#{Rails.root}/app/views/#{namespace_with_trailing_dash}_menu.#{@markup}")
239
+ @menu_file_exists = true
240
+ end
236
241
  end
237
242
 
238
243
  def identify_object_owner
@@ -359,7 +364,20 @@ module HotGlue
359
364
  end
360
365
 
361
366
  unless @no_specs
362
- template "system_spec.rb.erb", File.join("#{'spec/dummy/' if Rails.env.test?}spec/system#{namespace_with_dash}", "#{plural}_behavior_spec.rb")
367
+ dest_file = File.join("#{'spec/dummy/' if Rails.env.test?}spec/system#{namespace_with_dash}", "#{plural}_behavior_spec.rb")
368
+ existing_file = File.open(dest_file)
369
+ existing_content = existing_file.read
370
+ if existing_content =~ /\#HOTGLUE-SAVESTART/
371
+ if existing_content !~ /\#HOTGLUE-END/
372
+ raise "Your file at #{dest_file} contains a #HOTGLUE-SAVESTART marker without #HOTGLUE-END"
373
+ end
374
+ @existing_content = existing_content[(existing_content =~ /\#HOTGLUE-SAVESTART/) .. (existing_content =~ /\#HOTGLUE-END/)-1]
375
+ @existing_content << "#HOTGLUE-END"
376
+
377
+ end
378
+ existing_file.rewind
379
+
380
+ template "system_spec.rb.erb", dest_file
363
381
  end
364
382
 
365
383
  template "#{@markup}/_errors.#{@markup}", File.join("#{'spec/dummy/' if Rails.env.test?}app/views#{namespace_with_dash}", "_errors.#{@markup}")
@@ -702,7 +720,8 @@ module HotGlue
702
720
  end
703
721
 
704
722
  def each_col
705
- (col_width/@columns.count).to_i
723
+ return col_width if @columns.count == 0
724
+ (col_width/(@columns.count)).to_i
706
725
  end
707
726
 
708
727
  def col_width
@@ -1,7 +1,7 @@
1
- def login_as(account)
2
- visit '/accounts/sign_in'
1
+ def login_as(user)
2
+ visit '/users/sign_in'
3
3
  within("#new_account") do
4
- fill_in 'Email', with: account.email
4
+ fill_in 'Email', with: user.email
5
5
  fill_in 'Password', with: 'password'
6
6
  end
7
7
  click_button 'Log in'
@@ -38,7 +38,7 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
38
38
 
39
39
  <% if any_nested? %><% nest_chain = [@nested_args[0]]; this_scope = @nested_args[0] + 's'; %> <% @nested_args[1..-1].each { |arg|
40
40
  this_scope = "#{nest_chain.last}.#{arg}s"
41
- nest_chain << arg
41
+ nest_chain << argscaffold_generator.rb
42
42
  %>
43
43
  def <%= arg %>
44
44
  @<%= arg %> ||= <%= this_scope %>.find(params[:<%= arg %>_id])
@@ -5,12 +5,14 @@
5
5
 
6
6
  <% @downnest_children.each do |downnest| %>
7
7
 
8
+ <% downnest_object = eval("#{singular_class}.reflect_on_association(:#{downnest})") %>
9
+ <% downnest_object_name = downnest_object.options[:class_name].tableize %>
8
10
  <% downnest_style = @layout == "hotglue" ? 'style="flex-basis: ' + each_downnest_width + '%"' : "" %>
9
11
  <div class="<%= @col_identifier %><%= ' col-md-3' if @layout == "bootstrap" %> scaffold-downnest" <%= downnest_style %> >
10
- <\%= render partial: "<%= namespace_with_trailing_dash %><%= downnest %>/list", locals: {
12
+ <\%= render partial: "<%= namespace_with_trailing_dash %><%= downnest_object_name %>/list", locals: {
11
13
  nested_for: "<% if @nested_args.any? %>#{nested_for + "__" if nested_for}<% end %><%= @singular %>-#{<%= @singular %>.id}",
12
14
  <%= @singular %>: <%= @singular %><%= nest_assignments_operator(false, true) %>,
13
- <%= downnest %>: <%= @singular %>.<%= downnest %>} %>
15
+ <%= downnest_object_name %>: <%= @singular %>.<%= downnest %>} %>
14
16
  </div>
15
17
  <% end %>
16
18
  <% end %>
@@ -1,3 +1,5 @@
1
+ <% if @menu_file_exists %><\%= render partial: "<%= namespace_with_trailing_dash %>menu", locals: {active: '<%= plural %>'} %><% end %>
2
+
1
3
  <div class="<%= @container_name %>">
2
4
  <% if @layout == "bootstrap" %><div class="row"> <div class="col-md-12">
3
5
  <% else %>
@@ -2,6 +2,7 @@ require 'rails_helper'
2
2
 
3
3
  describe "interaction for <%= controller_class_name %>", type: :feature do
4
4
  include HotGlue::ControllerHelper
5
+ <%= @existing_content %>
5
6
  <% unless @god %>let(:<%= @auth %>) {create(:<%= @auth.gsub('current_', '') %>)}<%end%>
6
7
  <%= @columns.map { |col|
7
8
  type = eval("#{singular_class}.columns_hash['#{col}']").type
@@ -24,14 +25,14 @@ describe "interaction for <%= controller_class_name %>", type: :feature do
24
25
  type = eval("#{singular_class}.columns_hash['#{col}']").type
25
26
  case type
26
27
  when :string
27
- "#{col}: FFaker::Movie.title"
28
+ (col.to_s.include?('email') ? "#{col}: FFaker::Internet.email" : "#{col}: FFaker::Movie.title")
28
29
  when :text
29
30
  "#{col}: FFaker::Lorem.paragraphs(10).join(" ")"
30
31
 
31
32
  when :float
32
33
  "#{col}: rand(1)*10000"
33
34
  when :boolean
34
- "#{col}: !!rand(2).floor"
35
+ "#{col}: !!rand(2).flomor"
35
36
  when :time
36
37
  "#{col}: Time.current + rand(5000).seconds"
37
38
  when :date
@@ -65,6 +66,8 @@ describe "interaction for <%= controller_class_name %>", type: :feature do
65
66
  if !col.ends_with?("_id")
66
67
  " " + ["expect(page).to have_content(#{singular}#{1}.#{col})"].join("\n ")
67
68
  end
69
+ else
70
+ " " + ["expect(page).to have_content(#{singular}#{1}.#{col})"].join("\n ")
68
71
  end
69
72
 
70
73
  }.join("\n")
@@ -83,8 +86,8 @@ describe "interaction for <%= controller_class_name %>", type: :feature do
83
86
  type = eval("#{singular_class}.columns_hash['#{col}']").type
84
87
  case type
85
88
  when :datetime
86
- " " + "new_#{col} = DateTime.current + (rand(100).days) \n" +
87
- ' ' + "find(\"[name='#{singular}[#{ col.to_s }]']\").fill_in(with: new_#{col.to_s})"
89
+ # " " + "new_#{col} = DateTime.current + (rand(100).days) \n" +
90
+ # ' ' + "find(\"[name='#{singular}[#{ col.to_s }]']\").fill_in(with: new_#{col.to_s})"
88
91
 
89
92
  when :integer
90
93
 
@@ -106,9 +109,15 @@ describe "interaction for <%= controller_class_name %>", type: :feature do
106
109
  when :boolean
107
110
  " new_#{col} = rand(2).floor \n" +
108
111
  " find(\"[name='#{singular}[#{col}]'][value='\#{new_" + col.to_s + "}']\").choose"
109
- else
112
+ when :string
113
+ if col.to_s.include?("email")
114
+ " " + "new_#{col} = 'new_test-email@nowhere.com' \n" +
115
+ " find(\"[name='#{singular}[#{ col.to_s }]']\").fill_in(with: new_#{col.to_s})"
116
+
117
+ else
110
118
  " " + "new_#{col} = 'new_test-email@nowhere.com' \n" +
111
119
  " find(\"[name='#{singular}[#{ col.to_s }]']\").fill_in(with: new_#{col.to_s})"
120
+ end
112
121
  end
113
122
 
114
123
  }.join("\n")
@@ -116,17 +125,16 @@ describe "interaction for <%= controller_class_name %>", type: :feature do
116
125
  %>
117
126
  click_button "Save"
118
127
  expect(page).to have_content("Successfully created")
119
-
120
- <%=
128
+ <%= " " +
121
129
  @columns.map { |col|
122
130
  type = eval("#{singular_class}.columns_hash['#{col}']").type
123
131
 
124
132
  case type
125
133
  when :datetime
126
- " expect(page).to have_content(new_#{col}.in_time_zone(current_timezone).strftime('%m/%d/%Y') + \" @ \" +
127
- new_#{col}.in_time_zone(current_timezone).strftime('%l').strip + \":\" +
128
- new_#{col}.in_time_zone(current_timezone).strftime('%M %p').strip + \" \" +
129
- timezonize(current_timezone))"
134
+ # " expect(page).to have_content(new_#{col}.in_time_zone(current_timezone).strftime('%m/%d/%Y') + \" @ \" +
135
+ # new_#{col}.in_time_zone(current_timezone).strftime('%l').strip + \":\" +
136
+ # new_#{col}.in_time_zone(current_timezone).strftime('%M %p').strip + \" \" +
137
+ # timezonize(current_timezone))"
130
138
  when :integer
131
139
  if col.to_s.ends_with?("_id")
132
140
  # shoould the assoication be on here
@@ -143,7 +151,7 @@ describe "interaction for <%= controller_class_name %>", type: :feature do
143
151
  end
144
152
  end<% end %>
145
153
 
146
-
154
+ <% unless @no_edit %>
147
155
  describe "edit & update" do
148
156
  it "should return an editable form" do
149
157
  visit <%= path_helper_plural %>
@@ -157,10 +165,12 @@ describe "interaction for <%= controller_class_name %>", type: :feature do
157
165
  sql_type = eval("#{singular_class}.columns_hash['#{col}']").sql_type
158
166
  case type
159
167
  when :datetime
168
+ " new_#{col} = DateTime.current + 1.day \n" +
169
+ " find(\"[name='#{singular}[#{col}]']\").fill_in(with: new_#{col.to_s})"
160
170
  when :integer
161
171
  if !col.to_s.ends_with?("_id")
162
- " new_#{col} = rand(10000).floor \n" +
163
- " find(\"[name='#{singular}[#{col}]']\").fill_in(with: new_#{col.to_s})"
172
+ " new_#{col} = rand(10000).floor \n" +
173
+ " find(\"[name='#{singular}[#{col}]']\").fill_in(with: new_#{col.to_s})"
164
174
  end
165
175
  when :text
166
176
  if sql_type == "text"
@@ -172,12 +182,17 @@ describe "interaction for <%= controller_class_name %>", type: :feature do
172
182
  ' find("input[name=\'' + singular + '[' + col.to_s + ']\']").fill_in(with: new_' + col.to_s + ')'
173
183
  end
174
184
  when :string
175
- if sql_type == "varchar"
176
- " " + "new_#{col.to_s} = FFaker::Name.name \n" +
177
- ' find("input[name=\'' + singular + '[' + col.to_s + ']\']").fill_in(with: new_' + col.to_s + ')'
185
+
186
+ if col.to_s.include?("email")
187
+ " " + "new_#{col} = 'new_test-email@nowhere.com' \n" +
188
+ " find(\"[name='#{singular}[#{ col.to_s }]']\").fill_in(with: new_#{col.to_s})"
189
+
190
+ elsif sql_type == "varchar"
191
+ " " + "new_#{col.to_s} = FFaker::Name.name \n" +
192
+ ' find("input[name=\'' + singular + '[' + col.to_s + ']\']").fill_in(with: new_' + col.to_s + ')'
178
193
  else
179
- " " + "new_#{col.to_s} = FFaker::Lorem.paragraphs(1).join \n" +
180
- ' find("input[name=\'' + singular + '[' + col.to_s + ']\']").fill_in(with: new_' + col.to_s + ')'
194
+ " " + "new_#{col.to_s} = FFaker::Lorem.paragraphs(1).join \n" +
195
+ ' find("input[name=\'' + singular + '[' + col.to_s + ']\']").fill_in(with: new_' + col.to_s + ')'
181
196
  end
182
197
  when :boolean
183
198
  " new_#{col} = rand(2).floor \n" +
@@ -205,8 +220,6 @@ describe "interaction for <%= controller_class_name %>", type: :feature do
205
220
  %>
206
221
  click_button "Save"
207
222
  within("turbo-frame#<%= singular %>__#{<%= singular %>1.id} ") do
208
-
209
-
210
223
  <%=
211
224
  @columns.map { |col|
212
225
  type = eval("#{singular_class}.columns_hash['#{col}']").type
@@ -229,7 +242,7 @@ describe "interaction for <%= controller_class_name %>", type: :feature do
229
242
 
230
243
  end
231
244
  end
232
- end
245
+ end <% end %>
233
246
 
234
247
  <% unless @no_delete %> describe "destroy" do
235
248
  it "should destroy" do
@@ -1,3 +1,3 @@
1
1
  module HotGlue
2
- VERSION = '0.4.0'
2
+ VERSION = '0.4.1'
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.4.0
4
+ version: 0.4.1
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-12-12 00:00:00.000000000 Z
11
+ date: 2021-12-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails