Bloated Ruby files
dnesteryuk opened this issue ยท 1 comments
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.
Hi @dnesteryuk - i've thought about decoupling the sub API sets as extensions that are compiled into the build at install
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