tbpgr_utils 0.0.112 → 0.0.113
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.
- data/README.md +10 -0
- data/lib/markdown/backquotes.rb +3 -3
- data/lib/markdown/link.rb +23 -0
- data/lib/markdown_string.rb +1 -0
- data/lib/tbpgr_utils/version.rb +1 -1
- data/spec/markdown/link_spec.rb +58 -0
- metadata +15 -12
data/README.md
CHANGED
@@ -103,6 +103,7 @@ Or install it yourself as:
|
|
103
103
|
|[MarkdownString.heading6](#markdownstringheading6) |Return markdown heading level6 from text |
|
104
104
|
|[MarkdownString.hr](#markdownstringhr) |Return markdown hr |
|
105
105
|
|[MarkdownString.italic](#markdownstringitalic) |Return markdown italic |
|
106
|
+
|[MarkdownString.link](#markdownstringlink) |Return markdown link |
|
106
107
|
|[MarkdownString.ol](#markdownstringol) |Return markdown ol from array |
|
107
108
|
|[MarkdownString.ul](#markdownstringul) |Return markdown ul from array |
|
108
109
|
|[MetasyntacticVariable](#metasyntacticvariable) |META variable, META variable for classes |
|
@@ -2403,6 +2404,14 @@ MarkdownString.italic 'italic' # => '*italic*'
|
|
2403
2404
|
|
2404
2405
|
[back to list](#list)
|
2405
2406
|
|
2407
|
+
### MarkdownString.link
|
2408
|
+
~~~ruby
|
2409
|
+
require 'markdown_string'
|
2410
|
+
MarkdownString.link 'label', 'http://not_exists.com' # => '[label](http://not_exists.com)'
|
2411
|
+
~~~
|
2412
|
+
|
2413
|
+
[back to list](#list)
|
2414
|
+
|
2406
2415
|
### MarkdownString.ol
|
2407
2416
|
case list
|
2408
2417
|
~~~ruby
|
@@ -3475,6 +3484,7 @@ if you are Sublime Text2 user, you can use snippet for TbpgrUtils.
|
|
3475
3484
|
https://github.com/tbpgr/tbpgr_utils_snippets
|
3476
3485
|
|
3477
3486
|
## History
|
3487
|
+
* version 0.0.113 : add MarkdownString#link
|
3478
3488
|
* version 0.0.112 : add MarkdownString#backquotes
|
3479
3489
|
* version 0.0.111 : add MarkdownString#bold
|
3480
3490
|
* version 0.0.110 : add MarkdownString#italic
|
data/lib/markdown/backquotes.rb
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
class MarkdownString
|
4
|
+
# Return markdown link from label and url
|
5
|
+
#
|
6
|
+
# === Example
|
7
|
+
#
|
8
|
+
# case list
|
9
|
+
#
|
10
|
+
# MarkdownString.link 'label', 'http://hogehogehoge.com'
|
11
|
+
#
|
12
|
+
# result
|
13
|
+
#
|
14
|
+
# '[label](http://hogehogehoge.com)'
|
15
|
+
#
|
16
|
+
def self.link(label, url)
|
17
|
+
label = '' if label.nil?
|
18
|
+
url = '' if url.nil?
|
19
|
+
return label unless label.is_a?(String)
|
20
|
+
return url unless url.is_a?(String)
|
21
|
+
"[#{label}](#{url})"
|
22
|
+
end
|
23
|
+
end
|
data/lib/markdown_string.rb
CHANGED
data/lib/tbpgr_utils/version.rb
CHANGED
@@ -0,0 +1,58 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'markdown/link'
|
4
|
+
|
5
|
+
describe MarkdownString do
|
6
|
+
context :link do
|
7
|
+
cases = [
|
8
|
+
{
|
9
|
+
case_no: 1,
|
10
|
+
case_title: 'valid case',
|
11
|
+
label: 'label',
|
12
|
+
url: 'http://not_exists.com',
|
13
|
+
expected: '[label](http://not_exists.com)'
|
14
|
+
},
|
15
|
+
{
|
16
|
+
case_no: 2,
|
17
|
+
case_title: 'empty case',
|
18
|
+
label: '',
|
19
|
+
url: '',
|
20
|
+
expected: '[]()'
|
21
|
+
},
|
22
|
+
{
|
23
|
+
case_no: 3,
|
24
|
+
case_title: 'nil case',
|
25
|
+
label: nil,
|
26
|
+
url: nil,
|
27
|
+
expected: '[]()'
|
28
|
+
},
|
29
|
+
]
|
30
|
+
|
31
|
+
cases.each do |c|
|
32
|
+
it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
|
33
|
+
begin
|
34
|
+
case_before c
|
35
|
+
|
36
|
+
# -- given --
|
37
|
+
# nothing
|
38
|
+
|
39
|
+
# -- when --
|
40
|
+
actual = MarkdownString.link c[:label], c[:url]
|
41
|
+
|
42
|
+
# -- then --
|
43
|
+
expect(actual).to eq(c[:expected])
|
44
|
+
ensure
|
45
|
+
case_after c
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def case_before(c)
|
50
|
+
# implement each case before
|
51
|
+
end
|
52
|
+
|
53
|
+
def case_after(c)
|
54
|
+
# implement each case after
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tbpgr_utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.113
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-04-
|
12
|
+
date: 2014-04-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
16
|
-
requirement: &
|
16
|
+
requirement: &30004080 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 4.0.1
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *30004080
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: bundler
|
27
|
-
requirement: &
|
27
|
+
requirement: &30003792 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '1.3'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *30003792
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rake
|
38
|
-
requirement: &
|
38
|
+
requirement: &30003564 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *30003564
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rspec
|
49
|
-
requirement: &
|
49
|
+
requirement: &30003240 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 2.14.1
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *30003240
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: simplecov
|
60
|
-
requirement: &
|
60
|
+
requirement: &30002940 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
version: 0.8.2
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *30002940
|
69
69
|
description: Utilities
|
70
70
|
email:
|
71
71
|
- tbpgr@tbpgr.jp
|
@@ -113,6 +113,7 @@ files:
|
|
113
113
|
- lib/markdown/heading.rb
|
114
114
|
- lib/markdown/hr.rb
|
115
115
|
- lib/markdown/italic.rb
|
116
|
+
- lib/markdown/link.rb
|
116
117
|
- lib/markdown/ol.rb
|
117
118
|
- lib/markdown/ul.rb
|
118
119
|
- lib/markdown_string.rb
|
@@ -242,6 +243,7 @@ files:
|
|
242
243
|
- spec/markdown/heading_spec.rb
|
243
244
|
- spec/markdown/hr_spec.rb
|
244
245
|
- spec/markdown/italic_spec.rb
|
246
|
+
- spec/markdown/link_spec.rb
|
245
247
|
- spec/markdown/ol_spec.rb
|
246
248
|
- spec/markdown/ul_spec.rb
|
247
249
|
- spec/metasyntactic_variable_spec.rb
|
@@ -386,6 +388,7 @@ test_files:
|
|
386
388
|
- spec/markdown/heading_spec.rb
|
387
389
|
- spec/markdown/hr_spec.rb
|
388
390
|
- spec/markdown/italic_spec.rb
|
391
|
+
- spec/markdown/link_spec.rb
|
389
392
|
- spec/markdown/ol_spec.rb
|
390
393
|
- spec/markdown/ul_spec.rb
|
391
394
|
- spec/metasyntactic_variable_spec.rb
|