tbpgr_utils 0.0.109 → 0.0.110
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +10 -0
- data/lib/markdown/italic.rb +41 -0
- data/lib/markdown_string.rb +1 -0
- data/lib/tbpgr_utils/version.rb +1 -1
- data/spec/markdown/italic_spec.rb +61 -0
- data/spec/markdown/ol_spec.rb +1 -5
- data/spec/markdown/ul_spec.rb +1 -5
- metadata +15 -12
data/README.md
CHANGED
@@ -100,6 +100,7 @@ Or install it yourself as:
|
|
100
100
|
|[MarkdownString.heading5](#markdownstringheading5) |Return markdown heading level5 from text |
|
101
101
|
|[MarkdownString.heading6](#markdownstringheading6) |Return markdown heading level6 from text |
|
102
102
|
|[MarkdownString.hr](#markdownstringhr) |Return markdown hr |
|
103
|
+
|[MarkdownString.italic](#markdownstringitalic) |Return markdown italic |
|
103
104
|
|[MarkdownString.ol](#markdownstringol) |Return markdown ol from array |
|
104
105
|
|[MarkdownString.ul](#markdownstringul) |Return markdown ul from array |
|
105
106
|
|[MetasyntacticVariable](#metasyntacticvariable) |META variable, META variable for classes |
|
@@ -2362,6 +2363,14 @@ MarkdownString.hr # => '---'
|
|
2362
2363
|
|
2363
2364
|
[back to list](#list)
|
2364
2365
|
|
2366
|
+
### MarkdownString.italic
|
2367
|
+
~~~ruby
|
2368
|
+
require 'markdown_string'
|
2369
|
+
MarkdownString.italic 'italic' # => '*italic*'
|
2370
|
+
~~~
|
2371
|
+
|
2372
|
+
[back to list](#list)
|
2373
|
+
|
2365
2374
|
### MarkdownString.ol
|
2366
2375
|
case list
|
2367
2376
|
~~~ruby
|
@@ -3434,6 +3443,7 @@ if you are Sublime Text2 user, you can use snippet for TbpgrUtils.
|
|
3434
3443
|
https://github.com/tbpgr/tbpgr_utils_snippets
|
3435
3444
|
|
3436
3445
|
## History
|
3446
|
+
* version 0.0.110 : add MarkdownString#italic
|
3437
3447
|
* version 0.0.109 : add MarkdownString#hr
|
3438
3448
|
* version 0.0.108 : add MarkdownString#ol
|
3439
3449
|
* version 0.0.107 : add MarkdownString#ul
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
class MarkdownString
|
4
|
+
# Return markdown italic from text
|
5
|
+
#
|
6
|
+
# === Example
|
7
|
+
#
|
8
|
+
# case list
|
9
|
+
#
|
10
|
+
# MarkdownString.italic(%w{a b c})
|
11
|
+
#
|
12
|
+
# resitalict
|
13
|
+
#
|
14
|
+
# * a
|
15
|
+
# * b
|
16
|
+
# * c
|
17
|
+
#
|
18
|
+
# case not list
|
19
|
+
#
|
20
|
+
# MarkdownString.italic("test") # => "test"
|
21
|
+
#
|
22
|
+
# case nil list
|
23
|
+
#
|
24
|
+
# MarkdownString.italic([nil, nil])
|
25
|
+
#
|
26
|
+
# resitalict
|
27
|
+
#
|
28
|
+
# *
|
29
|
+
# *
|
30
|
+
#
|
31
|
+
# case empty list
|
32
|
+
#
|
33
|
+
# MarkdownString.italic([]) # => ""
|
34
|
+
#
|
35
|
+
def self.italic(text)
|
36
|
+
return '**' if text.nil?
|
37
|
+
return text unless text.is_a?(String)
|
38
|
+
return '**' if text.empty?
|
39
|
+
"*#{text}*"
|
40
|
+
end
|
41
|
+
end
|
data/lib/markdown_string.rb
CHANGED
data/lib/tbpgr_utils/version.rb
CHANGED
@@ -0,0 +1,61 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'markdown/italic'
|
4
|
+
|
5
|
+
describe MarkdownString do
|
6
|
+
context :italic do
|
7
|
+
cases = [
|
8
|
+
{
|
9
|
+
case_no: 1,
|
10
|
+
case_title: 'string case',
|
11
|
+
input: 'italic',
|
12
|
+
expected: '*italic*'
|
13
|
+
},
|
14
|
+
{
|
15
|
+
case_no: 2,
|
16
|
+
case_title: 'empty case',
|
17
|
+
input: '',
|
18
|
+
expected: '**',
|
19
|
+
},
|
20
|
+
{
|
21
|
+
case_no: 3,
|
22
|
+
case_title: 'nil case',
|
23
|
+
input: nil,
|
24
|
+
expected: '**',
|
25
|
+
},
|
26
|
+
{
|
27
|
+
case_no: 4,
|
28
|
+
case_title: 'not string case',
|
29
|
+
input: 1,
|
30
|
+
expected: 1,
|
31
|
+
},
|
32
|
+
]
|
33
|
+
|
34
|
+
cases.each do |c|
|
35
|
+
it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
|
36
|
+
begin
|
37
|
+
case_before c
|
38
|
+
|
39
|
+
# -- given --
|
40
|
+
# nothing
|
41
|
+
|
42
|
+
# -- when --
|
43
|
+
actual = MarkdownString.italic c[:input]
|
44
|
+
|
45
|
+
# -- then --
|
46
|
+
expect(actual).to eq(c[:expected])
|
47
|
+
ensure
|
48
|
+
case_after c
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def case_before(c)
|
53
|
+
# implement each case before
|
54
|
+
end
|
55
|
+
|
56
|
+
def case_after(c)
|
57
|
+
# implement each case after
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
data/spec/markdown/ol_spec.rb
CHANGED
data/spec/markdown/ul_spec.rb
CHANGED
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.110
|
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-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
16
|
-
requirement: &
|
16
|
+
requirement: &23274516 !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: *23274516
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: bundler
|
27
|
-
requirement: &
|
27
|
+
requirement: &23274228 !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: *23274228
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rake
|
38
|
-
requirement: &
|
38
|
+
requirement: &23274000 !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: *23274000
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rspec
|
49
|
-
requirement: &
|
49
|
+
requirement: &23273676 !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: *23273676
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: simplecov
|
60
|
-
requirement: &
|
60
|
+
requirement: &23273376 !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: *23273376
|
69
69
|
description: Utilities
|
70
70
|
email:
|
71
71
|
- tbpgr@tbpgr.jp
|
@@ -110,6 +110,7 @@ files:
|
|
110
110
|
- lib/ghostable.rb
|
111
111
|
- lib/markdown/heading.rb
|
112
112
|
- lib/markdown/hr.rb
|
113
|
+
- lib/markdown/italic.rb
|
113
114
|
- lib/markdown/ol.rb
|
114
115
|
- lib/markdown/ul.rb
|
115
116
|
- lib/markdown_string.rb
|
@@ -236,6 +237,7 @@ files:
|
|
236
237
|
- spec/ghostable_spec.rb
|
237
238
|
- spec/markdown/heading_spec.rb
|
238
239
|
- spec/markdown/hr_spec.rb
|
240
|
+
- spec/markdown/italic_spec.rb
|
239
241
|
- spec/markdown/ol_spec.rb
|
240
242
|
- spec/markdown/ul_spec.rb
|
241
243
|
- spec/metasyntactic_variable_spec.rb
|
@@ -377,6 +379,7 @@ test_files:
|
|
377
379
|
- spec/ghostable_spec.rb
|
378
380
|
- spec/markdown/heading_spec.rb
|
379
381
|
- spec/markdown/hr_spec.rb
|
382
|
+
- spec/markdown/italic_spec.rb
|
380
383
|
- spec/markdown/ol_spec.rb
|
381
384
|
- spec/markdown/ul_spec.rb
|
382
385
|
- spec/metasyntactic_variable_spec.rb
|