Tamashii Manager Gem Version Build Status Test Coverage Code Climate

Tamashii Manager is a package for managing IoT devices that can handle communication between IoT devices in a way similar to Rack.


Add the following code to your Gemfile:

gem 'tamashii-manager'

And then execute:

$ bundle install

Or install it yourself with:

$ gem install tamashii-manager


Tamashii Manager can be started directly through tamashii-manager .

$ tamashii-manager

Because the connection of IoT devices may need verification, we implement a simple Token authentication function, which can achieve through the configuration file.

# config.rb

Tamashii::Manager.config do |config|
  config.env = :test
  config.auth_type = :token
  config.token = 'abc123'
  config.port = ENV['PORT'] || 3000

Then start with tamashii-manager :

$ tamashii-manager -C config.rb


To integrate with the project that use Rack through config.ru .

# config.ru

require 'tamashii/manager'
require './config.rb'

run Tamashii::Manager.server

Then start Tamashii Manager through the web server.

$ puma

Use Rack :: URLMap to consolidate your project when collocating with Sinatra and other frameworks.

# config.ru

   '/' => App,
  '/tamashii' => Tamashii::Manager.server


To integrate with the Rails project, you can use the mount function to plug Tamashii Manager onto Rails.

# config/routes.rb

Rails.application.routes.draw do
    mount Tamashii::Manager.server => '/tamashii'

In Rails, we will want to intercept information in the Tamashii Manager, processed in advance and then send to each IoT device, so it will use Tamashii Resolver function.

# config/initializer/tamashii.rb

Tamashii::Manager.config do |config|
  config.env = Rails.env
  config.log_file = Rails.root.join('log', 'tamashii.log')
  config.auth_type = :token
  config.token = 'example'

Tamashii::Resolver.config do
  hook RailsHookForTamashii

Use the call method in Resolver function to handle incoming packets.

# app/tamashii/rails_hook_for_tamashii.rb

class RailsHookForTamashii < Tamashii::Hook
  def initialize(*args)
    @client = @env[:client]

  def call(packet)
      # Handle packets here
      return false if packet.nil? # The processing failed and let the other Handler go on
      true # Finished processing

In this way, you can use the Hook to handle the packets sent to Tamashii Manager.

send_to method

Tamashii Manager will require a serial number as a machine ID when authenticating, and so we can use thesend_to function to send packets to a specify machine.

Tamashii::Manager::Client.send_to('example', '...')


To get the source code

$ git clone [email protected]:tamashii-io/tamashii-manager.git

Initialize the development environment

$ ./bin/setup

Run the spec

$ rspec

Installation the version of development on localhost

$ bundle exec rake install


Please report to us on Github if there is any bug or suggested modified.

The project was developed by 5xruby Inc.