shell2html 0.0.5 → 0.0.6

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: 5eb1bc4e0dc68a7c3c76db7a1aaba7de6e85c634
4
- data.tar.gz: fe087019cd925c77d4cd3243642f530dccf413dd
3
+ metadata.gz: c11597cc04491645e7a641e45273f91331050793
4
+ data.tar.gz: fd19db170d10c0c595eb9f441ec23e3423111b5c
5
5
  SHA512:
6
- metadata.gz: 2215133ce6fa7ac128ae86eab2d640d87ce9b180a6519e6fba020d79ea2abdfa9d858a838bc639470bacdb0f3af08e1038088e344d5a82321b56d19fbd1f4e59
7
- data.tar.gz: 8348b33514269583c6735c1f728ead1315ab6fb0c5af9563f3ae30d61937e26b2c70aa6a455e2f6ebd683f33ce22797076a2161f412f2dae0767eeaa8b733536
6
+ metadata.gz: e0dd2aecb503f5e305884eb2249a6498b99665d7a011e69b4085bd19bc758eae8b8116cb0d62c66423176c1b4c061aae682fde4b91ef5fe6c9cc58afc0f80dcd
7
+ data.tar.gz: 813ff40b118bece38dceeccb140a4d7a2fc37e3d6c2bead148524f2902af172b2bbc0dcfdfa355d903351adfa03405117504d565fc696b180ad84f50555b449e
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.2.3
data/.travis.yml CHANGED
@@ -3,4 +3,4 @@ bundler_args: --path vendor
3
3
  cache: bundler
4
4
  rvm:
5
5
  - 1.9.3
6
- - 2.1.1
6
+ - 2.2.3
data/CHANGELOG.md CHANGED
@@ -1,6 +1,12 @@
1
- Shell to HTML
1
+ shell2html
2
2
  ==================
3
3
 
4
+ v0.0.6 - 2015-11-23
5
+ -------------------
6
+ - added a `shell2css` executable to render css
7
+ - use `shell2css sass` to print out sass version of the css
8
+ - made `shell2html` work with stdin or with a filename as argument
9
+
4
10
  v0.0.5 - 2014-08-19
5
11
  -------------------
6
12
  - added a link on urls with a custom style
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2014 mose
1
+ Copyright (c) 2014-2015 mose
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -2,6 +2,7 @@ Shell2html
2
2
  ===============
3
3
 
