html-pipeline-nico_link 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +291 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +50 -0
- data/Rakefile +6 -0
- data/html-pipeline-nico_link.gemspec +26 -0
- data/lib/html/pipeline/nico_link.rb +2 -0
- data/lib/html/pipeline/nico_link/filter.rb +128 -0
- data/lib/html/pipeline/nico_link/version.rb +7 -0
- data/spec/nico_link_filter_spec.rb +34 -0
- data/spec/spec_helper.rb +8 -0
- metadata +113 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e8182a5ba9e03d271c0cbfd783f337668d366b4c
|
4
|
+
data.tar.gz: c76d6d4bce7e4b186edf786ab66387f6e6e3c6d3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 31ec2eb5262be9a2cdbb794dff40f9ed2adc5c68cdedc45d3ad0114e18cc0921c98851d301590317e61cf82d7c2c55e6b28bba8359094948ac6eba0fc1605af6
|
7
|
+
data.tar.gz: 0adfaf0834d41ccb7cef831e4674ff9aaf393f801223269545ce6de987cd0a177bb80d35b04f9c54c5b8fe445b07d9a1779168363e1a26b658e29d715638b864
|
data/.gitignore
ADDED
@@ -0,0 +1,291 @@
|
|
1
|
+
/.bundle/
|
2
|
+
/.yardoc
|
3
|
+
/Gemfile.lock
|
4
|
+
/_yardoc/
|
5
|
+
/coverage/
|
6
|
+
/doc/
|
7
|
+
/pkg/
|
8
|
+
/spec/reports/
|
9
|
+
/tmp/
|
10
|
+
*.bundle
|
11
|
+
*.so
|
12
|
+
*.o
|
13
|
+
*.a
|
14
|
+
mkmf.log
|
15
|
+
|
16
|
+
# Created by https://www.gitignore.io
|
17
|
+
|
18
|
+
### OSX ###
|
19
|
+
.DS_Store
|
20
|
+
.AppleDouble
|
21
|
+
.LSOverride
|
22
|
+
|
23
|
+
# Icon must end with two \r
|
24
|
+
Icon
|
25
|
+
|
26
|
+
|
27
|
+
# Thumbnails
|
28
|
+
._*
|
29
|
+
|
30
|
+
# Files that might appear on external disk
|
31
|
+
.Spotlight-V100
|
32
|
+
.Trashes
|
33
|
+
|
34
|
+
# Directories potentially created on remote AFP share
|
35
|
+
.AppleDB
|
36
|
+
.AppleDesktop
|
37
|
+
Network Trash Folder
|
38
|
+
Temporary Items
|
39
|
+
.apdisk
|
40
|
+
|
41
|
+
|
42
|
+
### Windows ###
|
43
|
+
# Windows image file caches
|
44
|
+
Thumbs.db
|
45
|
+
ehthumbs.db
|
46
|
+
|
47
|
+
# Folder config file
|
48
|
+
Desktop.ini
|
49
|
+
|
50
|
+
# Recycle Bin used on file shares
|
51
|
+
$RECYCLE.BIN/
|
52
|
+
|
53
|
+
# Windows Installer files
|
54
|
+
*.cab
|
55
|
+
*.msi
|
56
|
+
*.msm
|
57
|
+
*.msp
|
58
|
+
|
59
|
+
# Windows shortcuts
|
60
|
+
*.lnk
|
61
|
+
|
62
|
+
|
63
|
+
### Linux ###
|
64
|
+
*~
|
65
|
+
|
66
|
+
# KDE directory preferences
|
67
|
+
.directory
|
68
|
+
|
69
|
+
|
70
|
+
### vim ###
|
71
|
+
[._]*.s[a-w][a-z]
|
72
|
+
[._]s[a-w][a-z]
|
73
|
+
*.un~
|
74
|
+
Session.vim
|
75
|
+
.netrwhist
|
76
|
+
*~
|
77
|
+
|
78
|
+
|
79
|
+
### Emacs ###
|
80
|
+
# -*- mode: gitignore; -*-
|
81
|
+
*~
|
82
|
+
\#*\#
|
83
|
+
/.emacs.desktop
|
84
|
+
/.emacs.desktop.lock
|
85
|
+
*.elc
|
86
|
+
auto-save-list
|
87
|
+
tramp
|
88
|
+
.\#*
|
89
|
+
|
90
|
+
# Org-mode
|
91
|
+
.org-id-locations
|
92
|
+
*_archive
|
93
|
+
|
94
|
+
# flymake-mode
|
95
|
+
*_flymake.*
|
96
|
+
|
97
|
+
# eshell files
|
98
|
+
/eshell/history
|
99
|
+
/eshell/lastdir
|
100
|
+
|
101
|
+
# elpa packages
|
102
|
+
/elpa/
|
103
|
+
|
104
|
+
# reftex files
|
105
|
+
*.rel
|
106
|
+
|
107
|
+
# AUCTeX auto folder
|
108
|
+
/auto/
|
109
|
+
|
110
|
+
|
111
|
+
### SublimeText ###
|
112
|
+
# cache files for sublime text
|
113
|
+
*.tmlanguage.cache
|
114
|
+
*.tmPreferences.cache
|
115
|
+
*.stTheme.cache
|
116
|
+
|
117
|
+
# workspace files are user-specific
|
118
|
+
*.sublime-workspace
|
119
|
+
|
120
|
+
# project files should be checked into the repository, unless a significant
|
121
|
+
# proportion of contributors will probably not be using SublimeText
|
122
|
+
# *.sublime-project
|
123
|
+
|
124
|
+
# sftp configuration file
|
125
|
+
sftp-config.json
|
126
|
+
|
127
|
+
|
128
|
+
### Intellij ###
|
129
|
+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm
|
130
|
+
|
131
|
+
/*.iml
|
132
|
+
|
133
|
+
## Directory-based project format:
|
134
|
+
.idea/
|
135
|
+
# if you remove the above rule, at least ignore the following:
|
136
|
+
|
137
|
+
# User-specific stuff:
|
138
|
+
# .idea/workspace.xml
|
139
|
+
# .idea/tasks.xml
|
140
|
+
# .idea/dictionaries
|
141
|
+
|
142
|
+
# Sensitive or high-churn files:
|
143
|
+
# .idea/dataSources.ids
|
144
|
+
# .idea/dataSources.xml
|
145
|
+
# .idea/sqlDataSources.xml
|
146
|
+
# .idea/dynamic.xml
|
147
|
+
# .idea/uiDesigner.xml
|
148
|
+
|
149
|
+
# Gradle:
|
150
|
+
# .idea/gradle.xml
|
151
|
+
# .idea/libraries
|
152
|
+
|
153
|
+
# Mongo Explorer plugin:
|
154
|
+
# .idea/mongoSettings.xml
|
155
|
+
|
156
|
+
## File-based project format:
|
157
|
+
*.ipr
|
158
|
+
*.iws
|
159
|
+
|
160
|
+
## Plugin-specific files:
|
161
|
+
|
162
|
+
# IntelliJ
|
163
|
+
out/
|
164
|
+
|
165
|
+
# mpeltonen/sbt-idea plugin
|
166
|
+
.idea_modules/
|
167
|
+
|
168
|
+
# JIRA plugin
|
169
|
+
atlassian-ide-plugin.xml
|
170
|
+
|
171
|
+
# Crashlytics plugin (for Android Studio and IntelliJ)
|
172
|
+
com_crashlytics_export_strings.xml
|
173
|
+
|
174
|
+
|
175
|
+
### RubyMine ###
|
176
|
+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm
|
177
|
+
|
178
|
+
/*.iml
|
179
|
+
|
180
|
+
## Directory-based project format:
|
181
|
+
.idea/
|
182
|
+
# if you remove the above rule, at least ignore the following:
|
183
|
+
|
184
|
+
# User-specific stuff:
|
185
|
+
# .idea/workspace.xml
|
186
|
+
# .idea/tasks.xml
|
187
|
+
# .idea/dictionaries
|
188
|
+
|
189
|
+
# Sensitive or high-churn files:
|
190
|
+
# .idea/dataSources.ids
|
191
|
+
# .idea/dataSources.xml
|
192
|
+
# .idea/sqlDataSources.xml
|
193
|
+
# .idea/dynamic.xml
|
194
|
+
# .idea/uiDesigner.xml
|
195
|
+
|
196
|
+
# Gradle:
|
197
|
+
# .idea/gradle.xml
|
198
|
+
# .idea/libraries
|
199
|
+
|
200
|
+
# Mongo Explorer plugin:
|
201
|
+
# .idea/mongoSettings.xml
|
202
|
+
|
203
|
+
## File-based project format:
|
204
|
+
*.ipr
|
205
|
+
*.iws
|
206
|
+
|
207
|
+
## Plugin-specific files:
|
208
|
+
|
209
|
+
# IntelliJ
|
210
|
+
out/
|
211
|
+
|
212
|
+
# mpeltonen/sbt-idea plugin
|
213
|
+
.idea_modules/
|
214
|
+
|
215
|
+
# JIRA plugin
|
216
|
+
atlassian-ide-plugin.xml
|
217
|
+
|
218
|
+
# Crashlytics plugin (for Android Studio and IntelliJ)
|
219
|
+
com_crashlytics_export_strings.xml
|
220
|
+
|
221
|
+
|
222
|
+
### Ruby ###
|
223
|
+
*.gem
|
224
|
+
*.rbc
|
225
|
+
/.config
|
226
|
+
/coverage/
|
227
|
+
/InstalledFiles
|
228
|
+
/pkg/
|
229
|
+
/spec/reports/
|
230
|
+
/test/tmp/
|
231
|
+
/test/version_tmp/
|
232
|
+
/tmp/
|
233
|
+
|
234
|
+
## Specific to RubyMotion:
|
235
|
+
.dat*
|
236
|
+
.repl_history
|
237
|
+
build/
|
238
|
+
|
239
|
+
## Documentation cache and generated files:
|
240
|
+
/.yardoc/
|
241
|
+
/_yardoc/
|
242
|
+
/doc/
|
243
|
+
/rdoc/
|
244
|
+
|
245
|
+
## Environment normalisation:
|
246
|
+
/.bundle/
|
247
|
+
/lib/bundler/man/
|
248
|
+
|
249
|
+
# for a library or gem, you might want to ignore these files since the code is
|
250
|
+
# intended to run in multiple environments; otherwise, check them in:
|
251
|
+
# Gemfile.lock
|
252
|
+
# .ruby-version
|
253
|
+
# .ruby-gemset
|
254
|
+
|
255
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
256
|
+
.rvmrc
|
257
|
+
|
258
|
+
|
259
|
+
### Rails ###
|
260
|
+
*.rbc
|
261
|
+
capybara-*.html
|
262
|
+
.rspec
|
263
|
+
/log
|
264
|
+
/tmp
|
265
|
+
/db/*.sqlite3
|
266
|
+
/public/system
|
267
|
+
/coverage/
|
268
|
+
/spec/tmp
|
269
|
+
**.orig
|
270
|
+
rerun.txt
|
271
|
+
pickle-email-*.html
|
272
|
+
|
273
|
+
# TODO Comment out these rules if you are OK with secrets being uploaded to the repo
|
274
|
+
config/initializers/secret_token.rb
|
275
|
+
config/secrets.yml
|
276
|
+
|
277
|
+
## Environment normalisation:
|
278
|
+
/.bundle
|
279
|
+
/vendor/bundle
|
280
|
+
|
281
|
+
# these should all be checked in to normalise the environment:
|
282
|
+
# Gemfile.lock, .ruby-version, .ruby-gemset
|
283
|
+
|
284
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
285
|
+
.rvmrc
|
286
|
+
|
287
|
+
# if using bower-rails ignore default bower_components path bower.json files
|
288
|
+
/vendor/assets/bower_components
|
289
|
+
*.bowerrc
|
290
|
+
bower.json
|
291
|
+
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Ru/MuckRu
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# Html::Pipeline::NicoLink
|
2
|
+
|
3
|
+
An HTML::Pipeline filter for niconico(http://www.nicovideo.jp) description links.
|
4
|
+
|
5
|
+
niconicoの動画説明文中のオートリンクです。mylist2.jsの定義を参考にしています。
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'html-pipeline-nico_link'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install html-pipeline-nico_link
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
To use this filter on its own
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
require 'html/pipeline/nico_link'
|
29
|
+
|
30
|
+
filter = HTML::Pipeline::NicoLinkFilter.new('伝説の動画: sm9')
|
31
|
+
filter.call.to_s # => '伝説の動画: <a href="http://www.nicovideo.jp/watch/sm9">sm9</a>'
|
32
|
+
```
|
33
|
+
|
34
|
+
To use this filter with HTML::Pipeline
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
pipeline = HTML::Pipeline.new [
|
38
|
+
HTML::Pipeline::MarkdownFilter,
|
39
|
+
HTML::Pipeline::NicoLinkFilter,
|
40
|
+
]
|
41
|
+
pipeline.call('**伝説の動画はこちら→** sm9') # => '<b>伝説の動画はこちら→</b> <a href="http://www.nicovideo.jp/watch/sm9">sm9</a>'
|
42
|
+
```
|
43
|
+
|
44
|
+
## Contributing
|
45
|
+
|
46
|
+
1. Fork it ( https://github.com/rutan/html-pipeline-nico_link/fork )
|
47
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
48
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
49
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
50
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'html/pipeline/nico_link/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'html-pipeline-nico_link'
|
8
|
+
spec.version = HTML::Pipeline::NicoLink::VERSION
|
9
|
+
spec.authors = ['Ru/MuckRu']
|
10
|
+
spec.email = ['ru_shalm@hazimu.com']
|
11
|
+
spec.summary = %q{niconico link for html-pipeline}
|
12
|
+
spec.description = %q{niconico link for html-pipeline}
|
13
|
+
spec.homepage = ''
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_dependency 'html-pipeline', '~> 1.11.0'
|
22
|
+
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.7'
|
24
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
25
|
+
spec.add_development_dependency 'rspec', '~> 3.1.0'
|
26
|
+
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
require 'html/pipeline'
|
2
|
+
|
3
|
+
module HTML
|
4
|
+
class Pipeline
|
5
|
+
class NicoLinkFilter < Filter
|
6
|
+
def initialize(doc, context = nil, result = nil)
|
7
|
+
super
|
8
|
+
@context = context || {}
|
9
|
+
end
|
10
|
+
|
11
|
+
def call
|
12
|
+
doc.search('text()').each do |node|
|
13
|
+
content = node.to_html
|
14
|
+
html = apply_filter(content)
|
15
|
+
next if html == content
|
16
|
+
node.replace(html)
|
17
|
+
end
|
18
|
+
doc
|
19
|
+
end
|
20
|
+
|
21
|
+
def apply_filter(content)
|
22
|
+
content = content.dup
|
23
|
+
self.patterns.each do |pattern_set|
|
24
|
+
content.gsub!(pattern_set[:pattern]) do
|
25
|
+
space = $1
|
26
|
+
text = $2
|
27
|
+
url = pattern_set[:link].gsub('%s', text)
|
28
|
+
"#{space}<a href=\"#{url}\">#{text}</a>"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
content
|
32
|
+
end
|
33
|
+
|
34
|
+
def patterns
|
35
|
+
@patterns ||= (@context[:nico_link] || DEFAULT_PATTERNS).map do |pattern_set|
|
36
|
+
{
|
37
|
+
pattern: create_pattern(pattern_set[:pattern]),
|
38
|
+
link: pattern_set[:link],
|
39
|
+
}
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def create_pattern(key)
|
44
|
+
/
|
45
|
+
(^|\W)
|
46
|
+
(#{key})
|
47
|
+
(?=
|
48
|
+
\.+[ \t\W]|
|
49
|
+
\.+$|
|
50
|
+
[^0-9a-zA-Z_.]|
|
51
|
+
$
|
52
|
+
)
|
53
|
+
/ix
|
54
|
+
end
|
55
|
+
|
56
|
+
DEFAULT_PATTERNS = [
|
57
|
+
{
|
58
|
+
pattern: /(?:sm|nm|so|ca|ax|yo|nl|ig|na|cw|z[a-e]|om|sk|yk)\d{1,14}/,
|
59
|
+
link: 'http://www.nicovideo.jp/watch/%s'
|
60
|
+
},
|
61
|
+
{
|
62
|
+
pattern: /(?:watch|user|myvideo|mylist)\d{1,14}/,
|
63
|
+
link: 'http://www.nicovideo.jp/%s'
|
64
|
+
},
|
65
|
+
{
|
66
|
+
pattern: /(?:co)\d{1,14}/,
|
67
|
+
link: 'http://com.nicovideo.jp/%s'
|
68
|
+
},
|
69
|
+
{
|
70
|
+
pattern: /(?:ch)\d{1,14}/,
|
71
|
+
link: 'http://ch.nicovideo.jp/%s'
|
72
|
+
},
|
73
|
+
{
|
74
|
+
pattern: /(?:ar)\d{1,14}/,
|
75
|
+
link: 'http://ch.nicovideo.jp/article/%s'
|
76
|
+
},
|
77
|
+
{
|
78
|
+
pattern: /(?:td)\d+/,
|
79
|
+
link: 'http://3d.nicovideo.jp/works/%s',
|
80
|
+
},
|
81
|
+
{
|
82
|
+
pattern: /(?:nc)\d{1,14}/,
|
83
|
+
link: 'http://commons.nicovideo.jp/material/%s',
|
84
|
+
},
|
85
|
+
{
|
86
|
+
pattern: /(?:dw\\d+|az[A-Z0-9]{10}|ys[a-zA-Z0-9-]+_[a-zA-Z0-9-]+|ga\\d+|ip[\\d_]+|gg[a-zA-Z0-9]+-[a-zA-Z0-9-]+)/,
|
87
|
+
link: 'http://ichiba.nicovideo.jp/item/%s',
|
88
|
+
},
|
89
|
+
{
|
90
|
+
pattern: /(?:lv)\d{1,14}/,
|
91
|
+
link: 'http://live.nicovideo.jp/watch/%s',
|
92
|
+
},
|
93
|
+
{
|
94
|
+
pattern: /(?:[sm]g)\d{1,14}/,
|
95
|
+
link: 'http://seiga.nicovideo.jp/watch/%s',
|
96
|
+
},
|
97
|
+
{
|
98
|
+
pattern: /(?:bk)\d{1,14}/,
|
99
|
+
link: 'http://seiga.nicovideo.jp/watch/%s',
|
100
|
+
},
|
101
|
+
{
|
102
|
+
pattern: /(?:im)\d{1,14}/,
|
103
|
+
link: 'http://seiga.nicovideo.jp/seiga/%s',
|
104
|
+
},
|
105
|
+
{
|
106
|
+
pattern: /commons\.nicovideo\.jp\/user\/\d+/,
|
107
|
+
link: 'http://%s',
|
108
|
+
},
|
109
|
+
{
|
110
|
+
pattern: /niconicommons\.jp\/user\/\d+/,
|
111
|
+
link: 'http://www.%s',
|
112
|
+
},
|
113
|
+
{
|
114
|
+
pattern: /user\/illust\/\d+/,
|
115
|
+
link: 'http://seiga.nicovideo.jp/%s',
|
116
|
+
},
|
117
|
+
{
|
118
|
+
pattern: /clip\/\d+/,
|
119
|
+
link: 'http://seiga.nicovideo.jp/%s',
|
120
|
+
},
|
121
|
+
{
|
122
|
+
pattern: /ch\.nicovideo\.jp\/[a-zA-Z0-9][-_a-zA-Z0-9]+(?=[^\-_A-Za-z0-9\/]|$)/,
|
123
|
+
link: 'http://%s',
|
124
|
+
},
|
125
|
+
]
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe 'NicoLinkFilter' do
|
5
|
+
subject do
|
6
|
+
filter = HTML::Pipeline::NicoLinkFilter.new(text)
|
7
|
+
filter.call.to_s
|
8
|
+
end
|
9
|
+
|
10
|
+
context 'sm12345' do
|
11
|
+
let(:text) { 'sm12345' }
|
12
|
+
it { expect(subject).to eq '<a href="http://www.nicovideo.jp/watch/sm12345">sm12345</a>' }
|
13
|
+
end
|
14
|
+
|
15
|
+
context 'commons.nicovideo.jp/user/123' do
|
16
|
+
let(:text) { 'commons.nicovideo.jp/user/123' }
|
17
|
+
it { expect(subject).to eq '<a href="http://commons.nicovideo.jp/user/123">commons.nicovideo.jp/user/123</a>' }
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'sm12345 ar23456 td34567' do
|
21
|
+
let(:text) { 'sm12345 ar23456 td34567' }
|
22
|
+
it { expect(subject).to eq '<a href="http://www.nicovideo.jp/watch/sm12345">sm12345</a> <a href="http://ch.nicovideo.jp/article/ar23456">ar23456</a> <a href="http://3d.nicovideo.jp/works/td34567">td34567</a>' }
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'sm12345sm23456' do
|
26
|
+
let(:text) { 'sm12345sm23456' }
|
27
|
+
it { expect(subject).to eq 'sm12345sm23456' }
|
28
|
+
end
|
29
|
+
|
30
|
+
context '<b>sm</b>123' do
|
31
|
+
let(:text) { '<b>sm</b>123' }
|
32
|
+
it { expect(subject).to eq '<b>sm</b>123' }
|
33
|
+
end
|
34
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: html-pipeline-nico_link
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ru/MuckRu
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-11-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: html-pipeline
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.11.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.11.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.7'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.7'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 3.1.0
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 3.1.0
|
69
|
+
description: niconico link for html-pipeline
|
70
|
+
email:
|
71
|
+
- ru_shalm@hazimu.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- Gemfile
|
78
|
+
- LICENSE.txt
|
79
|
+
- README.md
|
80
|
+
- Rakefile
|
81
|
+
- html-pipeline-nico_link.gemspec
|
82
|
+
- lib/html/pipeline/nico_link.rb
|
83
|
+
- lib/html/pipeline/nico_link/filter.rb
|
84
|
+
- lib/html/pipeline/nico_link/version.rb
|
85
|
+
- spec/nico_link_filter_spec.rb
|
86
|
+
- spec/spec_helper.rb
|
87
|
+
homepage: ''
|
88
|
+
licenses:
|
89
|
+
- MIT
|
90
|
+
metadata: {}
|
91
|
+
post_install_message:
|
92
|
+
rdoc_options: []
|
93
|
+
require_paths:
|
94
|
+
- lib
|
95
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
requirements: []
|
106
|
+
rubyforge_project:
|
107
|
+
rubygems_version: 2.2.2
|
108
|
+
signing_key:
|
109
|
+
specification_version: 4
|
110
|
+
summary: niconico link for html-pipeline
|
111
|
+
test_files:
|
112
|
+
- spec/nico_link_filter_spec.rb
|
113
|
+
- spec/spec_helper.rb
|