hauleth / vanilla-ujs

UJS without jQuery dependency
MIT License
194 stars 24 forks source link

Make railties an optional dependency #33

Open cllns opened 7 years ago

cllns commented 7 years ago

We'd like to use vanilla-ujs in Hanami but we can't depend on railties.

This also helps people using Sinatra, and other Ruby web frameworks. This is a first step towards freeing vanilla-ujs from Rails :)

I'm very flexible and not tied to any specific changes here. This PR:

  1. adds a guard to only load the Rails Engine if Rails is defined.
  2. changes the module definition in ujs.rb from Rails to Ujs, since that's more idiomatic.
  3. rearranges the requires to be within the module, so that this Vanilla::Ujs module is first defined in this file, and not in the version file.
  4. keeps railties as a development dependency, so contributors to this gem can test the Rails integration without any trouble.