4
4
  [![Gem Version](https://img.shields.io/gem/v/shell2html.svg)](http://rubygems.org/gems/shell2html)
5
+ [![Downloads](http://img.shields.io/gem/dt/shell2html.svg)](https://rubygems.org/gems/shell2html)
5
6
  [![Build Status](https://img.shields.io/travis/mose/shell2html.svg)](https://travis-ci.org/mose/shell2html)
6
7
  [![Coverage Status](https://img.shields.io/coveralls/mose/shell2html.svg)](https://coveralls.io/r/mose/shell2html?branch=master)
7
8
  [![Dependency Status](https://img.shields.io/gemnasium/mose/shell2html.svg)](https://gemnasium.com/mose/shell2html)
@@ -9,9 +10,9 @@ Shell2html
9
10
 
10
11
  ----
11
12
 
12
- A ruby lib for conversion between bash colors and HTML. It was created to help the Shellplay tool to export html from colored shell output.
13
+ A ruby lib for conversion between bash colors and HTML. It was created to help the [Shellplay](https://github.com/mose/shellplay) tool to export html from colored shell output.
13
14
 
14
- Code is still experimental, use at your own risk. But "it works for me".
15
+ Code is still experimental, use at your own risk. But "it works for me". An example of usage is visible on http://mose.com/20140814-dokku/
15
16
 
16
17
  Installation
17
18
  -------------------
@@ -39,8 +40,6 @@ puts Shell2html.to_html("\e[33m>\e[0m\e[1;31m some colored thing.\e[0m")
39
40
  Commandline command
40
41
  -------------------
41
42
 
42
- (not functionnal yet)
43
-
44
43
  There is a command `shell2html` provided in this lib for commandline execution.
45
44
 
46
45
  shell2html <file>
@@ -48,7 +47,9 @@ There is a command `shell2html` provided in this lib for commandline execution.
48
47
 
49
48
  The html is output in stdout.
50
49
 
51
- An example of usage is visible on http://mose.com/20140814-dokku/
50
+ Another command `shell2css` will print out the CSS associated with the generated html.
51
+
52
+ Use `shell2css sass` to generate a Sass version instead.
52
53
 
53
54
  Contributing
54
55
  -----------------
@@ -60,4 +61,4 @@ Contributing
60
61
 
61
62
  Copyright
62
63
  ----------------
63
- (c) Copyright 2014 mose. Distributed under MIT license
64
+ (c) Copyright 2014-2015 mose. Distributed under MIT license
data/bin/shell2css ADDED
@@ -0,0 +1,12 @@
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
+ if ARGV.count > 0 and ARGV[0] == 'sass'
9
+ puts Shell2html.sass
10
+ else
11
+ puts Shell2html.css
12
+ end
data/bin/shell2html CHANGED
@@ -5,4 +5,15 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
 
6
6
  require 'shell2html'
7
7
 
8
- puts "Nothing there yet."
8
+ if ARGV.count > 0
9
+ file = ARGV[0]
10
+ if !File.exists? file
11
+ puts "File #{file} Not found"
12
+ exit(1)
13
+ end
14
+ puts Shell2html.to_html(File.read(file))
15
+ else
16
+ txt = $stdin.read
17
+ puts Shell2html.to_html(txt)
18
+ end
19
+
data/lib/shell2html.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require 'cgi'
2
+
1
3
  module Shell2html
2
4
 
3
5
  module_function
@@ -67,6 +69,7 @@ module Shell2html
67
69
  key.split(';').each do |i|
68
70
  css << COLORS["#{i.to_i}"] if COLORS["#{i.to_i}"]
69
71
  end
72
+ count = 1
70
73
  if css.count > 0
71
74
  if inline
72
75
  span_style = css.map do |c|
@@ -76,15 +79,12 @@ module Shell2html
76
79
  end
77
80
  o
78
81
  end.flatten.join(';')
79
- count = 1
80
82
  "#{'</span>' * count}<span style=\"#{span_style}\">#{t}"
81
83
  else
82
- count = 1
83
84
  span_class = css.map { |c| c[:css] }.join(' ')
84
85
  "#{'</span>' * count}<span class=\"#{span_class}\">#{t}"
85
86
  end
86
87
  else
87
- count = 1
88
88
  "#{'</span>' * count}<span>#{t}"
89
89
  end
90
90
  end
@@ -99,17 +99,23 @@ module Shell2html
99
99
  COLORS.each do |_, c|
100
100
  o = []
101
101
  css = c[:style].each do |k, v|
102
- o << "#{k}:#{v}"
102
+ o << "#{k}: #{v}"
103
103
  end
104
104
  back << ".#{c[:css]} { #{o.join(';')} }"
105
105
  end
106
- back.join("\n")
107
- end
108
-
109
- def to_sass(text)
106
+ back.join("\n") + "\n"
110
107
  end
111
108
 
112
- def to_scss(text)
109
+ def sass
110
+ back = []
111
+ COLORS.each do |_, c|
112
+ o = []
113
+ back << ".#{c[:css]}"
114
+ c[:style].each do |k, v|
115
+ back << " #{k}: #{v}"
116
+ end
117
+ end
118
+ back.join("\n") + "\n"
113
119
  end
114
120
 
115
121
  end
data/shell2html.gemspec CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
8
8
  spec.authors = ["mose"]
9
9
  spec.email = ["mose@mose.com"]
10
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.}
11
+ spec.description = %q{A ruby lib for transforming bash colors into html. Parses escape chars and outputs html.}
12
12
  spec.homepage = "https://github.com/mose/shell2html"
13
13
  spec.license = "MIT"
14
14
 
@@ -17,7 +17,6 @@ Gem::Specification.new do |spec|
17
17
  spec.test_files = spec.files.grep(%r{^spec/})
18
18
  spec.require_paths = ["lib"]
19
19
 
20
- spec.add_development_dependency "bundler", "~> 1.6"
21
20
  spec.add_development_dependency "rake"
22
21
  spec.add_development_dependency 'rspec'
23
22
  spec.add_development_dependency 'coveralls'
@@ -0,0 +1,42 @@
1
+ .sh_bold { font-weight: bold }
2
+ .sh_dim { opacity: .5 }
3
+ .sh_underlined { border-bottom: 1px solid rgba(255,255,255,.6);padding-bottom: 1px }
4
+ .sh_blink { text-decoration: blink }
5
+ .sh_inverted { font-weight: bold }
6
+ .sh_hidden { opacity: 0 }
7
+ .sh_fg_default { color: #ffffff }
8
+ .sh_fg_black { color: #000000 }
9
+ .sh_fg_red { color: #cd0000 }
10
+ .sh_fg_green { color: #00cd00 }
11
+ .sh_fg_yellow { color: #cdcd00 }
12
+ .sh_fg_blue { color: #1e90ff }
13
+ .sh_fg_magenta { color: #cd00cd }
14
+ .sh_fg_cyan { color: #00cdcd }
15
+ .sh_fg_lightgray { color: #e5e5e5 }
16
+ .sh_fg_darkgray { color: #4c4c4c }
17
+ .sh_fg_lightred { color: #ff0000 }
18
+ .sh_fg_lightgreen { color: #00ff00 }
19
+ .sh_fg_lightyellow { color: #ffff00 }
20
+ .sh_fg_lightblue { color: #4682b4 }
21
+ .sh_fg_lightmagenta { color: #ff00ff }
22
+ .sh_fg_lightcyan { color: #00ffff }
23
+ .sh_fg_white { color: #ffffff }
24
+ .sh_bg_default { background-color: #000000 }
25
+ .sh_bg_black { background-color: #000000 }
26
+ .sh_bg_red { background-color: #cd0000 }
27
+ .sh_bg_green { background-color: #00cd00 }
28
+ .sh_bg_yellow { background-color: #cdcd00 }
29
+ .sh_bg_blue { background-color: #1e90ff }
30
+ .sh_bg_magenta { background-color: #cd00cd }
31
+ .sh_bg_cyan { background-color: #00cdcd }
32
+ .sh_bg_lightgray { background-color: #e5e5e5 }
33
+ .sh_bg_darkgray { background-color: #4c4c4c }
34
+ .sh_bg_lightred { background-color: #ff0000 }
35
+ .sh_bg_lightgreen { background-color: #00ff00 }
36
+ .sh_bg_lightyellow { background-color: #ffff00 }
37
+ .sh_bg_lightblue { background-color: #4682b4 }
38
+ .sh_bg_lightmagenta { background-color: #ff00ff }
39
+ .sh_bg_lightcyan { background-color: #00ffff }
40
+ .sh_bg_white { background-color: #ffffff }
41
+ .sh_a { color: inherit;text-decoration: inherit }
42
+ .sh_a:hover { background-color: #ffffff;color: #000000 }
@@ -0,0 +1,87 @@
1
+ .sh_bold
2
+ font-weight: bold
3
+ .sh_dim
4
+ opacity: .5
5
+ .sh_underlined
6
+ border-bottom: 1px solid rgba(255,255,255,.6)
7
+ padding-bottom: 1px
8
+ .sh_blink
9
+ text-decoration: blink
10
+ .sh_inverted
11
+ font-weight: bold
12
+ .sh_hidden
13
+ opacity: 0
14
+ .sh_fg_default
15
+ color: #ffffff
16
+ .sh_fg_black
17
+ color: #000000
18
+ .sh_fg_red
19
+ color: #cd0000
20
+ .sh_fg_green
21
+ color: #00cd00
22
+ .sh_fg_yellow
23
+ color: #cdcd00
24
+ .sh_fg_blue
25
+ color: #1e90ff
26
+ .sh_fg_magenta
27
+ color: #cd00cd
28
+ .sh_fg_cyan
29
+ color: #00cdcd
30
+ .sh_fg_lightgray
31
+ color: #e5e5e5
32
+ .sh_fg_darkgray
33
+ color: #4c4c4c
34
+ .sh_fg_lightred
35
+ color: #ff0000
36
+ .sh_fg_lightgreen
37
+ color: #00ff00
38
+ .sh_fg_lightyellow
39
+ color: #ffff00
40
+ .sh_fg_lightblue
41
+ color: #4682b4
42
+ .sh_fg_lightmagenta
43
+ color: #ff00ff
44
+ .sh_fg_lightcyan
45
+ color: #00ffff
46
+ .sh_fg_white
47
+ color: #ffffff
48
+ .sh_bg_default
49
+ background-color: #000000
50
+ .sh_bg_black
51
+ background-color: #000000
52
+ .sh_bg_red
53
+ background-color: #cd0000
54
+ .sh_bg_green
55
+ background-color: #00cd00
56
+ .sh_bg_yellow
57
+ background-color: #cdcd00
58
+ .sh_bg_blue
59
+ background-color: #1e90ff
60
+ .sh_bg_magenta
61
+ background-color: #cd00cd
62
+ .sh_bg_cyan
63
+ background-color: #00cdcd
64
+ .sh_bg_lightgray
65
+ background-color: #e5e5e5
66
+ .sh_bg_darkgray
67
+ background-color: #4c4c4c
68
+ .sh_bg_lightred
69
+ background-color: #ff0000
70
+ .sh_bg_lightgreen
71
+ background-color: #00ff00
72
+ .sh_bg_lightyellow
73
+ background-color: #ffff00
74
+ .sh_bg_lightblue
75
+ background-color: #4682b4
76
+ .sh_bg_lightmagenta
77
+ background-color: #ff00ff
78
+ .sh_bg_lightcyan
79
+ background-color: #00ffff
80
+ .sh_bg_white
81
+ background-color: #ffffff
82
+ .sh_a
83
+ color: inherit
84
+ text-decoration: inherit
85
+ .sh_a:hover
86
+ background-color: #ffffff
87
+ color: #000000
@@ -14,24 +14,34 @@ describe Shell2html do
14
14
  context 'when we need css classes, ' do
15
15
 
16
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>' }
17
+ it { expect(subject.to_html(unknown_text)).to eq '</span><span>text</span>' }
18
18
  end
19
19
 
20
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>' }
21
+ it { expect(subject.to_html(blue_text)).to eq '</span><span class="sh_fg_blue">text</span>' }
22
22
  end
23
23
 
24
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>' }
25
+ it { expect(subject.to_html(bold_blue_text)).to eq '</span><span class="sh_bold sh_fg_blue">text</span>' }
26
26
  end
27
27
  end
28
28
 
29
29
  context 'when we need inline styles, ' do
30
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>' }
31
+ it { expect(subject.to_html(blue_text,true)).to eq '</span><span style="color:#1e90ff">text</span>' }
32
32
  end
33
33
  end
34
34
 
35
35
  end
36
36
 
37
+ describe '.css' do
38
+ let(:expected) { File.read(File.expand_path('../../files/colors.css', __FILE__)) }
39
+ it { expect(subject.css).to eq expected }
40
+ end
41
+
42
+ describe '.sass' do
43
+ let(:expected) { File.read(File.expand_path('../../files/colors.sass', __FILE__)) }
44
+ it { expect(subject.sass).to eq expected }
45
+ end
46
+
37
47
  end
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shell2html
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - mose
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-19 00:00:00.000000000 Z
11
+ date: 2015-11-23 00:00:00.000000000 Z
12
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
13
  - !ruby/object:Gem::Dependency
28
14
  name: rake
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -67,25 +53,30 @@ dependencies:
67
53
  - !ruby/object:Gem::Version
68
54
  version: '0'
69
55
  description: A ruby lib for transforming bash colors into html. Parses escape chars
70
- an output sp.
56
+ and outputs html.
71
57
  email:
72
58
  - mose@mose.com
73
59
  executables:
60
+ - shell2css
74
61
  - shell2html
75
62
  extensions: []
76
63
  extra_rdoc_files: []
77
64
  files:
78
65
  - ".coveralls.yml"
79
66
  - ".gitignore"
67
+ - ".ruby-version"
80
68
  - ".travis.yml"
81
69
  - CHANGELOG.md
82
70
  - Gemfile
83
71
  - LICENSE.txt
84
72
  - README.md
85
73
  - Rakefile
74
+ - bin/shell2css
86
75
  - bin/shell2html
87
76
  - lib/shell2html.rb
88
77
  - shell2html.gemspec
78
+ - spec/files/colors.css
79
+ - spec/files/colors.sass
89
80
  - spec/lib/shell2html_spec.rb
90
81
  - spec/spec_helper.rb
91
82
  homepage: https://github.com/mose/shell2html
@@ -108,10 +99,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
99
  version: '0'
109
100
  requirements: []
110
101
  rubyforge_project:
111
- rubygems_version: 2.2.2
102
+ rubygems_version: 2.4.8
112
103
  signing_key:
113
104
  specification_version: 4
114
105
  summary: A ruby lib for transforming bash colors into html.
115
106
  test_files:
107
+ - spec/files/colors.css
108
+ - spec/files/colors.sass
116
109
  - spec/lib/shell2html_spec.rb
117
110
  - spec/spec_helper.rb