text-to-noise 0.1.2 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,10 +1,11 @@
1
- TailSounds
2
- ==========
3
- Ambient monitoring.
1
+ Text-To-Noise
2
+ =============
3
+ Ambient log file monitoring.
4
4
 
5
- Imagine if your servers created ambient noise instead of silent log messages. What if your
6
- application infrastructure sounded like a jungle? Page views are the chittering of crickets,
7
- logins are the cackle of monkeys, and errors are the roar of a lion.
5
+ Imagine if your servers created ambient noise instead of silent log messages.
6
+ What if your application infrastructure sounded like a jungle? Page views are
7
+ the chittering of crickets, logins are the cackle of monkeys, and errors are
8
+ the roar of a lion. This is what `text_to_noise` can do.
8
9
 
9
10
 
10
11
  Installation
@@ -12,24 +13,112 @@ Installation
12
13
 
13
14
  Stuff that I had to do to get this running:
14
15
 
15
- 1. Install the SDL Mixer library. I used [Homebrew][homebrew]:
16
- brew install sdl sdl_mixer
16
+ 1. Install the [SDL Mixer][sdlmixer] library. I used [Homebrew][homebrew]:
17
+ `brew install sdl sdl_mixer`
17
18
 
18
- 2. Install text_to_noise via [Rubygems][rubygems]:
19
- gem install rsdl text_to_noise
19
+ 2. Install `text_to_noise` via [Rubygems][rubygems]:
20
+ `gem install text-to-noise`
21
+
22
+
23
+ Configuration
24
+ =============
25
+
26
+ Text-To-Noise is configured with a Ruby file. The configuration contains a set
27
+ of rules for mapping a line of input text to a sound. Each mapping is a single
28
+ method of the form `map( pattern ).to "sound"`.
29
+
30
+ map( /a regex matching log lines to trigger sounds/ ).to "a sound name to play"
31
+
32
+ For example,
33
+
34
+ map( /Processing/ ).to "finch"
35
+
36
+ will match any input line that matches `/Processing/` and play the sound of a finch chirping.
37
+
38
+ A mapping may target multiple sounds for a given rule. It can get boring to
39
+ hear the same sound every time a page is loaded. Specify a set of sounds for
40
+ a rule by passing it a list of sound names:
41
+
42
+ map( /Processing/ ).to ["canary", "finch"]
43
+
44
+ the sounds will each be played in turn for each time the rule matches.
45
+
46
+
47
+ Dynamic Patterns
48
+ ----------------
49
+
50
+ You can also apply more advanced rules for sound generation by supplying a
51
+ block to the match rule. The block is passed the [MatchData][MatchData:RDoc]
52
+ object returned from the regular expression match:
53
+
54
+ map( /Completed in (\d+)ms/ ) { |match_data|
55
+ match_data[1].to_i > 500
56
+ }.to "vulture"
57
+
58
+ The above rule will play a vulture sound iff a line matches the expression _and_ the block
59
+ returns true. Applied to a Rails log, the above rule will play a vulture sound whenever a
60
+ page takes longer than 500ms to render.
61
+
62
+ For additional details, see the Cucumber [features][Features]. Also, have a
63
+ look at the [sample][SampleConfig] configuration.
64
+
65
+ Included Sounds
66
+ ---------------
67
+
68
+ `text-to-noise` currently comes with the following sounds for use in your
69
+ configurations:
70
+
71
+ australian_frogmouth
72
+ blue_amazon_macaw
73
+ canary
74
+ canary2
75
+ cardinal
76
+ chicken
77
+ crickets
78
+ crow-1
79
+ crow
80
+ finch
81
+ geese
82
+ hawk
83
+ lapwing
84
+ meadow_lark_long
85
+ meadow_lark_short
86
+ mexican_red_parrot
87
+ mockingbird
88
+ nightingale
89
+ owl
90
+ peacock
91
+ pigeons
92
+ red_lories
93
+ rooster
94
+ vulture
95
+ whipperwhill
96
+
97
+ Soon you'll be able to add your own `wav` files for playback, but not just yet.
20
98
 
21
99
 
22
100
  Usage
23
101
  -----
24
102
 
25
- Pipe a log into the +tail_sound+ script and it will start chirping:
103
+ First, create a sound mapping configuration as shown above. Then you can pipe
104
+ a log into the `text_to_noise` script and it will start chirping:
105
+
106
+ tail -f /var/log/mylog | text_to_noise -c my.sounds.rb
26
107
 
27
- tail -f /var/log/mylog | text_to_noise
108
+ Alternatively, you can run `text_to_noise` on an existing file:
109
+
110
+ text_to_noise -c my.sounds.rb -f file.log
111
+
112
+ Text-To-Noise will cease processing when it reaches the end of the file.
28
113
 
29
114
 
30
115
  TODO
31
116
  ----
32
117
 
