what is the best way to use sass in a sinatra application? - dart

I'm writing a small Sinatra project, using rack and a Gemfile for hosting on Heroku. In order to use sass, I wanted to add gem 'sass', '~> 3.7', '>= 3.7.4' to my Gemfile and then add this to config.ru
require 'sass/plugin/rack'
use Sass::Plugin::Rack
I turns out that the sass gem is deprecated, as per this information: https://github.com/sass/ruby-sass, saying we should use libsass . That would mean that I need to add gem 'sassc', '~> 2.4' to the Gemfile ... I haven't figured out yet how and where add this line so my Sinatra app knows is should use libsass - any help would be much appreciated:
SassC::Engine.new(sass, style: :compressed).render
Now, it turns out that libsass is also deprecated, and the Sass blog recommends using dart sass as per this post https://sass-lang.com/blog/libsass-is-deprecated. I didn't find any information (yet) on how to implement dart sass in a ruby project, or Sinatra specifically.
So now I'm puzzled. What to use and how?

Related

Bundle Update downgrades several gems in a gem

Disclaimer before reading: I have resolved this issue but I am asking because I still don't know the reasons behind it.
I'm working on an old gem that pulls assets into the asset pipeline. I'm not positive how the gem was originally created I imagine it was with rails plugin new static_assets.
Since it is a gem the Gemfile is not overly complex (I haven't made any changes to it):
source "http://rubygems.org"
gemspec
# jquery-rails is used by the dummy application
gem "jquery-rails"
But the Gemfile.lock has dozens of gems and dependencies showing up. For the most part, the gems seem up to date.
When I run a bundle update several of the gems go back to much older versions; like Rails 5 to Rails 3.
I believe I solved this by updating the Gemfile to
gem 'jquery-rails', '~> 4.3', '>= 4.3.3'
but I want to know why this was happening.
I'm not overly familiar with how Gemfile.lock gets created and updated but I was under the impression that it was based on the Gemfile, pulling all gems and their dependencies from the Gemfile. If all the gems in Gemfile.lock are dependant on jquery-rails why was it automatically downgrading them so unilaterally and by so much?

Is Nokogiri necessary for Rails?

I updated my Ruby from 1.9 to 2.2 and I found that the Nokogiri gem doesn't support Ruby 2.2 on Windows. Nokogiri was not in my Gemfile, but when I run bundle install it is automatically added. Maybe there are some dependency for it?
This is a very small project and I don't understand its necessity for the project.
Is it possible to use Ruby 2.2 without Nokogiri? Or should I downgrade to 1.9 again?
It looks like Nokogiri is required by rails-dom-testing which is required by Action Pack and Action View in Rails 4.2.3, so it seems difficult to bypass it.
It looks like it is a dependency of some gem, which is included in your Gemfile.
You can search for nokogiri in your Gemfile.lock to find a gem which is requiring it.
See https://github.com/sparklemotion/nokogiri/issues/1256
tl;dr, in your Gemfile:
gem 'nokogiri', '>= 1.6.7.rc3'
for Windows.

Can't bundle rubyracer on rails to get twitter bootstrap working RAILS 4

I've been trying to get twitter bootstrap to work for days, but I can't seem to bundle the rubyracer with the new rails. This is my gemfile for the twitter bootstrap.
gem 'twitter-bootstrap-rails'
gem "therubyracer"
gem "less-rails"
Thanks!
Consider installing node.js as an alternative (http://nodejs.org); I've found it to be a better platform all-around, with less deployment surprises.
Evidently therubyracer uses quite a lot of memory, see: https://devcenter.heroku.com/articles/rails-asset-pipeline#therubyracer

Adding Geocder to Spree Extension

I want to add geocoder gem to a spree extension and I have included in the the gemspec as
s.add_development_dependency 'geocoder', '~> 1.1'
and have added this line to lib/extension_name.rb file:
require 'geocoder'
When I do rake -T, I do not see any geocoder related tasks in my extensions and when I include this extension in a spree website, it throws
cannot load such file -- geocoder (LoadError)
error. Where am I going wrong?
In web, all I can see is to include the gem in gemspec and require it. What am I missing?
You're misunderstanding the gemspec dependencies a bit.
add_development_dependency is used for adding dependencies that aid in coding of the gem. Examples would be things like TestUnit, Pry, or RSpec. These dependencies won't be available in applications that use your gem.
add_dependency is used for dependencies which are important for the operation of your gem. For example, geocoder in your case.
If you make that change, you should be good to go.

Have Rails 2.3.x ignore the i18n gem

I have a Rails 2.3.5 project that uses the localization features of Rails. I also happen to have Rails 3 beta installed (which depends on the i18n gem). Rails 2.3.5 will happily handle localization on it's own (without i18n installed), however if the i18n gem is available, it makes use of it.
Recently I upgraded my gems and now have version 0.3.7 and 0.4.0 of i18n installed. Rails, of course, wants to load and use the latest version which is causing errors in my project. I tried setting the gem version to 0.3.7 which gets around the errors in the web app. However, we're using resque and resque_mailer to delay the sending of messages. When the worker picks up the mailer job from the queue, it ignores my config.gem requirement in environment.rb and uses version 0.4.0 anyway.
Ideally, I'd like to tell Rails to just not use the i18n gem at all. How do I do that?
Update: As of beta 4, Rails 3 now requires i18n version 0.4.1. I don't see how more people aren't running into this problem as it would seem now if you have both Rails 2 and Rails 3 installed, you're going to run into this.
I followed instructions as defined here:
http://gembundler.com/rails23.html
and it worked.
You could use Bundler or RVM's Gemsets to make the i18n gem unavailable from within your app. Or you could upgrade your Rails app.
Freeze the rails version: rake VERSION=2.3.5 rails:freeze:gems
Fix the version in the file vendor/rails/activesupport/lib/active_support/vendor.rb line 24 to: gem 'i18n', '>= 0.1.3', '< 0.4.0'
Or just edit: /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/vendor.rb
And turn gem 'i18n', '>= 0.1.3'
Into gem 'i18n', '0.1.3'

Resources