propel_api 0.1.1

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.
Files changed (30) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +59 -0
  3. data/LICENSE +21 -0
  4. data/README.md +320 -0
  5. data/Rakefile +36 -0
  6. data/lib/generators/propel_api/USAGE +8 -0
  7. data/lib/generators/propel_api/controller/controller_generator.rb +208 -0
  8. data/lib/generators/propel_api/core/base.rb +19 -0
  9. data/lib/generators/propel_api/core/configuration_methods.rb +187 -0
  10. data/lib/generators/propel_api/core/named_base.rb +457 -0
  11. data/lib/generators/propel_api/core/path_generation_methods.rb +45 -0
  12. data/lib/generators/propel_api/core/relationship_inferrer.rb +117 -0
  13. data/lib/generators/propel_api/install/install_generator.rb +343 -0
  14. data/lib/generators/propel_api/resource/resource_generator.rb +433 -0
  15. data/lib/generators/propel_api/templates/config/propel_api.rb.tt +149 -0
  16. data/lib/generators/propel_api/templates/controllers/api_controller_graphiti.rb +79 -0
  17. data/lib/generators/propel_api/templates/controllers/api_controller_propel_facets.rb +76 -0
  18. data/lib/generators/propel_api/templates/controllers/example_controller.rb.tt +96 -0
  19. data/lib/generators/propel_api/templates/scaffold/facet_controller_template.rb.tt +80 -0
  20. data/lib/generators/propel_api/templates/scaffold/facet_model_template.rb.tt +141 -0
  21. data/lib/generators/propel_api/templates/scaffold/graphiti_controller_template.rb.tt +82 -0
  22. data/lib/generators/propel_api/templates/scaffold/graphiti_model_template.rb.tt +32 -0
  23. data/lib/generators/propel_api/templates/seeds/seeds_template.rb.tt +493 -0
  24. data/lib/generators/propel_api/templates/tests/controller_test_template.rb.tt +485 -0
  25. data/lib/generators/propel_api/templates/tests/fixtures_template.yml.tt +250 -0
  26. data/lib/generators/propel_api/templates/tests/integration_test_template.rb.tt +487 -0
  27. data/lib/generators/propel_api/templates/tests/model_test_template.rb.tt +252 -0
  28. data/lib/generators/propel_api/unpack/unpack_generator.rb +304 -0
  29. data/lib/propel_api.rb +3 -0
  30. metadata +95 -0
