-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
125 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# encoding: utf-8 | ||
require 'active_support/core_ext/object/inclusion' | ||
require 'open_classes/string/heading_helper' | ||
|
||
class String | ||
include HeadingHelper | ||
# Tab | ||
TAB = "\t" | ||
|
||
# create heading string with Emmet-like grammar. | ||
# | ||
# ==== Examples | ||
# | ||
# > case | ||
# | ||
# 'hoge>hige'.to_tab_heading # => 'hoge\n\thige' | ||
# | ||
# + case | ||
# | ||
# 'hoge+hige'.to_tab_heading # => 'hoge\nhige' | ||
# | ||
# ^ case | ||
# | ||
# 'hoge>hige^hege'.to_tab_heading # => 'hoge\n\thige\nhege' | ||
# | ||
def to_tab_heading | ||
heading = to_heading | ||
to_tab heading | ||
end | ||
|
||
private | ||
def to_tab(heading) | ||
to_head(heading, TAB) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,5 @@ | |
|
||
# Tbpgr Utilities | ||
module TbpgrUtils | ||
VERSION = '0.0.48' | ||
VERSION = '0.0.49' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# encoding: utf-8 | ||
require 'spec_helper' | ||
require 'open_classes/string/to_tab_heading' | ||
|
||
describe String do | ||
context :to_tab_heading do | ||
cases = [ | ||
{ | ||
case_no: 1, | ||
case_title: '> case', | ||
input: 'hoge>hige', | ||
expected: "hoge\n\thige", | ||
}, | ||
{ | ||
case_no: 2, | ||
case_title: '+ case', | ||
input: 'hoge+hige', | ||
expected: "hoge\nhige", | ||
}, | ||
{ | ||
case_no: 3, | ||
case_title: '^ case', | ||
input: 'hoge>hige^hege', | ||
expected: "hoge\n\thige\nhege", | ||
}, | ||
{ | ||
case_no: 4, | ||
case_title: 'mix case', | ||
input: 'hoge>hige1+hige2^hege', | ||
expected: "hoge\n\thige1\n\thige2\nhege", | ||
}, | ||
] | ||
|
||
cases.each do |c| | ||
it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do | ||
begin | ||
case_before c | ||
|
||
# -- given -- | ||
# nothing | ||
|
||
# -- when -- | ||
actual = c[:input].to_tab_heading | ||
|
||
# -- then -- | ||
expect(actual).to eq(c[:expected]) | ||
ensure | ||
case_after c | ||
end | ||
end | ||
|
||
def case_before(c) | ||
# implement each case before | ||
end | ||
|
||
def case_after(c) | ||
# implement each case after | ||
end | ||
end | ||
end | ||
end |