ibrain-core 0.1.0 → 0.1.4

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/README.md +1 -1
  3. data/app/controllers/ibrain/graphql_controller.rb +1 -1
  4. data/app/graphql/ibrain/interfaces/record_interface.rb +0 -2
  5. data/app/graphql/ibrain/resolvers/base_resolver.rb +1 -1
  6. data/app/graphql/ibrain/types/base_node.rb +1 -1
  7. data/app/graphql/ibrain/types/base_object.rb +1 -1
  8. data/app/models/ibrain/base.rb +18 -12
  9. data/app/repositories/ibrain/base_repository.rb +18 -0
  10. data/lib/generators/ibrain/graphql/core.rb +4 -0
  11. data/lib/generators/ibrain/graphql/mutation_generator.rb +4 -0
  12. data/lib/generators/ibrain/graphql/object_generator.rb +7 -0
  13. data/lib/generators/ibrain/graphql/resolver_generator.rb +4 -0
  14. data/lib/generators/ibrain/graphql/resolvers_generator.rb +4 -0
  15. data/lib/generators/ibrain/graphql/templates/aggregate.erb +5 -2
  16. data/lib/generators/ibrain/graphql/templates/mutation.erb +8 -2
  17. data/lib/generators/ibrain/graphql/templates/object.erb +4 -0
  18. data/lib/generators/ibrain/graphql/templates/repository.erb +19 -0
  19. data/lib/generators/ibrain/graphql/templates/resolver.erb +8 -3
  20. data/lib/generators/ibrain/graphql/templates/resolvers.erb +8 -3
  21. data/lib/generators/ibrain/install/install_generator.rb +5 -15
  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 +615 -0
  26. data/lib/ibrain/core/controller_helpers/auth.rb +6 -2
  27. data/lib/ibrain/core/version.rb +2 -2
  28. metadata +5 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e306b2238fba539d079c52bbb0c6b6bb2ff1092e9f950c4c6fd85065b2325fa3
4
- data.tar.gz: d9ae60e6b5769f14339bcdba97ed42538523c34aa9d382454496d0ac49f1d320
3
+ metadata.gz: 4037e5cd9ca8b82b658114e6d61cf5376861c2d39dc0ad5b63e1a41a56ef482b
4
+ data.tar.gz: a1723cc8a56105297c25e92286d8547d9aead9936b342cf40b1adf19b156398b
5
5
  SHA512:
6
- metadata.gz: 3ae2d1c79c5931769a432d6532f104c88245afb7df5dc3d0af557b3496b215548cbae686203f229c7d5bac7226000e39caad0ffe42fae0361fe19b1ca64f38df
7
- data.tar.gz: 6b34268ff18f1eb0daafcd47d2b7a32f48360370ddc7367c18d5399048b69ca391758b4e0fdaa137a3a6f9d73d7cf02c84d828fe000a0ba7911d99d934dabe7e
6
+ metadata.gz: 5459ecaf4eb74fe6afa3a482040a3495d189f1a583344527b585be5203b58ba440bfceadcf8b14f5c7530fc3bc74f3d6ba2b093afb28c89a0d93efed8c553ad7
7
+ data.tar.gz: 3bdf0366d1c33131c247c767fe9ee8dd3c4637e453124d1ad04c93b8712b62a802276ddab578a372950db3ab5317162ff0868795ec3c9f1bc716f383a0c31ea2
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
  This is core plugin for rails api project
3
3
 
4
4
  ## Usage
5
- How to use my plugin.
5
+ Please remove puma gem from your project before add this gem
6
6
 
7
7
  ## Installation
8
8
  Add this line to your application's Gemfile:
@@ -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)
@@ -5,16 +5,12 @@ class Ibrain::Base < Ibrain::ApplicationRecord
5
5
 
6
6
  self.abstract_class = true
7
7
 
8
- def self.adjust_date_for_cdt(datetime)
9
- datetime.in_time_zone('UTC')
10
- end
11
-
12
8
  def string_id
13
9
  try(:id).try(:to_s)
14
10
  end
15
11
 
16
12
  scope :graphql_ransack, lambda { |params|
17
- ransack(params).result(distinct: true)
13
+ ransack(params).result
18
14
  }
