ansi_up-rails 0.1.1 → 0.1.2

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: 7d188d49ad63af98007abaf221ddf2989fe5e8a4
4
- data.tar.gz: 8d6c3a1f0df33b275acd6d1218235ef549f88c74
3
+ metadata.gz: 48cb004d6574949a8857888e085d4850586b682d
4
+ data.tar.gz: 440aecd6d644ff5e615002dd5b9ef96ed2f4e905
5
5
  SHA512:
6
- metadata.gz: fa2ddb7f61f20a2e7114ef457384608ab4f2cec566675e806ca8850d821b3a7a85fd963c0783eb1a5db390090c2597570ac634819fb65c8581d3fab2427291ae
7
- data.tar.gz: 46b76f95352f6a6a3af9c75e8a250f48d50e09775da4ba63a7609406e9959a14490e14e395f4992f4fdb72e1212ef5b056cec31b215e518572e08c7ccdc6d5dd
6
+ metadata.gz: 190725ac2f3e55de1a776464900fdef1686967110dba21059a54c0239e4320db422e536fd60d07d2b7819574137e2ab24238fde5cb53038c52e6b4d913ab84a8
7
+ data.tar.gz: 07bdf872ab3944edb0133fac81a7af89fa252d8664c3a4ceff1d1464073e0a6aee096d4e96eb93b7767ecf93c96735676df5ae13d1fe69721cdd4854bb502c1a
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2010 Andre Arko
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.
@@ -0,0 +1,21 @@
1
+ ## Setup
2
+
3
+ ```
4
+ gem 'ansi_up-rails'
5
+ ```
6
+
7
+ ## Installation
8
+
9
+ The ansi\_up file will be added to the asset pipeline
10
+
11
+ ```
12
+ //= require ansi_up
13
+ ```
14
+
15
+ ## Contributing
16
+
17
+ Feel free to open pull request if the library is obsolete or anything like this.
18
+ We won't accept pull request on ansi\_up modification, you have to edit the project
19
+ upstream:
20
+
21
+ https://github.com/drudru/ansi\_up
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/ansi_up/rails/version', __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "ansi_up-rails"
6
+ s.version = AnsiUp::Rails::VERSION
7
+ s.platform = Gem::Platform::RUBY
8
+ s.authors = ["Leo Unbekandt"]
9
+ s.email = ["leo@scalingo.com"]
10
+ s.homepage = "http://rubygems.org/gems/ansi_up-rails"
11
+ s.summary = "Use the ansi_up js library with Rails 4+"
12
+ s.description = "This gem provides ansi_up for your Rails 4+ application."
13
+ s.license = "MIT"
14
+
15
+ s.required_rubygems_version = ">= 1.3.6"
16
+
17
+ s.add_dependency "railties", "~> 4"
18
+
19
+ s.files = `git ls-files`.split("\n")
20
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
21
+ s.require_path = 'lib'
22
+ end
@@ -0,0 +1 @@
1
+ require 'ansi_up/rails'
@@ -0,0 +1,7 @@
1
+ require 'ansi_up/rails/engine'
2
+ require 'ansi_up/rails/version'
3
+
4
+ module AnsiUp
5
+ module Rails
6
+ end
7
+ end
@@ -0,0 +1,6 @@
1
+ module AnsiUp
2
+ module Rails
3
+ class Engine < ::Rails::Engine
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module AnsiUp
2
+ module Rails
3
+ VERSION = "0.1.2"
4
+ ANSI_UP_VERSION = "1.1.2"
5
+ end
6
+ end
@@ -0,0 +1,189 @@
1
+ // ansi_up.js
2
+ // version : 1.1.2
3
+ // author : Dru Nelson
4
+ // license : MIT
5
+ // http://github.com/drudru/ansi_up
6
+
7
+ (function (Date, undefined) {
8
+
9
+ var ansi_up,
10
+ VERSION = "1.1.2",
11
+
12
+ // check for nodeJS
13
+ hasModule = (typeof module !== 'undefined'),
14
+
15
+ // Normal and then Bright
16
+ ANSI_COLORS = [
17
+ [
18
+ { color: "0, 0, 0", class: "ansi-black" },
19
+ { color: "187, 0, 0", class: "ansi-red" },
20
+ { color: "0, 187, 0", class: "ansi-green" },
21
+ { color: "187, 187, 0", class: "ansi-yellow" },
22
+ { color: "0, 0, 187", class: "ansi-blue" },
23
+ { color: "187, 0, 187", class: "ansi-magenta" },
24
+ { color: "0, 187, 187", class: "ansi-cyan" },
25
+ { color: "255,255,255", class: "ansi-white" }
26
+ ],
27
+ [
28
+ { color: "85, 85, 85", class: "ansi-bright-black" },
29
+ { color: "255, 85, 85", class: "ansi-bright-red" },
30
+ { color: "0, 255, 0", class: "ansi-bright-green" },
31
+ { color: "255, 255, 85", class: "ansi-bright-yellow" },
32
+ { color: "85, 85, 255", class: "ansi-bright-blue" },
33
+ { color: "255, 85, 255", class: "ansi-bright-magenta" },
34
+ { color: "85, 255, 255", class: "ansi-bright-cyan" },
35
+ { color: "255, 255, 255", class: "ansi-bright-white" }
36
+ ]
37
+ ];
38
+
39
+ function Ansi_Up() {
40
+ this.fg = this.bg = null;
41
+ this.bright = 0;
42
+ }
43
+
44
+ Ansi_Up.prototype.escape_for_html = function (txt) {
45
+ return txt.replace(/[&<>]/gm, function(str) {
46
+ if (str == "&") return "&amp;";
47
+ if (str == "<") return "&lt;";
48
+ if (str == ">") return "&gt;";
49
+ });
50
+ };
51
+
52
+ Ansi_Up.prototype.linkify = function (txt) {
53
+ return txt.replace(/(https?:\/\/[^\s]+)/gm, function(str) {
54
+ return "<a href=\"" + str + "\">" + str + "</a>";
55
+ });
56
+ };
57
+
58
+ Ansi_Up.prototype.ansi_to_html = function (txt, options) {
59
+
60
+ var data4 = txt.split(/\033\[/);
61
+
62
+ var first = data4.shift(); // the first chunk is not the result of the split
63
+
64
+ var self = this;
65
+ var data5 = data4.map(function (chunk) {
66
+ return self.process_chunk(chunk, options);
67
+ });
68
+
69
+ data5.unshift(first);
70
+
71
+ var flattened_data = data5.reduce( function (a, b) {
72
+ if (Array.isArray(b))
73
+ return a.concat(b);
74
+
75
+ a.push(b);
76
+ return a;
77
+ }, []);
78
+
79
+ var escaped_data = flattened_data.join('');
80
+
81
+ return escaped_data;
82
+ };
83
+
84
+ Ansi_Up.prototype.process_chunk = function (text, options) {
85
+
86
+ // Are we using classes or styles?
87
+ options = typeof options == 'undefined' ? {} : options;
88
+ var use_classes = typeof options.use_classes != 'undefined' && options.use_classes;
89
+ var key = use_classes ? 'class' : 'color';
90
+
91
+ // Each 'chunk' is the text after the CSI (ESC + '[') and before the next CSI/EOF.
92
+ //
93
+ // This regex matches two groups within a chunk.
94
+ // The first group matches all of the number+semicolon command sequences
95
+ // before the 'm' character. These are the graphics or SGR commands.
96
+ // The second group is the text (including newlines) that is colored by
97
+ // the first group's commands.
98
+ var matches = text.match(/([\d;]*)m([\s\S]*)/m);
99
+
100
+ if (!matches) return text;
101
+
102
+ var orig_txt = matches[2];
103
+ var nums = matches[1].split(';');
104
+
105
+ var self = this;
106
+ nums.map(function (num_str) {
107
+
108
+ var num = parseInt(num_str);
109
+
110
+ if (isNaN(num) || num === 0) {
111
+ self.fg = self.bg = null;
112
+ self.bright = 0;
113
+ } else if (num === 1) {
114
+ self.bright = 1;
115
+ } else if ((num >= 30) && (num < 38)) {
116
+ self.fg = ANSI_COLORS[self.bright][(num % 10)][key];
117
+ } else if ((num >= 90) && (num < 98)) {
118
+ self.fg = ANSI_COLORS[1][(num % 10)][key];
119
+ } else if ((num >= 40) && (num < 48)) {
120
+ self.bg = ANSI_COLORS[0][(num % 10)][key];
121
+ } else if ((num >= 100) && (num < 108)) {
122
+ self.bg = ANSI_COLORS[1][(num % 10)][key];
123
+ }
124
+ });
125
+
126
+ if ((self.fg === null) && (self.bg === null)) {
127
+ return orig_txt;
128
+ } else {
129
+ var styles = classes = [];
130
+ if (self.fg) {
131
+ if (use_classes) {
132
+ classes.push(self.fg + "-fg");
133
+ } else {
134
+ styles.push("color:rgb(" + self.fg + ")");
135
+ }
136
+ }
137
+ if (self.bg) {
138
+ if (use_classes) {
139
+ classes.push(self.bg + "-bg");
140
+ } else {
141
+ styles.push("background-color:rgb(" + self.bg + ")");
142
+ }
143
+ }
144
+ if (use_classes) {
145
+ return ["<span class=\"" + classes.join(' ') + "\">", orig_txt, "</span>"];
146
+ } else {
147
+ return ["<span style=\"" + styles.join(';') + "\">", orig_txt, "</span>"];
148
+ }
149
+ }
150
+ };
151
+
152
+ // Module exports
153
+ ansi_up = {
154
+
155
+ escape_for_html: function (txt) {
156
+ var a2h = new Ansi_Up();
157
+ return a2h.escape_for_html(txt);
158
+ },
159
+
160
+ linkify: function (txt) {
161
+ var a2h = new Ansi_Up();
162
+ return a2h.linkify(txt);
163
+ },
164
+
165
+ ansi_to_html: function (txt, options) {
166
+ var a2h = new Ansi_Up();
167
+ return a2h.ansi_to_html(txt, options);
168
+ },
169
+
170
+ ansi_to_html_obj: function () {
171
+ return new Ansi_Up();
172
+ }
173
+ };
174
+
175
+ // CommonJS module is defined
176
+ if (hasModule) {
177
+ module.exports = ansi_up;
178
+ }
179
+ /*global ender:false */
180
+ if (typeof window !== 'undefined' && typeof ender === 'undefined') {
181
+ window.ansi_up = ansi_up;
182
+ }
183
+ /*global define:false */
184
+ if (typeof define === "function" && define.amd) {
185
+ define("ansi_up", [], function () {
186
+ return ansi_up;
187
+ });
188
+ }
189
+ })(Date);
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ansi_up-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leo Unbekandt
@@ -30,7 +30,15 @@ email:
30
30
  executables: []
31
31
  extensions: []
32
32
  extra_rdoc_files: []
33
- files: []
33
+ files:
34
+ - LICENSE
35
+ - README.md
36
+ - ansi_up-rails.gemspec
37
+ - lib/ansi_up-rails.rb
38
+ - lib/ansi_up/rails.rb
39
+ - lib/ansi_up/rails/engine.rb
40
+ - lib/ansi_up/rails/version.rb
41
+ - vendor/assets/javascripts/ansi_up.js
34
42
  homepage: http://rubygems.org/gems/ansi_up-rails
35
43
  licenses:
36
44
  - MIT