hylite 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/hylite/cli.rb +27 -0
- data/lib/hylite/version.rb +1 -1
- data/spec/binary_spec.rb +5 -0
- data/spec/hylite_spec.rb +1 -1
- data/spec/spec_helpers.rb +9 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be741bada65fd35ed3d9c42939375741d5c408cb
|
4
|
+
data.tar.gz: 21bccee5f900481ab42705a962a490d4aef2d484
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c91d0b3af7b9ca9bc0bce7c43a496bb3d0d258bebd53cdb01d7c7ede27e081c970c79651def8ec9f967e77f7f0f55fe9e71411346876a6d04fba6f1f337ad00c
|
7
|
+
data.tar.gz: 8ab41c0aa0978ecea108560599582e049afe2431ae348e2e6a028e3142a5391bc7c4fd90d1c9b1970051944a74d68d20e6f64f31b6ce0b97e9f723ebb1bba09e
|
data/lib/hylite/cli.rb
CHANGED
@@ -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
|
data/lib/hylite/version.rb
CHANGED
data/spec/binary_spec.rb
CHANGED
@@ -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
|
data/spec/hylite_spec.rb
CHANGED
@@ -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'
|
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"
|
data/spec/spec_helpers.rb
CHANGED
@@ -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.
|
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:
|
11
|
+
date: 2017-01-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|