modulorails 1.0.2 → 1.2.0

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 (38) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +216 -12
  3. data/Appraisals +6 -6
  4. data/CHANGELOG.md +18 -0
  5. data/app/helpers/modulorails/application_helper.rb +4 -2
  6. data/gemfiles/rails_52.gemfile +5 -5
  7. data/gemfiles/rails_60.gemfile +5 -5
  8. data/gemfiles/rails_61.gemfile +5 -5
  9. data/gemfiles/rails_70.gemfile +5 -5
  10. data/lib/generators/modulorails/bundleraudit/bundleraudit_generator.rb +26 -0
  11. data/lib/generators/modulorails/docker/docker_generator.rb +10 -1
  12. data/lib/generators/modulorails/docker/templates/Dockerfile.prod.tt +6 -1
  13. data/lib/generators/modulorails/docker/templates/Dockerfile.tt +3 -0
  14. data/lib/generators/modulorails/docker/templates/config/database.yml.tt +1 -1
  15. data/lib/generators/modulorails/docker/templates/docker-compose.yml.tt +6 -1
  16. data/lib/generators/modulorails/docker/templates/entrypoints/docker-entrypoint.sh.tt +2 -2
  17. data/lib/generators/modulorails/gitlabci/gitlabci_generator.rb +4 -2
  18. data/lib/generators/modulorails/gitlabci/templates/.gitlab-ci.yml.tt +7 -0
  19. data/lib/generators/modulorails/healthcheck/health_check_generator.rb +8 -5
  20. data/lib/generators/modulorails/rubocop/rubocop_generator.rb +8 -6
  21. data/lib/generators/modulorails/rubocop/templates/rubocop.yml.tt +252 -3
  22. data/lib/generators/modulorails/self_update/self_update_generator.rb +6 -3
  23. data/lib/generators/modulorails/service/service_generator.rb +3 -1
  24. data/lib/modulorails/configuration.rb +4 -0
  25. data/lib/modulorails/data.rb +113 -62
  26. data/lib/modulorails/error_data.rb +2 -0
  27. data/lib/modulorails/errors/invalid_format_error.rb +2 -0
  28. data/lib/modulorails/errors/invalid_value_error.rb +2 -0
  29. data/lib/modulorails/railtie.rb +8 -1
  30. data/lib/modulorails/services/base_service.rb +17 -15
  31. data/lib/modulorails/services/logs_for_method_service.rb +1 -0
  32. data/lib/modulorails/success_data.rb +2 -0
  33. data/lib/modulorails/validators/database_configuration.rb +19 -9
  34. data/lib/modulorails/version.rb +3 -1
  35. data/lib/modulorails.rb +48 -33
  36. data/modulorails.gemspec +9 -7
  37. metadata +46 -32
  38. data/lib/generators/modulorails/gitlabci/templates/config/database-ci.yml.tt +0 -8
@@ -9,10 +9,259 @@
9
9
  #
10
10
  # See https://docs.rubocop.org/rubocop/configuration
11
11
 
12
- inherit_gem:
13
- modulorails: .rubocop.yml
12
+ # Enabling Rails-specific cops.
13
+ require: rubocop-rails
14
14
 
15
- # Take into account the exclude list from the gem
16
15
  inherit_mode:
17
16
  merge:
18
17
  - Exclude
