ibrain-core 0.1.1 → 0.1.5

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 (28) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/ibrain/graphql_controller.rb +1 -1
  3. data/app/graphql/ibrain/interfaces/record_interface.rb +0 -2
  4. data/app/graphql/ibrain/resolvers/base_resolver.rb +1 -1
  5. data/app/graphql/ibrain/types/base_node.rb +1 -1
  6. data/app/graphql/ibrain/types/base_object.rb +1 -1
  7. data/app/models/ibrain/base.rb +24 -12
  8. data/app/repositories/ibrain/base_repository.rb +18 -0
  9. data/lib/generators/ibrain/graphql/core.rb +4 -0
  10. data/lib/generators/ibrain/graphql/mutation_generator.rb +4 -0
  11. data/lib/generators/ibrain/graphql/object_generator.rb +7 -0
  12. data/lib/generators/ibrain/graphql/resolver_generator.rb +4 -0
  13. data/lib/generators/ibrain/graphql/resolvers_generator.rb +4 -0
  14. data/lib/generators/ibrain/graphql/templates/aggregate.erb +5 -2
  15. data/lib/generators/ibrain/graphql/templates/mutation.erb +8 -2
  16. data/lib/generators/ibrain/graphql/templates/object.erb +4 -0
  17. data/lib/generators/ibrain/graphql/templates/repository.erb +19 -0
  18. data/lib/generators/ibrain/graphql/templates/resolver.erb +8 -3
  19. data/lib/generators/ibrain/graphql/templates/resolvers.erb +8 -3
  20. data/lib/generators/ibrain/install/install_generator.rb +6 -16
  21. data/lib/generators/ibrain/install/templates/config/initializers/cors.tt +1 -1
  22. data/lib/generators/ibrain/install/templates/graphql/app_schema.rb.tt +3 -1
  23. data/lib/generators/ibrain/install/templates/graphql/types/mutation_type.rb.tt +5 -1
  24. data/lib/generators/ibrain/install/templates/graphql/types/query_type.rb.tt +4 -0
  25. data/lib/generators/ibrain/install/templates/rubocop.yml.tt +299 -14
  26. data/lib/ibrain/core/controller_helpers/auth.rb +6 -2
  27. data/lib/ibrain/core/version.rb +2 -2
  28. metadata +4 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9f025cda0967d5fb69166c0c8414008674498f34ee663f835686fa72e928dcc8
4
- data.tar.gz: 4a70645118e2df91125b8baead82bfd1688cc7ea11dfe24c471a6cbc875761f0
3
+ metadata.gz: a0ba188722fa8379256471e8051ddff9b168466a2db3237d114c7d72f7432a59
4
+ data.tar.gz: a3f32c79ddb8421b25c83d4dd72aa47e8434859fe0cd45f35223a37651a6260b
5
5
  SHA512:
6
- metadata.gz: e4c427744bc5d9c0e7535b81827f805509173f6966bf1a1f9f227dec8acfee5baf0b284d1e4581bc6a2446671c7808e1a51e4e19ed29d8ea1a263187e9484152
7
- data.tar.gz: 3c652fd06e5202f33b7fc7c32c3d173ac608aec4c9010dc2163c7a6e41bf876f9a3035b9b5c2d56acfe068004e78652e471fa87ac7e6728f0078ab3d03fc32e0
6
+ metadata.gz: bb0361b7b0107f852212ff6e357dc41e7511a834bcc2c68941649e32125e20386193fd53f5fcac04d10659e17a965e7e8a9bba60b5790b4163ba8be091eea504
7
+ data.tar.gz: 737ef5f5f922fd55ab9970cd0cb2a6563adb09dcfcffa73b155395afeda228b0aed3cd77b73c6348592718adf4850b7bae67af01ae604378775de1d4dac61e6d
@@ -10,7 +10,7 @@ module Ibrain
10
10
  variables: variables,
11
11
  context: {
12
12
  session: session,
13
- current_user: current_ibrain_user
13
+ current_user: try_ibrain_current_user
14
14
  },
15
15
  operation_name: operation_name
16
16
  )
@@ -3,8 +3,6 @@
3
3
  module Ibrain::Interfaces::RecordInterface
4
4
  include Ibrain::Types::BaseInterface
5
5
 
