iro 0.1.0 → 0.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cefceb0c53b6c32f64eff6d7eb4109f2f7c209e49543de26ac9791cf3902c1cc
4
- data.tar.gz: abfda5fbc672cc944a106c3b701d15a6e44ee5913c3e225bd808b1146891ca27
3
+ metadata.gz: 7e8919acfe7f9be5a6458e9a9be7ecb82dfa93519b36b037167631cdd60a7eba
4
+ data.tar.gz: 07cdfaa58a518b5498c289e0edac1b4a8b628311233f9ca1a32afb9fddfd77b8
5
5
  SHA512:
6
- metadata.gz: 46c4a6a69ce46393b4668aff853b0bf08f11d22a250834f799184f2e069eb297bb418ef8fb10b7a5e9bbd8aa8babbcaef30f981f6f227e8b9f06b4adf72e6266
7
- data.tar.gz: 5d8cc37ea53613809b4f67159483463fdb1e607c5f05a38e623ed6ba6f4d699e643d3cec1514f872562998be11d996a514bc39d8ad814945d10a2ac972b11fb6
6
+ metadata.gz: a4bea256724d0ab3f55ad5fdd0bb41cfd0ee869330ec1c83665b4d09e925e6b67f9647500836092822cda924d7ce7b0621e06ae07d7d93c0bfb13dcd7397b722
7
+ data.tar.gz: 0bc07ca76b25009571cb1d0c64e2ebd5218f6fb50840f1bb8d97af88fa450220b80e4f052107ecad642b81b50afa9207d1795bca26f2686e151e56a4d59f79b2
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # Iro
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/iro`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ Iro is a library for syntax highlighting.
6
4
 
7
5
  ## Installation
8
6
 
@@ -22,7 +20,8 @@ Or install it yourself as:
22
20
 
23
21
  ## Usage
24
22
 
25
- TODO: Write usage instructions here
23
+ If you are a Vim user, you can use [Iro.vim](https://github.com/pocke/iro.vim).
24
+ And we have a DEMO web page. http://ruby-highlight.herokuapp.com/
26
25
 
27
26
  ## Development
28
27
 
data/Rakefile CHANGED
@@ -13,9 +13,11 @@ end
13
13
  task :smoke do
14
14
  sh 'bin/smoke', 'tric/trick2013'
15
15
  sh 'bin/smoke', 'tric/trick2015'
16
+ sh 'bin/smoke', 'tric/trick2018'
16
17
  sh 'bin/smoke', 'ruby/ruby', 'trunk'
17
18
  sh 'bin/smoke', 'gitlabhq/gitlabhq'
18
19
  sh 'bin/smoke', 'rails/rails'
20
+ sh 'bin/smoke', 'discourse/discourse'
19
21
  end
20
22
 
21
23
  namespace :bump do
@@ -46,6 +46,14 @@ module Iro
46
46
  def initialize(*)
47
47
  super
48
48
  @tokens = {}
49
+ @end_stack = []
50
+ end
51
+
52
+ def parse
53
+ super
54
+ @end_stack.each do |end_kw|
55
+ register_scanner_event 'Keyword', end_kw
56
+ end
49
57
  end
50
58
 
51
59
  def register_token(group, token)
@@ -59,6 +67,10 @@ module Iro
59
67
  register_token group, [pos[0], pos[1]+1, event.content.size]
60
68
  end
61
69
 
70
+ def highlight_end_as(group)
71
+ register_scanner_event group, @end_stack.pop
72
+ end
73
+
62
74
  def unhighlight!(scanner_event)
63
75
  t = scanner_event.type[1..-1].to_sym
64
76
  group = EVENT_NAME_TO_HIGHLIGT_NAME[t] ||
@@ -68,6 +80,7 @@ module Iro
68
80
  t = scanner_event.position + [scanner_event.content.size]
69
81
  t[1] += 1
70
82
  @tokens[group].reject! { |ev| ev == t }
83
+ @end_stack.reject!{|e| e == scanner_event} if scanner_event.kw_type? && scanner_event.content == 'end'
71
84
  end
72
85
 
73
86
  EVENT_NAME_TO_HIGHLIGT_NAME.each do |tok_type, group|
@@ -85,9 +98,14 @@ module Iro
85
98
  end
86
99
 
87
100
  def on_kw(str)
88
- group = kw_group(str)
89
- register_token group, [lineno, column+1, str.size]
90
- super
101
+ super.tap do |result|
102
+ if str == 'end'
103
+ @end_stack << result
104
+ else
105
+ group = kw_group(str)
106
+ register_token group, [lineno, column+1, str.size]
107
+ end
108
+ end
91
109
  end
92
110
 
93
111
  # foo: bar
@@ -108,12 +126,14 @@ module Iro
108
126
  def on_def(name, params, body)
109
127
  unhighlight! name if name.kw_type?
110
128
  register_scanner_event 'rubyFunction', name
129
+ highlight_end_as 'rubyDefine'
111
130
  nil
112
131
  end
113
132
 
114
133
  def on_defs(recv, period, name, params, body)
115
134
  unhighlight! name if name.kw_type?
116
135
  register_scanner_event 'rubyFunction', name
136
+ highlight_end_as 'rubyDefine'
117
137
  nil
118
138
  end
119
139
 
@@ -153,6 +173,10 @@ module Iro
153
173
  highlight_keyword_like_method(ident)
154
174
  end
155
175
 
176
+ def on_vcall(ident)
177
+ highlight_keyword_like_method(ident)
178
+ end
179
+
156
180
  def on_command(ident, _)
157
181
  highlight_keyword_like_method(ident)
158
182
  end
@@ -1,3 +1,3 @@
1
1
  module Iro
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iro
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masataka Pocke Kuwabara
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-05-28 00:00:00.000000000 Z
11
+ date: 2018-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler