tbpgr_utils 0.0.105 → 0.0.106

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -95,6 +95,10 @@ Or install it yourself as:
95
95
  |[TbpgrUtils Kernel#puts_eval](#kernelputs_eval) |Puts code + eval result |
96
96
  |[MarkdownString.heading1](#markdownstringheading1) |Return markdown heading level1 from text |
97
97
  |[MarkdownString.heading2](#markdownstringheading2) |Return markdown heading level2 from text |
98
+ |[MarkdownString.heading3](#markdownstringheading3) |Return markdown heading level3 from text |
99
+ |[MarkdownString.heading4](#markdownstringheading4) |Return markdown heading level4 from text |
100
+ |[MarkdownString.heading5](#markdownstringheading5) |Return markdown heading level5 from text |
101
+ |[MarkdownString.heading6](#markdownstringheading6) |Return markdown heading level6 from text |
98
102
  |[MetasyntacticVariable](#metasyntacticvariable) |META variable, META variable for classes |
99
103
  |[TbpgrUtils Module.alias_methods](#modulealias_methods) |create alias methods |
100
104
  |[TbpgrUtils Numeric#dice_back](#numericdice_back) |return dice back number |
@@ -2306,6 +2310,47 @@ MarkdownString.heading2(12345) # => "## 12345"
2306
2310
 
2307
2311
  [back to list](#list)
2308
2312
 
2313
+ ### MarkdownString.heading3
2314
+ ~~~ruby
2315
+ require 'markdown_string'
2316
+ MarkdownString.heading3("title") # => "### title"
2317
+ MarkdownString.heading3("") # => "### "
2318
+ MarkdownString.heading3(nil) # => "### "
2319
+ MarkdownString.heading3(12345) # => "### 12345"
2320
+ ~~~
2321
+ [back to list](#list)
2322
+
2323
+ ### MarkdownString.heading4
2324
+ ~~~ruby
2325
+ require 'markdown_string'
2326
+ MarkdownString.heading4("title") # => "#### title"
2327
+ MarkdownString.heading4("") # => "#### "
2328
+ MarkdownString.heading4(nil) # => "#### "
2329
+ MarkdownString.heading4(12345) # => "#### 12345"
2330
+ ~~~
2331
+ [back to list](#list)
2332
+
2333
+ ### MarkdownString.heading5
2334
+ ~~~ruby
2335
+ require 'markdown_string'
2336
+ MarkdownString.heading5("title") # => "##### title"
2337
+ MarkdownString.heading5("") # => "##### "
2338
+ MarkdownString.heading5(nil) # => "##### "
2339
+ MarkdownString.heading5(12345) # => "##### 12345"
2340
+ ~~~
2341
+ [back to list](#list)
2342
+
2343
+ ### MarkdownString.heading6
2344
+ ~~~ruby
2345
+ require 'markdown_string'
2346
+ MarkdownString.heading6("title") # => "###### title"
2347
+ MarkdownString.heading6("") # => "###### "
2348
+ MarkdownString.heading6(nil) # => "###### "
2349
+ MarkdownString.heading6(12345) # => "###### 12345"
2350
+ ~~~
2351
+
2352
+ [back to list](#list)
2353
+
2309
2354
  ### MetasyntacticVariable
2310
2355
  * META variable
2311
2356
 
@@ -3300,6 +3345,7 @@ if you are Sublime Text2 user, you can use snippet for TbpgrUtils.
3300
3345
  https://github.com/tbpgr/tbpgr_utils_snippets
3301
3346
 
3302
3347
  ## History
3348
+ * version 0.0.106 : add MarkdownString#heading3, heading4, heading5, heading6
3303
3349
  * version 0.0.105 : add MarkdownString#heading2
3304
3350
  * version 0.0.104 : add MarkdownString#heading1. remove File.insert_bom.
3305
3351
  * version 0.0.103 : add Integer#palindromic_prime
@@ -1,36 +1,32 @@
1
- # encoding: utf-8
2
-
3
- class MarkdownString
4
- # Return markdown heading level1 from text
5
- #
6
- # === Example
7
- #
8
- # MarkdownString.heading1("title") # => "# title"
9
- # MarkdownString.heading1("") # => "# "
10
- # MarkdownString.heading1(nil) # => "# "
11
- # MarkdownString.heading1(12345) # => "# 12345"
12
- #
13
- def self.heading1(text)
14
- heading(text, 1)
15
- end
16
-
17
- # Return markdown heading level2 from text
18
- #
19
- # === Example
20
- #
21
- # MarkdownString.heading2("title") # => "## title"
22
- # MarkdownString.heading2("") # => "## "
23
- # MarkdownString.heading2(nil) # => "## "
24
- # MarkdownString.heading2(12345) # => "## 12345"
25
- #
26
- def self.heading2(text)
27
- heading(text, 2)
28
- end
29
-
30
- private
31
- def self.heading(text, level)
32
- return '#' * level + ' ' if text.nil?
33
- return '#' * level + ' ' if text.respond_to?(:empty) && text.empty?
34
- '#' * level + " #{text.to_s}"
35
- end
36
- end
1
+ # encoding: utf-8
2
+
3
+ class MarkdownString
4
+ class << self
5
+ # Return markdown heading level1-6 from text
6
+ #
7
+ # === Example
8
+ #
9
+ # MarkdownString.heading1("title") # => "# title"
10
+ # MarkdownString.heading2("title") # => "## title"
11
+ # MarkdownString.heading3("title") # => "### title"
12
+ # MarkdownString.heading4("title") # => "#### title"
13
+ # MarkdownString.heading5("title") # => "##### title"
14
+ # MarkdownString.heading6("title") # => "###### title"
15
+ # MarkdownString.heading1("") # => "# "
16
+ # MarkdownString.heading1(nil) # => "# "
17
+ # MarkdownString.heading1(12345) # => "# 12345"
18
+ #
19
+ [*1..6].each do |i|
20
+ define_method "heading#{i.to_s}".to_sym do |text|
21
+ heading(text, i)
22
+ end
23
+ end
24
+ end
25
+
26
+ private
27
+ def self.heading(text, level)
28
+ return '#' * level + ' ' if text.nil?
29
+ return '#' * level + ' ' if text.respond_to?(:empty) && text.empty?
30
+ '#' * level + " #{text.to_s}"
31
+ end
32
+ end
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Tbpgr Utilities
4
4
  module TbpgrUtils
5
- VERSION = '0.0.105'
5
+ VERSION = '0.0.106'
6
6
  end
@@ -1,117 +1,63 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
- require 'markdown/heading'
4
-
5
- describe MarkdownString do
6
- context :heading1 do
7
- cases = [
8
- {
9
- case_no: 1,
10
- case_title: 'normal case',
11
- input: 'header1',
12
- expected: '# header1',
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: '',
24
- expected: '# ',
25
- },
26
- {
27
- case_no: 4,
28
- case_title: 'not String case',
29
- input: 12_345,
30
- expected: '# 12345',
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.heading1 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
-
62
- context :heading2 do
63
- cases = [
64
- {
65
- case_no: 1,
66
- case_title: 'normal case',
67
- input: 'heading2',
68
- expected: '## heading2',
69
- },
70
- {
71
- case_no: 2,
72
- case_title: 'empty case',
73
- input: '',
74
- expected: '## ',
75
- },
76
- {
77
- case_no: 3,
78
- case_title: 'nil case',
79
- input: '',
80
- expected: '## ',
81
- },
82
- {
83
- case_no: 4,
84
- case_title: 'not String case',
85
- input: 12_345,
86
- expected: '## 12345',
87
- },
88
- ]
89
-
90
- cases.each do |c|
91
- it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
92
- begin
93
- case_before c
94
-
95
- # -- given --
96
- # nothing
97
-
98
- # -- when --
99
- actual = MarkdownString.heading2 c[:input]
100
-
101
- # -- then --
102
- expect(actual).to eq(c[:expected])
103
- ensure
104
- case_after c
105
- end
106
- end
107
-
108
- def case_before(c)
109
- # implement each case before
110
- end
111
-
112
- def case_after(c)
113
- # implement each case after
114
- end
115
- end
116
- end
117
- end
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+ require 'markdown/heading'
4
+
5
+ describe MarkdownString do
6
+ [*1..6].each do |i|
7
+ context "heading#{i.to_s}" do
8
+ cases = [
9
+ {
10
+ case_no: 1,
11
+ case_title: 'normal case',
12
+ input: "heading#{i.to_s}",
13
+ expected: "#{'#' * i} heading#{i.to_s}",
14
+ },
15
+ {
16
+ case_no: 2,
17
+ case_title: 'empty case',
18
+ input: '',
19
+ expected: "#{'#' * i} ",
20
+ },
21
+ {
22
+ case_no: 3,
23
+ case_title: 'nil case',
24
+ input: '',
25
+ expected: "#{'#' * i} ",
26
+ },
27
+ {
28
+ case_no: 4,
29
+ case_title: 'not String case',
30
+ input: 12_345,
31
+ expected: "#{'#' * i} 12345",
32
+ },
33
+ ]
34
+
35
+ cases.each do |c|
36
+ it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
37
+ begin
38
+ case_before c
39
+
40
+ # -- given --
41
+ # nothing
42
+
43
+ # -- when --
44
+ actual = MarkdownString.send "heading#{i.to_s}", c[:input]
45
+
46
+ # -- then --
47
+ expect(actual).to eq(c[:expected])
48
+ ensure
49
+ case_after c
50
+ end
51
+ end
52
+
53
+ def case_before(c)
54
+ # implement each case before
55
+ end
56
+
57
+ def case_after(c)
58
+ # implement each case after
59
+ end
60
+ end
61
+ end
62
+ end
63
+ 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.105
4
+ version: 0.0.106
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-22 00:00:00.000000000 Z
12
+ date: 2014-04-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
16
- requirement: &22339656 !ruby/object:Gem::Requirement
16
+ requirement: &22500996 !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: *22339656
24
+ version_requirements: *22500996
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: bundler
27
- requirement: &22339368 !ruby/object:Gem::Requirement
27
+ requirement: &22500708 !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: *22339368
35
+ version_requirements: *22500708
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake
38
- requirement: &22339140 !ruby/object:Gem::Requirement
38
+ requirement: &22500480 !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: *22339140
46
+ version_requirements: *22500480
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec
49
- requirement: &22338816 !ruby/object:Gem::Requirement
49
+ requirement: &22500156 !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: *22338816
57
+ version_requirements: *22500156
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: simplecov
60
- requirement: &22338516 !ruby/object:Gem::Requirement
60
+ requirement: &22499856 !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: *22338516
68
+ version_requirements: *22499856
69
69
  description: Utilities
70
70
  email:
71
71
  - tbpgr@tbpgr.jp