Module: ConvenientService::Dependencies::Queries

Extended by:
Queries
Included in:
ConvenientService::Dependencies, Queries
Defined in:
lib/convenient_service/dependencies/queries.rb,
lib/convenient_service/dependencies/queries/ruby.rb,
lib/convenient_service/dependencies/queries/version.rb,
lib/convenient_service/dependencies/queries/gems/paint.rb,
lib/convenient_service/dependencies/queries/gems/rspec.rb,
lib/convenient_service/dependencies/queries/gems/logger.rb,
lib/convenient_service/dependencies/queries/gems/minitest.rb,
lib/convenient_service/dependencies/queries/gems/active_model.rb,
lib/convenient_service/dependencies/queries/version/null_version.rb

Defined Under Namespace

Modules: Gems Classes: Ruby, Version

Instance Method Summary collapse

Instance Method Details

#active_modelClass<ConvenientService::Dependencies::Queries::Gems::ActiveModel>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



649
650
651
# File 'lib/convenient_service/dependencies/queries.rb', line 649

def active_model
  Gems::ActiveModel
end

#appraisal_nameString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (String)


694
695
696
# File 'lib/convenient_service/dependencies/queries.rb', line 694

def appraisal_name
  ::ENV["APPRAISAL_NAME"].to_s
end

#appraisal_name_for_coverageString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (String)


706
707
708
# File 'lib/convenient_service/dependencies/queries.rb', line 706

def appraisal_name_for_coverage
  appraisal_name.empty? ? "without_appraisal" : appraisal_name
end

#benchmark?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns true when Convenient Service is in benchmark mode. In other words $CONVENIENT_SERVICE_BENCHMARK env variable is set to true.

Returns:

  • (Boolean)

Since:

  • 1.0.0



43
44
45
# File 'lib/convenient_service/dependencies/queries.rb', line 43

def benchmark?
  ::ENV["CONVENIENT_SERVICE_BENCHMARK"] == "true"
end

#ci?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns true when Convenient Service is in CI mode. In other words $CONVENIENT_SERVICE_CI env variable is set to true.

Returns:

  • (Boolean)

Since:

  • 1.0.0



54
55
56
# File 'lib/convenient_service/dependencies/queries.rb', line 54

def ci?
  ::ENV["CONVENIENT_SERVICE_CI"] == "true"
end

#debug?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns true when Convenient Service is in debug mode. In other words $CONVENIENT_SERVICE_DEBUG env variable is set to true.

Returns:

  • (Boolean)

Since:

  • 1.0.0



32
33
34
# File 'lib/convenient_service/dependencies/queries.rb', line 32

def debug?
  ::ENV["CONVENIENT_SERVICE_DEBUG"] == "true"
end

#loggerClass<ConvenientService::Dependencies::Queries::Gems::Logger>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



658
659
660
# File 'lib/convenient_service/dependencies/queries.rb', line 658

def logger
  Gems::Logger
end

#minitestClass<ConvenientService::Dependencies::Queries::Gems::Minitest>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



631
632
633
# File 'lib/convenient_service/dependencies/queries.rb', line 631

def minitest
  Gems::Minitest
end

#paintClass<ConvenientService::Dependencies::Queries::Gems::Paint>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



667
668
669
# File 'lib/convenient_service/dependencies/queries.rb', line 667

def paint
  Gems::Paint
end

#require_active_model_validations_standard_config_optionBoolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


303
304
305
# File 'lib/convenient_service/dependencies/queries.rb', line 303

def require_active_model_validations_standard_config_option
  require_has_j_send_result_params_validations_using_active_model_validations_plugin
end

#require_aliasBoolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


110
111
112
# File 'lib/convenient_service/dependencies/queries.rb', line 110

def require_alias
  ::Object.const_set(:CS, ::ConvenientService)
end

#require_amazing_print_inspect_standard_config_optionBoolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# File 'lib/convenient_service/dependencies/queries.rb', line 166

