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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a57b96797a0a477562740a5cf08fbd5c4183f2fe493a70cb69566f5f1cda980b
4
- data.tar.gz: 8a029707d19eda050c020c36600dda592d3f0a0451d05f51667343a5d6a8ad2f
3
+ metadata.gz: 87b717736b09f7fb0d8c595800e4beb6ab622b8664b6fba6391ee94b45f6ed3d
4
+ data.tar.gz: b112ea068f7dea6fc23f1f417b8e61e52b87fe35056f26bc5a5f950071efa147
5
5
  SHA512:
6
- metadata.gz: f46f143cc597d71e62948f95226c7bbee91541063d8d6ea03f8fc77e46bdbeeff35373e709ba663b9c5b745e4a2524413ba0c11b4254738792f7265794d7c110
7
- data.tar.gz: 0c608d8eda05af23a06ae4767e2b19d38e4c98f72a0136bded4e86c48ddc0c08731e5d07d99e3355f30135337fe70f1b9f457dd010216cb618f06d693af06d13
6
+ metadata.gz: 4bfb79e0fc7f341a3e9b05be8a3649d377a49e8af4d749dbbf156e0e06ff3c6dec9b2dba29d09428aee716a132d924baa9d1f6f7859542a575fc5fd9713a305b
7
+ data.tar.gz: 893e1f5cbe6d46a581f08681eb13b9e6b1caadc5ce3b921b2294db5e8518ce0e6658a637331edf43120747152c3e2af188e13913be0fdf83533b544dd347e3d5
data/.gitignore CHANGED
@@ -11,4 +11,7 @@
11
11
  .rspec_status
12
12
  /config/keyfile.json
13
13
  .env
14
- .irb_history
14
+ .irb_history
15
+ /spec/
16
+ /app/
17
+
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- souls (0.8.4)
4
+ souls (0.8.5)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
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
- `touch .rubocop.yml`
50
- `touch .env`
51
- `touch .gitignore`
52
- `touch .irbrc`
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"
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Souls
2
- VERSION = "0.8.5"
2
+ VERSION = "0.8.6"
3
3
  end
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.5
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-19 00:00:00.000000000 Z
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.