shell2html 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8b8c531b14ff57720cb05391d52b7fd353b49db6
4
+ data.tar.gz: 00d54e53ea2bfd2d41c4b4ea3d171a256cbb7dcb
5
+ SHA512:
6
+ metadata.gz: 0a36afe4b274b7a3d710ebe9477cb0645367b3e55a622c7a52cde68c1fd45ca925a84d8230682afc3ca1ca14fe76a76278be8f39cd719ad0c4baa6ec2dda57ff
7
+ data.tar.gz: 87fbb32bff9811e67fc308d1cd0b974009793994e4ea1882d2b45d431eb3e7198a37e1a9d077228f938b22471e57307948b3893749972460de361a8bfacf3099
data/.coveralls.yml ADDED
@@ -0,0 +1 @@
1
+ repo_token: at62zzlX4ZqAVEowJXgX0SJ9lZqNWzyPB
data/.gitignore ADDED
@@ -0,0 +1,23 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
23
+ vendor/
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ bundler_args: --path vendor
3
+ cache: bundler
4
+ rvm:
5
+ - 1.9.3
6
+ - 2.1.1
data/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ Shell to HTML
2
+ ==================
3
+
4
+ v0.0.1 - 2014-08-17
5
+ -----------------
6
+ - base gem skeleton
7
+ - base colors and transformation
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in shell2html.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 mose
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,52 @@
1
+ Shell2html
2
+ ===============
3
+
4
+ [![Gem Version](https://img.shields.io/gem/v/shell2html.svg)](http://rubygems.org/gems/shell2html)
5
+ [![Build Status](https://img.shields.io/travis/mose/shell2html.svg)](https://travis-ci.org/mose/shell2html)
6
+ [![Coverage Status](https://img.shields.io/coveralls/mose/shell2html.svg)](https://coveralls.io/r/mose/shell2html?branch=master)
7
+ [![Dependency Status](https://img.shields.io/gemnasium/mose/shell2html.svg)](https://gemnasium.com/mose/shell2html)
8
+ [![Code Climate](https://img.shields.io/codeclimate/github/mose/shell2html.svg)](https://codeclimate.com/github/mose/shell2html)
9
+
10
+ ----
11
+
12
+ A ruby lib for conversion between bash colors and HTML.
13
+
14
+ Code is still experimental, use at your own risk.
15
+
16
+ Installation
17
+ -------------------
18
+ Add this line to your application's Gemfile:
19
+
20
+ gem 'shell2html'
21
+
22
+ And then execute:
23
+
24
+ $ bundle
25
+
26
+ Or install it yourself as:
27
+
28
+ $ gem install shell2html
29
+
30
+ Usage
31
+ -----------------
32
+
33
+ Commandline command
34
+ -------------------
35
+ There is a command `shell2html` provided in this lib for commandline execution.
36
+
37
+ shell2html <file>
38
+ echo "\e[31mPrompt: \e[0m" | shell2html
39
+
40
+ The html is output in stdout.
41
+
42
+ Contributing
43
+ -----------------
44
+ 1. Fork it
45
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
46
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
47
+ 4. Push to the branch (`git push origin my-new-feature`)
48
+ 5. Create a new Pull Request
49
+
50
+ Copyright
51
+ ----------------
52
+ (c) Copyright 2014 mose. Distributed under MIT license
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rake/testtask'
4
+ require 'rspec/core/rake_task'
5
+
6
+ desc 'launch rspec tests'
7
+ task :spec do
8
+ RSpec::Core::RakeTask.new(:spec) do |t|
9
+ t.rspec_opts = ['-c', '-f progress', '-r ./spec/spec_helper.rb']
10
+ t.pattern = 'spec/lib/**/*_spec.rb'
11
+ end
12
+ end
13
+
14
+ task default: :spec
data/bin/shell2html ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ lib = File.expand_path('../../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+
6
+ require 'shell2html'
7
+
8
+ puts "Nothing there yet."
data/lib/shell2html.rb ADDED
@@ -0,0 +1,93 @@
1
+ module Shell2html
2
+
3
+ module_function
4
+
5
+ COLORS = {
6
+ "1" => { css: "sh_bold", style: { "font-weight" => "bold" } },
7
+ "2" => { css: "sh_dim", style: { "opacity" => ".5" } },
8
+ "4" => { css: "sh_underlined", style: { "text-decoration" => "underline" } },
9
+ "5" => { css: "sh_blink", style: { "text-decoration" => "blink" } },
10
+ "7" => { css: "sh_inverted", style: { "font-weight" => "bold" } },
11
+ "8" => { css: "sh_hidden", style: { "opacity" => "0" } },
12
+ "39" => { css: "sh_fg_default", style: { "color" => "#ffffff" } },
13
+ "30" => { css: "sh_fg_black", style: { "color" => "#000000" } },
14
+ "31" => { css: "sh_fg_red", style: { "color" => "#cd0000" } },
15
+ "32" => { css: "sh_fg_green", style: { "color" => "#00cd00" } },
16
+ "33" => { css: "sh_fg_yellow", style: { "color" => "#cdcd00" } },
17
+ "34" => { css: "sh_fg_blue", style: { "color" => "#1e90ff" } },
18
+ "35" => { css: "sh_fg_magenta", style: { "color" => "#cd00cd" } },
19
+ "36" => { css: "sh_fg_cyan", style: { "color" => "#00cdcd" } },
20
+ "37" => { css: "sh_fg_lightgray", style: { "color" => "#e5e5e5" } },
21
+ "90" => { css: "sh_fg_darkgray", style: { "color" => "#4c4c4c" } },
22
+ "91" => { css: "sh_fg_lightred", style: { "color" => "#ff0000" } },
23
+ "92" => { css: "sh_fg_lightgreen", style: { "color" => "#00ff00" } },
24
+ "93" => { css: "sh_fg_lightyellow", style: { "color" => "#ffff00" } },
25
+ "94" => { css: "sh_fg_lightblue", style: { "color" => "#4682b4" } },
26
+ "95" => { css: "sh_fg_lightmagenta", style: { "color" => "#ff00ff" } },
27
+ "96" => { css: "sh_fg_lightcyan", style: { "color" => "#00ffff" } },
28
+ "97" => { css: "sh_fg_white", style: { "color" => "#ffffff" } },
29
+ "49" => { css: "sh_bg_default", style: { "background-color" => "#000000" } },
30
+ "40" => { css: "sh_bg_black", style: { "background-color" => "#000000" } },
31
+ "41" => { css: "sh_bg_red", style: { "background-color" => "#cd0000" } },
32
+ "42" => { css: "sh_bg_green", style: { "background-color" => "#00cd00" } },
33
+ "43" => { css: "sh_bg_yellow", style: { "background-color" => "#cdcd00" } },
34
+ "44" => { css: "sh_bg_blue", style: { "background-color" => "#1e90ff" } },
35
+ "45" => { css: "sh_bg_magenta", style: { "background-color" => "#cd00cd" } },
36
+ "46" => { css: "sh_bg_cyan", style: { "background-color" => "#00cdcd" } },
37
+ "47" => { css: "sh_bg_lightgray", style: { "background-color" => "#e5e5e5" } },
38
+ "100" => { css: "sh_bg_darkgray", style: { "background-color" => "#4c4c4c" } },
39
+ "101" => { css: "sh_bg_lightred", style: { "background-color" => "#ff0000" } },
40
+ "102" => { css: "sh_bg_lightgreen", style: { "background-color" => "#00ff00" } },
41
+ "103" => { css: "sh_bg_lightyellow", style: { "background-color" => "#ffff00" } },
42
+ "104" => { css: "sh_bg_lightblue", style: { "background-color" => "#4682b4" } },
43
+ "105" => { css: "sh_bg_lightmagenta", style: { "background-color" => "#ff00ff" } },
44
+ "106" => { css: "sh_bg_lightcyan", style: { "background-color" => "#00ffff" } },
45
+ "107" => { css: "sh_bg_white", style: { "background-color" => "#ffffff" } }
46
+ }
47
+
48
+ def to_html(text, inline = false)
49
+ text.split(27.chr).map do |e|
50
+ if /^\[([0-9;]+)m(.*)$/.match e
51
+ case $1
52
+ when '0'
53
+ "</span>#{$2}"
54
+ else
55
+ t = $2
56
+ css = []
57
+ $1.split(';').each do |i|
58
+ css << COLORS["#{i}"] if COLORS["#{i}"]
59
+ end
60
+ if css.count > 0
61
+ if inline
62
+ span_style = css.map do |c|
63
+ o = []
64
+ c[:style].each do |k,v|
65
+ o << "#{k}:#{v}"
66
+ end
67
+ o
68
+ end.flatten.join(';')
69
+ "<span style=\"#{span_style}\">#{t}"
70
+ else
71
+ span_class = css.map { |c| c[:css] }.join(' ')
72
+ "<span class=\"#{span_class}\">#{t}"
73
+ end
74
+ else
75
+ "<span>#{t}"
76
+ end
77
+ end
78
+ else
79
+ e
80
+ end
81
+ end.join
82
+ end
83
+
84
+ def to_css(text)
85
+ end
86
+
87
+ def to_sass(text)
88
+ end
89
+
90
+ def to_scss(text)
91
+ end
92
+
93
+ end
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "shell2html"
7
+ spec.version = File.read(File.expand_path('../CHANGELOG.md', __FILE__))[/([0-9]+\.[0-9]+\.[0-9]+)/]
8
+ spec.authors = ["mose"]
9
+ spec.email = ["mose@mose.com"]
10
+ spec.summary = %q{A ruby lib for transforming bash colors into html.}
11
+ spec.description = %q{A ruby lib for transforming bash colors into html. Parses escape chars an output sp.}
12
+ spec.homepage = "https://github.com/mose/shell2html"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^spec/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_development_dependency "bundler", "~> 1.6"
21
+ spec.add_development_dependency "rake"
22
+ spec.add_development_dependency 'rspec'
23
+ spec.add_development_dependency 'coveralls'
24
+ end
@@ -0,0 +1,37 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+ require 'shell2html'
5
+
6
+ describe Shell2html do
7
+
8
+ let(:unknown_text) { "\e[12mtext\e[0m" }
9
+ let(:blue_text) { "\e[34mtext\e[0m" }
10
+ let(:bold_blue_text) { "\e[1;34mtext\e[0m" }
11
+
12
+ describe '.to_html' do
13
+
14
+ context 'when we need css classes, ' do
15
+
16
+ context 'when we input a text with an unknown foreground color, ' do
17
+ it { expect(subject.to_html(unknown_text)).to eq '<span>text</span>' }
18
+ end
19
+
20
+ context 'when we input a text with a simple foreground color, ' do
21
+ it { expect(subject.to_html(blue_text)).to eq '<span class="sh_fg_blue">text</span>' }
22
+ end
23
+
24
+ context 'when we input a text with a bold foreground color, ' do
25
+ it { expect(subject.to_html(bold_blue_text)).to eq '<span class="sh_bold sh_fg_blue">text</span>' }
26
+ end
27
+ end
28
+
29
+ context 'when we need inline styles, ' do
30
+ context 'when we input a text with a simple foreground color, ' do
31
+ it { expect(subject.to_html(blue_text,true)).to eq '<span style="color:#1e90ff">text</span>' }
32
+ end
33
+ end
34
+
35
+ end
36
+
37
+ end
@@ -0,0 +1,22 @@
1
+ $LOAD_PATH << File.expand_path('../../lib', __FILE__)
2
+ require 'rubygems'
3
+ require 'bundler'
4
+
5
+ if ENV['COV']
6
+ require 'simplecov'
7
+ SimpleCov.profiles.define :app do
8
+ add_filter '/vendor/'
9
+ add_filter '/spec/'
10
+ end
11
+ SimpleCov.start :app
12
+ else
13
+ require 'coveralls'
14
+ Coveralls.wear!
15
+ end
16
+
17
+ RSpec.configure do |config|
18
+ config.mock_with :rspec
19
+ config.expect_with :rspec do |c|
20
+ c.syntax = :expect
21
+ end
22
+ end
metadata ADDED
@@ -0,0 +1,117 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: shell2html
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - mose
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-08-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: coveralls
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: A ruby lib for transforming bash colors into html. Parses escape chars
70
+ an output sp.
71
+ email:
72
+ - mose@mose.com
73
+ executables:
74
+ - shell2html
75
+ extensions: []
76
+ extra_rdoc_files: []
77
+ files:
78
+ - ".coveralls.yml"
79
+ - ".gitignore"
80
+ - ".travis.yml"
81
+ - CHANGELOG.md
82
+ - Gemfile
83
+ - LICENSE.txt
84
+ - README.md
85
+ - Rakefile
86
+ - bin/shell2html
87
+ - lib/shell2html.rb
88
+ - shell2html.gemspec
89
+ - spec/lib/shell2html_spec.rb
90
+ - spec/spec_helper.rb
91
+ homepage: https://github.com/mose/shell2html
92
+ licenses:
93
+ - MIT
94
+ metadata: {}
95
+ post_install_message:
96
+ rdoc_options: []
97
+ require_paths:
98
+ - lib
99
+ required_ruby_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ requirements: []
110
+ rubyforge_project:
111
+ rubygems_version: 2.2.2
112
+ signing_key:
113
+ specification_version: 4
114
+ summary: A ruby lib for transforming bash colors into html.
115
+ test_files:
116
+ - spec/lib/shell2html_spec.rb
117
+ - spec/spec_helper.rb