tbpgr_utils 0.0.113 → 0.0.114

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -95,6 +95,7 @@ Or install it yourself as:
95
95
  |[TbpgrUtils Kernel#puts_eval](#kernelputs_eval) |Puts code + eval result |
96
96
  |[MarkdownString.backquotes](#markdownstringbackquotes) |Return markdown backquotes |
97
97
  |[MarkdownString.bold](#markdownstringbold) |Return markdown bold |
98
+ |[MarkdownString.code](#markdownstringcode) |Return markdown code |
98
99
  |[MarkdownString.heading1](#markdownstringheading1) |Return markdown heading level1 from text |
99
100
  |[MarkdownString.heading2](#markdownstringheading2) |Return markdown heading level2 from text |
100
101
  |[MarkdownString.heading3](#markdownstringheading3) |Return markdown heading level3 from text |
@@ -2325,6 +2326,14 @@ MarkdownString.bold(nil) # => "****"
2325
2326
 
2326
2327
  [back to list](#list)
2327
2328
 
2329
+ ### MarkdownString.code
2330
+ ~~~ruby
2331
+ require 'markdown_string'
2332
+ MarkdownString.code('print "hoge"') # => '`print "hoge"`'
2333
+ ~~~
2334
+
2335
+ [back to list](#list)
2336
+
2328
2337
  ### MarkdownString.heading1
2329
2338
  ~~~ruby
2330
2339
  require 'markdown_string'
@@ -3484,6 +3493,7 @@ if you are Sublime Text2 user, you can use snippet for TbpgrUtils.
3484
3493
  https://github.com/tbpgr/tbpgr_utils_snippets
3485
3494
 
3486
3495
  ## History
3496
+ * version 0.0.114 : add MarkdownString#code
3487
3497
  * version 0.0.113 : add MarkdownString#link
3488
3498
  * version 0.0.112 : add MarkdownString#backquotes
3489
3499
  * version 0.0.111 : add MarkdownString#bold
@@ -0,0 +1,16 @@
1
+ # encoding: utf-8
2
+
3
+ class MarkdownString
4
+ # Return markdown code from text
5
+ #
6
+ # === Example
7
+ #
8
+ # MarkdownString.code('print "hoge"') # => '`print "hoge"`'
9
+ #
10
+ def self.code(text)
11
+ return '``' if text.nil?
12
+ return text unless text.is_a?(String)
13
+ return '``' if text.empty?
14
+ "`#{text}`"
15
+ end
16
+ end
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'markdown/backquotes'
4
4
  require 'markdown/bold'
5
+ require 'markdown/code'
5
6
  require 'markdown/heading'
6
7
  require 'markdown/hr'
7
8
  require 'markdown/italic'
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Tbpgr Utilities
4
4
  module TbpgrUtils
5
- VERSION = '0.0.113'
5
+ VERSION = '0.0.114'
6
6
  end
@@ -0,0 +1,61 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+ require 'markdown/code'
4
+
5
+ describe MarkdownString do
6
+ context :code do
7
+ cases = [
8
+ {
9
+ case_no: 1,
10
+ case_title: 'string case',
11
+ input: 'print "hoge"',
12
+ expected: '`print "hoge"`'
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.code 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.113
4
+ version: 0.0.114
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-30 00:00:00.000000000 Z
12
+ date: 2014-05-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
16
- requirement: &30004080 !ruby/object:Gem::Requirement
16
+ requirement: &15775032 !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: *30004080
24
+ version_requirements: *15775032
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: bundler
27
- requirement: &30003792 !ruby/object:Gem::Requirement
27
+ requirement: &15771696 !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: *30003792
35
+ version_requirements: *15771696
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake
38
- requirement: &30003564 !ruby/object:Gem::Requirement
38
+ requirement: &15786060 !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: *30003564
46
+ version_requirements: *15786060
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec
49
- requirement: &30003240 !ruby/object:Gem::Requirement
49
+ requirement: &15780984 !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: *30003240
57
+ version_requirements: *15780984
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: simplecov
60
- requirement: &30002940 !ruby/object:Gem::Requirement
60
+ requirement: &15794292 !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: *30002940
68
+ version_requirements: *15794292
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/backquotes.rb
112
112
  - lib/markdown/bold.rb
113
+ - lib/markdown/code.rb
113
114
  - lib/markdown/heading.rb
114
115
  - lib/markdown/hr.rb
115
116
  - lib/markdown/italic.rb
@@ -240,6 +241,7 @@ files:
240
241
  - spec/ghostable_spec.rb
241
242
  - spec/markdown/backquotes_spec.rb
242
243
  - spec/markdown/bold_spec.rb
244
+ - spec/markdown/code_spec.rb
243
245
  - spec/markdown/heading_spec.rb
244
246
  - spec/markdown/hr_spec.rb
245
247
  - spec/markdown/italic_spec.rb
@@ -385,6 +387,7 @@ test_files:
385
387
  - spec/ghostable_spec.rb
386
388
  - spec/markdown/backquotes_spec.rb
387
389
  - spec/markdown/bold_spec.rb
390
+ - spec/markdown/code_spec.rb
388
391
  - spec/markdown/heading_spec.rb
389
392
  - spec/markdown/hr_spec.rb
390
393
  - spec/markdown/italic_spec.rb