terminal 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Dockerfile +4 -0
- data/Gemfile.lock +18 -15
- data/Readme.md +6 -6
- data/bin/terminal +1 -1
- data/examples/curl.sh +1 -1
- data/lib/terminal/renderer.rb +13 -19
- data/lib/terminal/version.rb +1 -1
- data/script/memory_profile +16 -0
- data/spec/terminal/renderer_spec.rb +1 -1
- data/terminal.gemspec +2 -1
- metadata +19 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8080e014246d4d9ff730114e8369fd447402772
|
4
|
+
data.tar.gz: 7fd43ca59d7f083934c9a0139fbbe34e502cf3de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1babbd0249d209f6c20e09c75d65d7612edad91c39ee9be3f4fa9212274ec4a20ac11689d307d8673f85bd0bf929b2a86955827b51b1630d53a358b807fcd8c9
|
7
|
+
data.tar.gz: 651b8d7ffccde7d611ca3a1c7dd0ad7eec2cd00c0848838b001d1e1286ab0b826e2388648864137d8e90dd05507ec091b4c6def53562fe13ea859638c189ee62
|
data/Dockerfile
ADDED
data/Gemfile.lock
CHANGED
@@ -1,33 +1,35 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
terminal (0.
|
4
|
+
terminal (1.0.1)
|
5
5
|
escape_utils (~> 1.0)
|
6
6
|
gemoji (~> 2.1)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
benchmark-ips (2.
|
11
|
+
benchmark-ips (2.1.1)
|
12
12
|
diff-lcs (1.2.5)
|
13
13
|
escape_utils (1.0.1)
|
14
14
|
gemoji (2.1.0)
|
15
|
-
hirb (0.7.
|
15
|
+
hirb (0.7.3)
|
16
|
+
memory_profiler (0.0.4)
|
16
17
|
method_profiler (2.0.1)
|
17
18
|
hirb (>= 0.6.0)
|
18
|
-
rake (10.
|
19
|
-
rspec (3.
|
20
|
-
rspec-core (~> 3.
|
21
|
-
rspec-expectations (~> 3.
|
22
|
-
rspec-mocks (~> 3.
|
23
|
-
rspec-core (3.
|
24
|
-
rspec-support (~> 3.
|
25
|
-
rspec-expectations (3.
|
19
|
+
rake (10.4.2)
|
20
|
+
rspec (3.2.0)
|
21
|
+
rspec-core (~> 3.2.0)
|
22
|
+
rspec-expectations (~> 3.2.0)
|
23
|
+
rspec-mocks (~> 3.2.0)
|
24
|
+
rspec-core (3.2.0)
|
25
|
+
rspec-support (~> 3.2.0)
|
26
|
+
rspec-expectations (3.2.0)
|
26
27
|
diff-lcs (>= 1.2.0, < 2.0)
|
27
|
-
rspec-support (~> 3.
|
28
|
-
rspec-mocks (3.
|
29
|
-
|
30
|
-
|
28
|
+
rspec-support (~> 3.2.0)
|
29
|
+
rspec-mocks (3.2.0)
|
30
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
31
|
+
rspec-support (~> 3.2.0)
|
32
|
+
rspec-support (3.2.1)
|
31
33
|
|
32
34
|
PLATFORMS
|
33
35
|
ruby
|
@@ -35,6 +37,7 @@ PLATFORMS
|
|
35
37
|
DEPENDENCIES
|
36
38
|
benchmark-ips
|
37
39
|
bundler (~> 1.6)
|
40
|
+
memory_profiler
|
38
41
|
method_profiler
|
39
42
|
rake
|
40
43
|
rspec
|
data/Readme.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
![logo](http://
|
1
|
+
![logo](http://buildkite.github.io/terminal/images/logo.svg)
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/terminal.png)](https://rubygems.org/gems/terminal)
|
4
4
|
|
@@ -84,14 +84,14 @@ and when the render has finished, it will open in your web browser with a before
|
|
84
84
|
rspec --color --tty | terminal --preview
|
85
85
|
```
|
86
86
|
|
87
|
-
![preview mode](http://
|
87
|
+
![preview mode](http://buildkite.github.io/terminal/images/preview.png)
|
88
88
|
|
89
|
-
### With the
|
89
|
+
### With the Buildkite API
|
90
90
|
|
91
|
-
You can use the `job_url` returned by the [Builds API](https://
|
91
|
+
You can use the `job_url` returned by the [Builds API](https://buildkite.com/docs/api/builds) to pipe a job's log directly into terminal, for example:
|
92
92
|
|
93
93
|
```bash
|
94
|
-
JOB_LOG_URL="https://api.
|
94
|
+
JOB_LOG_URL="https://api.buildkite.com/v1/accounts/[account]/projects/[project]/builds/[build]/jobs/[job]/log.txt?api_key=[api-key]"
|
95
95
|
curl $JOB_LOG_URL | terminal --preview
|
96
96
|
```
|
97
97
|
|
@@ -120,7 +120,7 @@ mv examples/*{raw,rendered} spec/fixtures
|
|
120
120
|
|
121
121
|
## Licence
|
122
122
|
|
123
|
-
> Copyright (c)
|
123
|
+
> Copyright (c) 2015 Keith Pitt, Tim Lucas, Buildkite Pty Ltd
|
124
124
|
>
|
125
125
|
> MIT License
|
126
126
|
>
|
data/bin/terminal
CHANGED
data/examples/curl.sh
CHANGED
@@ -1,4 +1,4 @@
|
|
1
1
|
#!/bin/bash
|
2
2
|
|
3
3
|
echo -e "\033[90m$\033[0m curl -o /tmp/file.txt https://example.com/file.txt"
|
4
|
-
curl -o /tmp/
|
4
|
+
curl -o /tmp/buildkite-agent.tar.gz https://github.com/buildkite/buildkite-agent/releases/download/v0.1-alpha/buildkite-agent-darwin-386.tar.gz
|
data/lib/terminal/renderer.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'escape_utils'
|
4
4
|
require 'emoji'
|
5
|
+
require 'strscan'
|
5
6
|
|
6
7
|
module Terminal
|
7
8
|
class Renderer
|
@@ -27,12 +28,8 @@ module Terminal
|
|
27
28
|
def render
|
28
29
|
return "" if @output.nil?
|
29
30
|
|
30
|
-
# First duplicate the string, because we're going to be editing and chopping it
|
31
|
-
# up directly.
|
32
|
-
output = @output.to_s.dup
|
33
|
-
|
34
31
|
# Don't allow parsing of outputs longer than 4 meg
|
35
|
-
output =
|
32
|
+
output = dup_check_and_chomp_length(@output)
|
36
33
|
|
37
34
|
# Force encoding on the output first
|
38
35
|
force_encoding!(output)
|
@@ -57,7 +54,7 @@ module Terminal
|
|
57
54
|
|
58
55
|
private
|
59
56
|
|
60
|
-
def
|
57
|
+
def dup_check_and_chomp_length(output)
|
61
58
|
# Limit the entire size of the output to 4 meg
|
62
59
|
max_total_size = 4 * MEGABYTES
|
63
60
|
if output.bytesize > max_total_size
|
@@ -65,7 +62,7 @@ module Terminal
|
|
65
62
|
new_output << "\n\nWarning: Terminal has chopped off the rest of the build as it's over the allowed 4 megabyte limit for logs."
|
66
63
|
new_output
|
67
64
|
else
|
68
|
-
output
|
65
|
+
output.dup
|
69
66
|
end
|
70
67
|
end
|
71
68
|
|
@@ -79,18 +76,15 @@ module Terminal
|
|
79
76
|
end
|
80
77
|
end
|
81
78
|
|
82
|
-
# Scan the string to create an array of interesting things, for example
|
83
|
-
# it would look like this:
|
84
|
-
# [ '\n', '\r', 'a', 'b', '\e123m' ]
|
85
|
-
def split_by_escape_character(string)
|
86
|
-
string.scan(INTERESTING_PARTS_REGEX)
|
87
|
-
end
|
88
|
-
|
89
79
|
def render_to_screen(string)
|
90
|
-
|
91
|
-
|
92
|
-
#
|
93
|
-
|
80
|
+
scanner = StringScanner.new(string)
|
81
|
+
|
82
|
+
# Scan the string for interesting things, for example:
|
83
|
+
# [ '\n', '\r', 'a', 'b', '\e123m' ]
|
84
|
+
while char = scanner.scan(INTERESTING_PARTS_REGEX)
|
85
|
+
# The when cases are ordered by most likely, the lest checks it has to go
|
86
|
+
# through before matching, the faster the render will be. Colors are
|
87
|
+
# usually most likey, so that's first.
|
94
88
|
if char == "\n".freeze
|
95
89
|
@screen.x = 0
|
96
90
|
@screen.y += 1
|
@@ -98,7 +92,7 @@ module Terminal
|
|
98
92
|
@screen.x = 0
|
99
93
|
elsif char == "\b".freeze
|
100
94
|
@screen.x -= 1
|
101
|
-
elsif char
|
95
|
+
elsif char.index("\e".freeze) == 0 && char.length > 1
|
102
96
|
sequence = char.match(ESCAPE_CAPTURE_REGEX)
|
103
97
|
|
104
98
|
instruction = sequence[1]
|
data/lib/terminal/version.rb
CHANGED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# Usage:
|
4
|
+
#
|
5
|
+
# script/memory_profile log.txt
|
6
|
+
|
7
|
+
$:.unshift(File.join(File.expand_path(File.dirname(__FILE__)), '..', 'lib'))
|
8
|
+
|
9
|
+
require 'terminal'
|
10
|
+
require 'memory_profiler'
|
11
|
+
|
12
|
+
log = $<.read
|
13
|
+
|
14
|
+
puts MemoryProfiler.report {
|
15
|
+
Terminal.render(log)
|
16
|
+
}.pretty_print
|
@@ -199,7 +199,7 @@ describe Terminal::Renderer do
|
|
199
199
|
it "renders unicode emoji" do
|
200
200
|
raw = "this is great 👍"
|
201
201
|
|
202
|
-
expect(render(raw)).to eql(%{this is great <img alt="
|
202
|
+
expect(render(raw)).to eql(%{this is great <img alt="+1" title="+1" src="/assets/emojis/unicode/1f44d.png" class="emoji" width="20" height="20" />})
|
203
203
|
end
|
204
204
|
|
205
205
|
it "returns nothing if the unicode emoji can't be found" do
|
data/terminal.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["me@keithpitt.com"]
|
11
11
|
spec.summary = %q{Converts ANSI to HTML}
|
12
12
|
spec.description = %q{Converts ANSI to HTML}
|
13
|
-
spec.homepage = "https://github.com/
|
13
|
+
spec.homepage = "https://github.com/buildkite/terminal"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0")
|
@@ -26,4 +26,5 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.add_development_dependency "rspec"
|
27
27
|
spec.add_development_dependency "benchmark-ips"
|
28
28
|
spec.add_development_dependency "method_profiler"
|
29
|
+
spec.add_development_dependency "memory_profiler"
|
29
30
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: terminal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Keith Pitt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: escape_utils
|
@@ -108,6 +108,20 @@ dependencies:
|
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: memory_profiler
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
111
125
|
description: Converts ANSI to HTML
|
112
126
|
email:
|
113
127
|
- me@keithpitt.com
|
@@ -119,6 +133,7 @@ files:
|
|
119
133
|
- ".DS_Store"
|
120
134
|
- ".gitignore"
|
121
135
|
- ".rspec"
|
136
|
+
- Dockerfile
|
122
137
|
- Gemfile
|
123
138
|
- Gemfile.lock
|
124
139
|
- Rakefile
|
@@ -145,6 +160,7 @@ files:
|
|
145
160
|
- script/buildbox/benchmark.sh
|
146
161
|
- script/buildbox/profile_methods.sh
|
147
162
|
- script/buildbox/specs.sh
|
163
|
+
- script/memory_profile
|
148
164
|
- script/profile_methods
|
149
165
|
- spec/fixtures/curl.sh.raw
|
150
166
|
- spec/fixtures/curl.sh.rendered
|
@@ -157,7 +173,7 @@ files:
|
|
157
173
|
- spec/terminal/renderer_spec.rb
|
158
174
|
- spec/terminal/screen_spec.rb
|
159
175
|
- terminal.gemspec
|
160
|
-
homepage: https://github.com/
|
176
|
+
homepage: https://github.com/buildkite/terminal
|
161
177
|
licenses:
|
162
178
|
- MIT
|
163
179
|
metadata: {}
|