terminal 1.0.1 → 1.0.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: c8080e014246d4d9ff730114e8369fd447402772
4
- data.tar.gz: 7fd43ca59d7f083934c9a0139fbbe34e502cf3de
3
+ metadata.gz: 7d9969578830c35e3587d7eb183a5ddca80faf78
4
+ data.tar.gz: 9c18bf8cc1e40b0b02a50d153291ddd678cce02e
5
5
  SHA512:
6
- metadata.gz: 1babbd0249d209f6c20e09c75d65d7612edad91c39ee9be3f4fa9212274ec4a20ac11689d307d8673f85bd0bf929b2a86955827b51b1630d53a358b807fcd8c9
7
- data.tar.gz: 651b8d7ffccde7d611ca3a1c7dd0ad7eec2cd00c0848838b001d1e1286ab0b826e2388648864137d8e90dd05507ec091b4c6def53562fe13ea859638c189ee62
6
+ metadata.gz: f84f5c8f4b3a26e5ca5c49d05d78ffdc99879e2e3087494f140054bfcac10f76b8c34ec3458a94161a0ebaed6504b09f31a8caa5e92718582a8bea1cb72a4db2
7
+ data.tar.gz: 7897b30eb970b80ec2cd72c212ef190eeb538f2c023b629e671168078f8dfab9f0e72ef6a665d531a8f1314efcaf32311a2e4526b8f1381c5b8df783e457d86d
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- terminal (1.0.1)
4
+ terminal (1.0.2)
5
5
  escape_utils (~> 1.0)
6
6
  gemoji (~> 2.1)
7
7
 
@@ -4,51 +4,48 @@
4
4
  $:.unshift(File.join(File.expand_path(File.dirname(__FILE__)), '..', 'lib'))
5
5
 
6
6
  require 'terminal'
7
+ require 'optparse'
7
8
 
8
- def help
9
- puts <<-usage
10
- Usage:
11
- $ cat output.text | terminal
12
- $ terminal output.text
9
+ options = Struct.new(:preview,
10
+ :emoji_asset_path).new
13
11
 
14
- Help:
15
- $ terminal -h
16
- $ terminal --help
12
+ option_parser = OptionParser.new do |opts|
13
+ opts.banner = "Usage: #{opts.program_name} [options] <input file>"
17
14
 
18
- Version:
19
- $ terminal -v
20
- $ terminal --version
15
+ opts.on("--preview", "Preview in the browser") do
16
+ options.preview = true
17
+ end
21
18
 
22
- Preview in the browser:
23
- $ terminal --preview
19
+ opts.on("--emoji-asset-path=PATH", "Path or URL to emoji image files") do |path|
20
+ options.emoji_asset_path = path
21
+ end
24
22
 
25
- See https://buildkite.github.io/terminal for more information.
26
- usage
27
- end
23
+ opts.on_tail("-h", "--help", "Show this help documentation") do
24
+ puts opts
25
+ exit
26
+ end
28
27
 
29
- def version
30
- puts "terminal v#{Terminal::VERSION}"
31
- end
28
+ opts.on_tail("-v", "--version", "Print the version") do
29
+ puts "terminal v#{Terminal::VERSION}"
30
+ exit
31
+ end
32
+ end.tap(&:parse!)
32
33
 
33
- preview = ARGV.delete('--preview')
34
+ if ($stdin.tty? && ARGV.empty?)
35
+ abort option_parser.help
36
+ end
34
37
 
35
- if ($stdin.tty? && ARGV.empty?) || ARGV.delete('-h') || ARGV.delete('--help')
36
- help
37
- elsif ARGV.delete('-v') || ARGV.delete('--version')
38
- version
39
- else
40
- raw = ARGF.read
41
- rendered = Terminal.render(raw)
38
+ raw = ARGF.read
39
+ rendered = Terminal.render(raw, emoji_asset_path: options[:emoji_asset_path])
42
40
 
43
- if preview
44
- require 'tempfile'
41
+ if options[:preview]
42
+ require 'tempfile'
45
43
 
46
- tempfile = Tempfile.new([ 'preview', '.html' ])
47
- tempfile.write(Terminal::Preview.new(raw, rendered).render)
48
- tempfile.close
44
+ tempfile = Tempfile.new([ 'preview', '.html' ])
45
+ tempfile.write(Terminal::Preview.new(raw, rendered).render)
46
+ tempfile.close
49
47
 
50
- exec %{open "#{tempfile.path}"}
51
- else
52
- puts rendered
53
- end
48
+ exec %{open "#{tempfile.path}"}
49
+ else
50
+ puts rendered
54
51
  end
@@ -1,3 +1,3 @@
1
1
  module Terminal
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  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.1
4
+ version: 1.0.2
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-19 00:00:00.000000000 Z
11
+ date: 2015-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: escape_utils