dinabaztag 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +94 -1
- data/lib/dinabaztag/message.rb +1 -3
- data/lib/dinabaztag/version.rb +1 -1
- metadata +1 -1
data/README.md
CHANGED
@@ -1,4 +1,97 @@
|
|
1
1
|
dinabaztag
|
2
2
|
==========
|
3
3
|
|
4
|
-
|
4
|
+
Dinabaztag is a Ruby wrapper for the Nabaztag rabbit's new API documented [here](nabaztag.com).
|
5
|
+
|
6
|
+
With Dinabaztag, you can control your Nabaztag's ears and lights through it's choreography API, and surely you can play sound files on it. It also supports Text To Speech functionality through Google's unofficial TTS API on any languages which Google supports.
|
7
|
+
|
8
|
+
Installation
|
9
|
+
------------
|
10
|
+
|
11
|
+
Dinabaztag is distributed as a gem, which is how it should be used in your app.
|
12
|
+
|
13
|
+
Include the gem in your Gemfile:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
gem "dinabaztag", ">=0.0.2"
|
17
|
+
```
|
18
|
+
To get an API key, you have to register your rabbit on nabaztag.com.
|
19
|
+
|
20
|
+
Usage
|
21
|
+
-----
|
22
|
+
|
23
|
+
### Initializing Message
|
24
|
+
|
25
|
+
You can communicate with the API through the Dinabaztag::Message class. You can play a soundfile, send a TTS message, or add some advanced choreography.
|
26
|
+
|
27
|
+
### Playing sound files
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
m = Dinabaztag::Message.new( '__YOUR_API_KEY_HERE__' )
|
31
|
+
m.play_sound("http://www.digitalnatives.hu/success.mp3")
|
32
|
+
m.perform
|
33
|
+
```
|
34
|
+
|
35
|
+
### Text To Speech
|
36
|
+
|
37
|
+
Set your Nabaztag's TTS language when initializing the Message class.
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
m = Dinabaztag::Message.new( '__YOUR_API_KEY_HERE__', :language => :en )
|
41
|
+
m.say_message("Hey, I'm Nabaztag, the rabbit!")
|
42
|
+
m.perform
|
43
|
+
```
|
44
|
+
### Choreography
|
45
|
+
|
46
|
+
#### Ear movement
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
ear_movement_action_0 = Dinabaztag::Action::EarMovement.new( :angle => 0 )
|
50
|
+
ear_movement_action_180 = Dinabaztag::Action::EarMovement.new( :angle => 180 )
|
51
|
+
|
52
|
+
chor = Dinabaztag::Choreography.new
|
53
|
+
chor.add_action(0, ear_movement_action_0 )
|
54
|
+
chor.add_action(1, ear_movement_action_180 )
|
55
|
+
|
56
|
+
m = Dinabaztag::Message.new( '__YOUR_API_KEY_HERE__' )
|
57
|
+
m.exec_choreography( chor )
|
58
|
+
m.perform
|
59
|
+
```
|
60
|
+
|
61
|
+
#### Led lights
|
62
|
+
|
63
|
+
Coming soon...
|
64
|
+
|
65
|
+
### Advanced usage
|
66
|
+
|
67
|
+
You can connect the examples above into one command with the wait_for_previous_commands method.
|
68
|
+
|
69
|
+
```ruby
|
70
|
+
ear_movement_action_0 = Dinabaztag::Action::EarMovement.new( :angle => 0 )
|
71
|
+
ear_movement_action_180 = Dinabaztag::Action::EarMovement.new( :angle => 180 )
|
72
|
+
|
73
|
+
chor = Dinabaztag::Choreography.new
|
74
|
+
chor.add_action(0, ear_movement_action_0 )
|
75
|
+
chor.add_action(1, ear_movement_action_180 )
|
76
|
+
|
77
|
+
m = Dinabaztag::Message.new( '__YOUR_API_KEY_HERE__', :language => :en )
|
78
|
+
m.play_sound("http://www.digitalnatives.hu/success.mp3")
|
79
|
+
m.wait_for_previous_commands
|
80
|
+
m.say_message("Hey, I'm Nabaztag, the rabbit!")
|
81
|
+
m.wait_for_previous_commands
|
82
|
+
m.exec_choreography( chor )
|
83
|
+
m.perform
|
84
|
+
```
|
85
|
+
|
86
|
+
Credits
|
87
|
+
-------
|
88
|
+
|
89
|
+
<img src="http://m.blog.hu/di/digitalnatives/skins/white_swirl_dina/img/logo.png" width="150"/>
|
90
|
+
|
91
|
+
Dinabaztag is maintained by [Digital Natives](http://digitalnatives.hu)
|
92
|
+
|
93
|
+
License
|
94
|
+
-------
|
95
|
+
|
96
|
+
Dinabaztag is Copyright © 2008-2012 Digital Natives. It is free software, and may be
|
97
|
+
redistributed under the terms specified in the MIT-LICENSE file.
|
data/lib/dinabaztag/message.rb
CHANGED
@@ -43,10 +43,8 @@ module Dinabaztag
|
|
43
43
|
exec_string = CGI.escape( exec_commands.join("\n") )
|
44
44
|
|
45
45
|
url = "http://www.nabaztag.com/nabaztags/#{self.api_key}/exec?command=#{exec_string}"
|
46
|
-
|
47
|
-
puts url
|
48
|
-
|
49
46
|
Net::HTTP.get( URI(url) )
|
47
|
+
# puts url
|
50
48
|
|
51
49
|
reset
|
52
50
|
rescue => e
|
data/lib/dinabaztag/version.rb
CHANGED