belt 0.1.6 → 0.1.8

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.
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative 'inflector'
4
+
3
5
  module Belt
4
6
  # DSL for defining API Gateway routes.
5
7
  # Ported from terraform-provider-conveyor-belt/scripts/lib/route_dsl.rb
@@ -256,17 +258,7 @@ module Belt
256
258
  end
257
259
 
258
260
  def singularize(word)
259
- if word.end_with?('ies')
260
- "#{word[0..-4]}y"
261
- elsif word.end_with?('xes') || word.end_with?('zes') || word.end_with?('ses')
262
- word[0..-3]
263
- elsif word.end_with?('ches') || word.end_with?('shes')
264
- word[0..-3]
265
- elsif word.end_with?('s') && !word.end_with?('ss')
266
- word[0..-2]
267
- else
268
- word
269
- end
261
+ Belt::Inflector.singularize(word)
270
262
  end
271
263
  end
272
264
 
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative 'inflector'
4
+
3
5
  module Belt
4
6
  # Infers DynamoDB table names from route paths by matching against
5
7
  # tables defined in a Terraform file containing aws_dynamodb_table resources.
@@ -45,27 +47,11 @@ module Belt
45
47
  end
46
48
 
47
49
  def pluralize(word)
48
- if word.end_with?('y')
49
- "#{word[0..-2]}ies"
50
- elsif word.end_with?('s', 'x', 'z', 'ch', 'sh')
51
- "#{word}es"
52
- else
53
- "#{word}s"
54
- end
50
+ Belt::Inflector.pluralize(word)
55
51
  end
56
52
 
57
53
  def singularize(word)
58
- if word.end_with?('ies')
59
- "#{word[0..-4]}y"
60
- elsif word.end_with?('xes', 'zes', 'ses')
61
- word[0..-3]
62
- elsif word.end_with?('ches', 'shes')
63
- word[0..-3]
64
- elsif word.end_with?('s') && !word.end_with?('ss')
65
- word[0..-2]
66
- else
67
- word
68
- end
54
+ Belt::Inflector.singularize(word)
69
55
  end
70
56
  end
71
57
  end
data/lib/belt/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Belt
4
- VERSION = '0.1.6'
4
+ VERSION = '0.1.8'
5
5
  end
@@ -38,7 +38,7 @@ resource "conveyor_belt" "main" {
38
38
  app_name = var.app_name
39
39
  lambda_source_dir = "${path.module}/../../lambda"
40
40
  lambda_shared_dirs = ["controllers", "helpers", "lib", "models", "views"]
41
- frontend_urls = ["http://localhost:3000"]
41
+ frontend_urls = var.environment == "prod" ? [] : ["http://localhost:3000"]
42
42
  friendly_errors = var.environment != "prod"
43
43
 
44
44
  # Per-lambda configuration: env vars, timeouts, memory
@@ -1,5 +1,10 @@
1
1
  output "api_url" {
2
2
  description = "API Gateway base URL"
3
+ value = values(conveyor_belt.main.api_gateway_urls)[0]
4
+ }
5
+
6
+ output "api_urls" {
7
+ description = "Map of gateway names to API Gateway URLs"
3
8
  value = conveyor_belt.main.api_gateway_urls
4
9
  }
5
10
 
@@ -153,7 +153,3 @@ output "frontend_distribution_id" {
153
153
  output "frontend_url" {
154
154
  value = "https://${aws_cloudfront_distribution.frontend.domain_name}"
155
155
  }
156
-
157
- output "api_url" {
158
- value = values(conveyor_belt.main.api_gateway_urls)[0]
159
- }
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'application_controller'
4
- require_relative '../../models/<%= @singular_name %>'
5
4
 
6
5
  module <%= @module_name %>Controllers
7
6
  class <%= @class_name %>sController < ApplicationController
@@ -1,8 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class <%= @class_name %> < ApplicationRecord
4
- include Concerns::Timestampable
5
-
6
4
  <% @fields.each do |field| -%>
7
5
  attr_accessor :<%= field[:name] %>
8
6
  <% end -%>
@@ -15,4 +15,10 @@ end
15
15
 
16
16
  # Load lib and models
17
17
  Dir[File.join(__dir__, '..', 'lib', '**', '*.rb')].sort.each { |f| require f }
18
- Dir[File.join(__dir__, '..', 'models', '**', '*.rb')].sort.each { |f| require f }
18
+
19
+ models_dir = File.join(__dir__, '..', 'models')
20
+ all_models = Dir[File.join(models_dir, '**', '*.rb')].sort
21
+ app_record = all_models.find { |f| File.basename(f) == 'application_record.rb' }
22
+ rest = all_models - [app_record].compact
23
+ require app_record if app_record
24
+ rest.each { |f| require f }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: belt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stowzilla
@@ -23,6 +23,20 @@ dependencies:
23
23
  - - "~>"
24
24
  - !ruby/object:Gem::Version
25
25
  version: '0.0'
26
+ - !ruby/object:Gem::Dependency
27
+ name: activesupport
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '7.0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '7.0'
26
40
  - !ruby/object:Gem::Dependency
27
41
  name: lambda_loadout
28
42
  requirement: !ruby/object:Gem::Requirement
@@ -59,6 +73,7 @@ files:
59
73
  - lib/belt/cli/bucket_security.rb
60
74
  - lib/belt/cli/console_command.rb
61
75
  - lib/belt/cli/deploy_command.rb
76
+ - lib/belt/cli/destroy_command.rb
62
77
  - lib/belt/cli/env_resolver.rb
63
78
  - lib/belt/cli/environment_command.rb
64
79
  - lib/belt/cli/frontend_command.rb
@@ -79,6 +94,7 @@ files:
79
94
  - lib/belt/helpers/cors_origin.rb
80
95
  - lib/belt/helpers/error_logging.rb
81
96
  - lib/belt/helpers/response.rb
97
+ - lib/belt/inflector.rb
82
98
  - lib/belt/lambda_handler.rb
83
99
  - lib/belt/observability.rb
84
100
  - lib/belt/parameters.rb
@@ -117,7 +133,6 @@ files:
117
133
  - lib/templates/new_app/lambda/controllers/application_controller.rb.erb
118
134
  - lib/templates/new_app/lambda/lib/routes/routes.rb.erb
119
135
  - lib/templates/new_app/lambda/models/application_record.rb.erb
120
- - lib/templates/new_app/lambda/models/concerns/timestampable.rb.erb
121
136
  - lib/templates/views/Edit.jsx.erb
122
137
  - lib/templates/views/Form.jsx.erb
123
138
  - lib/templates/views/Index.jsx.erb
@@ -1,23 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Concerns
4
- module Timestampable
5
- def self.included(base)
6
- base.attr_accessor :created_at, :updated_at
7
- base.set_callback :create, :before, :set_timestamps
8
- base.set_callback :update, :before, :set_updated_at
9
- end
10
-
11
- private
12
-
13
- def set_timestamps
14
- now = Time.now.utc.iso8601
15
- self.created_at ||= now
16
- self.updated_at = now
17
- end
18
-
19
- def set_updated_at
20
- self.updated_at = Time.now.utc.iso8601
21
- end
22
- end
23
- end