@@ -0,0 +1,250 @@
1
+ # Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
2
+
3
+ one:
4
+ <% attributes.each do |attribute| -%>
5
+ <% if attribute.type == :references -%>
6
+ <% if attribute.name == 'organization' -%>
7
+ <%= attribute.name %>: acme_org
8
+ <% elsif attribute.name == 'user' -%>
9
+ <%= attribute.name %>: john_user
10
+ <% else -%>
11
+ <%= attribute.name %>: one
12
+ <% end -%>
13
+ <% elsif attribute.type == :string -%>
14
+ <% if attribute.name.to_s.match?(/\A(email|email_address)\z/i) -%>
15
+ <%= attribute.name %>: test1@example.com
16
+ <% elsif attribute.name.to_s.match?(/\A(username)\z/i) -%>
17
+ <%= attribute.name %>: test_user_1
18
+ <% elsif attribute.name.to_s.match?(/\A(phone|phone_number)\z/i) -%>
19
+ <%= attribute.name %>: "+1-555-0001"
20
+ <% elsif attribute.name.to_s.match?(/\A(url|website|web_address)\z/i) -%>
21
+ <%= attribute.name %>: "https://example1.com"
22
+ <% elsif attribute.name.to_s.match?(/\A(name|title|label)\z/i) -%>
23
+ <%= attribute.name %>: "Test <%= attribute.name.humanize %> One"
24
+ <% elsif attribute.name.to_s.match?(/\A(slug)\z/i) -%>
25
+ <%= attribute.name %>: "test-<%= singular_table_name %>-one"
26
+ <% elsif attribute.name.to_s.match?(/\A(status|state)\z/i) -%>
27
+ <%= attribute.name %>: "active"
28
+ <% else -%>
29
+ <%= attribute.name %>: "Test <%= attribute.name.humanize %> One"
30
+ <% end -%>
31
+ <% elsif attribute.type == :text -%>
32
+ <% if attribute.name.to_s.match?(/\A(description|content|body|notes|comment|bio|about|summary)\z/i) -%>
33
+ <%= attribute.name %>: "This is a comprehensive test <%= attribute.name %> for the first <%= singular_table_name %> fixture. It provides detailed information for testing purposes."
34
+ <% else -%>
35
+ <%= attribute.name %>: "Test <%= attribute.name.humanize %> content for the first fixture"
36
+ <% end -%>
37
+ <% elsif attribute.type == :integer -%>
38
+ <% if attribute.name.to_s.match?(/\A(age)\z/i) -%>
39
+ <%= attribute.name %>: 25
40
+ <% elsif attribute.name.to_s.match?(/\A(count|quantity|amount)\z/i) -%>
41
+ <%= attribute.name %>: 10
42
+ <% elsif attribute.name.to_s.match?(/\A(priority|order|position|rank)\z/i) -%>
43
+ <%= attribute.name %>: 1
44
+ <% elsif attribute.name.to_s.match?(/\A(year)\z/i) -%>
45
+ <%= attribute.name %>: 2024
46
+ <% elsif attribute.name.to_s.match?(/\A(month)\z/i) -%>
47
+ <%= attribute.name %>: 6
48
+ <% elsif attribute.name.to_s.match?(/\A(day)\z/i) -%>
49
+ <%= attribute.name %>: 15
50
+ <% else -%>
51
+ <%= attribute.name %>: 1
52
+ <% end -%>
53
+ <% elsif attribute.type == :decimal || attribute.type == :float -%>
54
+ <% if attribute.name.to_s.match?(/\A(price|cost|amount|total)\z/i) -%>
55
+ <%= attribute.name %>: 99.99
56
+ <% elsif attribute.name.to_s.match?(/\A(latitude)\z/i) -%>
57
+ <%= attribute.name %>: 40.7128
58
+ <% elsif attribute.name.to_s.match?(/\A(longitude)\z/i) -%>
59
+ <%= attribute.name %>: -74.0060
60
+ <% elsif attribute.name.to_s.match?(/\A(rating|score)\z/i) -%>
61
+ <%= attribute.name %>: 4.5
62
+ <% elsif attribute.name.to_s.match?(/\A(percentage|percent)\z/i) -%>
63
+ <%= attribute.name %>: 85.5
64
+ <% else -%>
65
+ <%= attribute.name %>: 10.5
66
+ <% end -%>
67
+ <% elsif attribute.type == :boolean -%>
68
+ <% if attribute.name.to_s.match?(/\A(active|enabled|published|visible|confirmed|verified)\z/i) -%>
69
+ <%= attribute.name %>: true
70
+ <% elsif attribute.name.to_s.match?(/\A(archived|deleted|disabled|hidden|locked)\z/i) -%>
71
+ <%= attribute.name %>: false
72
+ <% else -%>
73
+ <%= attribute.name %>: true
74
+ <% end -%>
75
+ <% elsif attribute.type == :date -%>
76
+ <%= attribute.name %>: "2024-06-15"
77
+ <% elsif attribute.type == :datetime || attribute.type == :timestamp -%>
78
+ <%= attribute.name %>: "2024-06-15 10:30:00"
79
+ <% elsif attribute.type == :time -%>
80
+ <%= attribute.name %>: "10:30:00"
81
+ <% else -%>
82
+ <%= attribute.name %>: "test_value_one"
83
+ <% end -%>
84
+ <% end -%>
85
+
86
+ two:
87
+ <% attributes.each do |attribute| -%>
88
+ <% if attribute.type == :references -%>
89
+ <% if attribute.name == 'organization' -%>
90
+ <%= attribute.name %>: tech_startup
91
+ <% elsif attribute.name == 'user' -%>
92
+ <%= attribute.name %>: jane_user
93
+ <% else -%>
94
+ <%= attribute.name %>: one
95
+ <% end -%>
96
+ <% elsif attribute.type == :string -%>
97
+ <% if attribute.name.to_s.match?(/\A(email|email_address)\z/i) -%>
98
+ <%= attribute.name %>: test2@example.com
99
+ <% elsif attribute.name.to_s.match?(/\A(username)\z/i) -%>
100
+ <%= attribute.name %>: test_user_2
101
+ <% elsif attribute.name.to_s.match?(/\A(phone|phone_number)\z/i) -%>
102
+ <%= attribute.name %>: "+1-555-0002"
103
+ <% elsif attribute.name.to_s.match?(/\A(url|website|web_address)\z/i) -%>
104
+ <%= attribute.name %>: "https://example2.com"
105
+ <% elsif attribute.name.to_s.match?(/\A(name|title|label)\z/i) -%>
106
+ <%= attribute.name %>: "Test <%= attribute.name.humanize %> Two"
107
+ <% elsif attribute.name.to_s.match?(/\A(slug)\z/i) -%>
108
+ <%= attribute.name %>: "test-<%= singular_table_name %>-two"
109
+ <% elsif attribute.name.to_s.match?(/\A(status|state)\z/i) -%>
110
+ <%= attribute.name %>: "inactive"
111
+ <% else -%>
112
+ <%= attribute.name %>: "Test <%= attribute.name.humanize %> Two"
113
+ <% end -%>
114
+ <% elsif attribute.type == :text -%>
115
+ <% if attribute.name.to_s.match?(/\A(description|content|body|notes|comment|bio|about|summary)\z/i) -%>
116
+ <%= attribute.name %>: "This is another comprehensive test <%= attribute.name %> for the second <%= singular_table_name %> fixture. It provides different content for variety in testing."
117
+ <% else -%>
118
+ <%= attribute.name %>: "Test <%= attribute.name.humanize %> content for the second fixture"
119
+ <% end -%>
120
+ <% elsif attribute.type == :integer -%>
121
+ <% if attribute.name.to_s.match?(/\A(age)\z/i) -%>
122
+ <%= attribute.name %>: 30
123
+ <% elsif attribute.name.to_s.match?(/\A(count|quantity|amount)\z/i) -%>
124
+ <%= attribute.name %>: 20
125
+ <% elsif attribute.name.to_s.match?(/\A(priority|order|position|rank)\z/i) -%>
126
+ <%= attribute.name %>: 2
127
+ <% elsif attribute.name.to_s.match?(/\A(year)\z/i) -%>
128
+ <%= attribute.name %>: 2023
129
+ <% elsif attribute.name.to_s.match?(/\A(month)\z/i) -%>
130
+ <%= attribute.name %>: 12
131
+ <% elsif attribute.name.to_s.match?(/\A(day)\z/i) -%>
132
+ <%= attribute.name %>: 25
133
+ <% else -%>
134
+ <%= attribute.name %>: 2
135
+ <% end -%>
136
+ <% elsif attribute.type == :decimal || attribute.type == :float -%>
137
+ <% if attribute.name.to_s.match?(/\A(price|cost|amount|total)\z/i) -%>
138
+ <%= attribute.name %>: 149.99
139
+ <% elsif attribute.name.to_s.match?(/\A(latitude)\z/i) -%>
140
+ <%= attribute.name %>: 34.0522
141
+ <% elsif attribute.name.to_s.match?(/\A(longitude)\z/i) -%>
142
+ <%= attribute.name %>: -118.2437
143
+ <% elsif attribute.name.to_s.match?(/\A(rating|score)\z/i) -%>
144
+ <%= attribute.name %>: 3.8
145
+ <% elsif attribute.name.to_s.match?(/\A(percentage|percent)\z/i) -%>
146
+ <%= attribute.name %>: 72.3
147
+ <% else -%>
148
+ <%= attribute.name %>: 20.5
149
+ <% end -%>
150
+ <% elsif attribute.type == :boolean -%>
151
+ <% if attribute.name.to_s.match?(/\A(active|enabled|published|visible|confirmed|verified)\z/i) -%>
152
+ <%= attribute.name %>: false
153
+ <% elsif attribute.name.to_s.match?(/\A(archived|deleted|disabled|hidden|locked)\z/i) -%>
154
+ <%= attribute.name %>: true
155
+ <% else -%>
156
+ <%= attribute.name %>: false
157
+ <% end -%>
158
+ <% elsif attribute.type == :date -%>
159
+ <%= attribute.name %>: "2023-12-25"
160
+ <% elsif attribute.type == :datetime || attribute.type == :timestamp -%>
161
+ <%= attribute.name %>: "2023-12-25 15:45:00"
162
+ <% elsif attribute.type == :time -%>
163
+ <%= attribute.name %>: "15:45:00"
164
+ <% else -%>
165
+ <%= attribute.name %>: "test_value_two"
166
+ <% end -%>
167
+ <% end -%>
168
+
169
+ three:
170
+ <% attributes.each do |attribute| -%>
171
+ <% if attribute.type == :references -%>
172
+ <% if attribute.name == 'organization' -%>
173
+ <%= attribute.name %>: acme_org
174
+ <% elsif attribute.name == 'user' -%>
175
+ <%= attribute.name %>: confirmed_user
176
+ <% else -%>
177
+ <%= attribute.name %>: one
178
+ <% end -%>
179
+ <% elsif attribute.type == :string -%>
180
+ <% if attribute.name.to_s.match?(/\A(email|email_address)\z/i) -%>
181
+ <%= attribute.name %>: test3@example.com
182
+ <% elsif attribute.name.to_s.match?(/\A(username)\z/i) -%>
183
+ <%= attribute.name %>: test_user_3
184
+ <% elsif attribute.name.to_s.match?(/\A(phone|phone_number)\z/i) -%>
185
+ <%= attribute.name %>: "+1-555-0003"
186
+ <% elsif attribute.name.to_s.match?(/\A(url|website|web_address)\z/i) -%>
187
+ <%= attribute.name %>: "https://example3.com"
188
+ <% elsif attribute.name.to_s.match?(/\A(name|title|label)\z/i) -%>
189
+ <%= attribute.name %>: "Test <%= attribute.name.humanize %> Three"
190
+ <% elsif attribute.name.to_s.match?(/\A(slug)\z/i) -%>
191
+ <%= attribute.name %>: "test-<%= singular_table_name %>-three"
192
+ <% elsif attribute.name.to_s.match?(/\A(status|state)\z/i) -%>
193
+ <%= attribute.name %>: "pending"
194
+ <% else -%>
195
+ <%= attribute.name %>: "Test <%= attribute.name.humanize %> Three"
196
+ <% end -%>
197
+ <% elsif attribute.type == :text -%>
198
+ <% if attribute.name.to_s.match?(/\A(description|content|body|notes|comment|bio|about|summary)\z/i) -%>
199
+ <%= attribute.name %>: "This is a third comprehensive test <%= attribute.name %> for testing edge cases and ensuring variety in fixture data for the <%= singular_table_name %> model."
200
+ <% else -%>
201
+ <%= attribute.name %>: "Test <%= attribute.name.humanize %> content for the third fixture"
202
+ <% end -%>
203
+ <% elsif attribute.type == :integer -%>
204
+ <% if attribute.name.to_s.match?(/\A(age)\z/i) -%>
205
+ <%= attribute.name %>: 35
206
+ <% elsif attribute.name.to_s.match?(/\A(count|quantity|amount)\z/i) -%>
207
+ <%= attribute.name %>: 5
208
+ <% elsif attribute.name.to_s.match?(/\A(priority|order|position|rank)\z/i) -%>
209
+ <%= attribute.name %>: 3
210
+ <% elsif attribute.name.to_s.match?(/\A(year)\z/i) -%>
211
+ <%= attribute.name %>: 2025
212
+ <% elsif attribute.name.to_s.match?(/\A(month)\z/i) -%>
213
+ <%= attribute.name %>: 3
214
+ <% elsif attribute.name.to_s.match?(/\A(day)\z/i) -%>
215
+ <%= attribute.name %>: 10
216
+ <% else -%>
217
+ <%= attribute.name %>: 3
218
+ <% end -%>
219
+ <% elsif attribute.type == :decimal || attribute.type == :float -%>
220
+ <% if attribute.name.to_s.match?(/\A(price|cost|amount|total)\z/i) -%>
221
+ <%= attribute.name %>: 299.99
222
+ <% elsif attribute.name.to_s.match?(/\A(latitude)\z/i) -%>
223
+ <%= attribute.name %>: 41.8781
224
+ <% elsif attribute.name.to_s.match?(/\A(longitude)\z/i) -%>
225
+ <%= attribute.name %>: -87.6298
226
+ <% elsif attribute.name.to_s.match?(/\A(rating|score)\z/i) -%>
227
+ <%= attribute.name %>: 5.0
228
+ <% elsif attribute.name.to_s.match?(/\A(percentage|percent)\z/i) -%>
229
+ <%= attribute.name %>: 95.7
230
+ <% else -%>
231
+ <%= attribute.name %>: 30.5
232
+ <% end -%>
233
+ <% elsif attribute.type == :boolean -%>
234
+ <% if attribute.name.to_s.match?(/\A(active|enabled|published|visible|confirmed|verified)\z/i) -%>
235
+ <%= attribute.name %>: true
236
+ <% elsif attribute.name.to_s.match?(/\A(archived|deleted|disabled|hidden|locked)\z/i) -%>
237
+ <%= attribute.name %>: false
238
+ <% else -%>
239
+ <%= attribute.name %>: true
240
+ <% end -%>
241
+ <% elsif attribute.type == :date -%>
242
+ <%= attribute.name %>: "2025-03-10"
243
+ <% elsif attribute.type == :datetime || attribute.type == :timestamp -%>
244
+ <%= attribute.name %>: "2025-03-10 08:15:00"
245
+ <% elsif attribute.type == :time -%>
246
+ <%= attribute.name %>: "08:15:00"
247
+ <% else -%>
248
+ <%= attribute.name %>: "test_value_three"
249
+ <% end -%>
250
+ <% end -%>