سؤال

I am using axlsx 2.0.1 gem to generate spreadsheets. I came to situation in which I have to hide some worksheets. In examples it is given that you can hide the sheet with:

 wb.add_worksheet name: 'hidden', state: :hidden do |sheet|
    sheet.add_row ['you cant see me!']
  end

But this is not working with it. Then after, I'd included gem with

gem 'axlsx', git: "git@github.com:randym/axlsx.git"

And then it worked. So what should I do then? Should I continue with the git url or something else?

هل كانت مفيدة؟

المحلول

The problem is that the author of this gem has not released an updated version in RubyGems since last September. You can see that by visiting the gem's entry in RubyGems. As you can see, the latest release (2.0.1) happened 13/9/2013.

As the feature you are interested in was added after that on the gem's master branch, having a git URL in your Gemfile works fine for you. However this is far from ideal for production systems! Any changes in the gem's master branch (which is not always stable or well-tested) could end up in your project if you were to (inadvertently) update this gem.

You could fork the project on github and use the forked URL in your Gemfile to ensure that no changes happen overnight. Or you could search for a git tag that represents the project in the state you desire it (i.e. after the hidden-sheets feature was implemented). You could even set a specific commit hash in your Gemfile if you want!

Once the author releases a new stable version of his gem and after you ensure that it works fine for you (e.g. there are no regressions), you can change back your Gemfile to the simpler gem 'axlsl'.

If you want to see how you can specify a certain branch, commit, or tag in your Gemfile have a look here: How to get a specific "commit" of a gem from github?

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top