terminal 0.3 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/Readme.md +5 -9
- data/app/assets/stylesheets/terminal.css +13 -0
- data/lib/terminal/renderer.rb +8 -0
- data/lib/terminal/templates/preview.html.erb +2 -16
- data/lib/terminal/version.rb +1 -1
- data/spec/terminal/renderer_spec.rb +7 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54b22e3e05336e785b66eaead924b54a341c3938
|
4
|
+
data.tar.gz: 0a2f52dd360a0fafeb918ce605ba28c63202aac5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65c72b0e4cbba9ff22208bbe619678d362391c22e213143825e9ed2e54ae211e7b3f30b72251408a9ffac04dae4f7484acd938d8d1c7864f87da286a3e90776a
|
7
|
+
data.tar.gz: 056609e233229daeb9ee4b6f95c1cd84f76ce4a10591a97413da6370050061807bed57d291dd8f7e7875f054576620c677332d675dd3c667c09a937fb5d19956
|
data/Gemfile.lock
CHANGED
data/Readme.md
CHANGED
@@ -48,7 +48,7 @@ Then in your `app/assets/application.css` file:
|
|
48
48
|
Now in your views:
|
49
49
|
|
50
50
|
```
|
51
|
-
<div class="
|
51
|
+
<div class="term-container"><%= Terminal.render(output) %></div>
|
52
52
|
```
|
53
53
|
|
54
54
|
### Emojis :+1:
|
@@ -84,21 +84,17 @@ 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
|
-

|
88
88
|
|
89
89
|
### With the Buildbox API
|
90
90
|
|
91
|
-
|
92
|
-
|
93
|
-
Then, you can:
|
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:
|
94
92
|
|
95
93
|
```bash
|
96
|
-
|
97
|
-
curl $JOB_LOG_URL
|
94
|
+
JOB_LOG_URL="https://api.buildbox.io/v1/accounts/[account]/projects/[project]/builds/[build]/jobs/[job]/log.txt?api_key=[api-key]"
|
95
|
+
curl $JOB_LOG_URL | terminal --preview
|
98
96
|
```
|
99
97
|
|
100
|
-
For more information on the Buildbox Builds API, see: https://buildbox.io/docs/api/builds
|
101
|
-
|
102
98
|
## Generating Fixtures
|
103
99
|
|
104
100
|
To generate a fixture, first create a test case inside the `examples` folder. See the `curl.sh`
|
@@ -1,3 +1,16 @@
|
|
1
|
+
.term-container {
|
2
|
+
background: #171717;
|
3
|
+
border-radius: 5px;
|
4
|
+
color: white;
|
5
|
+
word-break: break-word;
|
6
|
+
overflow-wrap: break-word;
|
7
|
+
font-family: Monaco, courier;
|
8
|
+
font-size: 12px;
|
9
|
+
line-height: 20px;
|
10
|
+
padding: 14px 18px;
|
11
|
+
white-space: pre-wrap;
|
12
|
+
}
|
13
|
+
|
1
14
|
.term-fg30 { color: #666; } /* black (but we can't use black, so a diff color) */
|
2
15
|
.term-fg31 { color: #e10c02; } /* red */
|
3
16
|
.term-fg32 { color: #00bd02; } /* green */
|
data/lib/terminal/renderer.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
1
3
|
require 'escape_utils'
|
2
4
|
require 'emoji'
|
3
5
|
|
@@ -172,6 +174,10 @@ module Terminal
|
|
172
174
|
end
|
173
175
|
end
|
174
176
|
|
177
|
+
# The Emoji API will be transitioning to a nil-based find API, at the
|
178
|
+
# moment it raies exceptions for Emojis that can't be found:
|
179
|
+
# https://github.com/github/gemoji/commit/b1736a387c7c1c2af300506fea5603e2e1fb89d8
|
180
|
+
# Will support both for now.
|
175
181
|
def emoji_image_from_unicode(unicode)
|
176
182
|
emoji = Emoji.find_by_unicode(unicode)
|
177
183
|
|
@@ -183,6 +189,8 @@ module Terminal
|
|
183
189
|
else
|
184
190
|
unicode
|
185
191
|
end
|
192
|
+
rescue
|
193
|
+
unicode
|
186
194
|
end
|
187
195
|
end
|
188
196
|
end
|
@@ -4,20 +4,6 @@
|
|
4
4
|
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
5
5
|
<link href="<%= asset_path("stylesheets/terminal.css") %>" media="screen" rel="stylesheet" />
|
6
6
|
<style>
|
7
|
-
.code {
|
8
|
-
background: #171717;
|
9
|
-
border-radius: 5px;
|
10
|
-
color: white;
|
11
|
-
word-break: break-word;
|
12
|
-
overflow-wrap: break-word;
|
13
|
-
font-family: Monaco, courier;
|
14
|
-
font-size: 12px;
|
15
|
-
line-height: 20px;
|
16
|
-
padding: 14px 18px;
|
17
|
-
white-space: pre-wrap;
|
18
|
-
margin-bottom: 15px;
|
19
|
-
}
|
20
|
-
|
21
7
|
body {
|
22
8
|
margin: 0;
|
23
9
|
padding: 20px;
|
@@ -46,11 +32,11 @@
|
|
46
32
|
<body>
|
47
33
|
<div id="rendered" class="preview">
|
48
34
|
<div class="controls"><a href="#" onclick="switchViews(); return false">Show Raw Output</a></div>
|
49
|
-
<div class="
|
35
|
+
<div class="term-container"><%= rendered %></div>
|
50
36
|
</div>
|
51
37
|
<div id="raw" class="preview" style="display: none">
|
52
38
|
<div class="controls"><a href="#" onclick="switchViews(); return false">Show Rendered Output</a></div>
|
53
|
-
<div class="
|
39
|
+
<div class="term-container raw"><%= raw %></div>
|
54
40
|
</div>
|
55
41
|
</body>
|
56
42
|
</html>
|
data/lib/terminal/version.rb
CHANGED
@@ -200,6 +200,13 @@ describe Terminal::Renderer do
|
|
200
200
|
|
201
201
|
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
202
|
end
|
203
|
+
|
204
|
+
it "returns nothing if the unicode emoji can't be found" do
|
205
|
+
expect(Emoji).to receive(:unicodes_index) { {} }
|
206
|
+
raw = "this is great 👍"
|
207
|
+
|
208
|
+
expect(render(raw)).to eql(%{this is great 👍})
|
209
|
+
end
|
203
210
|
end
|
204
211
|
|
205
212
|
private
|