Skip to content

Bloated Ruby files #174

Open
Open

Description

@dnesteryuk

I understand that you generate this client, but if you check memory which is needed to load your gem with

bundle exec derailed bundle:mem

See for more details of the derailed command. You will get this:

  xero-ruby: 30.25 MiB
    xero-ruby/api/accounting_api: 6.7891 MiB
    xero-ruby/api/payroll_uk_api: 2.3203 MiB
    xero-ruby/api/payroll_nz_api: 1.2891 MiB
    xero-ruby/api_client: 0.7734 MiB

Just one accounting_api.rb needs almost 7 Mb!

Our project uses lots of other gem, but xero-ruby is the most expensive. For example, Rails:

rails/all: 17.9023 MiB

Rails has way more features and it is lighter.

Can we do something with this, guys? Thanks. 🙂

Activity

  1. SerKnight commented on Jun 8, 2021

    @SerKnight
    Contributor

    Hi @dnesteryuk - i've thought about decoupling the sub API sets as extensions that are compiled into the build at install

    https://guides.rubygems.org/gems-with-extensions/
    Example

    creds = {
      client_id: ENV['CLIENT_ID'],
      client_secret: ENV['CLIENT_SECRET'],
      redirect_uri: ENV['REDIRECT_URI'],
      scopes: ENV['SCOPES'],
      api_sets: ['accounting', 'files']
    }
    xero_client ||= XeroRuby::ApiClient.new(credentials: creds)
    
    xero_client.accounting_api => accounting_api_instance
    xero_client.projecets_api => undefined method etc.

    However I've not done this before and I think would be quite a decent refactor. Do you have any other ideas how to slim it down?

    Haha had to compare to rails, couldn't have picked Nokogiri :trollface:

  2. self-assigned this
    on Jun 8, 2021
  3. ngan commented on Aug 5, 2026

    @ngan

    Hoping to fix this here: #380

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions