tbpgr_utils 0.0.41 → 0.0.42

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -64,6 +64,7 @@ Or install it yourself as:
64
64
  |[TbpgrUtils Kernel#print_eval](#kernelprint_eval) |Print code + eval result |
65
65
  |[TbpgrUtils Kernel#puts_eval](#kernelputs_eval) |Puts code + eval result |
66
66
  |[TbpgrUtils Kernel#bulk_puts_eval](#kernelbulk_puts_eval) |Puts each-line-code + eval result |
67
+ |[MetasyntacticVariable](#metasyntacticvariable) |META variable, META variable for classes |
67
68
  |[TbpgrUtils Module.alias_methods](#modulealias_methods) |create alias methods |
68
69
  |[TbpgrUtils Object#any_of?](#objectany_of) |if self match any one of items, return true |
69
70
  |[TbpgrUtils Object#boolean?](#objectboolean) |data type check for boolean |
@@ -1284,6 +1285,23 @@ output
1284
1285
 
1285
1286
  [back to list](#list)
1286
1287
 
1288
+ ### MetasyntacticVariable
1289
+ * META variable
1290
+
1291
+ ~~~ruby
1292
+ MetasyntacticVariable::META_VARIABLES # => [:foo, :bar, :baz, :qux, :quux, :corge, :grault, :garply, :waldo, :fred, :plugh, :xyzzy, :thud]
1293
+ MetasyntacticVariable.meta_variables # => [:foo, :bar, :baz, :qux, :quux, :corge, :grault, :garply, :waldo, :fred, :plugh, :xyzzy, :thud]
1294
+ ~~~
1295
+
1296
+ * META variable for classes
1297
+
1298
+ ~~~ruby
1299
+ MetasyntacticVariable::META_CLASSES # => [:foo, :bar, :baz, :qux, :quux, :corge, :grault, :garply, :waldo, :fred, :plugh, :xyzzy, :thud]
1300
+ MetasyntacticVariable.meta_classes # => [:foo, :bar, :baz, :qux, :quux, :corge, :grault, :garply, :waldo, :fred, :plugh, :xyzzy, :thud]
1301
+ ~~~
1302
+
1303
+ [back to list](#list)
1304
+
1287
1305
  ### Module.alias_methods
1288
1306
  create alias methods.
1289
1307
 
@@ -1607,6 +1625,7 @@ if you are Sublime Text2 user, you can use snippet for TbpgrUtils.
1607
1625
  https://github.com/tbpgr/tbpgr_utils_snippets
1608
1626
 
1609
1627
  ## History
1628
+ * version 0.0.42 : add MetasyntacticVariable
1610
1629
  * version 0.0.41 : add Object#guard, unless_guard
1611
1630
  * version 0.0.40 : add Kernel#aa_ancestors.
1612
1631
  * version 0.0.39 : add String#surround.
@@ -0,0 +1,21 @@
1
+ # encoding: utf-8
2
+
3
+ # MetasyntacticVariable
4
+ class MetasyntacticVariable
5
+ # META variables array
6
+ META_VARIABLES = [:foo, :bar, :baz, :qux, :quux, :corge, :grault, :garply, :waldo, :fred, :plugh, :xyzzy, :thud]
7
+ # META variables for classes array
8
+ META_CLASSES = [:Foo, :Bar, :Baz, :Qux, :Quux, :Corge, :Grault, :Garply, :Waldo, :Fred, :Plugh, :Xyzzy, :Thud]
9
+
10
+ class << self
11
+ # get META variables array
12
+ def meta_variables
13
+ META_VARIABLES
14
+ end
15
+
16
+ # get META variables for class array
17
+ def meta_classes
18
+ META_CLASSES
19
+ end
20
+ end
21
+ end
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Tbpgr Utilities
4
4
  module TbpgrUtils
5
- VERSION = '0.0.41'
5
+ VERSION = '0.0.42'
6
6
  end
@@ -0,0 +1,83 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+ require 'metasyntactic_variable'
4
+
5
+ describe MetasyntacticVariable do
6
+ context :meta_variables do
7
+ cases = [
8
+ {
9
+ case_no: 1,
10
+ case_title: 'valid case',
11
+ expected: [:foo, :bar, :baz, :qux, :quux, :corge, :grault, :garply, :waldo, :fred, :plugh, :xyzzy, :thud],
12
+ },
13
+ ]
14
+
15
+ cases.each do |c|
16
+ it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
17
+ begin
18
+ case_before c
19
+
20
+ # -- given --
21
+ # nothing
22
+
23
+ # -- when --
24
+ actual_method = MetasyntacticVariable.meta_variables
25
+ actual_constants = MetasyntacticVariable::META_VARIABLES
26
+
27
+ # -- then --
28
+ expect(actual_method).to eq(c[:expected])
29
+ expect(actual_constants).to eq(c[:expected])
30
+ ensure
31
+ case_after c
32
+ end
33
+ end
34
+
35
+ def case_before(c)
36
+ # implement each case before
37
+ end
38
+
39
+ def case_after(c)
40
+ # implement each case after
41
+ end
42
+ end
43
+ end
44
+
45
+ context :meta_classes do
46
+ cases = [
47
+ {
48
+ case_no: 1,
49
+ case_title: 'valid case',
50
+ expected: [:Foo, :Bar, :Baz, :Qux, :Quux, :Corge, :Grault, :Garply, :Waldo, :Fred, :Plugh, :Xyzzy, :Thud],
51
+ },
52
+ ]
53
+
54
+ cases.each do |c|
55
+ it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
56
+ begin
57
+ case_before c
58
+
59
+ # -- given --
60
+ # nothing
61
+
62
+ # -- when --
63
+ actual_method = MetasyntacticVariable.meta_classes
64
+ actual_constants = MetasyntacticVariable::META_CLASSES
65
+
66
+ # -- then --
67
+ expect(actual_method).to eq(c[:expected])
68
+ expect(actual_constants).to eq(c[:expected])
69
+ ensure
70
+ case_after c
71
+ end
72
+ end
73
+
74
+ def case_before(c)
75
+ # implement each case before
76
+ end
77
+
78
+ def case_after(c)
79
+ # implement each case after
80
+ end
81
+ end
82
+ end
83
+ 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.41
4
+ version: 0.0.42
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-02-17 00:00:00.000000000 Z
12
+ date: 2014-02-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
16
- requirement: &27980232 !ruby/object:Gem::Requirement
16
+ requirement: &27331128 !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: *27980232
24
+ version_requirements: *27331128
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: bundler
27
- requirement: &27994020 !ruby/object:Gem::Requirement
27
+ requirement: &29159244 !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: *27994020
35
+ version_requirements: *29159244
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake
38
- requirement: &27990504 !ruby/object:Gem::Requirement
38
+ requirement: &29157324 !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: *27990504
46
+ version_requirements: *29157324
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec
49
- requirement: &27989256 !ruby/object:Gem::Requirement
49
+ requirement: &29155320 !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: *27989256
57
+ version_requirements: *29155320
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: simplecov
60
- requirement: &27988116 !ruby/object:Gem::Requirement
60
+ requirement: &29154024 !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: *27988116
68
+ version_requirements: *29154024
69
69
  description: Utilities
70
70
  email:
71
71
  - tbpgr@tbpgr.jp
@@ -85,6 +85,7 @@ files:
85
85
  - lib/attributes_hashable.rb
86
86
  - lib/attributes_initializable.rb
87
87
  - lib/ghostable.rb
88
+ - lib/metasyntactic_variable.rb
88
89
  - lib/open_classes/array.rb
89
90
  - lib/open_classes/array/together.rb
90
91
  - lib/open_classes/array/together_at.rb
@@ -136,6 +137,7 @@ files:
136
137
  - spec/attributes_hashable_spec.rb
137
138
  - spec/attributes_initializable_spec.rb
138
139
  - spec/ghostable_spec.rb
140
+ - spec/metasyntactic_variable_spec.rb
139
141
  - spec/open_classes/array/together_at_spec.rb
140
142
  - spec/open_classes/array/together_clear_spec.rb
141
143
  - spec/open_classes/array/together_compact_spec.rb
@@ -208,6 +210,7 @@ test_files:
208
210
  - spec/attributes_hashable_spec.rb
209
211
  - spec/attributes_initializable_spec.rb
210
212
  - spec/ghostable_spec.rb
213
+ - spec/metasyntactic_variable_spec.rb
211
214
  - spec/open_classes/array/together_at_spec.rb
212
215
  - spec/open_classes/array/together_clear_spec.rb
213
216
  - spec/open_classes/array/together_compact_spec.rb