hylite 1.1.0 → 1.1.1

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: d62665fa2a24a184b51d5ab4bf55882c323885f9
4
- data.tar.gz: 3dcd0bdeb8cbc8a5cd1fb0f947e8fb4104e5e96e
3
+ metadata.gz: be741bada65fd35ed3d9c42939375741d5c408cb
4
+ data.tar.gz: 21bccee5f900481ab42705a962a490d4aef2d484
5
5
  SHA512:
6
- metadata.gz: cfe3816c2a24afc19906855b85cc10b91cfea1340e45ad6555c6c3ecf673d72d28fb330bda9f0633eaac1635cb88a0b135cea25eb78f450bb728b8f9b3c7cdcb
7
- data.tar.gz: 63d935be6b66b5c4a142756a9ea23db326229df3b69602db1b0b2661307e02bda17e64407ce3973391d7ab893dedb53fb943b5bc3913e30cb731b74d029aa18b
6
+ metadata.gz: c91d0b3af7b9ca9bc0bce7c43a496bb3d0d258bebd53cdb01d7c7ede27e081c970c79651def8ec9f967e77f7f0f55fe9e71411346876a6d04fba6f1f337ad00c
7
+ data.tar.gz: 8ab41c0aa0978ecea108560599582e049afe2431ae348e2e6a028e3142a5391bc7c4fd90d1c9b1970051944a74d68d20e6f64f31b6ce0b97e9f723ebb1bba09e
@@ -2,17 +2,44 @@ require 'hylite'
2
2
 
3
3
  class Hylite
4
4
  class CLI
5
+ def help_screen
6
+ <<-HELP
7
+ Usage: echo '1+1' | hylite
8
+
9
+ Syntax Highlighting for Scripters.
10
+
11
+ Finds an existing syntax highlighting tool (rouge, coderay, pygments),
12
+ and uses that to highlight the code.
13
+
14
+ Options:
15
+ -h This help screen
16
+ -l LANG Set the language (defaults to Ruby)
17
+
18
+ Examples:
19
+ Set the language to JavaScript
20
+ $ echo 'function alphabet() { console.log("abc"); }' | hylite -l javascript
21
+
22
+ Add syntax highlighting to `cat`
23
+ $ cat lib/hylite.rb | hylite
24
+
25
+ Highlight sassy style sheets
26
+ $ cat app/assets/stylesheets/site.css.scss | hylite -l scss
27
+ HELP
28
+ end
29
+
5
30
  def initialize(stdin, argv)
6
31
  self.stdin = stdin
7
32
  self.argv = argv
8
33
  end
9
34
 
10
35
  def result
36
+ return help_screen if config[:help]
11
37
  ensure_evaluated
12
38
  @result
13
39
  end
14
40
 
15
41
  def success?
42
+ return true if config[:help]
16
43
  ensure_evaluated
17
44
  errors.none?
18
45
  end
@@ -1,3 +1,3 @@
1
1
  class Hylite
2
- VERSION = '1.1.0'
2
+ VERSION = '1.1.1'
3
3
  end
@@ -45,6 +45,11 @@ RSpec.describe 'binaries' do
45
45
 
46
46
  assert_parses ['--help'], :help, true
47
47
  assert_parses ['--help'], :errors, []
48
+
49
+ code = Untouchable.new('code')
50
+ cli = Hylite::CLI.new(code, ['-h'])
51
+ expect(cli).to be_success
52
+ expect(cli.result).to match /usage/i
48
53
  end
49
54
 
50
55
  describe 'language' do
@@ -3,7 +3,7 @@ require 'spec_helpers'
3
3
  require 'hylite'
4
4
 
5
5
  RSpec.describe 'hylite' do
6
- it 'invokes whichever hyliter "ChooseHyliter" returns', t:true do
6
+ it 'invokes whichever hyliter "ChooseHyliter" returns' do
7
7
  expect(Hylite::ChooseHyliter).to receive(:call).with("to hylite", 'some lang').and_return(-> { "hylited" })
8
8
  hylited = Hylite.new("to hylite", l: "some lang").call
9
9
  expect(hylited).to eq "hylited"
@@ -6,6 +6,15 @@ module SpecHelpers
6
6
  end
7
7
  end
8
8
 
9
+ class Untouchable < BasicObject
10
+ def initialize(name)
11
+ @nme = name
12
+ end
13
+ def method_missing(method_name, *)
14
+ ::Kernel.raise "#{@name} should not have been touched, but received #{method_name.inspect}"
15
+ end
16
+ end
17
+
9
18
  RSpec.configure do |config|
10
19
  config.include SpecHelpers
11
20
  config.fail_fast = true
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hylite
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Cheek
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-24 00:00:00.000000000 Z
11
+ date: 2017-01-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec