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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6a1fd9f219146ed4463a928b67224582819d8757
4
- data.tar.gz: 53c7767794c1bb69439d5e6e441bc70cb97e0b86
3
+ metadata.gz: c8080e014246d4d9ff730114e8369fd447402772
4
+ data.tar.gz: 7fd43ca59d7f083934c9a0139fbbe34e502cf3de
5
5
  SHA512:
6
- metadata.gz: 9d1e0f48a43edfed6e63d95740fc51de8ad5ee17415f630dc43c1a39d1cbc5052927976614109633d0f3eaad57d736f52fa1c630bbda4db2ac951a9254cf4e59
7
- data.tar.gz: debe42f4483592f784a20c739f95407852ed690c5924d58d587b9c7de3fca3592597b23c954a9145a7fcb6a802178eb6ee5f5ab6d8e3791b2f24026aaeec2fca
6
+ metadata.gz: 1babbd0249d209f6c20e09c75d65d7612edad91c39ee9be3f4fa9212274ec4a20ac11689d307d8673f85bd0bf929b2a86955827b51b1630d53a358b807fcd8c9
7
+ data.tar.gz: 651b8d7ffccde7d611ca3a1c7dd0ad7eec2cd00c0848838b001d1e1286ab0b826e2388648864137d8e90dd05507ec091b4c6def53562fe13ea859638c189ee62
@@ -0,0 +1,4 @@
1
+ FROM ruby:2.1.5
2
+
3
+ ADD . /app
4
+ WORKDIR /app
@@ -1,33 +1,35 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- terminal (0.4)
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.0.0)
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.2)
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.3.2)
19
- rspec (3.1.0)
20
- rspec-core (~> 3.1.0)
21
- rspec-expectations (~> 3.1.0)
22
- rspec-mocks (~> 3.1.0)
23
- rspec-core (3.1.7)
24
- rspec-support (~> 3.1.0)
25
- rspec-expectations (3.1.2)
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.1.0)
28
- rspec-mocks (3.1.3)
29
- rspec-support (~> 3.1.0)
30
- rspec-support (3.1.2)
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://buildbox.github.io/terminal/images/logo.svg)
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://buildbox.github.io/terminal/images/preview.png)
87
+ ![preview mode](http://buildkite.github.io/terminal/images/preview.png)
88
88
 
89
- ### With the Buildbox API
89
+ ### With the Buildkite API
90
90
 
91
- You can use the `job_url` returned by the [Builds API](https://buildbox.io/docs/api/builds) to pipe a job's log directly into terminal, for example:
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.buildbox.io/v1/accounts/[account]/projects/[project]/builds/[build]/jobs/[job]/log.txt?api_key=[api-key]"
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) 2014 Keith Pitt, Buildbox
123
+ > Copyright (c) 2015 Keith Pitt, Tim Lucas, Buildkite Pty Ltd
124
124
  >
125
125
  > MIT License
126
126
  >
@@ -22,7 +22,7 @@ Version:
22
22
  Preview in the browser:
23
23
  $ terminal --preview
24
24
 
25
- See https://buildbox.github.io/terminal for more information.
25
+ See https://buildkite.github.io/terminal for more information.
26
26
  usage
27
27
  end
28
28
 
@@ -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/buildbox-agent.tar.gz https://github.com/buildbox/buildbox-agent/releases/download/v0.1-alpha/buildbox-agent-darwin-386.tar.gz
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
@@ -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 = check_and_chomp_length(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 check_and_chomp_length(output)
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
- # The when cases are ordered by most likely, the lest checks it has to go
91
- # through before matching, the faster the render will be. Colors are
92
- # usually most likey, so that's first.
93
- split_by_escape_character(string).each do |char|
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[0] == "\e".freeze && char.length > 1
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]
@@ -1,3 +1,3 @@
1
1
  module Terminal
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -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=":+1:" title=":+1:" src="/assets/emojis/unicode/1f44d.png" class="emoji" width="20" height="20" />})
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
@@ -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/buildbox/terminal"
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.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-13 00:00:00.000000000 Z
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/buildbox/terminal
176
+ homepage: https://github.com/buildkite/terminal
161
177
  licenses:
162
178
  - MIT
163
179
  metadata: {}