6
- description 'Common Interface'
7
-
8
6
  field :created_at, ::GraphQL::Types::ISO8601DateTime, null: false
9
7
  field :updated_at, ::GraphQL::Types::ISO8601DateTime, null: false
10
8
  end
@@ -4,8 +4,8 @@ module Ibrain
4
4
  module Resolvers
5
5
  class BaseResolver < GraphQL::Schema::Resolver
6
6
  argument :filter, Ibrain::Types::FilterType, required: false, default_value: nil
7
- argument :offset, Int, required: false, default_value: 0
8
7
  argument :limit, Int, required: false, default_value: 10
8
+ argument :offset, Int, required: false, default_value: 0
9
9
 
10
10
  def current_user
11
11
  context.fetch(:current_user)
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Ibrain::Types::BaseNode < Types::BaseObject
4
- implements ::GraphQL::Relay::Node.interface
4
+ include ::GraphQL::Relay::Node
5
5
  implements ::Ibrain::Interfaces::RecordInterface
6
6
 
7
7
  global_id_field :id
@@ -3,7 +3,7 @@
3
3
  module Ibrain
4
4
  module Types
5
5
  class BaseObject < GraphQL::Schema::Object
6
- implements GraphQL::Relay::Node.interface
6
+ include GraphQL::Relay::Node
7
7
 
8
8
  edge_type_class(Ibrain::Types::BaseEdge)
9
9
  connection_type_class(Ibrain::Types::BaseConnection)
@@ -1,20 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ IGNORE_ATTRIBUTES = %w(id created_at updated_at)
4
+
3
5
  class Ibrain::Base < Ibrain::ApplicationRecord
4
6
  include ActionView::Helpers::DateHelper
5
7
 
6
8
  self.abstract_class = true
7
9
 
8
- def self.adjust_date_for_cdt(datetime)
9
- datetime.in_time_zone('UTC')
10
- end
11
-
12
10
  def string_id
13
11
  try(:id).try(:to_s)
14
12
  end
15
13
 
16
14
  scope :graphql_ransack, lambda { |params|
17
- ransack(params).result(distinct: true)
15
+ ransack(params).result
18
16
  }
19
17
 
