tamashii-manager 0.2.4 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0a4a056c16a53a471ec345555af9fab757c2bc07
4
- data.tar.gz: 7a8d8f76b80661f220abf2bafa9d08552189b9ba
3
+ metadata.gz: e261e9f42acf76a96f678f43a6c95d6ca206680c
4
+ data.tar.gz: e1a3c8fa43ecbd156abff71ba9d1a73a39cf79a1
5
5
  SHA512:
6
- metadata.gz: 71e0d71ba4c8dddfe8644b1d6b76c5c5f4a291a28a31d3c696f45012591f963192c6c99ac8acdaee957f6d70ccf76397814f49928d709cb5f060b974e6351e03
7
- data.tar.gz: d500c1cb4e003e8e2076d8043be9689c2ec677826d0dde28fc1bf22e8ef18059e2c55e1bdd456d12dd0009c9740f061fa04860679868a9676cb3936b3024c7e1
6
+ metadata.gz: 407385d718724a79a0aad75aeeba1ebe8cdf6ed363fff05683a57d16244d3f9caa04698961caf3e1671e27f95f096f32542873861aa24167ca3747249d23c541
7
+ data.tar.gz: e1494e24c0ffa4a5bd6789ab9ff5d2dd9b2cf6fbabc955f6615404b6fea13dad0d7e2e1849e41990b909d8eae51257e1002dafd595f25ad366d95d77975e35f6
data/.travis.yml CHANGED
@@ -1,5 +1,11 @@
1
1
  sudo: false
2
+ cache: bundler
2
3
  language: ruby
3
4
  rvm:
4
- - 2.3.1
5
- before_install: gem install bundler -v 1.13.6
5
+ - 2.4.1
6
+ before_script:
7
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
8
+ - chmod +x ./cc-test-reporter
9
+ - ./cc-test-reporter before-build
10
+ after_script:
11
+ - if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT; fi
data/README.md CHANGED
@@ -1,38 +1,156 @@
1
- # Tamashii::Manager
1
+ 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)
2
+ ===
2
3
 
3
- 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.
4
-
5
- TODO: Delete this and the text above, and describe your gem
4
+ Tamashii Manager is a package for managing IoT devices that can handle communication between IoT devices in a way similar to Rack.
6
5
 
7
6
  ## Installation
8
7
 
9
- Add this line to your application's Gemfile:
8
+ Add the following code to your `Gemfile`:
10
9
 
11
10
  ```ruby
12
11
  gem 'tamashii-manager'
13
12
  ```
14
13
 
15
14
  And then execute:
15
+ ```ruby
16
+ $ bundle install
17
+ ```
16
18
 
17
- $ bundle
19
+ Or install it yourself with:
20
+ ```ruby
21
+ $ gem install tamashii-manager
22
+ ```
18
23
 
19
- Or install it yourself as:
24
+ ## Usage
20
25
 
21
- $ gem install tamashii-manager
26
+ Tamashii Manager can be started directly through `tamashii-manager` .
22
27
 
23
- ## Usage
28
+ $ tamashii-manager
29
+
30
+ Because the connection of IoT devices may need verification, we implement a simple Token authentication function, which can achieve through the configuration file.
31
+
32
+ ```ruby
33
+ # config.rb
34
+
35
+ Tamashii::Manager.config do |config|
36
+ config.env = :test
37
+ config.auth_type = :token
38
+ config.token = 'abc123'
39
+ config.port = ENV['PORT'] || 3000
40
+ end
41
+ ```
42
+
43
+ Then start with `tamashii-manager` :
44
+
45
+ $ tamashii-manager -C config.rb
46
+
47
+ ### Rack
48
+
49
+ To integrate with the project that use Rack through `config.ru` .
50
+
51
+ ```ruby
52
+ # config.ru
53
+
54
+ require 'tamashii/manager'
55
+ require './config.rb'
56
+
57
+ run Tamashii::Manager.server
58
+ ```
59
+
60
+ Then start Tamashii Manager through the web server.
61
+
62
+ $ puma
63
+
64
+ Use `Rack :: URLMap` to consolidate your project when collocating with Sinatra and other frameworks.
65
+
66
+ ```ruby
67
+ # config.ru
68
+
69
+ Rack::URLMap.new(
70
+ '/' => App,
71
+ '/tamashii' => Tamashii::Manager.server
72
+ )
73
+ ```
74
+
75
+ ### Rails
76
+
77
+ To integrate with the Rails project, you can use the `mount` function to plug Tamashii Manager onto Rails.
78
+
79
+ ```ruby
80
+ # config/routes.rb
81
+
82
+ Rails.application.routes.draw do
83
+ mount Tamashii::Manager.server => '/tamashii'
84
+ end
85
+ ```
86
+
87
+ 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.
88
+
89
+ ```ruby
90
+ # config/initializer/tamashii.rb
91
+
92
+ Tamashii::Manager.config do |config|
93
+ config.env = Rails.env
94
+ config.log_file = Rails.root.join('log', 'tamashii.log')
95
+ config.auth_type = :token
96
+ config.token = 'example'
97
+ end
98
+
99
+ Tamashii::Resolver.config do
100
+ hook RailsHookForTamashii
101
+ end
102
+ ```
103
+
104
+ Use the `call` method in Resolver function to handle incoming packets.
105
+
106
+ ```ruby
107
+ # app/tamashii/rails_hook_for_tamashii.rb
108
+
109
+ class RailsHookForTamashii < Tamashii::Hook
110
+ def initialize(*args)
111
+ super
112
+ @client = @env[:client]
113
+ end
114
+
115
+ def call(packet)
116
+ # Handle packets here
117
+ return false if packet.nil? # The processing failed and let the other Handler go on
118
+ true # Finished processing
119
+ end
120
+ end
121
+ ```
122
+
123
+ In this way, you can use the Hook to handle the packets sent to Tamashii Manager.
124
+
125
+ ### send_to method
24
126
 
25
- TODO: Write usage instructions here
127
+ 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.
128
+
129
+ ```ruby
130
+ Tamashii::Manager::Client.send_to('example', '...')
131
+ ```
26
132
 
27
133
  ## Development
28
134
 
29
- 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.
135
+ To get the source code
136
+
137
+ $ git clone git@github.com:tamashii-io/tamashii-manager.git
138
+
139
+ Initialize the development environment
140
+
141
+ $ ./bin/setup
142
+
143
+ Run the spec
144
+
145
+ $ rspec
146
+
147
+ Installation the version of development on localhost
30
148
 
31
- 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).
149
+ $ bundle exec rake install
32
150
 
33
- ## Contributing
151
+ ## Contribution
34
152
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/lctseng/tamashii-manager.
153
+ Please report to us on [Github](https://github.com/tamashii-io/tamashii-manager) if there is any bug or suggested modified.
36
154
 
37
- Contributed by [5xruby Inc.](https://5xruby.tw/)
155
+ The project was developed by [5xruby Inc.](https://5xruby.tw/)
38
156
 
@@ -24,6 +24,10 @@ module Tamashii
24
24
  @event_loop.post { Client.accepted_clients.values.map(&:beat) }
25
25
  end
26
26
  end
27
+
28
+ def inspect
29
+ "Tamashii::Manager::Server v#{VERSION}"
30
+ end
27
31
  end
28
32
  end
29
33
  end
@@ -1,5 +1,5 @@
1
1
  module Tamashii
2
2
  module Manager
3
- VERSION = "0.2.4"
3
+ VERSION = "0.2.5"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tamashii-manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - 蒼時弦也
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2017-08-01 00:00:00.000000000 Z
13
+ date: 2017-09-20 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: puma