tbpgr_utils 0.0.76 → 0.0.77
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +26 -0
- data/lib/eval_helper/each_with_index_do_code.rb +0 -1
- data/lib/open_classes/string/is_meta_variable.rb +19 -0
- data/lib/open_classes/string.rb +1 -0
- data/lib/open_classes/symbol/is_meta_variable.rb +18 -0
- data/lib/open_classes/symbol.rb +2 -0
- data/lib/tbpgr_utils/version.rb +1 -1
- data/lib/tbpgr_utils.rb +1 -0
- data/spec/open_classes/string/is_meta_variable_spec.rb +71 -0
- data/spec/open_classes/symbol/is_meta_variable_spec.rb +65 -0
- metadata +19 -12
data/README.md
CHANGED
@@ -103,6 +103,7 @@ Or install it yourself as:
|
|
103
103
|
|[TbpgrUtils String#ascii1_other2_size](#stringascii1_other2_size) |count string size. ascii => count1, not ascii => count2 |
|
104
104
|
|[TbpgrUtils String#comma_to_a](#stringcomma_to_a) |comma-format string to array |
|
105
105
|
|[TbpgrUtils String#hyphen_to_a](#stringhyphen_to_a) |hyphen-format string to array |
|
106
|
+
|[TbpgrUtils String#is_meta_variable?](#stringis_meta_variable) |is meta variable. |
|
106
107
|
|[TbpgrUtils String#justify_table](#stringjustify_table) |justify pipe format table string |
|
107
108
|
|[TbpgrUtils String#say](#stringsay) |say string |
|
108
109
|
|[TbpgrUtils String#stripe](#stringstripe) |stripe string |
|
@@ -112,6 +113,7 @@ Or install it yourself as:
|
|
112
113
|
|[TbpgrUtils String#to_space2_heading](#stringto_space2_heading) |create space2-format heading string with Emmet-like grammar |
|
113
114
|
|[TbpgrUtils String#to_space4_heading](#stringto_space4_heading) |create space4-format heading string with Emmet-like grammar |
|
114
115
|
|[TbpgrUtils String#to_tab_heading](#stringto_tab_heading) |create tab-format heading string with Emmet-like grammar |
|
116
|
+
|[TbpgrUtils Symbol#is_meta_variable?](#symbolis_meta_variable) |is meta variable. |
|
115
117
|
|[Templatable module](#templatable) |get result from template + placeholder |
|
116
118
|
|[TemplateMethodable module](#templatemethodable) |for Template Method Pattern |
|
117
119
|
|
@@ -2376,6 +2378,17 @@ require 'tbpgr_utils'
|
|
2376
2378
|
|
2377
2379
|
[back to list](#list)
|
2378
2380
|
|
2381
|
+
### String#is_meta_variable?
|
2382
|
+
~~~ruby
|
2383
|
+
'foo'.is_meta_variable? # => true
|
2384
|
+
'bar'.is_meta_variable? # => true
|
2385
|
+
'baz'.is_meta_variable? # => true
|
2386
|
+
'aaa'.is_meta_variable? # => false
|
2387
|
+
''.is_meta_variable? # => false
|
2388
|
+
~~~
|
2389
|
+
|
2390
|
+
[back to list](#list)
|
2391
|
+
|
2379
2392
|
### String#justify_table
|
2380
2393
|
~~~ruby
|
2381
2394
|
require 'tbpgr_utils'
|
@@ -2614,6 +2627,18 @@ require 'tbpgr_utils'
|
|
2614
2627
|
'hoge>hige^hege'.to_tab_heading # => 'hoge\n\thige\nhege'
|
2615
2628
|
~~~
|
2616
2629
|
|
2630
|
+
[back to list](#list)
|
2631
|
+
|
2632
|
+
### Symbol#is_meta_variable?
|
2633
|
+
~~~ruby
|
2634
|
+
:foo.is_meta_variable? # => true
|
2635
|
+
:bar.is_meta_variable? # => true
|
2636
|
+
:baz.is_meta_variable? # => true
|
2637
|
+
:aaa.is_meta_variable? # => false
|
2638
|
+
~~~
|
2639
|
+
|
2640
|
+
[back to list](#list)
|
2641
|
+
|
2617
2642
|
### Templatable
|
2618
2643
|
* include Templatable
|
2619
2644
|
* set template by here-document
|
@@ -2714,6 +2739,7 @@ if you are Sublime Text2 user, you can use snippet for TbpgrUtils.
|
|
2714
2739
|
https://github.com/tbpgr/tbpgr_utils_snippets
|
2715
2740
|
|
2716
2741
|
## History
|
2742
|
+
* version 0.0.77 : add String#is_meta_variable?, Symbol#is_meta_variable?
|
2717
2743
|
* version 0.0.76 : add EvalHelper#attr_init_class_code, Numeric#is_ascii?, String#ascii1_other2_size
|
2718
2744
|
* version 0.0.75 : add Object#method_nameable?
|
2719
2745
|
* version 0.0.74 : add Hash#table
|
@@ -20,7 +20,6 @@ module EvalHelper
|
|
20
20
|
# EvalHelperEachWithIndexDoTest.new.hoge(hash) # => return "[:a, :b].each_with_index do |v, i|\n puts \"\#{i}:\#{v}1\"\n puts \"\#{i}:\#{v}2\"\nend"
|
21
21
|
#
|
22
22
|
def each_with_index_do_code(target, proc)
|
23
|
-
"#{target}.each { |v, i|#{proc} }"
|
24
23
|
indented = proc.split("\n").reduce([]) { |ret, v|ret << " #{v}" ; ret }.join("\n")
|
25
24
|
"#{target}.each_with_index do |v, i|\n#{indented}\nend"
|
26
25
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require'metasyntactic_variable'
|
3
|
+
|
4
|
+
# String
|
5
|
+
class String
|
6
|
+
# is meta variable.
|
7
|
+
#
|
8
|
+
# ==== Examples
|
9
|
+
#
|
10
|
+
# 'foo'.is_meta_variable? # => true
|
11
|
+
# 'bar'.is_meta_variable? # => true
|
12
|
+
# 'baz'.is_meta_variable? # => true
|
13
|
+
# ''.is_meta_variable? # => false
|
14
|
+
# 'aaa'.is_meta_variable? # => false
|
15
|
+
#
|
16
|
+
def is_meta_variable?
|
17
|
+
MetasyntacticVariable.meta_variables.include? to_sym
|
18
|
+
end
|
19
|
+
end
|
data/lib/open_classes/string.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
require 'open_classes/string/ascii1_other2_size'
|
3
3
|
require 'open_classes/string/comma_to_a'
|
4
4
|
require 'open_classes/string/hyphen_to_a'
|
5
|
+
require 'open_classes/string/is_meta_variable'
|
5
6
|
require 'open_classes/string/justify_table'
|
6
7
|
require 'open_classes/string/say'
|
7
8
|
require 'open_classes/string/stripe'
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require'metasyntactic_variable'
|
3
|
+
|
4
|
+
# Symbol
|
5
|
+
class Symbol
|
6
|
+
# is meta variable.
|
7
|
+
#
|
8
|
+
# ==== Examples
|
9
|
+
#
|
10
|
+
# :foo.is_meta_variable? # => true
|
11
|
+
# :bar.is_meta_variable? # => true
|
12
|
+
# :baz.is_meta_variable? # => true
|
13
|
+
# :aaa.is_meta_variable? # => false
|
14
|
+
#
|
15
|
+
def is_meta_variable?
|
16
|
+
MetasyntacticVariable.meta_variables.include? self
|
17
|
+
end
|
18
|
+
end
|
data/lib/tbpgr_utils/version.rb
CHANGED
data/lib/tbpgr_utils.rb
CHANGED
@@ -0,0 +1,71 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'tbpgr_utils'
|
4
|
+
|
5
|
+
describe String do
|
6
|
+
context :is_meta_variable? do
|
7
|
+
cases = [
|
8
|
+
{
|
9
|
+
case_no: 1,
|
10
|
+
case_title: 'meta variable foo case',
|
11
|
+
input: 'foo',
|
12
|
+
expected: true
|
13
|
+
},
|
14
|
+
{
|
15
|
+
case_no: 2,
|
16
|
+
case_title: 'meta variable bar case',
|
17
|
+
input: 'bar',
|
18
|
+
expected: true
|
19
|
+
},
|
20
|
+
{
|
21
|
+
case_no: 3,
|
22
|
+
case_title: 'meta variable baz case',
|
23
|
+
input: 'baz',
|
24
|
+
expected: true
|
25
|
+
},
|
26
|
+
{
|
27
|
+
case_no: 4,
|
28
|
+
case_title: 'not meta variable case',
|
29
|
+
input: 'aaa',
|
30
|
+
expected: false
|
31
|
+
},
|
32
|
+
{
|
33
|
+
case_no: 5,
|
34
|
+
case_title: 'empty case',
|
35
|
+
input: '',
|
36
|
+
expected: false
|
37
|
+
},
|
38
|
+
]
|
39
|
+
|
40
|
+
cases.each do |c|
|
41
|
+
it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
|
42
|
+
begin
|
43
|
+
case_before c
|
44
|
+
|
45
|
+
# -- given --
|
46
|
+
# nothing
|
47
|
+
|
48
|
+
# -- when --
|
49
|
+
if c[:expect_error]
|
50
|
+
lambda { c[:input].is_meta_variable?(c[:option]) }.should raise_error(StandardError)
|
51
|
+
next
|
52
|
+
end
|
53
|
+
actual = c[:option] ? c[:input].is_meta_variable?(c[:option]) : c[:input].is_meta_variable?
|
54
|
+
|
55
|
+
# -- then --
|
56
|
+
expect(actual).to eq(c[:expected])
|
57
|
+
ensure
|
58
|
+
case_after c
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def case_before(c)
|
63
|
+
# implement each case before
|
64
|
+
end
|
65
|
+
|
66
|
+
def case_after(c)
|
67
|
+
# implement each case after
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'tbpgr_utils'
|
4
|
+
|
5
|
+
describe Symbol do
|
6
|
+
context :is_meta_variable? do
|
7
|
+
cases = [
|
8
|
+
{
|
9
|
+
case_no: 1,
|
10
|
+
case_title: 'meta variable foo case',
|
11
|
+
input: :foo,
|
12
|
+
expected: true
|
13
|
+
},
|
14
|
+
{
|
15
|
+
case_no: 2,
|
16
|
+
case_title: 'meta variable bar case',
|
17
|
+
input: :bar,
|
18
|
+
expected: true
|
19
|
+
},
|
20
|
+
{
|
21
|
+
case_no: 3,
|
22
|
+
case_title: 'meta variable baz case',
|
23
|
+
input: :baz,
|
24
|
+
expected: true
|
25
|
+
},
|
26
|
+
{
|
27
|
+
case_no: 4,
|
28
|
+
case_title: 'not meta variable case',
|
29
|
+
input: :aaa,
|
30
|
+
expected: false
|
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
|
+
if c[:expect_error]
|
44
|
+
lambda { c[:input].is_meta_variable?(c[:option]) }.should raise_error(StandardError)
|
45
|
+
next
|
46
|
+
end
|
47
|
+
actual = c[:option] ? c[:input].is_meta_variable?(c[:option]) : c[:input].is_meta_variable?
|
48
|
+
|
49
|
+
# -- then --
|
50
|
+
expect(actual).to eq(c[:expected])
|
51
|
+
ensure
|
52
|
+
case_after c
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def case_before(c)
|
57
|
+
# implement each case before
|
58
|
+
end
|
59
|
+
|
60
|
+
def case_after(c)
|
61
|
+
# implement each case after
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
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.
|
4
|
+
version: 0.0.77
|
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-03-
|
12
|
+
date: 2014-03-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
16
|
-
requirement: &
|
16
|
+
requirement: &25548636 !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: *
|
24
|
+
version_requirements: *25548636
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: bundler
|
27
|
-
requirement: &
|
27
|
+
requirement: &25548348 !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: *
|
35
|
+
version_requirements: *25548348
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rake
|
38
|
-
requirement: &
|
38
|
+
requirement: &25548120 !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: *
|
46
|
+
version_requirements: *25548120
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rspec
|
49
|
-
requirement: &
|
49
|
+
requirement: &25547796 !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: *
|
57
|
+
version_requirements: *25547796
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: simplecov
|
60
|
-
requirement: &
|
60
|
+
requirement: &25547496 !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: *
|
68
|
+
version_requirements: *25547496
|
69
69
|
description: Utilities
|
70
70
|
email:
|
71
71
|
- tbpgr@tbpgr.jp
|
@@ -160,6 +160,7 @@ files:
|
|
160
160
|
- lib/open_classes/string/comma_to_a.rb
|
161
161
|
- lib/open_classes/string/heading_helper.rb
|
162
162
|
- lib/open_classes/string/hyphen_to_a.rb
|
163
|
+
- lib/open_classes/string/is_meta_variable.rb
|
163
164
|
- lib/open_classes/string/justify_table.rb
|
164
165
|
- lib/open_classes/string/say.rb
|
165
166
|
- lib/open_classes/string/stripe.rb
|
@@ -169,6 +170,8 @@ files:
|
|
169
170
|
- lib/open_classes/string/to_space2_heading.rb
|
170
171
|
- lib/open_classes/string/to_space4_heading.rb
|
171
172
|
- lib/open_classes/string/to_tab_heading.rb
|
173
|
+
- lib/open_classes/symbol.rb
|
174
|
+
- lib/open_classes/symbol/is_meta_variable.rb
|
172
175
|
- lib/simple_tournament.rb
|
173
176
|
- lib/tbpgr_utils.rb
|
174
177
|
- lib/tbpgr_utils/version.rb
|
@@ -245,6 +248,7 @@ files:
|
|
245
248
|
- spec/open_classes/string/ascii1_other2_size_spec.rb
|
246
249
|
- spec/open_classes/string/comma_to_a_spec.rb
|
247
250
|
- spec/open_classes/string/hyphen_to_a_spec.rb
|
251
|
+
- spec/open_classes/string/is_meta_variable_spec.rb
|
248
252
|
- spec/open_classes/string/justify_table_spec.rb
|
249
253
|
- spec/open_classes/string/say_spec.rb
|
250
254
|
- spec/open_classes/string/stripe_spec.rb
|
@@ -254,6 +258,7 @@ files:
|
|
254
258
|
- spec/open_classes/string/to_space2_heading_spec.rb
|
255
259
|
- spec/open_classes/string/to_space4_heading_spec.rb
|
256
260
|
- spec/open_classes/string/to_tab_heading_spec.rb
|
261
|
+
- spec/open_classes/symbol/is_meta_variable_spec.rb
|
257
262
|
- spec/set_variables_code_spec.rb
|
258
263
|
- spec/simple_tournament_spec.rb
|
259
264
|
- spec/spec_helper.rb
|
@@ -355,6 +360,7 @@ test_files:
|
|
355
360
|
- spec/open_classes/string/ascii1_other2_size_spec.rb
|
356
361
|
- spec/open_classes/string/comma_to_a_spec.rb
|
357
362
|
- spec/open_classes/string/hyphen_to_a_spec.rb
|
363
|
+
- spec/open_classes/string/is_meta_variable_spec.rb
|
358
364
|
- spec/open_classes/string/justify_table_spec.rb
|
359
365
|
- spec/open_classes/string/say_spec.rb
|
360
366
|
- spec/open_classes/string/stripe_spec.rb
|
@@ -364,6 +370,7 @@ test_files:
|
|
364
370
|
- spec/open_classes/string/to_space2_heading_spec.rb
|
365
371
|
- spec/open_classes/string/to_space4_heading_spec.rb
|
366
372
|
- spec/open_classes/string/to_tab_heading_spec.rb
|
373
|
+
- spec/open_classes/symbol/is_meta_variable_spec.rb
|
367
374
|
- spec/set_variables_code_spec.rb
|
368
375
|
- spec/simple_tournament_spec.rb
|
369
376
|
- spec/spec_helper.rb
|