README.md in tamashii-manager-0.2.4 vs README.md in tamashii-manager-0.2.5
- old
+ new
@@ -1,38 +1,156 @@
-# Tamashii::Manager
+Tamashii Manager [![Gem Version](https://badge.fury.io/rb/tamashii-manager.svg)](https://badge.fury.io/rb/tamashii-manager) [![Build Status](https://travis-ci.org/tamashii-io/tamashii-manager.svg?branch=master)](https://travis-ci.org/tamashii-io/tamashii-manager) [![Test Coverage](https://codeclimate.com/github/tamashii-io/tamashii-manager/badges/coverage.svg)](https://codeclimate.com/github/tamashii-io/tamashii-manager/coverage) [![Code Climate](https://codeclimate.com/github/tamashii-io/tamashii-manager/badges/gpa.svg)](https://codeclimate.com/github/tamashii-io/tamashii-manager)
+===
-Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/tamashii/manager`. To experiment with that code, run `bin/console` for an interactive prompt.
+Tamashii Manager is a package for managing IoT devices that can handle communication between IoT devices in a way similar to Rack.
-TODO: Delete this and the text above, and describe your gem
-
## Installation
-Add this line to your application's Gemfile:
+Add the following code to your `Gemfile`:
```ruby
gem 'tamashii-manager'
```
And then execute:
+```ruby
+$ bundle install
+```
- $ bundle
+Or install it yourself with:
+```ruby
+$ gem install tamashii-manager
+```
-Or install it yourself as:
+## Usage
- $ gem install tamashii-manager
+Tamashii Manager can be started directly through `tamashii-manager` .
-## Usage
+ $ tamashii-manager
-TODO: Write usage instructions here
+Because the connection of IoT devices may need verification, we implement a simple Token authentication function, which can achieve through the configuration file.
+```ruby
+# config.rb
+
+Tamashii::Manager.config do |config|
+ config.env = :test
+ config.auth_type = :token
+ config.token = 'abc123'
+ config.port = ENV['PORT'] || 3000
+end
+```
+
+Then start with `tamashii-manager` :
+
+ $ tamashii-manager -C config.rb
+
+### Rack
+
+To integrate with the project that use Rack through `config.ru` .
+
+```ruby
+# 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.
+
+```ruby
+# config.ru
+
+Rack::URLMap.new(
+ '/' => App,
+ '/tamashii' => Tamashii::Manager.server
+)
+```
+
+### Rails
+
+To integrate with the Rails project, you can use the `mount` function to plug Tamashii Manager onto Rails.
+
+```ruby
+# config/routes.rb
+
+Rails.application.routes.draw do
+ mount Tamashii::Manager.server => '/tamashii'
+end
+```
+
+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.
+
+```ruby
+# 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'
+end
+
+Tamashii::Resolver.config do
+ hook RailsHookForTamashii
+end
+```
+
+Use the `call` method in Resolver function to handle incoming packets.
+
+```ruby
+# app/tamashii/rails_hook_for_tamashii.rb
+
+class RailsHookForTamashii < Tamashii::Hook
+ def initialize(*args)
+ super
+ @client = @env[:client]
+ end
+
+ def call(packet)
+ # Handle packets here
+ return false if packet.nil? # The processing failed and let the other Handler go on
+ true # Finished processing
+ end
+end
+```
+
+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 the` send_to` function to send packets to a specify machine.
+
+```ruby
+Tamashii::Manager::Client.send_to('example', '...')
+```
+
## Development
-After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
+To get the source code
-To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
+ $ git clone git@github.com:tamashii-io/tamashii-manager.git
-## Contributing
+Initialize the development environment
-Bug reports and pull requests are welcome on GitHub at https://github.com/lctseng/tamashii-manager.
+ $ ./bin/setup
-Contributed by [5xruby Inc.](https://5xruby.tw/)
+Run the spec
+
+ $ rspec
+
+Installation the version of development on localhost
+
+ $ bundle exec rake install
+
+## Contribution
+
+Please report to us on [Github](https://github.com/tamashii-io/tamashii-manager) if there is any bug or suggested modified.
+
+The project was developed by [5xruby Inc.](https://5xruby.tw/)