20
18
  scope :reverse_scope, lambda {
@@ -36,12 +34,26 @@ class Ibrain::Base < Ibrain::ApplicationRecord
36
34
  time_ago_in_words(created_at)
37
35
  end
38
36
 
39
- # Provides a scope that should be included any time data
40
- # are fetched with the intention of displaying to the user.
41
- #
42
- # Allows individual stores to include any active record scopes or joins
43
- # when data are displayed.
44
- def self.display_includes
45
- where(nil)
37
+ class << self
38
+ # Provides a scope that should be included any time data
39
+ # are fetched with the intention of displaying to the user.
40
+ #
41
+ # Allows individual stores to include any active record scopes or joins
42
+ # when data are displayed.
43
+ def display_includes
44
+ where(nil)
45
+ end
46
+
47
+ def paginate(args)
48
+ limit(args[:limit]).offset(args[:offset])
49
+ end
50
+
51
+ def adjust_date_for_cdt(datetime)
52
+ datetime.in_time_zone('UTC')
53
+ end
54
+
55
+ def permitted_attributes
56
+ column_names.reject { |k| IGNORE_ATTRIBUTES.include?(k) }
57
+ end
46
58
  end
47
59
  end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ibrain
4
+ class BaseRepository
5
+ def initialize(current_user, record)
6
+ @current_user = current_user
7
+ @record = record
8
+ end
9
+
10
+ attr_reader :current_user, :record
11
+
12
+ protected
13
+
14
+ def cryptor
15
+ Ibrain::Encryptor.new
16
+ end
17
+ end
18
+ end
@@ -36,6 +36,10 @@ module Ibrain
36
36
  insert_root_type('query', 'QueryType')
37
37
  end
38
38
 
39
+ def create_repository_root_type
40
+ create_dir("app/repositories")
41
+ end
42
+
39
43
  def schema_file_path
40
44
  "#{options[:directory]}/#{schema_name.underscore}.rb"
41
45
  end
@@ -36,6 +36,10 @@ module Ibrain
36
36
  create_mutation_root_type
37
37
  end
38
38
 
39
+ if options[:model].present?
40
+ system("bundle exec rails generate ibrain:graphql:object #{options[:model].downcase}")
41
+ end
42
+
39
43
  template "mutation.erb", "#{options[:directory]}/mutations/#{file_name}.rb"
40
44
 
41
45
  sentinel = /class .*MutationType\s*<\s*[^\s]+?\n/m
@@ -29,7 +29,10 @@ module Ibrain
29
29
  desc: "Include the Relay Node interface"
30
30
 
31
31
  def create_type_file
32
+ create_dir('app/repositories') unless Dir.exist?('app/repositories')
33
+
32
34
  template "object.erb", "#{options[:directory]}/types/objects/#{type_file_name}.rb"
35
+ template "repository.erb", "app/repositories/#{type_name}_repository.rb"
33
36
  end
34
37
 
35
38
  def fields
@@ -72,6 +75,10 @@ module Ibrain
72
75
  false
73
76
  end
74
77
 
78
+ def model_name
79
+ type_name.capitalize
80
+ end
81
+
75
82
  def klass
76
83
  @klass ||= Module.const_get(type_name.camelize)
77
84
  end
@@ -20,6 +20,10 @@ module Ibrain
20
20
  create_resolver_root_type
21
21
  end
22
22
 
23
+ if options[:model].present?
24
+ system("bundle exec rails generate ibrain:graphql:object #{options[:model].downcase}")
25
+ end
26
+
23
27
  template "resolver.erb", "#{options[:directory]}/resolvers/#{file_name}.rb"
24
28
 
25
29
  sentinel = /class .*QueryType\s*<\s*[^\s]+?\n/m
@@ -36,6 +36,10 @@ module Ibrain
36
36
  create_resolver_root_type
37
37
  end
38
38
 
39
+ if options[:model].present?
40
+ system("bundle exec rails generate ibrain:graphql:object #{options[:model].downcase}")
41
+ end
42
+
39
43
  template "resolvers.erb", "#{options[:directory]}/resolvers/#{file_name}.rb"
40
44
  template "aggregate.erb", "#{options[:directory]}/resolvers/#{file_name}_aggregate.rb"
41
45
 
@@ -1,9 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  <% module_namespacing_when_supported do -%>
2
4
  module Resolvers
3
- class <%= "#{resolver_name}Aggregate" %> < Ibrain::Resolvers::BaseAggregate
5
+ class <%= resolver_name %>Aggregate < Ibrain::Resolvers::BaseAggregate
6
+ description 'Define aggregate to count total records for <%= resolver_name %>'
4
7
  # define resolve method
5
8
  def resolve(args)
6
- <%= model_name.capitalize %>.ransack(args[:filter]).result
9
+ <%= model_name.capitalize %>Repository.aggregate(args)
7
10
  end
8
11
  end
9
12
  end
@@ -1,15 +1,21 @@
1
+ # frozen_string_literal: true
2
+
1
3
  <% module_namespacing_when_supported do -%>
2
4
  module Mutations
3
5
  class <%= mutation_name %> < Ibrain::Mutations::BaseMutation
6
+ # TODO: define description describe about this mutation
7
+ # description
8
+
4
9
  # TODO: define return fields
5
- field :<%= model_name.underscore %>, Types::<%= model_name %>Type, null: false
10
+ field :<%= model_name.underscore %>, Types::<%= model_name %>Type, null: false, description: 'Record Type for mutation response'
6
11
 
7
12
  # TODO: define arguments
8
13
  # argument :name, String, required: true
9
14
 
10
15
  # TODO: define resolve method
11
16
  def resolve(args)
12
- # TODO: define logic
17
+ # TODO: define logic inside repository
18
+ # Something like Repository.new(current_user, Post.new).create(args)
13
19
  end
14
20
  end
15
21
  end
@@ -1,8 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  <% module_namespacing_when_supported do -%>
2
4
  module Types
3
5
  module Objects
4
6
  class <%= type_ruby_name.split('::')[-1] %> < Ibrain::Types::BaseObject
5
7
  implements Ibrain::Interfaces::RecordInterface
8
+
9
+ description '<%= type_ruby_name.split('::')[-1] %>'
6
10
 
7
11
  <% normalized_fields.each do |f| %> <%= f.to_ruby %>
8
12
  <% end %>end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ <% module_namespacing_when_supported do -%>
4
+ class <%= model_name %>Repository < Ibrain::BaseRepository
5
+ def initialize(current_user, record = nil)
6
+ super(current_user, record)
7
+ end
8
+
9
+ class << self
10
+ def find(args)
11
+ <%= model_name %>.find args[:id]
12
+ end
13
+
14
+ def aggregate(args)
15
+ <%= model_name %>.ransack(args[:filter]).result
16
+ end
17
+ end
18
+ end
19
+ <% end -%>
@@ -1,14 +1,19 @@
1
+ # frozen_string_literal: true
2
+
1
3
  <% module_namespacing_when_supported do -%>
2
4
  module Resolvers
3
5
  class <%= resolver_name %> < Ibrain::Resolvers::BaseResolver
6
+ # TODO: define description describe about this mutation
7
+ # description
8
+
4
9
  # TODO: define return fields
5
- type Types::Objects::<%= model_name.capitalize %>Type, null: false
10
+ type Types::Objects::<%= model_name.capitalize %>Type, null: false, description: 'Define data type will be response to client'
6
11
 
7
- argument :id, ID, required: false
12
+ argument :id, ID, required: false, description: 'TODO: describe about this argument'
8
13
 
9
14
  # TODO: define resolve method
10
15
  def resolve(args)
11
- <%= model_name.capitalize %>.find args[:id]
16
+ <%= model_name.capitalize %>Repository.find args[:id]
12
17
  end
13
18
  end
14
19
  end
@@ -1,12 +1,17 @@
1
+ # frozen_string_literal: true
2
+
1
3
  <% module_namespacing_when_supported do -%>
2
4
  module Resolvers
3
- class <%= resolver_name %> < <%= "#{resolver_name}Aggregate" %>
5
+ class <%= resolver_name %> < <%= resolver_name %>Aggregate
6
+ # TODO: define description describe about this mutation
7
+ # description
8
+
4
9
  # TODO: define return fields
5
- type [Types::Objects::<%= model_name.capitalize %>Type], null: false
10
+ type [Types::Objects::<%= model_name.capitalize %>Type], null: false, description: 'Define data type will be response to client'
6
11
 
7
12
  # TODO: define resolve method
8
13
  def resolve(args)
9
- super(args).limit(args[:limit]).offset(args[:offset])
14
+ super(args).paginate(args)
10
15
  end
11
16
  end
12
17
  end
@@ -35,17 +35,6 @@ module Ibrain
35
35
  end
36
36
 
37
37
  def configure_application
38
- application <<-RUBY
39
- # Load application's model / class decorators
40
- initializer 'ibrain.decorators' do |app|
41
- config.to_prepare do
42
- Dir.glob(Rails.root.join('app/**/*_decorator*.rb')) do |path|
43
- require_dependency(path)
44
- end
45
- end
46
- end
47
- RUBY
48
-
49
38
  if !options[:enforce_available_locales].nil?
50
39
  application <<-RUBY
51
40
  I18n.enforce_available_locales = #{options[:enforce_available_locales]}
@@ -66,7 +55,7 @@ module Ibrain
66
55
  Would you like to install it? (Y/n)"))
67
56
 
68
57
  @plugins_to_be_installed << 'ibrain-auth' unless system('gem list | grep ibrain-auth')
69
- @plugin_generators_to_run << 'ibrain:auth:install'
58
+ @plugin_generators_to_run << "ibrain:auth:install --with-ridgpole=#{options[:with_ridgepole]}"
70
59
  end
71
60
  end
72
61
 
@@ -79,6 +68,7 @@ module Ibrain
79
68
  append_gem('rubocop', '1.23.0', 'development')
80
69
  append_gem('rubocop-performance', '1.12.0', 'development')
81
70
  append_gem('rubocop-rails', '2.12.4', 'development')
71
+ append_gem('rubocop-graphql', '0.11.2', 'development')
82
72
  end
83
73
 
84
74
  if options[:with_graphql]
@@ -134,10 +124,10 @@ module Ibrain
134
124
 
135
125
  def add_files
136
126
  template 'config/initializers/ibrain.rb.tt', 'config/initializers/ibrain.rb', { skip: true }
137
- template 'config/initializers/cors.tt', 'config/initializers/cors.rb', { skip: true }
138
- template 'config/puma.tt', 'config/puma.rb', { skip: true }
139
- yml_template 'config/database.tt', 'config/database.yml', { skip: true }
140
- template 'rubocop.yml.tt', '.rubocop.yml', { skip: true } if options[:with_rubocop]
127
+ template 'config/initializers/cors.tt', 'config/initializers/cors.rb'
128
+ template 'config/puma.tt', 'config/puma.rb'
129
+ yml_template 'config/database.tt', 'config/database.yml'
130
+ template 'rubocop.yml.tt', '.rubocop.yml' if options[:with_rubocop]
141
131
 
142
132
  if options[:with_graphql]
143
133
  template 'graphql/app_schema.rb.tt', 'app/graphql/app_schema.rb', { skip: true }
@@ -7,7 +7,7 @@
7
7
 
8
8
  Rails.application.config.middleware.insert_before 0, Rack::Cors do
9
9
  allow do
10
- origins '*'
10
+ origins ['localhost']
11
11
 
12
12
  resource '*',
13
13
  headers: :any,
@@ -1,4 +1,6 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class AppSchema < Ibrain::BaseSchema
2
4
  mutation(Types::MutationType)
3
5
  query(Types::QueryType)
4
- end
6
+ end
@@ -1,5 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Types
2
4
  class MutationType < Ibrain::Types::BaseObject
5
+ description 'Define all mutation for client'
6
+
3
7
  # TODO: remove me
4
8
  field :test_field, String, null: false,
5
9
  description: 'An example field added by the generator'
@@ -7,4 +11,4 @@ module Types
7
11
  'Hello World'
8
12
  end
9
13
  end
10
- end
14
+ end
@@ -1,5 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Types
2
4
  class QueryType < Ibrain::Types::BaseObject
5
+ description 'Define all resolver for client'
6
+
3
7
  # Add `node(id: ID!) and `nodes(ids: [ID!]!)`
4
8
  include GraphQL::Types::Relay::HasNodeField
5
9
  include GraphQL::Types::Relay::HasNodesField
@@ -3,15 +3,11 @@
3
3
  require:
4
4
  - rubocop-performance
5
5
  - rubocop-rails
6
+ - rubocop-graphql
6
7
 
7
8
  AllCops:
8
9
  TargetRubyVersion: 2.5
9
10
 
10
- # Sometimes I believe this reads better
11
- # This also causes spacing issues on multi-line fixes
12
- Style/BracesAroundHashParameters:
13
- Enabled: false
14
-
15
11
  # We use class vars and will have to continue doing so for compatability
16
12
  Style/ClassVars:
17
13
  Enabled: false
@@ -78,7 +74,7 @@ Layout/ElseAlignment:
78
74
  Layout/IndentationWidth:
79
75
  Enabled: false
80
76
 
81
- Layout/AlignParameters:
77
+ Layout/ParameterAlignment:
82
78
  Enabled: false
83
79
 
84
80
  Layout/ClosingParenthesisIndentation:
@@ -87,13 +83,13 @@ Layout/ClosingParenthesisIndentation:
87
83
  Layout/MultilineMethodCallIndentation:
88
84
  Enabled: false
89
85
 
90
- Layout/IndentFirstArrayElement:
86
+ Layout/FirstArrayElementIndentation:
91
87
  Enabled: false
92
88
 
93
- Layout/IndentFirstHashElement:
89
+ Layout/FirstHashElementIndentation:
94
90
  Enabled: false
95
91
 
96
- Layout/AlignHash:
92
+ Layout/HashAlignment:
97
93
  Enabled: false
98
94
 
99
95
  Style/TrailingCommaInArguments:
@@ -117,6 +113,7 @@ Rails/DynamicFindBy:
117
113
  # It's okay to skip model validations to setup a spec.
118
114
  Rails/SkipsModelValidations:
119
115
  Exclude:
116
+ - db/seeds/**/*.rb
120
117
  - '*/spec/**/*'
121
118
 
122
119
  # We use a lot of
@@ -281,7 +278,7 @@ Metrics/BlockLength:
281
278
  Metrics/CyclomaticComplexity:
282
279
  Enabled: false
283
280
 
284
- Metrics/LineLength:
281
+ Layout/LineLength:
285
282
  Enabled: false
286
283
 
287
284
  Metrics/MethodLength:
@@ -307,7 +304,7 @@ Style/FrozenStringLiteralComment:
307
304
  Style/LambdaCall:
308
305
  Enabled: false
309
306
 
310
- Naming/UncommunicativeMethodParamName:
307
+ Naming/MethodParameterName:
311
308
  AllowedNames:
312
309
  - id
313
310
  - to
@@ -320,11 +317,299 @@ Style/IdenticalConditionalBranches:
320
317
  Naming/MemoizedInstanceVariableName:
321
318
  Enabled: false
322
319
 
323
- Lint/UselessComparison:
320
+ Lint/BinaryOperatorWithIdenticalOperands:
324
321
  Enabled: false
325
322
 
326
- Lint/HandleExceptions:
323
+ Lint/SuppressedException:
327
324
  Enabled: false
328
325
 
329
326
  Rails/ReflectionClassName:
330
- Enabled: true
327
+ Enabled: true
328
+ Exclude:
329
+ - app/models/ibrain/role_user.rb
330
+
331
+ Gemspec/DateAssignment: # new in 1.10
332
+ Enabled: true
333
+
334
+ Gemspec/RequireMFA: # new in 1.23
335
+ Enabled: true
336
+
337
+ Layout/LineEndStringConcatenationIndentation: # new in 1.18
338
+ Enabled: true
339
+
340
+ Layout/SpaceBeforeBrackets: # new in 1.7
341
+ Enabled: true
342
+
343
+ Lint/AmbiguousAssignment: # new in 1.7
344
+ Enabled: true
345
+
346
+ Lint/AmbiguousOperatorPrecedence: # new in 1.21
347
+ Enabled: true
348
+
349
+ Lint/AmbiguousRange: # new in 1.19
350
+ Enabled: true
351
+
352
+ Lint/DeprecatedConstants: # new in 1.8
353
+ Enabled: true
354
+
355
+ Lint/DuplicateBranch: # new in 1.3
356
+ Enabled: true
357
+
358
+ Lint/DuplicateRegexpCharacterClassElement: # new in 1.1
359
+ Enabled: true
360
+
361
+ Lint/EmptyBlock: # new in 1.1
362
+ Enabled: true
363
+
364
+ Lint/EmptyClass: # new in 1.3
365
+ Enabled: true
366
+
367
+ Lint/EmptyInPattern: # new in 1.16
368
+ Enabled: true
369
+
370
+ Lint/IncompatibleIoSelectWithFiberScheduler: # new in 1.21
371
+ Enabled: true
372
+
373
+ Lint/LambdaWithoutLiteralBlock: # new in 1.8
374
+ Enabled: true
375
+
376
+ Lint/NoReturnInBeginEndBlocks: # new in 1.2
377
+ Enabled: true
378
+
379
+ Lint/NumberedParameterAssignment: # new in 1.9
380
+ Enabled: true
381
+
382
+ Lint/OrAssignmentToConstant: # new in 1.9
383
+ Enabled: true
384
+
385
+ Lint/RedundantDirGlobSort: # new in 1.8
386
+ Enabled: true
387
+
388
+ Lint/RequireRelativeSelfPath: # new in 1.22
389
+ Enabled: true
390
+
391
+ Lint/SymbolConversion: # new in 1.9
392
+ Enabled: true
393
+
394
+ Lint/ToEnumArguments: # new in 1.1
395
+ Enabled: true
396
+
397
+ Lint/TripleQuotes: # new in 1.9
398
+ Enabled: true
399
+
400
+ Lint/UnexpectedBlockArity: # new in 1.5
401
+ Enabled: true
402
+
403
+ Lint/UnmodifiedReduceAccumulator: # new in 1.1
404
+ Enabled: true
405
+
406
+ Lint/UselessRuby2Keywords: # new in 1.23
407
+ Enabled: true
408
+
409
+ Security/IoMethods: # new in 1.22
410
+ Enabled: true
411
+
412
+ Style/ArgumentsForwarding: # new in 1.1
413
+ Enabled: true
414
+
415
+ Style/CollectionCompact: # new in 1.2
416
+ Enabled: true
417
+
418
+ Style/DocumentDynamicEvalDefinition: # new in 1.1
419
+ Enabled: true
420
+
421
+ Style/EndlessMethod: # new in 1.8
422
+ Enabled: true
423
+
424
+ Style/HashConversion: # new in 1.10
425
+ Enabled: true
426
+
427
+ Style/HashExcept: # new in 1.7
428
+ Enabled: true
429
+
430
+ Style/IfWithBooleanLiteralBranches: # new in 1.9
431
+ Enabled: true
432
+
433
+ Style/InPatternThen: # new in 1.16
434
+ Enabled: true
435
+
436
+ Style/MultilineInPatternThen: # new in 1.16
437
+ Enabled: true
438
+
439
+ Style/NegatedIfElseCondition: # new in 1.2
440
+ Enabled: true
441
+
442
+ Style/NilLambda: # new in 1.3
443
+ Enabled: true
444
+
445
+ Style/NumberedParameters: # new in 1.22
446
+ Enabled: true
447
+
448
+ Style/NumberedParametersLimit: # new in 1.22
449
+ Enabled: true
450
+
451
+ Style/OpenStructUse: # new in 1.23
452
+ Enabled: true
453
+
454
+ Style/QuotedSymbols: # new in 1.16
455
+ Enabled: true
456
+
457
+ Style/RedundantArgument: # new in 1.4
458
+ Enabled: true
459
+
460
+ Style/RedundantSelfAssignmentBranch: # new in 1.19
461
+ Enabled: true
462
+
463
+ Style/SelectByRegexp: # new in 1.22
464
+ Enabled: true
465
+
466
+ Style/StringChars: # new in 1.12
467
+ Enabled: true
468
+
469
+ Style/SwapValues: # new in 1.1
470
+ Enabled: true
471
+
472
+ Performance/AncestorsInclude: # new in 1.7
473
+ Enabled: true
474
+
475
+ Performance/BigDecimalWithNumericArgument: # new in 1.7
476
+ Enabled: true
477
+
478
+ Performance/BlockGivenWithExplicitBlock: # new in 1.9
479
+ Enabled: true
480
+
481
+ Performance/CollectionLiteralInLoop: # new in 1.8
482
+ Enabled: true
483
+
484
+ Performance/ConcurrentMonotonicTime: # new in 1.12
485
+ Enabled: true
486
+
487
+ Performance/ConstantRegexp: # new in 1.9
488
+ Enabled: true
489
+
490
+ Performance/MapCompact: # new in 1.11
491
+ Enabled: true
492
+
493
+ Performance/MethodObjectAsBlock: # new in 1.9
494
+ Enabled: true
495
+
496
+ Performance/RedundantEqualityComparisonBlock: # new in 1.10
497
+ Enabled: true
498
+
499
+ Performance/RedundantSortBlock: # new in 1.7
500
+ Enabled: true
501
+
502
+ Performance/RedundantSplitRegexpArgument: # new in 1.10
503
+ Enabled: true
504
+
505
+ Performance/RedundantStringChars: # new in 1.7
506
+ Enabled: true
507
+
508
+ Performance/ReverseFirst: # new in 1.7
509
+ Enabled: true
510
+
511
+ Performance/SortReverse: # new in 1.7
512
+ Enabled: true
513
+
514
+ Performance/Squeeze: # new in 1.7
515
+ Enabled: true
516
+
517
+ Performance/StringInclude: # new in 1.7
518
+ Enabled: true
519
+
520
+ Performance/Sum: # new in 1.8
521
+ Enabled: true
522
+
523
+ Rails/ActiveRecordCallbacksOrder: # new in 2.7
524
+ Enabled: true
525
+
526
+ Rails/AddColumnIndex: # new in 2.11
527
+ Enabled: true
528
+
529
+ Rails/AfterCommitOverride: # new in 2.8
530
+ Enabled: true
531
+
532
+ Rails/AttributeDefaultBlockValue: # new in 2.9
533
+ Enabled: true
534
+
535
+ Rails/EagerEvaluationLogMessage: # new in 2.11
536
+ Enabled: true
537
+
538
+ Rails/ExpandedDateRange: # new in 2.11
539
+ Enabled: true
540
+
541
+ Rails/FindById: # new in 2.7
542
+ Enabled: true
543
+
544
+ Rails/I18nLocaleAssignment: # new in 2.11
545
+ Enabled: true
546
+
547
+ Rails/Inquiry: # new in 2.7
548
+ Enabled: true
549
+
550
+ Rails/MailerName: # new in 2.7
551
+ Enabled: true
552
+
553
+ Rails/MatchRoute: # new in 2.7
554
+ Enabled: true
555
+
556
+ Rails/NegateInclude: # new in 2.7
557
+ Enabled: true
558
+
559
+ Rails/Pluck: # new in 2.7
560
+ Enabled: true
561
+
562
+ Rails/PluckInWhere: # new in 2.7
563
+ Enabled: true
564
+
565
+ Rails/RedundantTravelBack: # new in 2.12
566
+ Enabled: true
567
+
568
+ Rails/RenderInline: # new in 2.7
569
+ Enabled: true
570
+
571
+ Rails/RenderPlainText: # new in 2.7
572
+ Enabled: true
573
+
574
+ Rails/ShortI18n: # new in 2.7
575
+ Enabled: true
576
+
577
+ Rails/SquishedSQLHeredocs: # new in 2.8
578
+ Enabled: true
579
+
580
+ Rails/TimeZoneAssignment: # new in 2.10
581
+ Enabled: true
582
+
583
+ Rails/UnusedIgnoredColumns: # new in 2.11
584
+ Enabled: true
585
+
586
+ Rails/WhereEquals: # new in 2.9
587
+ Enabled: true
588
+
589
+ Rails/WhereExists: # new in 2.7
590
+ Enabled: true
591
+
592
+ Rails/WhereNot: # new in 2.8
593
+ Enabled: true
594
+
595
+ Gemspec/RequiredRubyVersion:
596
+ Enabled: false
597
+
598
+ GraphQL/FieldDescription:
599
+ Enabled: false
600
+
601
+ GraphQL/ObjectDescription:
602
+ Enabled: true
603
+ Exclude:
604
+ - app/graphql/policies/*.rb
605
+ - app/graphql/*.rb
606
+
607
+ GraphQL/ExtractType:
608
+ Enabled: false
609
+
610
+ Rails/UnknownEnv:
611
+ Environments:
612
+ - production
613
+ - development
614
+ - test
615
+ - staging
@@ -52,11 +52,15 @@ module Ibrain
52
52
  # This one will be defined by apps looking to hook into Ibrain
53
53
  # As per authentication_helpers.rb
54
54
  if respond_to?(:ibrain_current_user, true)
55
- ibrain_current_user
55
+ try(:ibrain_current_user)
56
56
  # This one will be defined by Devise
57
57
  elsif respond_to?(:current_ibrain_user, true)
58
- current_ibrain_user
58
+ try(:current_ibrain_user)
59
59
  end
60
+ rescue StandardError => e
61
+ Ibrain::Logger.warn e.message.to_s
62
+
63
+ nil
60
64
  end
61
65
  end
62
66
  end
@@ -1,14 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ibrain
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.5"
5
5
 
6
6
  def self.ibrain_version
7
7
  VERSION
8
8
  end
9
9
 
10
10
  def self.previous_ibrain_minor_version
11
- '0.1.0'
11
+ '0.1.4'
12
12
  end
13
13
 
14
14
  def self.ibrain_gem_version
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ibrain-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tai Nguyen Van
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-19 00:00:00.000000000 Z
11
+ date: 2021-12-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord-session_store
@@ -210,6 +210,7 @@ files:
210
210
  - app/models/ibrain/legacy_user.rb
211
211
  - app/models/ibrain/role.rb
212
212
  - app/models/ibrain/role_user.rb
213
+ - app/repositories/ibrain/base_repository.rb
213
214
  - config/initializers/friendly_id.rb
214
215
  - config/locales/en.yml
215
216
  - config/locales/jp.yml
@@ -223,6 +224,7 @@ files:
223
224
  - lib/generators/ibrain/graphql/templates/aggregate.erb
224
225
  - lib/generators/ibrain/graphql/templates/mutation.erb
225
226
  - lib/generators/ibrain/graphql/templates/object.erb
227
+ - lib/generators/ibrain/graphql/templates/repository.erb
226
228
  - lib/generators/ibrain/graphql/templates/resolver.erb
227
229
  - lib/generators/ibrain/graphql/templates/resolvers.erb
228
230
  - lib/generators/ibrain/graphql/type_generator.rb