19
15
 
20
16
  scope :reverse_scope, lambda {
@@ -36,12 +32,22 @@ class Ibrain::Base < Ibrain::ApplicationRecord
36
32
  time_ago_in_words(created_at)
37
33
  end
38
34
 
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)
35
+ class << self
36
+ # Provides a scope that should be included any time data
37
+ # are fetched with the intention of displaying to the user.
38
+ #
39
+ # Allows individual stores to include any active record scopes or joins
40
+ # when data are displayed.
41
+ def display_includes
42
+ where(nil)
43
+ end
44
+
45
+ def paginate(args)
46
+ limit(args[:limit]).offset(args[:offset])
47
+ end
48
+
49
+ def adjust_date_for_cdt(datetime)
50
+ datetime.in_time_zone('UTC')
51
+ end
46
52
  end
47
53
  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]}
@@ -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 }
@@ -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
@@ -0,0 +1,615 @@
1
+ # Relaxed.Ruby.Style
2
+
3
+ require:
4
+ - rubocop-performance
5
+ - rubocop-rails
6
+ - rubocop-graphql
7
+
8
+ AllCops:
9
+ TargetRubyVersion: 2.5
10
+
11
+ # We use class vars and will have to continue doing so for compatability
12
+ Style/ClassVars:
13
+ Enabled: false
14
+
15
+ # We need these names for backwards compatability
16
+ Naming/PredicateName:
17
+ Enabled: false
18
+
19
+ # We want to name rescued errors as error not simply e.
20
+ Naming/RescuedExceptionsVariableName:
21
+ Enabled: false
22
+
23
+ Naming/AccessorMethodName:
24
+ Enabled: false
25
+
26
+ # This has been used for customization
27
+ Style/MutableConstant:
28
+ Enabled: false
29
+
30
+ Style/ClassAndModuleChildren:
31
+ Enabled: false
32
+
33
+ Style/EmptyElse:
34
+ Enabled: false
35
+
36
+ Style/GuardClause:
37
+ Enabled: false
38
+
39
+ Style/Next:
40
+ Enabled: false
41
+
42
+ Style/NumericPredicate:
43
+ Enabled: false
44
+
45
+ Style/WordArray:
46
+ Enabled: false
47
+
48
+ Style/ConditionalAssignment:
49
+ Enabled: false
50
+
51
+ Performance/Count:
52
+ Enabled: false
53
+
54
+ Style/RaiseArgs:
55
+ Enabled: false
56
+
57
+ Naming/BinaryOperatorParameterName:
58
+ Enabled: false
59
+
60
+ # We can use good judgement here
61
+ Style/RegexpLiteral:
62
+ Enabled: false
63
+
64
+ # Unicode comments are useful
65
+ Style/AsciiComments:
66
+ Enabled: false
67
+
68
+ Layout/EndAlignment:
69
+ Enabled: false
70
+
71
+ Layout/ElseAlignment:
72
+ Enabled: false
73
+
74
+ Layout/IndentationWidth:
75
+ Enabled: false
76
+
77
+ Layout/ParameterAlignment:
78
+ Enabled: false
79
+
80
+ Layout/ClosingParenthesisIndentation:
81
+ Enabled: false
82
+
83
+ Layout/MultilineMethodCallIndentation:
84
+ Enabled: false
85
+
86
+ Layout/FirstArrayElementIndentation:
87
+ Enabled: false
88
+
89
+ Layout/FirstHashElementIndentation:
90
+ Enabled: false
91
+
92
+ Layout/HashAlignment:
93
+ Enabled: false
94
+
95
+ Style/TrailingCommaInArguments:
96
+ Enabled: false
97
+
98
+ Style/TrailingCommaInArrayLiteral:
99
+ Enabled: false
100
+
101
+ Style/TrailingCommaInHashLiteral:
102
+ Enabled: false
103
+
104
+ # Symbol Arrays are ok and the %i syntax widely unknown
105
+ Style/SymbolArray:
106
+ Enabled: false
107
+
108
+ Rails/DynamicFindBy:
109
+ Whitelist:
110
+ - find_by_param
111
+ - find_by_param!
112
+
113
+ # It's okay to skip model validations to setup a spec.
114
+ Rails/SkipsModelValidations:
115
+ Exclude:
116
+ - db/seeds/**/*.rb
117
+ - '*/spec/**/*'
118
+
119
+ # We use a lot of
120
+ #
121
+ # expect {
122
+ # something
123
+ # }.to { happen }
124
+ #
125
+ # syntax in the specs files.
126
+ Lint/AmbiguousBlockAssociation:
127
+ Exclude:
128
+ - '*/spec/**/*'
129
+ - 'spec/**/*' # For the benefit of apps that inherit from this config
130
+
131
+ Security/Eval:
132
+ Exclude:
133
+ - 'Gemfile'
134
+ - '*/Gemfile'
135
+
136
+ Naming/VariableNumber:
137
+ Enabled: false
138
+
139
+ # Write empty methods as you wish.
140
+ Style/EmptyMethod:
141
+ Enabled: false
142
+
143
+ # From http://relaxed.ruby.style/
144
+
145
+ Style/Alias:
146
+ Enabled: false
147
+ StyleGuide: http://relaxed.ruby.style/#stylealias
148
+
149
+ Style/BeginBlock:
150
+ Enabled: false
151
+ StyleGuide: http://relaxed.ruby.style/#stylebeginblock
152
+
153
+ Style/BlockDelimiters:
154
+ Enabled: false
155
+ StyleGuide: http://relaxed.ruby.style/#styleblockdelimiters
156
+
157
+ Style/Documentation:
158
+ Enabled: false
159
+ StyleGuide: http://relaxed.ruby.style/#styledocumentation
160
+
161
+ Layout/DotPosition:
162
+ Enabled: false
163
+ StyleGuide: http://relaxed.ruby.style/#styledotposition
164
+
165
+ Style/DoubleNegation:
166
+ Enabled: false
167
+ StyleGuide: http://relaxed.ruby.style/#styledoublenegation
168
+
169
+ Style/EndBlock:
170
+ Enabled: false
171
+ StyleGuide: http://relaxed.ruby.style/#styleendblock
172
+
173
+ Style/FormatString:
174
+ Enabled: false
175
+ StyleGuide: http://relaxed.ruby.style/#styleformatstring
176
+
177
+ Style/IfUnlessModifier:
178
+ Enabled: false
179
+ StyleGuide: http://relaxed.ruby.style/#styleifunlessmodifier
180
+
181
+ Style/Lambda:
182
+ Enabled: false
183
+ StyleGuide: http://relaxed.ruby.style/#stylelambda
184
+
185
+ Style/ModuleFunction:
186
+ Enabled: false
187
+ StyleGuide: http://relaxed.ruby.style/#stylemodulefunction
188
+
189
+ Style/MultilineBlockChain:
190
+ Enabled: false
191
+ StyleGuide: http://relaxed.ruby.style/#stylemultilineblockchain
192
+
193
+ Style/NegatedIf:
194
+ Enabled: false
195
+ StyleGuide: http://relaxed.ruby.style/#stylenegatedif
196
+
197
+ Style/NegatedWhile:
198
+ Enabled: false
199
+ StyleGuide: http://relaxed.ruby.style/#stylenegatedwhile
200
+
201
+ Style/ParallelAssignment:
202
+ Enabled: false
203
+ StyleGuide: http://relaxed.ruby.style/#styleparallelassignment
204
+
205
+ Style/PercentLiteralDelimiters:
206
+ Enabled: false
207
+ StyleGuide: http://relaxed.ruby.style/#stylepercentliteraldelimiters
208
+
209
+ Style/PerlBackrefs:
210
+ Enabled: false
211
+ StyleGuide: http://relaxed.ruby.style/#styleperlbackrefs
212
+
213
+ Style/Semicolon:
214
+ Enabled: false
215
+ StyleGuide: http://relaxed.ruby.style/#stylesemicolon
216
+
217
+ Style/SignalException:
218
+ Enabled: false
219
+ StyleGuide: http://relaxed.ruby.style/#stylesignalexception
220
+
221
+ Style/SingleLineBlockParams:
222
+ Enabled: false
223
+ StyleGuide: http://relaxed.ruby.style/#stylesinglelineblockparams
224
+
225
+ Style/SingleLineMethods:
226
+ Enabled: false
227
+ StyleGuide: http://relaxed.ruby.style/#stylesinglelinemethods
228
+
229
+ Layout/SpaceBeforeBlockBraces:
230
+ Enabled: false
231
+ StyleGuide: http://relaxed.ruby.style/#stylespacebeforeblockbraces
232
+
233
+ Layout/SpaceInsideParens:
234
+ Enabled: false
235
+ StyleGuide: http://relaxed.ruby.style/#stylespaceinsideparens
236
+
237
+ Style/SpecialGlobalVars:
238
+ Enabled: false
239
+ StyleGuide: http://relaxed.ruby.style/#stylespecialglobalvars
240
+
241
+ Style/StringLiterals:
242
+ Enabled: false
243
+ StyleGuide: http://relaxed.ruby.style/#stylestringliterals
244
+
245
+ Style/SymbolProc:
246
+ Enabled: false
247
+
248
+ Style/TernaryParentheses:
249
+ Enabled: false
250
+
251
+ Style/WhileUntilModifier:
252
+ Enabled: false
253
+ StyleGuide: http://relaxed.ruby.style/#stylewhileuntilmodifier
254
+
255
+ Lint/AmbiguousRegexpLiteral:
256
+ Enabled: false
257
+ StyleGuide: http://relaxed.ruby.style/#lintambiguousregexpliteral
258
+
259
+ Lint/AssignmentInCondition:
260
+ Enabled: false
261
+ StyleGuide: http://relaxed.ruby.style/#lintassignmentincondition
262
+
263
+ Metrics/AbcSize:
264
+ Enabled: false
265
+
266
+ Metrics/BlockNesting:
267
+ Enabled: false
268
+
269
+ Metrics/ClassLength:
270
+ Enabled: false
271
+
272
+ Metrics/ModuleLength:
273
+ Enabled: false
274
+
275
+ Metrics/BlockLength:
276
+ Enabled: false
277
+
278
+ Metrics/CyclomaticComplexity:
279
+ Enabled: false
280
+
281
+ Layout/LineLength:
282
+ Enabled: false
283
+
284
+ Metrics/MethodLength:
285
+ Enabled: false
286
+
287
+ Metrics/ParameterLists:
288
+ Enabled: false
289
+
290
+ Metrics/PerceivedComplexity:
291
+ Enabled: false
292
+
293
+ Bundler/OrderedGems:
294
+ Enabled: false
295
+
296
+ Style/NumericLiterals:
297
+ Enabled: false
298
+
299
+ Style/FrozenStringLiteralComment:
300
+ Enabled: true
301
+ EnforcedStyle: always
302
+
303
+ # json.() is idiomatic in jbuilder files
304
+ Style/LambdaCall:
305
+ Enabled: false
306
+
307
+ Naming/MethodParameterName:
308
+ AllowedNames:
309
+ - id
310
+ - to
311
+ - _
312
+
313
+ # Rubocop doesn't understand side-effects
314
+ Style/IdenticalConditionalBranches:
315
+ Enabled: false
316
+
317
+ Naming/MemoizedInstanceVariableName:
318
+ Enabled: false
319
+
320
+ Lint/BinaryOperatorWithIdenticalOperands:
321
+ Enabled: false
322
+
323
+ Lint/SuppressedException:
324
+ Enabled: false
325
+
326
+ Rails/ReflectionClassName:
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.0"
4
+ VERSION = "0.1.4"
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.3'
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.0
4
+ version: 0.1.4
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-20 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
@@ -234,6 +236,7 @@ files:
234
236
  - lib/generators/ibrain/install/templates/graphql/app_schema.rb.tt
235
237
  - lib/generators/ibrain/install/templates/graphql/types/mutation_type.rb.tt
236
238
  - lib/generators/ibrain/install/templates/graphql/types/query_type.rb.tt
239
+ - lib/generators/ibrain/install/templates/rubocop.yml.tt
237
240
  - lib/ibrain/app_configuration.rb
238
241
  - lib/ibrain/config.rb
239
242
  - lib/ibrain/core.rb