def require_amazing_print_inspect_standard_config_option
  ##
  # - https://github.com/amazing-print/amazing_print
  #
  require "amazing_print"

  require "convenient_service/service/plugins/has_amazing_print_inspect"
  require "convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_amazing_print_inspect"
  require "convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/data/plugins/has_amazing_print_inspect"
  require "convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/message/plugins/has_amazing_print_inspect"
  require "convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/status/plugins/has_amazing_print_inspect"
  require "convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/code/plugins/has_amazing_print_inspect"
  require "convenient_service/service/plugins/can_have_steps/entities/step/plugins/has_amazing_print_inspect"
  require "convenient_service/feature/plugins/has_amazing_print_inspect"
end

#require_assigns_attributes_in_constructor_using_active_model_attribute_assignment_pluginBoolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


119
120
121
122
123
124
125
126
127
128
# File 'lib/convenient_service/dependencies/queries.rb', line 119

def require_assigns_attributes_in_constructor_using_active_model_attribute_assignment_plugin
  ##
  # - https://edgeguides.rubyonrails.org/active_model_basics.html
  # - https://api.rubyonrails.org/classes/ActiveModel.html
  # - https://github.com/rails/rails/tree/main/activemodel
  #
  require "active_model"

  require "convenient_service/common/plugins/assigns_attributes_in_constructor/using_active_model_attribute_assignment"
end

#require_assigns_attributes_in_constructor_using_dry_initializer_pluginBoolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


135
136
137
138
139
140
141
142
143
# File 'lib/convenient_service/dependencies/queries.rb', line 135

def require_assigns_attributes_in_constructor_using_dry_initializer_plugin
  ##
  # - https://dry-rb.org/gems/dry-initializer/main
  # - https://github.com/dry-rb/dry-initializer
  #
  require "dry-initializer"

  require "convenient_service/common/plugins/assigns_attributes_in_constructor/using_dry_initializer"
end

#require_awesome_print_inspect_standard_config_optionBoolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Loads a config that patches services to use Awesome Print to generate colored inspect strings.
Useful for debugging.
Works as expected for byebug and pry.

Has issues with escaping colors for binding.break and irb.
There is a workaround in the examples, but its possible negative outcome has not been investigated yet. Use it at your own risk.

Examples:

:awesome_print_inspect output for byebug or pry.

class Service
  include ::ConvenientService::Standard::Config.with(:awesome_print_inspect)

  def result
    success(foo: :bar)
  end
end

Service.result
# =>
{
  :ConvenientService => {
         :entity => "Result",
        :service => "Service",
         :status => :success,
      :data_keys => [
          [0] :foo
      ]
  }
}

:awesome_print_inspect output for binding.break or irb.


class Service
  include ::ConvenientService::Standard::Config.with(:awesome_print_inspect)

  def result
    success(foo: :bar)
  end
end

