
Security News
PodRocket Podcast: Inside the Recent npm Supply Chain Attacks
Socket CEO Feross Aboukhadijeh discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.
xively-rb-connector is a ruby gem that provides an interface to Xively. It extends Sam Mulube's excellent xively-rb gem. This gem adds convenience functions such as find_by_id lookup functions, datastream compression (only saves datapoints when value changes), a datapoint recording buffer, etc.
Xively is a public cloud specifically built for the "Internet of Things". With their platform, developers can connect physical devices, that produce one or more datastreams, to a managed data store. The device's details and datastreams are accessible via key-based access to any service or application that has access to the web. Xively provides a fantastic development portal and prototyping accounts are free.
Please file bugs / issues and feature requests on the issue tracker
gem install xively-rb-connector
require 'xively-rb-connector'
# Xively provides a master api-key and device specific keys. To my knowledge, either can be used here.
my_api_key = 'XIVELY-ACCOUNT-OR-DEVICE-API-KEY-HERE'
# Each device on Xively gets thier own ID, which is exposed via thier REST API as a "feed"
feed_id = '123456789'
# Find your device on Xively by its feed_id
d = XivelyConnector.find_device_by_id(feed_id, my_api_key)
# Access details about the device
d.id # 123456789
d.feed # https://api.xively.com/v2/feeds/123456789.json
d.auto_feed_url # https://api.xively.com/v2/feeds/123456789.json
d.title # My Meter
d.device_serial # FOOBAR123456
d.description # The xively on xively.com
d.tags # ["Gas", "Power", "Propane", "Water"]
d.creator # https://xively.com/users/foo
d.email # your.email@gmail.com
d.website # http://www.your-website.com
d.icon
d.created # 2014-01-01 16:36:30 UTC
d.updated # 2014-03-31 05:02:25 UTC
d.private # true
d.is_private? # true
d.status # live
d.is_frozen? # false
# Access location data directly
d.has_location? # true
d.location_name # The location name on xively.com
d.location_domain # physical
d.location_lon # -78.12343456
d.location_lat # 35.12343454
d.location_ele # 354 feet
d.location_exposure
d.location_disposition
d.location_waypoints
# Or get a structure that has all the location details
l = d.location #<OpenStruct name="The location name on xively.com", latitude=35.12343454, longitude=-78.12343456, elevation="354 feet", exposure=nil, disposition=nil, waypoints=nil, domain="physical">
l.name # The location name on xively.com
l.domain # physical
l.longitude # -78.12343456
l.latitude # 35.12343454
l.elevation # 354 feet
l.exposure
l.disposition
l.waypoints
# Examine datastreams
d.datastream_ids # ["Amperage", "Propane", "Voltage", "Power", "Well"]
d.datastream_values # ["Amperage in Amps (A) = 0", "Propane in Cubic Feet (cft) = 0", "Voltage in Volts (V) = 9", "Power in Watts (W) = 0", "Well in Cubic Feet (cft) = 0"]
d.has_channel?('Voltage') # true
# Access datastreams by channel name using bracket syntax
d['Voltage'] # <XivelyConnector::Datastream:0x007ff62a137b80>
d['Voltage'].current_value # 9
ds = d['Volts']
ds.id # Voltage
ds.unit_label # Volts
ds.unit_symbol # V
ds.current_value # 9
ds.tags # Power
ds.min_value # 0.0
ds.max_value # 25.0
# Setup my datastream buffer
ds.only_save_changes = true # Will only queue a datapoint if its value is different from the previous datapoint's which is also the current_value
ds.datapoint_buffer_size = 60 # Will auto-save to feed when 60 points are queued
ds.only_save_changes # true
ds.only_saves_changes? # true
ds.datapoint_buffer_size # 60
# Queue new datapoints in a number of ways using the shift operator
# BigDecimal is used for value comparison so "10" == 10 == 10.0
ds.datapoints.size # 0
ds << Xively::Datapoint.new(:value => "10", :at => Time.now,())
ds << {:at=>':at => Time.now(), :value => "10"}
ds << "10"
ds << 10
ds << 10.0
ds << 11
# If ds.only_save_changes is true, the commands above only result in two datapoints being queued (because the only unique values recorded were 10 and 11)
ds.datapoints.size # 2
# Save datapoints to xively.com
ds.save_datapoints
ds.datapoints.size # 0
FAQs
Unknown package
We found that xively-rb-connector 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
Socket CEO Feross Aboukhadijeh discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.
Security News
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.