tbpgr_utils 0.0.43 → 0.0.44
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +33 -1
- data/lib/end_erb.rb +37 -0
- data/lib/tbpgr_utils/version.rb +1 -1
- metadata +13 -12
data/README.md
CHANGED
@@ -56,6 +56,7 @@ Or install it yourself as:
|
|
56
56
|
|[AttributesInitializable::ClassMethods.attr_accessor_init](#attributesinitializableclassmethodsattr_accessor_init) |generate attr_accessor + initializer |
|
57
57
|
|[AttributesInitializable::ClassMethods.attr_reader_init](#attributesinitializableclassmethodsattr_reader_init) |generate attr_reader + initializer |
|
58
58
|
|[AttributesInitializable::ClassMethods.attr_writer init](#attributesinitializableclassmethodsattr_writer_init) |generate attr_writer + initializer |
|
59
|
+
|[EndERB.apply](#enderbapply) |for single template script using __END__ and DATA |
|
59
60
|
|[TbpgrUtils File.insert_bom](#fileinsert_bom) |insert BOM to UTF-8 File |
|
60
61
|
|[Ghostable module](#ghostable) |help to create ghost method(dynamic method define by ussing method_missing + pattern-method-name) |
|
61
62
|
|[TbpgrUtils Kernel#bulk_define_methods](#kernelbulk_define_methods) |define methods to classes. methods have simple return value. |
|
@@ -65,7 +66,7 @@ Or install it yourself as:
|
|
65
66
|
|[TbpgrUtils Kernel#print_eval](#kernelprint_eval) |Print code + eval result |
|
66
67
|
|[TbpgrUtils Kernel#puts_eval](#kernelputs_eval) |Puts code + eval result |
|
67
68
|
|[TbpgrUtils Kernel#bulk_puts_eval](#kernelbulk_puts_eval) |Puts each-line-code + eval result |
|
68
|
-
|[MetasyntacticVariable](#metasyntacticvariable) |META variable, META variable for classes
|
69
|
+
|[MetasyntacticVariable](#metasyntacticvariable) |META variable, META variable for classes |
|
69
70
|
|[TbpgrUtils Module.alias_methods](#modulealias_methods) |create alias methods |
|
70
71
|
|[TbpgrUtils Object#any_of?](#objectany_of) |if self match any one of items, return true |
|
71
72
|
|[TbpgrUtils Object#boolean?](#objectboolean) |data type check for boolean |
|
@@ -1069,6 +1070,36 @@ atr_sample2.instance_variable_get "@atr2" # => atr2
|
|
1069
1070
|
|
1070
1071
|
[back to list](#list)
|
1071
1072
|
|
1073
|
+
### EndERB.apply
|
1074
|
+
for single template script using __END__ and DATA
|
1075
|
+
|
1076
|
+
sample case
|
1077
|
+
|
1078
|
+
~~~ruby
|
1079
|
+
def hoge
|
1080
|
+
hash = {
|
1081
|
+
hoge: '@hoge@',
|
1082
|
+
hige: '@hige@',
|
1083
|
+
}
|
1084
|
+
EndERB.apply(hash)
|
1085
|
+
end
|
1086
|
+
|
1087
|
+
puts hoge
|
1088
|
+
|
1089
|
+
__END__
|
1090
|
+
hoge=<%=hash[:hoge]%>
|
1091
|
+
hige=<%=hash[:hige]%>
|
1092
|
+
~~~
|
1093
|
+
|
1094
|
+
output
|
1095
|
+
|
1096
|
+
~~~
|
1097
|
+
hoge=@hoge@
|
1098
|
+
hige=@hige@
|
1099
|
+
~~~
|
1100
|
+
|
1101
|
+
[back to list](#list)
|
1102
|
+
|
1072
1103
|
### File.insert_bom
|
1073
1104
|
* this method's main purpose is 'UTF-8 Excel CSV File'.
|
1074
1105
|
|
@@ -1656,6 +1687,7 @@ if you are Sublime Text2 user, you can use snippet for TbpgrUtils.
|
|
1656
1687
|
https://github.com/tbpgr/tbpgr_utils_snippets
|
1657
1688
|
|
1658
1689
|
## History
|
1690
|
+
* version 0.0.44 : add EndERB.apply
|
1659
1691
|
* version 0.0.43 : add Array#together_slice(alias tslice).
|
1660
1692
|
* version 0.0.42 : add MetasyntacticVariable
|
1661
1693
|
* version 0.0.41 : add Object#guard, unless_guard
|
data/lib/end_erb.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'erb'
|
3
|
+
|
4
|
+
class EndERB
|
5
|
+
class << self
|
6
|
+
# for single template script using __END__ and DATA
|
7
|
+
#
|
8
|
+
# === Params
|
9
|
+
#
|
10
|
+
# * <tt>:hash</tt> - erb template variable hash
|
11
|
+
#
|
12
|
+
# === Example
|
13
|
+
#
|
14
|
+
# def hoge
|
15
|
+
# hash = {
|
16
|
+
# hoge: '@hoge@',
|
17
|
+
# hige: '@hige@',
|
18
|
+
# }
|
19
|
+
# EndERB.apply(hash)
|
20
|
+
# end
|
21
|
+
#
|
22
|
+
# puts hoge
|
23
|
+
#
|
24
|
+
# __END__
|
25
|
+
# hoge=<%=hoge%>
|
26
|
+
# hige=<%=hige%>
|
27
|
+
#
|
28
|
+
# output
|
29
|
+
#
|
30
|
+
# hoge=@hoge@
|
31
|
+
# hige=@hige@
|
32
|
+
#
|
33
|
+
def apply(hash)
|
34
|
+
ERB.new(DATA.read).result(binding)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/tbpgr_utils/version.rb
CHANGED
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.44
|
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-
|
12
|
+
date: 2014-02-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
16
|
-
requirement: &
|
16
|
+
requirement: &22954584 !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: *22954584
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: bundler
|
27
|
-
requirement: &
|
27
|
+
requirement: &22954284 !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: *22954284
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rake
|
38
|
-
requirement: &
|
38
|
+
requirement: &22953936 !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: *22953936
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rspec
|
49
|
-
requirement: &
|
49
|
+
requirement: &22953516 !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: *22953516
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: simplecov
|
60
|
-
requirement: &
|
60
|
+
requirement: &22953204 !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: *22953204
|
69
69
|
description: Utilities
|
70
70
|
email:
|
71
71
|
- tbpgr@tbpgr.jp
|
@@ -84,6 +84,7 @@ files:
|
|
84
84
|
- Rakefile
|
85
85
|
- lib/attributes_hashable.rb
|
86
86
|
- lib/attributes_initializable.rb
|
87
|
+
- lib/end_erb.rb
|
87
88
|
- lib/ghostable.rb
|
88
89
|
- lib/metasyntactic_variable.rb
|
89
90
|
- lib/open_classes/array.rb
|