Service.result
# =>
{
  :ConvenientService^[[0;37m => ^[[0m{
         :entity^[[0;37m => ^[[0m^[[0;33m"Result"^[[0m,
        :service^[[0;37m => ^[[0m^[[0;33m"Service"^[[0m,
         :status^[[0;37m => ^[[0m^[[0;36m:success^[[0m,
      :data_keys^[[0;37m => ^[[0m[
          ^[[1;37m[0] ^[[0m^[[0;36m:foo^[[0m
      ]
    }
}

:awesome_print_inspect output for binding.break or irb with Reline hack.


class Service
  include ::ConvenientService::Standard::Config.with(:awesome_print_inspect)

  def result
    success(foo: :bar)
  end
end

class Reline::Unicode
  def self.escape_for_print(str)
    str
  end
end

Service.result
# =>
{
  :ConvenientService => {
         :entity => "Result",
        :service => "Service",
         :status => :success,
      :data_keys => [
          [0] :foo
      ]
  }
}

Returns:

  • (Boolean)

See Also:



273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
# File 'lib/convenient_service/dependencies/queries.rb', line 273

def require_awesome_print_inspect_standard_config_option
  ##
  # - https://github.com/awesome-print/awesome_print
  #
  require "awesome_print"

  require "convenient_service/service/plugins/has_awesome_print_inspect"
  require "convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_awesome_print_inspect"
  require "convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/data/plugins/has_awesome_print_inspect"
  require "convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/message/plugins/has_awesome_print_inspect"
  require "convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/status/plugins/has_awesome_print_inspect"
  require "convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/code/plugins/has_awesome_print_inspect"
  require "convenient_service/service/plugins/can_have_steps/entities/step/plugins/has_awesome_print_inspect"
  require "convenient_service/feature/plugins/has_awesome_print_inspect"
end

#require_development_tools(amazing_print: false, awesome_print: true) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Note:

Expected to be called from irb, pry, spec_helper.rb, etc.

Returns:

  • (Boolean)


390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
# File 'lib/convenient_service/dependencies/queries.rb', line 390

def require_development_tools(amazing_print: false, awesome_print: true)
  return if ci?

  ##
  # - https://github.com/awesome-print/awesome_print
  #
  require "awesome_print" if awesome_print

  ##
  # - https://github.com/amazing-print/amazing_print
  #
  require "amazing_print" if amazing_print

  ##
  # - https://github.com/gsamokovarov/break
  #
  require "break"

  ##
  # - https://github.com/deivid-rodriguez/byebug
  #
  require "byebug" if support_byebug?

  ##
  # - https://github.com/ruby/debug
  #
  require "debug" if ruby.mri?

  ##
  # - https://ruby-doc.org/stdlib-2.7.0/libdoc/ostruct/rdoc/OpenStruct.html
  # - https://github.com/ruby/ostruct
  #
  require "ostruct"

  ##
  # - https://github.com/janlelis/paint
  #
  require "paint"

  ##
  # - https://github.com/ruby/pp
  #
  require "pp"

  ##
  # - https://github.com/rouge-ruby/rouge
  #
  require "rouge" if support_byebug?

  ##
  # - https://ruby-doc.org/stdlib-2.7.0/libdoc/tempfile/rdoc/Tempfile.html
  # - https://github.com/ruby/tempfile
  #
  require "tempfile"

  require "convenient_service/debug/convenient_service"

  require "convenient_service/debug/b" if support_byebug?
  require "convenient_service/debug/byebug_syntax_highlighting" if support_byebug?
  require "convenient_service/debug/bb" if ruby.mri?
  require "convenient_service/debug/ce"
  require "convenient_service/debug/ds"

  require "convenient_service/debug/thread_backtraces"
  require "convenient_service/debug/break"
  require "convenient_service/debug/timeout"
end

#require_dry_examples(version: "") ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Loads dry config examples.

Parameters:

  • version (String) (defaults to: "")

Returns:

  • (Boolean)


596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
# File 'lib/convenient_service/dependencies/queries.rb', line 596

def require_dry_examples(version: "")
  ##
  # - https://ruby-doc.org/stdlib-2.7.0/libdoc/json/rdoc/JSON.html
  # - https://github.com/flori/json
  #
  require "json"

  ##
  # - https://github.com/jfelchner/ruby-progressbar
  #
  require "progressbar"

  ##
  # - https://ruby-doc.org/stdlib-2.7.0/libdoc/webrick/rdoc/WEBrick.html
  # - https://github.com/ruby/webrick
  #
  require "webrick"

  require ::File.join("convenient_service", "examples", "dry", version, "gemfile")
end

#require_dry_initializer_standard_config_optionBoolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


294
295
296
# File 'lib/convenient_service/dependencies/queries.rb', line 294

def require_dry_initializer_standard_config_option
  require_assigns_attributes_in_constructor_using_dry_initializer_plugin
end

#require_has_attributes_using_active_model_attributes_pluginBoolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


150
151
152
153
154
155
156
157
158
159
# File 'lib/convenient_service/dependencies/queries.rb', line 150

def require_has_attributes_using_active_model_attributes_plugin
  ##
  # - https://edgeguides.rubyonrails.org/active_model_basics.html
  # - https://api.rubyonrails.org/classes/ActiveModel.html
  # - https://github.com/rails/rails/tree/main/activemodel
  #
  require "active_model"

  require "convenient_service/common/plugins/has_attributes/using_active_model_attributes"
end

#require_has_j_send_result_params_validations_using_active_model_validations_pluginBoolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



323
324
325
326
327
328
329
330
331
332
# File 'lib/convenient_service/dependencies/queries.rb', line 323

def require_has_j_send_result_params_validations_using_active_model_validations_plugin
  ##
  # - https://edgeguides.rubyonrails.org/active_model_basics.html
  # - https://api.rubyonrails.org/classes/ActiveModel.html
  # - https://github.com/rails/rails/tree/main/activemodel
  #
  require "active_model"

  require "convenient_service/service/plugins/has_j_send_result_params_validations/using_active_model_validations"
end

#require_has_j_send_result_params_validations_using_dry_validation_pluginBoolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


339
340
341
342
343
344
345
346
347
# File 'lib/convenient_service/dependencies/queries.rb', line 339

def require_has_j_send_result_params_validations_using_dry_validation_plugin
  ##
  # - https://dry-rb.org/gems/dry-validation/main/
  # - https://github.com/dry-rb/dry-validation
  #
  require "dry-validation"

  require "convenient_service/service/plugins/has_j_send_result_params_validations/using_dry_validation"
end

#require_has_memoization_using_memo_wise_pluginBoolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


354
355
356
357
358
359
360
361
# File 'lib/convenient_service/dependencies/queries.rb', line 354

def require_has_memoization_using_memo_wise_plugin
  ##
  # - https://github.com/panorama-ed/memo_wise
  #
  require "memo_wise"

  require "convenient_service/common/plugins/has_memoization/using_memo_wise"
end

#require_memo_wise_standard_config_optionBoolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


312
313
314
# File 'lib/convenient_service/dependencies/queries.rb', line 312

def require_memo_wise_standard_config_option
  require_has_memoization_using_memo_wise_plugin
end

#require_rails_examples(version: "") ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Loads rails config examples.

Parameters:

  • version (String) (defaults to: "")

Returns:

  • (Boolean)


567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
# File 'lib/convenient_service/dependencies/queries.rb', line 567

def require_rails_examples(version: "")
  ##
  # - https://ruby-doc.org/stdlib-2.7.0/libdoc/json/rdoc/JSON.html
  # - https://github.com/flori/json
  #
  require "json"

  ##
  # - https://github.com/jfelchner/ruby-progressbar
  #
  require "progressbar"

  ##
  # - https://ruby-doc.org/stdlib-2.7.0/libdoc/webrick/rdoc/WEBrick.html
  # - https://github.com/ruby/webrick
  #
  require "webrick"

  require ::File.join("convenient_service", "examples", "rails", version, "gemfile")
end

#require_rspec_extentionsBoolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Note:

Expected to be called from spec_helper.rb.

Loads RSpec extensions like be_success matcher, stub_service helper, etc.

Returns:

  • (Boolean)


502
503
504
505
506
507
508
509
510
511
# File 'lib/convenient_service/dependencies/queries.rb', line 502

def require_rspec_extentions
  require "rspec/expectations"
  require "rspec/matchers"
  require "rspec/mocks"

  require "convenient_service/service/plugins/can_have_rspec_stubbed_results"
  require "convenient_service/feature/plugins/can_have_rspec_stubbed_entries"

  require "convenient_service/rspec"
end

#require_standard_examples(version: "") ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Loads standard config examples.

Parameters:

  • version (String) (defaults to: "")

Returns:

  • (Boolean)


521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
# File 'lib/convenient_service/dependencies/queries.rb', line 521

def require_standard_examples(version: "")
  ##
  # - https://ruby-doc.org/stdlib-2.7.0/libdoc/date/rdoc/Date.html
  # - https://ruby-doc.org/stdlib-2.7.0/libdoc/date/rdoc/DateTime.html
  # - https://github.com/ruby/date
  #
  require "date"

  ##
  # - https://ruby-doc.org/stdlib-2.7.0/libdoc/json/rdoc/JSON.html
  # - https://github.com/flori/json
  #
  require "json"

  ##
  # - https://github.com/jfelchner/ruby-progressbar
  #
  require "progressbar"

  ##
  # - https://ruby-doc.org/stdlib-2.7.0/libdoc/webrick/rdoc/WEBrick.html
  # - https://github.com/ruby/webrick
  #
  require "webrick"

  ##
  # - https://ruby-doc.org/stdlib-2.7.0/libdoc/uri/rdoc/URI.html
  # - https://github.com/ruby/uri
  #
  require "uri"

  require ::File.join("convenient_service", "examples", "standard", version, "cowsay")
  require ::File.join("convenient_service", "examples", "standard", version, "date_time")
  require ::File.join("convenient_service", "examples", "standard", version, "factorial")
  require ::File.join("convenient_service", "examples", "standard", version, "gemfile")
  require ::File.join("convenient_service", "examples", "standard", version, "request_params")
end

#require_test_toolsBoolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Note:

Expected to be called from spec_helper.rb.

Returns:

  • (Boolean)


464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
# File 'lib/convenient_service/dependencies/queries.rb', line 464

def require_test_tools
  ##
  # - https://github.com/janlelis/paint
  #
  require "paint"

  ##
  # - https://github.com/faker-ruby/faker
  #
  require "faker"

  ##
  # - https://ruby-doc.org/stdlib-2.7.0/libdoc/ostruct/rdoc/OpenStruct.html
  # - https://github.com/ruby/ostruct
  #
  require "ostruct"

  ##
  # - https://ruby-doc.org/stdlib-2.7.0/libdoc/strscan/rdoc/StringScanner.html
  # - https://github.com/ruby/strscan
  #
  require "strscan"

  ##
  # - https://ruby-doc.org/stdlib-2.7.0/libdoc/tempfile/rdoc/Tempfile.html
  # - https://github.com/ruby/tempfile
  #
  require "tempfile"
end

#require_wraps_result_in_db_transaction_using_active_record_base_transaction_pluginBoolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


368
369
370
371
372
373
374
375
376
377
# File 'lib/convenient_service/dependencies/queries.rb', line 368

def require_wraps_result_in_db_transaction_using_active_record_base_transaction_plugin
  ##
  # - https://edgeguides.rubyonrails.org/active_record_basics.html
  # - https://api.rubyonrails.org/classes/ActiveRecord.html
  # - https://github.com/rails/rails/tree/main/activerecord
  #
  require "active_record"

  require "convenient_service/service/plugins/wraps_result_in_db_transaction/using_active_record_base_transaction"
end

#rspecClass<ConvenientService::Dependencies::Queries::Gems::RSpec>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



640
641
642
# File 'lib/convenient_service/dependencies/queries.rb', line 640

def rspec
  Gems::RSpec
end

#rubyClass<ConvenientService::Dependencies::Queries::Ruby>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



622
623
624
# File 'lib/convenient_service/dependencies/queries.rb', line 622

def ruby
  Ruby
end

#support_byebug?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



77
78
79
# File 'lib/convenient_service/dependencies/queries.rb', line 77

def support_byebug?
  ruby.mri? && ruby.version < 4.0
end

#support_has_j_send_result_params_validations_using_active_model_validations_plugin?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

See Also:

  • ConvenientService.Dependencies.require_has_j_send_result_params_validations_using_active_model_validations_plugin


87
88
89
90
91
92
# File 'lib/convenient_service/dependencies/queries.rb', line 87

def support_has_j_send_result_params_validations_using_active_model_validations_plugin?
  return false unless active_model.loaded?
  return false if ruby.version >= 3.0 && active_model.version < 6.0

  true
end

#support_logger_non_integer_levels?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



101
102
103
# File 'lib/convenient_service/dependencies/queries.rb', line 101

def support_logger_non_integer_levels?
  logger.version >= "1.3.0"
end