How to get Convenient Service root folder?

  • Call ConvenientService.root to get the gem's installation directory as a Pathname.

    ConvenientService.root
    # => #<Pathname:/path/to/gems/convenient_service-1.0.0>
  • Since the returned value is a Pathname, all standard path operations are available.

    ConvenientService.root.join("lib", "convenient_service.rb")
    # => #<Pathname:/path/to/gems/convenient_service-1.0.0/lib/convenient_service.rb>
    
    ConvenientService.root.join("lib", "convenient_service.rb").exist?
    # => true
  • ConvenientService.root is inspired by Rails.root.

Sources