18
+ - Include
19
+
20
+ AllCops:
21
+ # No suggestions since the gem is the sole truth for rubocop configuration.
22
+ SuggestExtensions: false
23
+
24
+ # Enable new cops by default
25
+ NewCops: enable
26
+
27
+ # Excluding most directories with generated files and directories with configuration files.
28
+ Exclude:
29
+ - 'vendor/**/*'
30
+ - 'db/**/*'
31
+ - 'tmp/**/*'
32
+ - 'bin'
33
+ - '**/Gemfile'
34
+ - '**/Guardfile'
35
+ - '**/Capfile'
36
+ - '**/Rakefile'
37
+ - 'config/**/*'
38
+ - 'test/**/*'
39
+ - 'node_modules/**/*'
40
+ - 'spec/**/*'
41
+
42
+ # Instructing rubocop about all standard Modulotech environments.
43
+ Rails/UnknownEnv:
44
+ Environments:
45
+ - production
46
+ - development
47
+ - test
48
+ - staging
49
+ - preprod
50
+
51
+ # Checks if String literals are using single quotes when no interpolation is required
52
+ Style/StringLiterals:
53
+ Enabled: true
54
+ EnforcedStyle: single_quotes
55
+ ConsistentQuotesInMultiline: false
56
+
57
+ # Checks if the quotes used for quoted symbols are single quotes when no interpolation is required
58
+ Style/QuotedSymbols:
59
+ Enabled: true
60
+ EnforcedStyle: same_as_string_literals
61
+
62
+ # This cop checks for uses of literal strings converted to a symbol where a literal symbol could be used instead.
63
+ Lint/SymbolConversion:
64
+ Enabled: true
65
+ EnforcedStyle: strict
66
+
67
+ # Useless cop. It checks for unnecessary safe navigations.
68
+ # Example:
69
+ # obj&.a && obj.b
70
+ # Triggers rubocop error: it requires to add safe navigation for "obj.b" call => "obj&.b".
71
+ # but it is not necessary. obj&.a will return nil if obj is nil, and it will stop
72
+ # execution of the operation because `&&` right part executes only when left part is truthy.
73
+ Lint/SafeNavigationConsistency:
74
+ Enabled: false
75
+
76
+ # Checks for places where keyword arguments can be used instead of boolean arguments when defining methods.
77
+ # Disabled because moving from default arguments to keywords is not that easy.
78
+ Style/OptionalBooleanParameter:
79
+ Enabled: false
80
+
81
+ # Checks for use of the lambda.(args) syntax.
82
+ # Disabled while the Ruby team has not voted on this.
83
+ Style/LambdaCall:
84
+ Enabled: false
85
+ EnforcedStyle: braces
86
+
87
+ # Checks for presence or absence of braces around hash literal as a last array item depending on configuration.
88
+ # Disabled because it would break a lot of permitted_params definitions
89
+ Style/HashAsLastArrayItem:
90
+ Enabled: false
91
+
92
+ # Checks for grouping of accessors in class and module bodies.
93
+ # Useless.
94
+ Style/AccessorGrouping:
95
+ Enabled: false
96
+
97
+ # Makes our lives happier: we don't need to disable it in each case/when method
98
+ # with more than 5 "when"s.
99
+ Metrics/CyclomaticComplexity:
100
+ Max: 10
101
+
102
+ # Commonly used screens these days easily fit more than 80 characters.
103
+ Layout/LineLength:
104
+ Max: 100
105
+
106
+ # Too short methods lead to extraction of single-use methods, which can make
107
+ # the code easier to read (by naming things), but can also clutter the class
108
+ Metrics/MethodLength:
109
+ Max: 20
110
+
111
+ # The guiding principle of classes is SRP, SRP can't be accurately measured by LoC
112
+ Metrics/ClassLength:
113
+ Max: 1500
114
+
115
+ # No space makes the method definition shorter and differentiates
116
+ # from a regular assignment.
117
+ Layout/SpaceAroundEqualsInParameterDefault:
118
+ EnforcedStyle: no_space
119
+
120
+ # We do not need to support Ruby 1.9, so this is good to use.
121
+ Style/SymbolArray:
122
+ Enabled: true
123
+
124
+ # Most readable form.
125
+ Layout/HashAlignment:
126
+ EnforcedHashRocketStyle: table
127
+ EnforcedColonStyle: table
128
+
129
+ # Mixing the styles looks just silly.
130
+ Style/HashSyntax:
131
+ EnforcedStyle: ruby19_no_mixed_keys
132
+
133
+ # has_key? and has_value? are far more readable than key? and value?
134
+ Style/PreferredHashMethods:
135
+ Enabled: false
136
+
137
+ # String#% is by far the least verbose and only object oriented variant.
138
+ Style/FormatString:
139
+ EnforcedStyle: percent
140
+
141
+ # Annotated or template are too verbose and rarely needed.
142
+ Style/FormatStringToken:
143
+ EnforcedStyle: unannotated
144
+
145
+ Style/CollectionMethods:
146
+ Enabled: true
147
+ PreferredMethods:
148
+ # inject seems more common in the community.
149
+ reduce: "inject"
150
+
151
+ # Either allow this style or don't. Marking it as safe with parenthesis
152
+ # is silly. Let's try to live without them for now.
153
+ Style/ParenthesesAroundCondition:
154
+ AllowSafeAssignment: false
155
+ Lint/AssignmentInCondition:
156
+ AllowSafeAssignment: false
157
+
158
+ # A specialized exception class will take one or more arguments and construct the message from it.
159
+ # So both variants make sense.
160
+ Style/RaiseArgs:
161
+ Enabled: false
162
+
163
+ # Indenting the chained dots beneath each other is not supported by this cop,
164
+ # see https://github.com/bbatsov/rubocop/issues/1633
165
+ Layout/MultilineOperationIndentation:
166
+ Enabled: false
167
+
168
+ # Fail is an alias of raise. Avoid aliases, it's more cognitive load for no gain.
169
+ # The argument that fail should be used to abort the program is wrong too,
170
+ # there's Kernel#abort for that.
171
+ Style/SignalException:
172
+ EnforcedStyle: only_raise
173
+
174
+ # Suppressing exceptions can be perfectly fine, and be it to avoid to
175
+ # explicitly type nil into the rescue since that's what you want to return,
176
+ # or suppressing LoadError for optional dependencies
177
+ Lint/SuppressedException:
178
+ Enabled: false
179
+
180
+ # { ... } for multi-line blocks is okay, follow Weirichs rule instead:
181
+ # https://web.archive.org/web/20140221124509/http://onestepback.org/index.cgi/Tech/Ruby/BraceVsDoEnd.rdoc
182
+ Style/BlockDelimiters:
183
+ Enabled: false
184
+
185
+ # do / end blocks should be used for side effects,
186
+ # methods that run a block for side effects and have
187
+ # a useful return value are rare, assign the return
188
+ # value to a local variable for those cases.
189
+ Style/MethodCalledOnDoEndBlock:
190
+ Enabled: true
191
+
192
+ # Enforcing the names of variables? To single letter ones? Just no.
193
+ Style/SingleLineBlockParams:
194
+ Enabled: false
195
+
196
+ # Shadowing outer local variables with block parameters is often useful
197
+ # to not reinvent a new name for the same thing, it highlights the relation
198
+ # between the outer variable and the parameter. The cases where it's actually
199
+ # confusing are rare, and usually bad for other reasons already, for example
200
+ # because the method is too long.
201
+ Lint/ShadowingOuterLocalVariable:
202
+ Enabled: false
203
+
204
+ # Check with yard instead.
205
+ Style/Documentation:
206
+ Enabled: false
207
+
208
+ # This is just silly. Calling the argument `other` in all cases makes no sense.
209
+ Naming/BinaryOperatorParameterName:
210
+ Enabled: false
211
+
212
+ # Disable frozen string
213
+ Style/FrozenStringLiteralComment:
214
+ Enabled: false
215
+
216
+ # Disable No ASCII char in comments
217
+ Style/AsciiComments:
218
+ Enabled: false
219
+
220
+ # Disable ordered Gems By ascii
221
+ Bundler/OrderedGems:
222
+ Enabled: false
223
+
224
+ # Change ABC max value
225
+ Metrics/AbcSize:
226
+ Max: 35
227
+
228
+ # Disable empty method in one line
229
+ Style/EmptyMethod:
230
+ EnforcedStyle: expanded
231
+
232
+ # Disable max height block
233
+ Metrics/BlockLength:
234
+ Enabled: true
235
+ Exclude:
236
+ - 'app/admin/**/*'
237
+ - 'lib/tasks/**/*'
238
+
239
+ # Checks if empty lines around the bodies of classes match the configuration.
240
+ Layout/EmptyLinesAroundClassBody:
241
+ EnforcedStyle: empty_lines
242
+ # Checks if empty lines around the bodies of modules match the configuration.
243
+ Layout/EmptyLinesAroundModuleBody:
244
+ EnforcedStyle: empty_lines
245
+
246
+ # Enforces the consistent usage of %-literal delimiters.
247
+ Style/PercentLiteralDelimiters:
248
+ PreferredDelimiters:
249
+ default: '()'
250
+ '%i': '[]'
251
+ '%I': '[]'
252
+ '%r': '{}'
253
+ '%w': '[]'
254
+ '%W': '[]'
255
+
256
+ # Unnecessary cop. In what universe "A || B && C" or "A && B || C && D" is ambiguous? looks
257
+ # like a cop for those who can't in boolean.
258
+ Lint/AmbiguousOperatorPrecedence:
259
+ Enabled: false
260
+
261
+ # Checks for simple usages of parallel assignment.
262
+ Style/ParallelAssignment:
263
+ Enabled: false
264
+
265
+ # Checks the style of children definitions at classes and modules.
266
+ Style/ClassAndModuleChildren:
267
+ Enabled: false
@@ -5,10 +5,11 @@ require 'rails/generators'
5
5
  # Author: Matthieu 'ciappa_m' Ciappara
