tbpgr_utils 0.0.111 → 0.0.112

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.backquotes](#markdownstringbackquotes) |Return markdown backquotes |
96
97
  |[MarkdownString.bold](#markdownstringbold) |Return markdown bold |
97
98
  |[MarkdownString.heading1](#markdownstringheading1) |Return markdown heading level1 from text |
98
99
  |[MarkdownString.heading2](#markdownstringheading2) |Return markdown heading level2 from text |
@@ -2293,6 +2294,26 @@ EvalHelperTest.new.hoge(hash) # => return 'default'
2293
2294
 
2294
2295
  [back to list](#list)
2295
2296
 
2297
+ ### MarkdownString.backquotes
2298
+ ~~~ruby
2299
+ require 'markdown_string'
2300
+ MarkdownString.backquotes <<-EOS
2301
+ hoge
2302
+ hige
2303
+ hage
2304
+ EOS
2305
+ ~~~
2306
+
2307
+ result
2308
+
2309
+ ~~~
2310
+ >hoge
2311
+ >hige
2312
+ >hage
2313
+ ~~~
2314
+
2315
+ [back to list](#list)
2316
+
2296
2317
  ### MarkdownString.bold
2297
2318
  ~~~ruby
2298
2319
  require 'markdown_string'
@@ -3454,6 +3475,7 @@ if you are Sublime Text2 user, you can use snippet for TbpgrUtils.
3454
3475
  https://github.com/tbpgr/tbpgr_utils_snippets
3455
3476
 
3456
3477
  ## History
3478
+ * version 0.0.112 : add MarkdownString#backquotes
3457
3479
  * version 0.0.111 : add MarkdownString#bold
3458
3480
  * version 0.0.110 : add MarkdownString#italic
3459
3481
  * version 0.0.109 : add MarkdownString#hr
@@ -0,0 +1,25 @@
1
+ # encoding: utf-8
2
+
3
+ class MarkdownString
4
+ # Return markdown backquotes from text
5
+ #
6
+ # === Example
7
+ #
8
+ # MarkdownString.backquotes "hoge\nhige\nhage\n"
9
+ #
10
+ # result
11
+ #
12
+ # >hoge
13
+ # >hige
14
+ # >hage
15
+ #
16
+ def self.backquotes(text)
17
+ return '>' if text.nil?
18
+ return text unless text.is_a?(String)
19
+ return '>' if text.empty?
20
+ text.split("\n").reduce([]) do |ret, elm|
21
+ ret << ">#{elm} "
22
+ ret
23
+ end.join("\n") + "\n"
24
+ end
25
+ end
@@ -1,5 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require 'markdown/backquotes'
3
4
  require 'markdown/bold'
4
5
  require 'markdown/heading'
5
6
  require 'markdown/hr'
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Tbpgr Utilities
4
4
  module TbpgrUtils
5
- VERSION = '0.0.111'
5
+ VERSION = '0.0.112'
6
6
  end
@@ -0,0 +1,61 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+ require 'markdown/backquotes'
4
+
5
+ describe MarkdownString do
6
+ context :backquotes do
7
+ cases = [
8
+ {
9
+ case_no: 1,
10
+ case_title: 'string case',
11
+ input: "hoge\nhige\nhage\n",
12
+ expected: ">hoge \n>hige \n>hage \n"
13
+ },
14
+ {
15
+ case_no: 2,
16
+ case_title: 'not string case',
17
+ input: 1,
18
+ expected: 1,
19
+ },
20
+ {
21
+ case_no: 3,
22
+ case_title: 'empty case',
23
+ input: '',
24
+ expected: '>',
25
+ },
26
+ {
27
+ case_no: 4,
28
+ case_title: 'nil case',
29
+ input: nil,
30
+ expected: '>',
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.backquotes 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.111
4
+ version: 0.0.112
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-28 00:00:00.000000000 Z
12
+ date: 2014-04-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
16
- requirement: &27279504 !ruby/object:Gem::Requirement
16
+ requirement: &21174768 !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: *27279504
24
+ version_requirements: *21174768
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: bundler
27
- requirement: &27279216 !ruby/object:Gem::Requirement
27
+ requirement: &21174480 !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: *27279216
35
+ version_requirements: *21174480
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake
38
- requirement: &27278988 !ruby/object:Gem::Requirement
38
+ requirement: &21174252 !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: *27278988
46
+ version_requirements: *21174252
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec
49
- requirement: &27278664 !ruby/object:Gem::Requirement
49
+ requirement: &21173928 !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: *27278664
57
+ version_requirements: *21173928
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: simplecov
60
- requirement: &27278364 !ruby/object:Gem::Requirement
60
+ requirement: &21173628 !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: *27278364
68
+ version_requirements: *21173628
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/backquotes.rb
111
112
  - lib/markdown/bold.rb
112
113
  - lib/markdown/heading.rb
113
114
  - lib/markdown/hr.rb
@@ -236,6 +237,7 @@ files:
236
237
  - spec/eval_helper/unless_code_spec.rb
237
238
  - spec/familyable/familyable_spec.rb
238
239
  - spec/ghostable_spec.rb
240
+ - spec/markdown/backquotes_spec.rb
239
241
  - spec/markdown/bold_spec.rb
240
242
  - spec/markdown/heading_spec.rb
241
243
  - spec/markdown/hr_spec.rb
@@ -379,6 +381,7 @@ test_files:
379
381
  - spec/eval_helper/unless_code_spec.rb
380
382
  - spec/familyable/familyable_spec.rb
381
383
  - spec/ghostable_spec.rb
384
+ - spec/markdown/backquotes_spec.rb
382
385
  - spec/markdown/bold_spec.rb
383
386
  - spec/markdown/heading_spec.rb
384
387
  - spec/markdown/hr_spec.rb