tbpgr_utils 0.0.110 → 0.0.111

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -93,6 +93,7 @@ Or install it yourself as:
93
93
  |[TbpgrUtils Kernel#null](#kernelnull) |null is alias of nil |
94
94
  |[TbpgrUtils Kernel#print_eval](#kernelprint_eval) |Print code + eval result |
95
95
  |[TbpgrUtils Kernel#puts_eval](#kernelputs_eval) |Puts code + eval result |
96
+ |[MarkdownString.bold](#markdownstringbold) |Return markdown bold |
96
97
  |[MarkdownString.heading1](#markdownstringheading1) |Return markdown heading level1 from text |
97
98
  |[MarkdownString.heading2](#markdownstringheading2) |Return markdown heading level2 from text |
98
99
  |[MarkdownString.heading3](#markdownstringheading3) |Return markdown heading level3 from text |
@@ -2292,6 +2293,16 @@ EvalHelperTest.new.hoge(hash) # => return 'default'
2292
2293
 
2293
2294
  [back to list](#list)
2294
2295
 
2296
+ ### MarkdownString.bold
2297
+ ~~~ruby
2298
+ require 'markdown_string'
2299
+ MarkdownString.bold("strong") # => "**strong**"
2300
+ MarkdownString.bold("") # => "****"
2301
+ MarkdownString.bold(nil) # => "****"
2302
+ ~~~
2303
+
2304
+ [back to list](#list)
2305
+
2295
2306
  ### MarkdownString.heading1
2296
2307
  ~~~ruby
2297
2308
  require 'markdown_string'
@@ -3443,6 +3454,7 @@ if you are Sublime Text2 user, you can use snippet for TbpgrUtils.
3443
3454
  https://github.com/tbpgr/tbpgr_utils_snippets
3444
3455
 
3445
3456
  ## History
3457
+ * version 0.0.111 : add MarkdownString#bold
3446
3458
  * version 0.0.110 : add MarkdownString#italic
3447
3459
  * version 0.0.109 : add MarkdownString#hr
3448
3460
  * version 0.0.108 : add MarkdownString#ol
@@ -0,0 +1,20 @@
1
+ # encoding: utf-8
2
+
3
+ class MarkdownString
4
+ # Return markdown bold from text
5
+ #
6
+ # === Example
7
+ #
8
+ # case list
9
+ #
10
+ # MarkdownString.bold("hoge") # '**hoge**'
11
+ # MarkdownString.bold("") # '****'
12
+ # MarkdownString.bold(nil) # '****'
13
+ #
14
+ def self.bold(text)
15
+ return '****' if text.nil?
16
+ return text unless text.is_a?(String)
17
+ return '****' if text.empty?
18
+ "**#{text}**"
19
+ end
20
+ end
@@ -1,5 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require 'markdown/bold'
3
4
  require 'markdown/heading'
4
5
  require 'markdown/hr'
5
6
  require 'markdown/italic'
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Tbpgr Utilities
4
4
  module TbpgrUtils
5
- VERSION = '0.0.110'
5
+ VERSION = '0.0.111'
6
6
  end
@@ -0,0 +1,61 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+ require 'markdown/bold'
4
+
5
+ describe MarkdownString do
6
+ context :bold do
7
+ cases = [
8
+ {
9
+ case_no: 1,
10
+ case_title: 'string case',
11
+ input: 'bold',
12
+ expected: '**bold**'
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.bold 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
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.110
4
+ version: 0.0.111
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-27 00:00:00.000000000 Z
12
+ date: 2014-04-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
16
- requirement: &23274516 !ruby/object:Gem::Requirement
16
+ requirement: &27279504 !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: *23274516
24
+ version_requirements: *27279504
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: bundler
27
- requirement: &23274228 !ruby/object:Gem::Requirement
27
+ requirement: &27279216 !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: *23274228
35
+ version_requirements: *27279216
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake
38
- requirement: &23274000 !ruby/object:Gem::Requirement
38
+ requirement: &27278988 !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: *23274000
46
+ version_requirements: *27278988
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec
49
- requirement: &23273676 !ruby/object:Gem::Requirement
49
+ requirement: &27278664 !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: *23273676
57
+ version_requirements: *27278664
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: simplecov
60
- requirement: &23273376 !ruby/object:Gem::Requirement
60
+ requirement: &27278364 !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: *23273376
68
+ version_requirements: *27278364
69
69
  description: Utilities
70
70
  email:
71
71
  - tbpgr@tbpgr.jp
@@ -108,6 +108,7 @@ files:
108
108
  - lib/familyable/familynize.rb
109
109
  - lib/familyable/person.rb
110
110
  - lib/ghostable.rb
111
+ - lib/markdown/bold.rb
111
112
  - lib/markdown/heading.rb
112
113
  - lib/markdown/hr.rb
113
114
  - lib/markdown/italic.rb
@@ -235,6 +236,7 @@ files:
235
236
  - spec/eval_helper/unless_code_spec.rb
236
237
  - spec/familyable/familyable_spec.rb
237
238
  - spec/ghostable_spec.rb
239
+ - spec/markdown/bold_spec.rb
238
240
  - spec/markdown/heading_spec.rb
239
241
  - spec/markdown/hr_spec.rb
240
242
  - spec/markdown/italic_spec.rb
@@ -377,6 +379,7 @@ test_files:
377
379
  - spec/eval_helper/unless_code_spec.rb
378
380
  - spec/familyable/familyable_spec.rb
379
381
  - spec/ghostable_spec.rb
382
+ - spec/markdown/bold_spec.rb
380
383
  - spec/markdown/heading_spec.rb
381
384
  - spec/markdown/hr_spec.rb
382
385
  - spec/markdown/italic_spec.rb