ttycoke 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +16 -0
- data/.togglerc +10 -0
- data/.tork.rb +2 -0
- data/.travis.yml +6 -0
- data/LICENSE +21 -0
- data/README.md +150 -0
- data/Rakefile +25 -0
- data/bin/ttycoke +10 -0
- data/config/config.yaml +5 -0
- data/config/ttycoke.d/id.yaml +4 -0
- data/config/ttycoke.d/lsmod.yaml +3 -0
- data/config/ttycoke.d/tail_focus.yaml +14 -0
- data/config/ttycoke.d/tail_tork_logs.yaml +26 -0
- data/config/ttycoke.d/top.yaml +8 -0
- data/doc/TTYCoke/ANSI.html +598 -0
- data/doc/TTYCoke/ANSIColor.html +586 -0
- data/doc/TTYCoke/CLI.html +242 -0
- data/doc/TTYCoke/Config/Configuration.html +210 -0
- data/doc/TTYCoke/Config.html +347 -0
- data/doc/TTYCoke/Errors/CustomizationFailed.html +135 -0
- data/doc/TTYCoke/Errors/FallbackError.html +216 -0
- data/doc/TTYCoke/Errors/ProgramNotFoundError.html +216 -0
- data/doc/TTYCoke/Errors/TTYCokeError.html +206 -0
- data/doc/TTYCoke/Errors/TTYCokeTypeError.html +216 -0
- data/doc/TTYCoke/Errors/YamlSyntaxError.html +216 -0
- data/doc/TTYCoke/Errors.html +106 -0
- data/doc/TTYCoke/LineParser.html +210 -0
- data/doc/TTYCoke/Log.html +391 -0
- data/doc/TTYCoke/Parser.html +210 -0
- data/doc/TTYCoke/Platform.html +398 -0
- data/doc/TTYCoke/Run.html +198 -0
- data/doc/TTYCoke/TTYCokeLogFormat.html +204 -0
- data/doc/TTYCoke/Version.html +136 -0
- data/doc/TTYCoke.html +110 -0
- data/doc/_index.html +279 -0
- data/doc/class_list.html +47 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +55 -0
- data/doc/css/style.css +322 -0
- data/doc/file.README.html +153 -0
- data/doc/file_list.html +49 -0
- data/doc/frames.html +13 -0
- data/doc/index.html +153 -0
- data/doc/js/app.js +205 -0
- data/doc/js/full_list.js +167 -0
- data/doc/js/jquery.js +16 -0
- data/doc/method_list.html +238 -0
- data/doc/top-level-namespace.html +130 -0
- data/lib/ttycoke/ansi.rb +127 -0
- data/lib/ttycoke/cli.rb +33 -0
- data/lib/ttycoke/config.rb +39 -0
- data/lib/ttycoke/errors.rb +40 -0
- data/lib/ttycoke/import.rb +72 -0
- data/lib/ttycoke/log.rb +84 -0
- data/lib/ttycoke/parser.rb +59 -0
- data/lib/ttycoke/platform.rb +33 -0
- data/lib/ttycoke/run.rb +59 -0
- data/lib/ttycoke/version.rb +10 -0
- data/lib/ttycoke.rb +15 -0
- data/test/data/ansi_lines.yaml +12 -0
- data/test/data/config.yaml +4 -0
- data/test/data/syntax_error_config.yaml +6 -0
- data/test/data/ttycoke.d/id.yaml +4 -0
- data/test/data/ttycoke.d/lsmod.yaml +3 -0
- data/test/data/ttycoke.d/tail_focus.yaml +14 -0
- data/test/data/ttycoke.d/tail_tork_logs.yaml +26 -0
- data/test/data/ttycoke.d/top.yaml +8 -0
- data/test/test_helper.rb +14 -0
- data/test/ttycoke/test_ansi.rb +89 -0
- data/test/ttycoke/test_cli.rb +8 -0
- data/test/ttycoke/test_config.rb +23 -0
- data/test/ttycoke/test_log.rb +22 -0
- data/test/ttycoke/test_parser.rb +24 -0
- data/ttycoke.gemspec +16 -0
- metadata +120 -0
data/.gitignore
ADDED
data/.togglerc
ADDED
data/.tork.rb
ADDED
data/.travis.yml
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2012 Jose Pablo Barrantes
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,150 @@
|
|
1
|
+
# TTYCoke [![Build Status](https://secure.travis-ci.org/jpablobr/ttycoke.png?branch=master)][travis]
|
2
|
+
|
3
|
+
[travis]: http://travis-ci.org/jpablobr/ttycoke
|
4
|
+
|
5
|
+
TTYCoke lets one modify the colorset of a running program (that
|
6
|
+
display output to the command-line) based on predefined regular
|
7
|
+
expression. Basically it's wrapper around the program, executing it
|
8
|
+
and parsing its stdout stream (where it will apply the matching
|
9
|
+
rules/colors).
|
10
|
+
|
11
|
+
## <a name="Before-After"></a>Before/After
|
12
|
+
|
13
|
+
[![before](http://i.imgur.com/nIen0.png)][before] [![after](http://i.imgur.com/4iVkc.png)][after]
|
14
|
+
|
15
|
+
[before]: http://i.imgur.com/nIen0.png
|
16
|
+
[after]: http://i.imgur.com/4iVkc.png
|
17
|
+
|
18
|
+
Initial disclaimer! This mess is raw, like sushi. So, haters to the left.
|
19
|
+
|
20
|
+
anyway,
|
21
|
+
|
22
|
+
## <a name="Installation"></a>Installation :)
|
23
|
+
|
24
|
+
For specific Ruby version requirements, see the [Travis build](http://travis-ci.org/#!/jpablobr/ttycoke). ATM > 1.9.
|
25
|
+
|
26
|
+
With RubyGems, simply open a terminal and type:
|
27
|
+
|
28
|
+
$ {sudo} gem install ttycoke
|
29
|
+
|
30
|
+
Local installation:
|
31
|
+
|
32
|
+
[Download](http://github.com/jpablobr/ttycoke/download) the tarball package and:
|
33
|
+
|
34
|
+
$ tar -xvzf ttycoke-{version}.tgz
|
35
|
+
|
36
|
+
or
|
37
|
+
|
38
|
+
$ git clone https://github.com/jpablobr/ttycoke.git
|
39
|
+
|
40
|
+
then
|
41
|
+
|
42
|
+
$ cd ttycoke-{version}
|
43
|
+
$ {sudo} rake install
|
44
|
+
|
45
|
+
Now you are ready to start coking!
|
46
|
+
|
47
|
+
## <a name="Usage"></a>Usage
|
48
|
+
|
49
|
+
$ ttycoke {program-name}
|
50
|
+
|
51
|
+
If the program exist in the config file, it will use its rules to `ttycoke`
|
52
|
+
it, otherwise it will fallback to its normal execution.
|
53
|
+
|
54
|
+
You can also define your own rules for things such as `tailing` your logs! Something like the following should work:
|
55
|
+
|
56
|
+
Create an executable shell script and name it lets say, `my_awesome_app_logs.sh` with:
|
57
|
+
|
58
|
+
#!/bin/sh
|
59
|
+
tail -f ~/apps/my_awesome_app/log/**/*.log
|
60
|
+
|
61
|
+
Then in your terminal you can `ttycoke` it as such:
|
62
|
+
|
63
|
+
$ ttycoke my_awesome_app_logs.sh # <3<3<3
|
64
|
+
|
65
|
+
if you were creative enough, you'll be seeing rainbows!
|
66
|
+
|
67
|
+
Again, it's just a wrapper around the program, It just parses it
|
68
|
+
stdout stream, so its capable of much more!
|
69
|
+
|
70
|
+
## <a name="Configuration"></a>Configuration
|
71
|
+
The following rake task will copy the `ttycoke/config/config.yaml` file to your `$HOME` directory as `.ttycokerc`.
|
72
|
+
|
73
|
+
$ rake setup
|
74
|
+
|
75
|
+
This file contains the regular expression rules and it's also where you'll be adding yours!
|
76
|
+
|
77
|
+
## <a name="How-it-works"></a>How it works
|
78
|
+
|
79
|
+
Basically it's just 1:1 match to the specified colors in the regular
|
80
|
+
expression groups. So for example, with the following rule:
|
81
|
+
|
82
|
+
``` yaml
|
83
|
+
lsmod:
|
84
|
+
regex: !ruby/regexp
|
85
|
+
/^(?<green>\w+)(?<uncolored>\s+)(?<blue>\d+)(?<uncolored>\s+)(?<yellow>\d+)(?<magenta>.+)/
|
86
|
+
|
87
|
+
```
|
88
|
+
|
89
|
+
the lsmod program will be matched as follows: (I know kind of obvious)
|
90
|
+
|
91
|
+
'/^(?<green>\w+)(?<uncolored>\s+)(?<blue>\d+)(?<uncolored>\s+)(?<yellow>\d+)(?<magenta>.+)/'
|
92
|
+
| | | | | |
|
93
|
+
| | | | | \_: magenta
|
94
|
+
| | | | \_: yellow
|
95
|
+
| | | \_: uncolored
|
96
|
+
| | \_:blue
|
97
|
+
| \_:uncolored
|
98
|
+
\_:green
|
99
|
+
|
100
|
+
Based on that you can now take it a bit further and for example the
|
101
|
+
following will create a green/red TDD kind of output:
|
102
|
+
|
103
|
+
((?<green>success)|(?<red>fail|error))
|
104
|
+
|
105
|
+
The first screenshot is based of the following:
|
106
|
+
|
107
|
+
``` yaml
|
108
|
+
tail_tork_logs:
|
109
|
+
-
|
110
|
+
results:
|
111
|
+
regex: !ruby/regexp
|
112
|
+
/^(?<underscore>Finished.*)/
|
113
|
+
error:
|
114
|
+
regex: !ruby/regexp
|
115
|
+
/(?<red>.+(Error|Failure):)/
|
116
|
+
expected:
|
117
|
+
regex: !ruby/regexp
|
118
|
+
/(?<blue>--- expected)/
|
119
|
+
expected-string:
|
120
|
+
regex: !ruby/regexp
|
121
|
+
/(?<blue>-\".+)/
|
122
|
+
actual:
|
123
|
+
regex: !ruby/regexp
|
124
|
+
/(?<red>\++ actual)/
|
125
|
+
actual-string:
|
126
|
+
regex: !ruby/regexp
|
127
|
+
/(?<red>\+\".+)/
|
128
|
+
at:
|
129
|
+
regex: !ruby/regexp
|
130
|
+
/(?<on_yellow>@.+)/
|
131
|
+
stats:
|
132
|
+
regex: !ruby/regexp
|
133
|
+
/(?<white>\d+ tests, )(?<green>\d+ assertions, )(?<magenta>\d+ failures, )(?<red>\d+ errors, )(?<yellow>\d+ skips)/
|
134
|
+
```
|
135
|
+
|
136
|
+
and the `tail_tork_logs` looks like this:
|
137
|
+
|
138
|
+
#!/bin/sh
|
139
|
+
|
140
|
+
tail -f log/test/**/*.log
|
141
|
+
|
142
|
+
That's just from `tailing` the ouput of the [Tork](https://github.com/sunaku/tork) continuous testing framework.
|
143
|
+
|
144
|
+
## <a name="todo"></a>TODO
|
145
|
+
* Add more sample regular expression parsers.
|
146
|
+
|
147
|
+
## <a name="copyright"></a>Copyright
|
148
|
+
Copyright (c) 2012 Jose Pablo Barrantes. See [LICENSE][] for details.
|
149
|
+
|
150
|
+
[license]: https://github.com/jpablobr/ttycoke/blob/master/LICENSE
|
data/Rakefile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
|
5
|
+
namespace :test do
|
6
|
+
Rake::TestTask.new do |t|
|
7
|
+
t.name = "minitest"
|
8
|
+
t.libs << "test"
|
9
|
+
t.test_files = FileList['test/ttycoke/test_*.rb', 'test/test_*.rb']
|
10
|
+
t.verbose = true
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
desc "install the rc file into user's home directory"
|
15
|
+
task :setup do
|
16
|
+
if File.exist?(File.join(ENV['HOME'], ".ttycokerc"))
|
17
|
+
puts "#{File.join(ENV['HOME'], '.ttycokerc')} already exist."
|
18
|
+
else
|
19
|
+
puts "Coping .ttycokerc to $HOME directory"
|
20
|
+
system %Q{cp "$PWD/config/config.yaml" "$HOME/.ttycokerc"}
|
21
|
+
puts "done."
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
task :default => "test:minitest"
|
data/bin/ttycoke
ADDED
data/config/config.yaml
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
tail_tork_logs:
|
2
|
+
-
|
3
|
+
results:
|
4
|
+
regex: !ruby/regexp
|
5
|
+
/^(?<underscore>Finished.*)/
|
6
|
+
error:
|
7
|
+
regex: !ruby/regexp
|
8
|
+
/(?<red>.+(Error|Failure):)/
|
9
|
+
expected:
|
10
|
+
regex: !ruby/regexp
|
11
|
+
/(?<blue>--- expected)/
|
12
|
+
expected-string:
|
13
|
+
regex: !ruby/regexp
|
14
|
+
/(?<blue>-\".+)/
|
15
|
+
actual:
|
16
|
+
regex: !ruby/regexp
|
17
|
+
/(?<red>\++ actual)/
|
18
|
+
actual-string:
|
19
|
+
regex: !ruby/regexp
|
20
|
+
/(?<red>\+\".+)/
|
21
|
+
at:
|
22
|
+
regex: !ruby/regexp
|
23
|
+
/(?<on_yellow>@.+)/
|
24
|
+
stats:
|
25
|
+
regex: !ruby/regexp
|
26
|
+
/(?<white>\d+ tests, )(?<green>\d+ assertions, )(?<magenta>\d+ failures, )(?<red>\d+ errors, )(?<yellow>\d+ skips)/
|