
Security News
New Website “Is It Really FOSS?” Tracks Transparency in Open Source Distribution Models
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
in_bed_with is a gem to easily embed common javascript snippets in your application. It's both very simple and much webscale!
Works with or without Rails, so it's very possible to use it with Sinatra or any other Ruby lib/framework.
gem install in_bed_with
In your Gemfile, add:
gem 'in_bed_with'
The simplest way to use in_bed_with in Rails is to create an initializer file config/initializers/in_bed_with.rb
. Use it to specify the properties of the relevant service:
InBedWith.config do |config|
config.analytics_property_id = 'UA-1234567-1'
end
Then, in your view, simply use:
<%= in_bed_with.analytics %>
That's it!
If you don't want to set the properties through config, you can also pass any property into the method directly:
<%= in_bed_with.analytics(property_id: 'UA-1234567-1') %>
This approach is also useful if you have multiple objects with different properties to embed. You can still specify defaults through the config:
# config/initializers/in_bed_with.rb
InBedWith.config do |config|
config.adsense_client = 'ca-pub-1234567890123456'
config.adsense_ad_type = :small_rectangle
end
# app/views/layouts/application.html.erb
# Will create a small rectangle ad with a slot parameter of '1234567890'
<%= in_bed_with.adsense(ad_slot: '1234567890') %>
# Will create a wide skyscraper ad with a slot parameter of '0987654321'
<%= in_bed_with.adsense(ad_slot: '0987654321', ad_type: :wide_skyscraper) %>
With Sinatra, you'll need to use the helper
method to register the in_bed_with
helper.
helper InBedWith::Helper
With any other lib/framework, use extend:
extend InBedWith::Helper
You can also forego the helper completely and call the InBedWith
module directly:
InBedWith.analytics
# same as:
in_bed_with.analytics
in_bed_with currently supports Google Analytics, Adsense and Gauges. Many more are planned--feel free to open an issue/pull request for integration with your favorite service!
Available properties:
property_id
: The ID of the property. Usually a string formatted along the likes of UA-xxxxxxx-x
, where x
is a digit.Example:
# initializer
InBedWith.config do |config|
config.analytics_property_id = 'UA-1234567-1'
end
# view
<%= in_bed_with.analytics %>
Available properties:
client
: The Adsense client id. Usually a string formatted along the likes of ca-pub–xxxxxxxxxxxxxxxx
, where x
is a digit.ad_slot
: The ad slot. Usually a 10-digit number.ad_type
: The type of the ad. Does not need to be set if both ad_width
and ad_height
are set. Can be any of (see here for exact sizes):
:banner
, :button
, :half_banner
, :large_rectangle
, :leaderboard
, :medium_rectangle
, :skyscraper
, :small_rectangle
, :small_square
, :square
, :vertical_banner
, :wide_skyscraper
ad_width
: The width of the ad. Does not need to be set if ad_type
is set. Usually a 2 or 3-digit number.ad_height
: The height of the ad. Does not need to be set if ad_type
is set. Usually a 2 or 3-digit number.Example:
# initializer
InBedWith.config do |config|
config.adsense_client = 'ca-pub-1234567890123456'
config.adsense_ad_type = :small_rectangle
end
# view
<%= in_bed_with.adsense(ad_slot: '1234567890') %>
Available properties:
site_id
: The ID of the site. (As far as I know) a 24-character hexadecimal string.Example:
# initializer
InBedWith.config do |config|
config.gauges_site_id = '1234567890abcdef12345678'
end
# view
<%= in_bed_with.gauges %>
Pull requests for integration with additional service are very welcome!
in_bed_with
is licensed under the MIT license. See LICENSE
for details.
FAQs
Unknown package
We found that in_bed_with demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
Security News
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
Security News
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.