6
6
  # This updates modulorails by editing the gemfile and running a bundle update
7
7
  class Modulorails::SelfUpdateGenerator < Rails::Generators::Base
8
+
8
9
  source_root File.expand_path('templates', __dir__)
9
10
  desc 'This generator updates Modulorails if required'
10
11
 
11
- LATEST_VERSION_URL = 'https://rubygems.org/api/v1/versions/modulorails/latest.json'.freeze
12
+ LATEST_VERSION_URL = 'https://rubygems.org/api/v1/versions/modulorails/latest.json'
12
13
 
13
14
  def create_config_file
14
15
  modulorails_version = Gem::Version.new(Modulorails::VERSION)
@@ -22,11 +23,13 @@ class Modulorails::SelfUpdateGenerator < Rails::Generators::Base
22
23
  return if last_published_version <= modulorails_version
23
24
 
24
25
  # Add gem to Gemfile
25
- gsub_file 'Gemfile', /^\s*gem\s['"]modulorails['"].*$/, "gem 'modulorails', '= #{last_published_version}'"
26
+ gsub_file 'Gemfile', /^\s*gem\s['"]modulorails['"].*$/,
27
+ "gem 'modulorails', '= #{last_published_version}'"
26
28
 
27
29
  # Update the gem and the Gemfile.lock
28
30
  system('bundle install')
29
31
  rescue StandardError => e
30
- $stderr.puts("[Modulorails] Error: cannot generate health_check configuration: #{e.message}")
32
+ warn("[Modulorails] Error: cannot generate health_check configuration: #{e.message}")
31
33
  end
34
+
32
35
  end
@@ -3,11 +3,13 @@
3
3
  require 'rails/generators'
4
4
 
5
5
  class Modulorails::ServiceGenerator < Rails::Generators::NamedBase
6
+
6
7
  source_root File.expand_path('templates', __dir__)
7
8
  desc 'This generator creates a service inheriting Modulorails::BaseService'
8
9
  argument :arguments, type: :array, default: [], banner: 'argument argument'
9
10
 
10
11
  def create_service_files
11
- template "service.rb", File.join("app/services", class_path, "#{file_name}_service.rb")
12
+ template 'service.rb', File.join('app/services', class_path, "#{file_name}_service.rb")
12
13
  end
14
+
13
15
  end
@@ -1,7 +1,9 @@
1
1
  module Modulorails
2
+
2
3
  # Author: Matthieu 'ciappa_m' Ciappara
3
4
  # The configuration of the gem
4
5
  class Configuration
6
+
5
7
  # All the keys to configure the gem
6
8
  attr_accessor :_name, :_main_developer, :_project_manager, :_endpoint, :_api_key,
7
9
  :_no_auto_update, :_production_url, :_staging_url, :_review_base_url
@@ -30,5 +32,7 @@ module Modulorails
30
32
  send("_#{field}=", value)
31
33
  end
32
34
  end
35
+
33
36
  end
37
+
34
38
  end
@@ -3,47 +3,90 @@ require 'active_record'
3
3
  require 'git'
4
4
 
5
5
  module Modulorails
6
+
6
7
  # Author: Matthieu 'ciappa_m' Ciappara
7
8
  # This holds the data gathered by the gem. Some come from the configuration by the gem's user.
8
9
  # Some are fetched dynamically.
9
10
  class Data
11
+
10
12
  # All the data handled by this class
11
13
  ATTRIBUTE_KEYS = %i[
12
14
  name main_developer project_manager repository type rails_name ruby_version rails_version
13
- bundler_version modulorails_version adapter db_version adapter_version production_url
14
- staging_url review_base_url
15
+ bundler_version modulorails_version adapter db_version adapter_version webpacker_version
16
+ importmap_version jsbundling_version
17
+ production_url staging_url review_base_url
15
18
  ].freeze
16
19
 
17
20
  # Useful if the gem's user need to read one of the data
18
- attr_reader *ATTRIBUTE_KEYS
21
+ attr_reader(*ATTRIBUTE_KEYS)
19
22
 
20
23
  def initialize
24
+ initialize_from_constants
25
+ initialize_from_configuration
26
+ initialize_from_database
27
+ initialize_from_gem_specs
28
+ initialize_from_git
29
+ end
30
+
31
+ # @author Matthieu 'ciappa_m' Ciappara
32
+ # @return [String] Text version of the data
33
+ def to_s
34
+ ATTRIBUTE_KEYS.map { |key| "#{key}: #{send(key)}" }.join(', ')
35
+ end
36
+
37
+ # @author Matthieu 'ciappa_m' Ciappara
38
+ # @return [Hash] The payload for the request to the intranet
39
+ def to_params
40
+ {
41
+ 'name' => @name,
42
+ 'main_developer' => @main_developer,
43
+ 'project_manager' => @project_manager,
44
+ 'repository' => @repository,
45
+ 'app_type' => @type,
46
+ 'project_data' => to_project_data_params
47
+ }
48
+ end
49
+
50
+ private
51
+
52
+ def initialize_from_constants
53
+ # The API can handle more project types but this gem is (obviously) intended for Rails
54
+ # projects only
55
+ @type = 'rails'
56
+
57
+ # The name defined for the Rails application; it can be completely different from the usual
58
+ # name or can be the same
59
+ @rails_name = ::Rails.application.class.name&.split('::')&.first
60
+
61
+ # The Ruby version used by the application
62
+ @ruby_version = RUBY_VERSION
63
+
64
+ # The version of the gem
65
+ @modulorails_version = Modulorails::VERSION
66
+ end
67
+
68
+ def initialize_from_configuration
21
69
  # Get the gem's configuration to get the application's usual name, main dev and PM
22
70
  configuration = Modulorails.configuration
23
- # Get the database connection to identify the database used by the application
24
- # or return nil if the database does not exist
25
- db_connection = begin
26
- ActiveRecord::Base.connection
27
- rescue ActiveRecord::NoDatabaseError => e
28
- $stderr.puts("[Modulorails] Error: #{e.message}")
29
- nil
30
- end
31
- # Get the gem's specifications to fetch the versions of critical gems
32
- loaded_specs = Gem.loaded_specs
33
71
 
34
72
  # The data written by the user in the configuration
35
73
  # The name is the usual name of the project, the one used in conversations at Modulotech
36
74
  @name = configuration.name
75
+
37
76
  # The main developer, the lead developer, in short the developer to call when something's
38
77
  # wrong with the application ;)
39
78
  @main_developer = configuration.main_developer
79
+
40
80
  # The project manager of the application; the other person to call when something's wrong with
41
81
  # the application ;)
42
82
  @project_manager = configuration.project_manager
83
+
43
84
  # The URL of the production environment for the application
44
85
  @production_url = configuration.production_url
86
+
45
87
  # The URL of the staging environment for the application
46
88
  @staging_url = configuration.staging_url
89
+
47
90
  # The base URL of the review environment for the application.
48
91
  # A real review URL is built like this at Modulotech:
49
92
  # https://review-#{shortened_branch_name}-#{ci_slug}.#{review_base_url}
@@ -53,21 +96,29 @@ module Modulorails
53
96
  # ci_slug: jzzham
54
97
  # |-> https://review-786-a_sup-jzzham.dev.app.com/
55
98
  @review_base_url = configuration.review_base_url
99
+ end
56
100
 
57
- # Theorically, origin is the main repository of the project and git is the sole VCS we use
58
- # at Modulotech
59
- @repository = Git.open(::Rails.root).config('remote.origin.url')
101
+ def initialize_from_database
102
+ # Get the database connection to identify the database used by the application
103
+ # or return nil if the database does not exist
104
+ db_connection = begin
105
+ ActiveRecord::Base.connection
106
+ rescue ActiveRecord::NoDatabaseError, ActiveRecord::ConnectionNotEstablished => e
107
+ warn("[Modulorails] Error: #{e.message}")
108
+ nil
109
+ end
60
110
 
61
- # The API can handle more project types but this gem is (obviously) intended for Rails
62
- # projects only
63
- @type = 'rails'
111
+ # The name of the ActiveRecord adapter; it gives the name of the database system too
112
+ @adapter = db_connection&.adapter_name&.downcase
64
113
 
65
- # The name defined for the Rails application; it can be completely different from the usual
66
- # name or can be the same
67
- @rails_name = ::Rails.application.class.name.split('::').first
114
+ # The version of the database engine; this request works only on MySQL and PostgreSQL
115
+ # It should not be a problem since those are the sole database engines used at Modulotech
116
+ @db_version = db_connection&.select_value('SELECT version()')
117
+ end
68
118
 
69
- # The Ruby version used by the application
70
- @ruby_version = RUBY_VERSION
119
+ def initialize_from_gem_specs
120
+ # Get the gem's specifications to fetch the versions of critical gems
121
+ loaded_specs = Gem.loaded_specs
71
122
 
72
123
  # The Rails version used by the application
73
124
  @rails_version = loaded_specs['rails'].version.version
@@ -76,53 +127,53 @@ module Modulorails
76
127
  # Bundler 1 are not compatible)
77
128
  @bundler_version = loaded_specs['bundler'].version.version
78
129
 
79
- # The version of the gem
80
- @modulorails_version = Modulorails::VERSION
130
+ # The version of the ActiveRecord adapter
131
+ @adapter_version = loaded_specs[@adapter]&.version&.version
81
132
 
82
- # The name of the ActiveRecord adapter; it gives the name of the database system too
83
- @adapter = db_connection&.adapter_name&.downcase
133
+ # The version of the webpacker gem - might be nil
134
+ @webpacker_version = loaded_specs['webpacker']&.version&.version
84
135
 
85
- # The version of the database engine; this request works only on MySQL and PostgreSQL
86
- # It should not be a problem since those are the sole database engines used at Modulotech
87
- @db_version = db_connection&.select_value('SELECT version()')
136
+ # The version of the importmap-rails gem - might be nil
137
+ @importmap_version = loaded_specs['importmap-rails']&.version&.version
88
138
 
89
- # The version of the ActiveRecord adapter
90
- @adapter_version = loaded_specs[@adapter]&.version&.version
139
+ # The version of the jsbundling-rails gem - might be nil
140
+ @jsbundling_version = loaded_specs['jsbundling-rails']&.version&.version
91
141
  end
92
142
 
93
- # @author Matthieu 'ciappa_m' Ciappara
94
- # @return [String] Text version of the data
95
- def to_s
96
- ATTRIBUTE_KEYS.map { |key| "#{key}: #{send(key)}" }.join(', ')
143
+ def initialize_from_git
144
+ # Theorically, origin is the main repository of the project and git is the sole VCS we use
145
+ # at Modulotech
146
+ @repository = Git.open(::Rails.root).config('remote.origin.url')
97
147
  end
98
148
 
99
- # @author Matthieu 'ciappa_m' Ciappara
100
- # @return [Hash] The payload for the request to the intranet
101
- def to_params
149
+ def to_project_data_params
102
150
  {
103
- 'name' => @name,
104
- 'main_developer' => @main_developer,
105
- 'project_manager' => @project_manager,
106
- 'repository' => @repository,
107
- 'app_type' => @type,
108
- 'project_data' => {
109
- 'name' => @rails_name,
110
- 'ruby_version' => @ruby_version,
111
- 'rails_version' => @rails_version,
112
- 'bundler_version' => @bundler_version,
113
- 'modulorails_version' => @modulorails_version,
114
- 'database' => {
115
- 'adapter' => @adapter,
116
- 'db_version' => @db_version,
117
- 'gem_version' => @adapter_version
118
- },
119
- 'urls' => {
120
- 'production' => @production_url,
121
- 'staging' => @staging_url,
122
- 'review_base' => @review_base_url
123
- }
124
- }
151
+ 'name' => @rails_name,
152
+ 'ruby_version' => @ruby_version,
153
+ 'rails_version' => @rails_version,
154
+ 'bundler_version' => @bundler_version,
155
+ 'modulorails_version' => @modulorails_version,
156
+ 'database' => to_database_params,
157
+ 'urls' => to_urls_params
158
+ }
159
+ end
160
+
161
+ def to_database_params
162
+ {
163
+ 'adapter' => @adapter,
164
+ 'db_version' => @db_version,
165
+ 'gem_version' => @adapter_version
125
166
  }
126
167
  end
168
+
169
+ def to_urls_params
170
+ {
171
+ 'production' => @production_url,
172
+ 'staging' => @staging_url,
173
+ 'review_base' => @review_base_url
174
+ }
175
+ end
176
+
127
177
  end
178
+
128
179
  end
@@ -1,6 +1,7 @@
1
1
  # @author Matthieu Ciappara <ciappa_m@modulotech>
2
2
  # An error encountered during an operation with additional data.
3
3
  class Modulorails::ErrorData
4
+
4
5
  # @!attribute r errors
5
6
  # An error message or an array of error messages (those will be joined by a coma and a space).
6
7
  # @!attribute r exception
@@ -18,4 +19,5 @@ class Modulorails::ErrorData
18
19
  def success?
19
20
  false
20
21
  end
22
+
21
23
  end
@@ -1,6 +1,7 @@
1
1
  # @author Matthieu CIAPPARA <ciappa_m@modulotech.fr>
2
2
  # An exception representing an invalid format for a given field.
3
3
  class Modulorails::InvalidFormatError < Modulorails::BaseError
4
+
4
5
  # @!attribute r field
5
6
  # The name of the field that had a wrong format.
6
7
  attr_reader :field
@@ -11,4 +12,5 @@ class Modulorails::InvalidFormatError < Modulorails::BaseError
11
12
 
12
13
  @field = field
13
14
  end
15
+
14
16
  end
@@ -1,6 +1,7 @@
1
1
  # @author Matthieu CIAPPARA <ciappa_m@modulotech.fr>
2
2
  # An exception representing an invalid value for a given field.
3
3
  class Modulorails::InvalidValueError < Modulorails::BaseError
4
+
4
5
  # @!attribute r field
5
6
  # The name of the field that had a wrong value.
6
7
  attr_reader :field
@@ -11,4 +12,5 @@ class Modulorails::InvalidValueError < Modulorails::BaseError
11
12
 
12
13
  @field = field
13
14
  end
15
+
14
16
  end
@@ -1,8 +1,10 @@
1
1
  require_relative '../../app/helpers/modulorails/application_helper'
2
2
 
3
3
  module Modulorails
4
+
4
5
  # Bind in the Rails lifecycle
5
6
  class Railtie < ::Rails::Railtie
7
+
6
8
  # Update and add gems before we load the configuration
7
9
  config.before_configuration do
8
10
  # Currently, we limit everything to the development environment
@@ -35,7 +37,7 @@ module Modulorails
35
37
  # Currently, we limit everything to the development environment
36
38
  if Rails.env.development?
37
39
  # Load translations
38
- I18n.load_path += [File.expand_path('../../../config/locales/en.yml', __FILE__)]
40
+ I18n.load_path += [File.expand_path('../../config/locales/en.yml', __dir__)]
39
41
 
40
42
  # Effectively send the data to the intranet
41
43
  Modulorails.send_data
@@ -49,9 +51,14 @@ module Modulorails
49
51
  # Add/update Rubocop config
50
52
  Modulorails.generate_rubocop_template
51
53
 
54
+ # Add/update Bundler-audit config
55
+ Modulorails.generate_bundleraudit_template
56
+
52
57
  # Gem's self-update if a new version was released
53
58
  Modulorails.self_update
54
59
  end
55
60
  end
61
+
56
62
  end
63
+
57
64
  end