Hi,
I strongly suggest that you add a Gemfile to Zen, specifying the gems needed to work with Sass. The following Gemfile would probably do the job:

source "http://rubygems.org/"
gem "sass"
gem "compass"
gem "zen-grids"

With this and Bundler, getting started with Sass is just a matter of

cd path/to/my/zen/sub-theme
bundle install --path .bundle
bundle install --binstubs

This would make a sub-theme project self-contained. Using Bundler is standard practice for managing dependencies in Ruby projects. Among the rest, it avoids the problems like the one mentioned at http://drupal.org/node/1548946#comment-6070036. Besides, no root privileges are needed (the commands are not run with sudo), and you can get rid of the sass-extensions folder.

Comments

lifepillar’s picture

you can get rid of the sass-extensions folder.

To be precise, you might remove extensions_dir="sass-extensions" and add require 'zen-grids' instead, in config.rb.

JohnAlbin’s picture

Status: Active » Postponed (maintainer needs more info)

A sub-theme isn't a Ruby project. It's a PHP project.

Can you explain in more detail what advantages this would give us? And how to implement it?

lifepillar’s picture

It's PHP, but to use Sass you need to install some Ruby gems. Typically, a user may install gems globally with “sudo gem install ”, but installing gems globally has some disadvantages because, in general, root privileges are needed and conflicts may arise (as witnessed by the comment I have linked to). In the Ruby community, it has become customary to include, in every project that depends on Ruby gems (not necessarily a Ruby project), a text file called “Gemfile”, which is a specification of gem dependencies for the project. Giving a single command like “bundle install”, a user may have all the gem dependencies installed in a subfolder of the project (think of it as “drush make” for gems). Advantages:

  • no root privileges needed to install/update the gems;
  • no conflicts with other versions of the same gems installed in the system arise;
  • if you move your sub-theme, the gems are moved along with it;
  • you may link your project to specific versions of some gems through the Gemfile.

To implement my suggestion, you just need to add a Gemfile in the top folder of the Zen sub-theme. If you include zen-grids in the Gemfile, you may also remove the sass-extensions folder and uncomment “require zen-grids" in config.rb instead, as I have explained. A user not interested in Sass or not using Bundler may simply ignore the Gemfile or delete it.

For the details about Bundler and Gemfiles, see http://gembundler.com.

JohnAlbin’s picture

That's interesting. But it seems to be duplicate functionality with 'compass unpack' which will “Copy an extension into your extensions folder”.

I have not seen anybody in the Compass community talking about using Bundler. But I have seen them many times talking about adding "require" to the compass.config file.

I think I'd rather use a standard Compass feature over a standard Ruby feature. Especially since you can use Zen's config.rb and Zen Grids with GUI-only tools with Compass built-in, like Fire.app. http://fireapp.handlino.com

lifepillar’s picture

Yes, compass unpack has overlapping features, but the two (Compass and Bundler) may live together. You may “compass unpack zen-grids”, but you still may use “bundle install” to get Sass and Compass (and possibly other gems in the future) in the first place. The advantage is mainly in keeping those gems up to date: “bundle update” does not affect anything outside the sub-theme folder. Without Bundler, users would likely use “(sudo) gem update”, which updates all the gems in the system, with the risk of breaking other Ruby apps.

But I understand your point and I won't insist any further: after all, adding a Gemfile manually to a sub-theme, as I have done for mine, is not too much of a burden. Maybe, this approach might be just documented.

JohnAlbin’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)

Thanks for the information.

I don't like to add stuff to Zen that I don't understand. Especially since everything needs to be well documented. I think adding it at this point would just be confusing to users not familiar with Bundler (like me.)

JohnAlbin’s picture

Version: 7.x-5.x-dev » 7.x-6.x-dev
Issue summary: View changes
Status: Closed (works as designed) » Active

Reopening!

MacMladen’s picture

I'd just add that there are two kinds of people:

  1. Those familiar with gems
  2. Those not familiar with gems

If we are looking at those who are not familiar with Ruby, Gems and overall process then we will see that they will hardly be able make proper use of SASS while usage of SASS, Compass, Ruby, Gems, RVM, Bundler is not too complicated for skilled developers which are targeted by Zen.

Adding Gemfile will be in line with good practice, does not add any complexity and helps maintain dependencies and mental health. It could be very tricky in some situations even for skilled ones.

If you agree I can add something like [#1936970] for Zen theme in documentation? There are some obstacles and some terminology that need explanation and I'd be glad to document it. (I will do so in some time unless you oppose and sooner if there is interest)

JohnAlbin’s picture

Title: Add Gemfile to manage Ruby gems » Add Gemfile to control versions of Sass/Compass
Status: Active » Fixed

I've added this to both 7.x-5.x and 7.x-6.x.

JohnAlbin’s picture

Status: Fixed » Needs work

I've updated the README file included with Zen, but this still needs online docs.

@MacMladen I'd love some help! Thanks for the offer.

  • JohnAlbin committed 8d7cb1c on 7.x-5.x authored by lifepillar
    Issue #1696924 by lifepillar: Add Gemfile to control versions of Sass/...
JohnAlbin’s picture

Status: Needs work » Fixed

Moved docs updates to a new issue

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.