souls 0.8.5 → 0.8.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 +4 -4
- data/.gitignore +4 -1
- data/Gemfile.lock +1 -1
- data/exe/souls +21 -4
- data/lib/souls/init.rb +143 -0
- data/lib/souls/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 87b717736b09f7fb0d8c595800e4beb6ab622b8664b6fba6391ee94b45f6ed3d
|
4
|
+
data.tar.gz: b112ea068f7dea6fc23f1f417b8e61e52b87fe35056f26bc5a5f950071efa147
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4bfb79e0fc7f341a3e9b05be8a3649d377a49e8af4d749dbbf156e0e06ff3c6dec9b2dba29d09428aee716a132d924baa9d1f6f7859542a575fc5fd9713a305b
|
7
|
+
data.tar.gz: 893e1f5cbe6d46a581f08681eb13b9e6b1caadc5ce3b921b2294db5e8518ce0e6658a637331edf43120747152c3e2af188e13913be0fdf83533b544dd347e3d5
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
data/exe/souls
CHANGED
@@ -46,10 +46,27 @@ begin
|
|
46
46
|
when "-v", "--version"
|
47
47
|
puts Souls::VERSION
|
48
48
|
when "g", "generate"
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
49
|
+
case ARGV[1]
|
50
|
+
when "model"
|
51
|
+
Souls::Init.model class_name: ARGV[2]
|
52
|
+
when "mutation"
|
53
|
+
Souls::Init.mutation class_name: ARGV[2]
|
54
|
+
when "query"
|
55
|
+
Souls::Init.query class_name: ARGV[2]
|
56
|
+
when "type"
|
57
|
+
Souls::Init.type class_name: ARGV[2]
|
58
|
+
when "migration"
|
59
|
+
Souls::Init.migration class_name: ARGV[2]
|
60
|
+
when "rspec_model"
|
61
|
+
Souls::Init.rspec_model class_name: ARGV[2]
|
62
|
+
when "rspec_mutation"
|
63
|
+
Souls::Init.rspec_mutation class_name: ARGV[2]
|
64
|
+
when "rspec_query"
|
65
|
+
Souls::Init.rspec_query class_name: ARGV[2]
|
66
|
+
when "rspec_type"
|
67
|
+
Souls::Init.rspec_type class_name: ARGV[2]
|
68
|
+
else
|
69
|
+
end
|
53
70
|
when "t", "test"
|
54
71
|
case ARGV[1]
|
55
72
|
when "-r"
|
data/lib/souls/init.rb
CHANGED
@@ -243,6 +243,149 @@ module Souls
|
|
243
243
|
`souls i delete_ingress`
|
244
244
|
end
|
245
245
|
|
246
|
+
def model class_name: "souls"
|
247
|
+
file_path = "./app/models/#{class_name}.rb"
|
248
|
+
File.open(file_path, "w") do |f|
|
249
|
+
f.write <<~EOS
|
250
|
+
class #{class_name.capitalize} < ActiveRecord::Base
|
251
|
+
end
|
252
|
+
EOS
|
253
|
+
end
|
254
|
+
puts "model #{class_name}.rb created!: `#{file_path}`"
|
255
|
+
end
|
256
|
+
|
257
|
+
def mutation class_name: "souls"
|
258
|
+
file_path = "./app/graphql/mutations/create_#{class_name}.rb"
|
259
|
+
File.open(file_path, "w") do |f|
|
260
|
+
f.write <<~EOS
|
261
|
+
module Mutations
|
262
|
+
class Create#{class_name.capitalize} < BaseMutation
|
263
|
+
field :#{class_name}, Types::#{class_name.capitalize}Type, null: false
|
264
|
+
field :error, String, null: true
|
265
|
+
|
266
|
+
## Change argument as you needed
|
267
|
+
# argument :id, Integer, required: true
|
268
|
+
# argument :title, String, required: true
|
269
|
+
# argument :tag, [String], required: false
|
270
|
+
# argument :is_public, Boolean, required: true
|
271
|
+
# argument :public_date, GraphQL::Types::ISO8601DateTime, required: true
|
272
|
+
|
273
|
+
def resolve **args
|
274
|
+
#{class_name} = #{class_name.capitalize}.new args
|
275
|
+
if #{class_name}.save
|
276
|
+
{ #{class_name}: #{class_name} }
|
277
|
+
else
|
278
|
+
{ error: #{class_name}.errors.full_messages }
|
279
|
+
end
|
280
|
+
rescue StandardError => error
|
281
|
+
GraphQL::ExecutionError.new error
|
282
|
+
end
|
283
|
+
end
|
284
|
+
end
|
285
|
+
EOS
|
286
|
+
end
|
287
|
+
puts "mutation create_#{class_name}.rb created!: `#{file_path}`"
|
288
|
+
end
|
289
|
+
|
290
|
+
def query class_name: "souls"
|
291
|
+
file_path = "./app/graphql/queries/#{class_name}s.rb"
|
292
|
+
File.open(file_path, "w") do |f|
|
293
|
+
f.write <<~EOS
|
294
|
+
module Queries
|
295
|
+
class #{class_name.capitalize}s < Queries::BaseQuery
|
296
|
+
type [Types::#{class_name.capitalize}Type], null: false
|
297
|
+
|
298
|
+
def resolve
|
299
|
+
::#{class_name.capitalize}.all
|
300
|
+
rescue StandardError => error
|
301
|
+
GraphQL::ExecutionError.new error
|
302
|
+
end
|
303
|
+
end
|
304
|
+
end
|
305
|
+
EOS
|
306
|
+
end
|
307
|
+
puts "query #{class_name}s.rb created!: `#{file_path}`"
|
308
|
+
file_path = "./app/graphql/queries/#{class_name}.rb"
|
309
|
+
File.open(file_path, "w") do |f|
|
310
|
+
f.write <<~EOS
|
311
|
+
module Queries
|
312
|
+
class #{class_name.capitalize} < Queries::BaseQuery
|
313
|
+
type Types::#{class_name.capitalize}Type, null: false
|
314
|
+
argument :id, Integer, required: true
|
315
|
+
|
316
|
+
def resolve id:
|
317
|
+
::#{class_name.capitalize}.find(id)
|
318
|
+
rescue StandardError => error
|
319
|
+
GraphQL::ExecutionError.new error
|
320
|
+
end
|
321
|
+
end
|
322
|
+
end
|
323
|
+
EOS
|
324
|
+
puts "query #{class_name}.rb created!: `#{file_path}`"
|
325
|
+
end
|
326
|
+
end
|
327
|
+
|
328
|
+
def type class_name: "souls"
|
329
|
+
file_path = "./app/graphql/types/#{class_name}_type.rb"
|
330
|
+
File.open(file_path, "w") do |f|
|
331
|
+
f.write <<~EOS
|
332
|
+
module Types
|
333
|
+
class #{class_name.capitalize}Type < GraphQL::Schema::Object
|
334
|
+
implements GraphQL::Types::Relay::Node
|
335
|
+
|
336
|
+
## Change field as you needed
|
337
|
+
# global_id_field :id
|
338
|
+
# field :user, Types::UserType, null: false
|
339
|
+
# field :title, String, null: false
|
340
|
+
# field :tag, [String], null: true
|
341
|
+
# field :public_date, GraphQL::Types::ISO8601DateTime, null: false
|
342
|
+
# field :is_public, Boolean, null: false
|
343
|
+
# field :article_category, Types::ArticleCategoryType, null: false
|
344
|
+
# field :created_at, GraphQL::Types::ISO8601DateTime, null: true
|
345
|
+
# field :updated_at, GraphQL::Types::ISO8601DateTime, null: true
|
346
|
+
end
|
347
|
+
end
|
348
|
+
EOS
|
349
|
+
end
|
350
|
+
puts "type #{class_name}.rb created!: `#{file_path}`"
|
351
|
+
end
|
352
|
+
|
353
|
+
def rspec_model class_name: "souls"
|
354
|
+
file_path = "./spec/models/#{class_name}_spec.rb"
|
355
|
+
File.open(file_path, "w") do |f|
|
356
|
+
f.write <<~EOS
|
357
|
+
RSpec.describe #{class_name.capitalize}, type: :model do
|
358
|
+
it "作成する" do
|
359
|
+
expect(FactoryBot.build(:#{class_name})).to be_valid
|
360
|
+
end
|
361
|
+
|
362
|
+
it "同じtitleがあると作成できない" do
|
363
|
+
FactoryBot.build(:#{class_name}, title: "hey")
|
364
|
+
expect(FactoryBot.build(:#{class_name}, title: "hey")).to be_valid
|
365
|
+
end
|
366
|
+
end
|
367
|
+
EOS
|
368
|
+
end
|
369
|
+
puts "rspec_model #{class_name}_spec.rb created!: `#{file_path}`"
|
370
|
+
end
|
371
|
+
|
372
|
+
def rspec_mutation class_name: "souls"
|
373
|
+
end
|
374
|
+
|
375
|
+
def rspec_query class_name: "souls"
|
376
|
+
end
|
377
|
+
|
378
|
+
def rspec_type class_name: "souls"
|
379
|
+
end
|
380
|
+
|
381
|
+
def migration class_name: "souls"
|
382
|
+
model class_name: class_name
|
383
|
+
mutation class_name: class_name
|
384
|
+
query class_name: class_name
|
385
|
+
type class_name: class_name
|
386
|
+
rspec_model class_name: class_name
|
387
|
+
end
|
388
|
+
|
246
389
|
end
|
247
390
|
end
|
248
391
|
end
|
data/lib/souls/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: souls
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- POPPIN-FUMI
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2021-01-
|
13
|
+
date: 2021-01-20 00:00:00.000000000 Z
|
14
14
|
dependencies: []
|
15
15
|
description: SOULS is a Web Application Framework for Microservices on Multi Cloud
|
16
16
|
Platform such as Google Cloud Platform, Amazon Web Services, and Alibaba Cloud.
|