118
+ At the moment, this only supports playing some free bird songs that are included in the gem.
119
+ Highest priority is the ability to add your own sound sets for playback.
120
+
121
+ * Add sounds to the available noises for playback
33
122
  * Automatically refresh configurations
34
123
  * Add generators to create stub configurations
35
124
  * Support sound themes?
@@ -37,3 +126,7 @@ TODO
37
126
 
38
127
  [Homebrew]:http://mxcl.github.com/homebrew
39
128
  [Rubygems]:http://rubygems.org
129
+ [sdlmixer]:http://www.libsdl.org/projects/SDL_mixer/
130
+ [MatchData:RDoc]:http://ruby-doc.org/core/classes/MatchData.html
131
+ [Features]:https://github.com/tobytripp/text_to_noise/blob/master/features/configuration.feature
132
+ [SampleConfig]:https://github.com/tobytripp/text_to_noise/blob/master/sample.sounds.rb
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ lib = File.expand_path( '../../lib/', __FILE__ )
4
+ $:.unshift lib unless $:.include?( lib )
5
+
6
+ require 'text_to_noise'
7
+
8
+ player = TextToNoise::Player.new
9
+
10
+ ARGV.each do |sound|
11
+ sound += ".wav" unless sound =~ /\.wav$/
12
+ player.play sound
13
+ sleep 1
14
+ end
15
+
16
+ sleep 1 while player.playing?
@@ -62,3 +62,19 @@ Feature: Mapping input lines to sounds for playback
62
62
 
63
63
  Then the output should contain "Playing slow_query.wav"
64
64
  And the output should not contain "Playing slow_request.wav"
65
+
66
+ Scenario: Inputs that match multiple rules should fire all sounds
67
+ Given a file named "sound_mapping.rb" with:
68
+ """
69
+ map /caw/ => "crow", /bakawk/ => "chicken"
70
+ """
71
+
72
+ And a file named "input.log" with:
73
+ """
74
+ caw bakawk!
75
+ """
76
+
77
+ When I run `text_to_noise -c sound_mapping.rb -f input.log -m`
78
+
79
+ Then the output should contain "Playing crow.wav"
80
+ And the output should contain "Playing chicken.wav"
@@ -1,3 +1,3 @@
1
1
  module TextToNoise
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.4"
3
3
  end
@@ -18,6 +18,8 @@ Gem::Specification.new do |spec|
18
18
 
19
19
  spec.add_dependency "rubygame", "~> 2.6.4"
20
20
 
21
+ spec.requirements << "SDL_mixer [http://www.libsdl.org/projects/SDL_mixer/]"
22
+
21
23
  spec.add_development_dependency "cucumber"
22
24
  spec.add_development_dependency "aruba"
23
25
  spec.add_development_dependency "rspec"
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: text-to-noise
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.2
5
+ version: 0.1.4
6
6
  platform: ruby
7
7
  authors:
8
8
  - Toby Tripp
@@ -11,8 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2011-04-30 00:00:00 -05:00
15
- default_executable:
14
+ date: 2011-04-30 00:00:00 Z
16
15
  dependencies:
17
16
  - !ruby/object:Gem::Dependency
18
17
  name: rubygame
@@ -61,7 +60,7 @@ dependencies:
61
60
  description: Pipe a file, like a log file, into text_to_noise and it will play sound effects triggered by regex matches in the input.
62
61
  email: toby.tripp+tailsounds@gmail.com
63
62
  executables:
64
- - play
63
+ - play_noise
65
64
  - text_to_noise
66
65
  extensions: []
67
66
 
@@ -75,7 +74,7 @@ files:
75
74
  - LICENSE
76
75
  - README.md
77
76
  - Rakefile
78
- - bin/play
77
+ - bin/play_noise
79
78
  - bin/text_to_noise
80
79
  - cucumber.yml
81
80
  - features/configuration.feature
@@ -128,7 +127,6 @@ files:
128
127
  - text_to_noise.gemspec
129
128
  - ts.gems
130
129
  - watchr.rb
131
- has_rdoc: true
132
130
  homepage: https://github.com/tobytripp/text_to_noise
133
131
  licenses: []
134
132
 
@@ -149,10 +147,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
149
147
  - - ">="
150
148
  - !ruby/object:Gem::Version
151
149
  version: 1.3.6
152
- requirements: []
153
-
150
+ requirements:
151
+ - SDL_mixer [http://www.libsdl.org/projects/SDL_mixer/]
154
152
  rubyforge_project:
155
- rubygems_version: 1.6.2
153
+ rubygems_version: 1.7.2
156
154
  signing_key:
157
155
  specification_version: 3
158
156
  summary: Play sounds based on string matches.
data/bin/play DELETED
@@ -1,12 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require './lib/text_to_noise'
4
-
5
- player = TailSounds::Player.new
6
-
7
- ARGV.each do |sound|
8
- player.play sound
9
- sleep 1
10
- end
11
-
12
- sleep 1 while player.playing?