tbpgr_utils 0.0.93 → 0.0.94

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -129,6 +129,7 @@ Or install it yourself as:
129
129
  |[TbpgrUtils String#to_space4_heading](#stringto_space4_heading) |create space4-format heading string with Emmet-like grammar |
130
130
  |[TbpgrUtils String#to_tab_heading](#stringto_tab_heading) |create tab-format heading string with Emmet-like grammar |
131
131
  |[TbpgrUtils String#unescape_double_quote](#stringunescape_double_quote) |unescape double quote |
132
+ |[TbpgrUtils String#unescape_quote](#stringunescape_quote) |unescape single quote |
132
133
  |[TbpgrUtils Symbol#is_meta_variable?](#symbolis_meta_variable) |is meta variable. |
133
134
  |[Templatable module](#templatable) |get result from template + placeholder |
134
135
  |[TemplateMethodable module](#templatemethodable) |for Template Method Pattern |
@@ -2954,6 +2955,14 @@ require 'tbpgr_utils'
2954
2955
 
2955
2956
  [back to list](#list)
2956
2957
 
2958
+ ### String#unescape_quote
2959
+ ~~~ruby
2960
+ require 'tbpgr_utils'
2961
+ "hoge''h''ige".unescape_quote # => "hoge'h'ige"
2962
+ ~~~
2963
+
2964
+ [back to list](#list)
2965
+
2957
2966
  ### Symbol#is_meta_variable?
2958
2967
  ~~~ruby
2959
2968
  :foo.is_meta_variable? # => true
@@ -3064,6 +3073,7 @@ if you are Sublime Text2 user, you can use snippet for TbpgrUtils.
3064
3073
  https://github.com/tbpgr/tbpgr_utils_snippets
3065
3074
 
3066
3075
  ## History
3076
+ * version 0.0.94 : add String#unescape_quote
3067
3077
  * version 0.0.93 : add String#unescape_double_quote
3068
3078
  * version 0.0.92 : add Fixnum.to_fixnum_html_table
3069
3079
  * version 0.0.91 : add Array#to_html_table
@@ -26,4 +26,6 @@ module AttributesHashable
26
26
  hash
27
27
  end
28
28
  end
29
+
30
+ alias_method :to_h, :to_hash
29
31
  end
@@ -0,0 +1,13 @@
1
+ # encoding: utf-8
2
+
3
+ class String
4
+ # unescape single quote.
5
+ #
6
+ # ==== Examples
7
+ #
8
+ # "hoge''h''ige".unescape_quote # => "hoge'hige"
9
+ #
10
+ def unescape_quote
11
+ gsub("''", "'")
12
+ end
13
+ end
@@ -18,3 +18,4 @@ require 'open_classes/string/to_space2_heading'
18
18
  require 'open_classes/string/to_space4_heading'
19
19
  require 'open_classes/string/to_tab_heading'
20
20
  require 'open_classes/string/unescape_double_quote'
21
+ require 'open_classes/string/unescape_quote'
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Tbpgr Utilities
4
4
  module TbpgrUtils
5
- VERSION = '0.0.93'
5
+ VERSION = '0.0.94'
6
6
  end
@@ -11,7 +11,7 @@ describe Familyable::Family do
11
11
  persons: [
12
12
  a = Familyable::Person.new(id: 1, parent_ids: [2, 3]),
13
13
  b = Familyable::Person.new(id: 2, parent_ids: []),
14
- c = Familyable::Person.new(id: 3, parent_ids: [4], ),
14
+ c = Familyable::Person.new(id: 3, parent_ids: [4],),
15
15
  d = Familyable::Person.new(id: 4, parent_ids: []),
16
16
  e = Familyable::Person.new(id: 5, parent_ids: [2]),
17
17
  ],
@@ -59,7 +59,7 @@ describe Familyable::Family do
59
59
  persons: [
60
60
  a = Familyable::Person.new(id: 1, parent_ids: [2, 3]),
61
61
  b = Familyable::Person.new(id: 2, parent_ids: []),
62
- c = Familyable::Person.new(id: 3, parent_ids: [4], ),
62
+ c = Familyable::Person.new(id: 3, parent_ids: [4],),
63
63
  d = Familyable::Person.new(id: 4, parent_ids: []),
64
64
  e = Familyable::Person.new(id: 5, parent_ids: [2]),
65
65
  ],
@@ -107,7 +107,7 @@ describe Familyable::Family do
107
107
  persons: [
108
108
  a = Familyable::Person.new(id: 1, parent_ids: [2, 3]),
109
109
  b = Familyable::Person.new(id: 2, parent_ids: []),
110
- c = Familyable::Person.new(id: 3, parent_ids: [4], ),
110
+ c = Familyable::Person.new(id: 3, parent_ids: [4],),
111
111
  d = Familyable::Person.new(id: 4, parent_ids: [3]),
112
112
  e = Familyable::Person.new(id: 5, parent_ids: [2]),
113
113
  ],
@@ -0,0 +1,49 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+ require 'open_classes/string/unescape_quote'
4
+
5
+ describe String do
6
+ context :unescape_quote do
7
+ cases = [
8
+ {
9
+ case_no: 1,
10
+ case_title: 'exist double quote case',
11
+ input: "hoge''h''ige",
12
+ expected: "hoge'h'ige",
13
+ },
14
+ {
15
+ case_no: 2,
16
+ case_title: 'not exist quote case',
17
+ input: 'hogehige',
18
+ expected: 'hogehige',
19
+ },
20
+ ]
21
+
22
+ cases.each do |c|
23
+ it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
24
+ begin
25
+ case_before c
26
+
27
+ # -- given --
28
+ # nothing
29
+
30
+ # -- when --
31
+ actual = c[:input].unescape_quote
32
+
33
+ # -- then --
34
+ expect(actual).to eq(c[:expected])
35
+ ensure
36
+ case_after c
37
+ end
38
+ end
39
+
40
+ def case_before(c)
41
+ # implement each case before
42
+ end
43
+
44
+ def case_after(c)
45
+ # implement each case after
46
+ end
47
+ end
48
+ end
49
+ 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.93
4
+ version: 0.0.94
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-10 00:00:00.000000000 Z
12
+ date: 2014-04-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
16
- requirement: &27335292 !ruby/object:Gem::Requirement
16
+ requirement: &28496988 !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: *27335292
24
+ version_requirements: *28496988
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: bundler
27
- requirement: &27335004 !ruby/object:Gem::Requirement
27
+ requirement: &28496700 !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: *27335004
35
+ version_requirements: *28496700
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake
38
- requirement: &27334776 !ruby/object:Gem::Requirement
38
+ requirement: &28496472 !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: *27334776
46
+ version_requirements: *28496472
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec
49
- requirement: &27334452 !ruby/object:Gem::Requirement
49
+ requirement: &28496148 !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: *27334452
57
+ version_requirements: *28496148
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: simplecov
60
- requirement: &27334152 !ruby/object:Gem::Requirement
60
+ requirement: &28495848 !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: *27334152
68
+ version_requirements: *28495848
69
69
  description: Utilities
70
70
  email:
71
71
  - tbpgr@tbpgr.jp
@@ -190,6 +190,7 @@ files:
190
190
  - lib/open_classes/string/to_space4_heading.rb
191
191
  - lib/open_classes/string/to_tab_heading.rb
192
192
  - lib/open_classes/string/unescape_double_quote.rb
193
+ - lib/open_classes/string/unescape_quote.rb
193
194
  - lib/open_classes/symbol.rb
194
195
  - lib/open_classes/symbol/is_meta_variable.rb
195
196
  - lib/simple_tournament.rb
@@ -294,6 +295,7 @@ files:
294
295
  - spec/open_classes/string/to_space4_heading_spec.rb
295
296
  - spec/open_classes/string/to_tab_heading_spec.rb
296
297
  - spec/open_classes/string/unescape_double_quote_spec.rb
298
+ - spec/open_classes/string/unescape_quote_spec.rb
297
299
  - spec/open_classes/symbol/is_meta_variable_spec.rb
298
300
  - spec/set_variables_code_spec.rb
299
301
  - spec/simple_tournament_spec.rb
@@ -422,6 +424,7 @@ test_files:
422
424
  - spec/open_classes/string/to_space4_heading_spec.rb
423
425
  - spec/open_classes/string/to_tab_heading_spec.rb
424
426
  - spec/open_classes/string/unescape_double_quote_spec.rb
427
+ - spec/open_classes/string/unescape_quote_spec.rb
425
428
  - spec/open_classes/symbol/is_meta_variable_spec.rb
426
429
  - spec/set_variables_code_spec.rb
427
430
  - spec/simple_tournament_spec.rb