tbpgr_utils 0.0.60 → 0.0.61
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +52 -0
- data/lib/eval_helper/set_variable_code.rb +51 -0
- data/lib/eval_helper.rb +1 -0
- data/lib/tbpgr_utils/version.rb +1 -1
- data/spec/eval_helper/set_variable_code_spec.rb +58 -0
- metadata +15 -12
data/README.md
CHANGED
@@ -1542,6 +1542,57 @@ EvalHelperRequireRelativeTest.new.hoge(args) # => return "require_relative 'tbpg
|
|
1542
1542
|
|
1543
1543
|
[back to list](#list)
|
1544
1544
|
|
1545
|
+
### EvalHelper#set_variable_code
|
1546
|
+
set string variable case
|
1547
|
+
~~~ruby
|
1548
|
+
require 'eval_helper'
|
1549
|
+
class EvalHelperSetVariableTest
|
1550
|
+
include EvalHelper
|
1551
|
+
|
1552
|
+
def hoge(name, value)
|
1553
|
+
set_variable_code(name, value)
|
1554
|
+
end
|
1555
|
+
end
|
1556
|
+
|
1557
|
+
hash = {
|
1558
|
+
name: 'hoge',
|
1559
|
+
value: '"hoge"',
|
1560
|
+
}
|
1561
|
+
EvalHelperSetVariableTest.new.hoge(hash[:name], hash[:value])
|
1562
|
+
~~~
|
1563
|
+
|
1564
|
+
return
|
1565
|
+
|
1566
|
+
~~~ruby
|
1567
|
+
hoge = "hoge"
|
1568
|
+
~~~
|
1569
|
+
|
1570
|
+
set numeric variable case
|
1571
|
+
~~~ruby
|
1572
|
+
require 'eval_helper'
|
1573
|
+
class EvalHelperSetVariableTest
|
1574
|
+
include EvalHelper
|
1575
|
+
|
1576
|
+
def hoge(name, value)
|
1577
|
+
set_variable_code(name, value)
|
1578
|
+
end
|
1579
|
+
end
|
1580
|
+
|
1581
|
+
hash = {
|
1582
|
+
name: 'hoge_num',
|
1583
|
+
value: '1',
|
1584
|
+
}
|
1585
|
+
EvalHelperSetVariableTest.new.hoge(hash[:name], hash[:value])
|
1586
|
+
~~~
|
1587
|
+
|
1588
|
+
return
|
1589
|
+
|
1590
|
+
~~~ruby
|
1591
|
+
hoge_num = 1
|
1592
|
+
~~~
|
1593
|
+
|
1594
|
+
[back to list](#list)
|
1595
|
+
|
1545
1596
|
### EvalHelper#times_code
|
1546
1597
|
|
1547
1598
|
single_line_proc case
|
@@ -2269,6 +2320,7 @@ if you are Sublime Text2 user, you can use snippet for TbpgrUtils.
|
|
2269
2320
|
https://github.com/tbpgr/tbpgr_utils_snippets
|
2270
2321
|
|
2271
2322
|
## History
|
2323
|
+
* version 0.0.61 : add EvalHelper#set_variable_code
|
2272
2324
|
* version 0.0.60 : add EvalHelper#times_code
|
2273
2325
|
* version 0.0.59 : add EvalHelper Object
|
2274
2326
|
* version 0.0.58 : add EvalHelper#require_relative_code
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module EvalHelper
|
4
|
+
# create set variable logic strings, for eval
|
5
|
+
#
|
6
|
+
# ==== Examples
|
7
|
+
#
|
8
|
+
# set string variable case
|
9
|
+
#
|
10
|
+
# class EvalHelperSetVariableTest
|
11
|
+
# include EvalHelper
|
12
|
+
#
|
13
|
+
# def hoge(name, value)
|
14
|
+
# set_variable_code(name, value)
|
15
|
+
# end
|
16
|
+
# end
|
17
|
+
#
|
18
|
+
# hash = {
|
19
|
+
# name: 'hoge',
|
20
|
+
# value: '"hoge"',
|
21
|
+
# }
|
22
|
+
# EvalHelperSetVariableTest.new.hoge(hash[:name], hash[:value])
|
23
|
+
#
|
24
|
+
# return
|
25
|
+
#
|
26
|
+
# hoge = "hoge"
|
27
|
+
#
|
28
|
+
# set numeric variable case
|
29
|
+
#
|
30
|
+
# class EvalHelperSetVariableTest
|
31
|
+
# include EvalHelper
|
32
|
+
#
|
33
|
+
# def hoge(name, value)
|
34
|
+
# set_variable_code(name, value)
|
35
|
+
# end
|
36
|
+
# end
|
37
|
+
#
|
38
|
+
# hash = {
|
39
|
+
# name: 'hoge_num',
|
40
|
+
# value: '1',
|
41
|
+
# }
|
42
|
+
# EvalHelperSetVariableTest.new.hoge(hash[:name], hash[:value])
|
43
|
+
#
|
44
|
+
# return
|
45
|
+
#
|
46
|
+
# hoge_num = 1
|
47
|
+
#
|
48
|
+
def set_variable_code(name, value)
|
49
|
+
"#{name} = #{value}"
|
50
|
+
end
|
51
|
+
end
|
data/lib/eval_helper.rb
CHANGED
@@ -5,6 +5,7 @@ module EvalHelper
|
|
5
5
|
require 'eval_helper/if_code_after'
|
6
6
|
require 'eval_helper/require_code'
|
7
7
|
require 'eval_helper/require_relative_code'
|
8
|
+
require 'eval_helper/set_variable_code'
|
8
9
|
require 'eval_helper/ternary_operator'
|
9
10
|
require 'eval_helper/times_code'
|
10
11
|
require 'eval_helper/unless_code'
|
data/lib/tbpgr_utils/version.rb
CHANGED
@@ -0,0 +1,58 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'eval_helper'
|
4
|
+
|
5
|
+
describe 'EvalHelper' do
|
6
|
+
context :set_variable_code do
|
7
|
+
class EvalHelperSetVariableTest
|
8
|
+
include EvalHelper
|
9
|
+
|
10
|
+
def hoge(name, value)
|
11
|
+
set_variable_code(name, value)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
cases = [
|
15
|
+
{
|
16
|
+
case_no: 1,
|
17
|
+
case_title: 'set string case',
|
18
|
+
name: 'hoge',
|
19
|
+
value: '"hoge"',
|
20
|
+
expected: 'hoge = "hoge"'
|
21
|
+
},
|
22
|
+
{
|
23
|
+
case_no: 2,
|
24
|
+
case_title: 'set numeric case',
|
25
|
+
name: 'hoge_num',
|
26
|
+
value: '1',
|
27
|
+
expected: 'hoge_num = 1'
|
28
|
+
},
|
29
|
+
]
|
30
|
+
|
31
|
+
cases.each do |c|
|
32
|
+
it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
|
33
|
+
begin
|
34
|
+
case_before c
|
35
|
+
|
36
|
+
# -- given --
|
37
|
+
# nothing
|
38
|
+
|
39
|
+
# -- when --
|
40
|
+
actual = EvalHelperSetVariableTest.new.hoge c[:name], c[:value]
|
41
|
+
|
42
|
+
# -- then --
|
43
|
+
expect(actual).to eq(c[:expected])
|
44
|
+
ensure
|
45
|
+
case_after c
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def case_before(c)
|
50
|
+
# implement each case before
|
51
|
+
end
|
52
|
+
|
53
|
+
def case_after(c)
|
54
|
+
# implement each case after
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
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.61
|
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-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
16
|
-
requirement: &
|
16
|
+
requirement: &23574216 !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: *23574216
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: bundler
|
27
|
-
requirement: &
|
27
|
+
requirement: &23573928 !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: *23573928
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rake
|
38
|
-
requirement: &
|
38
|
+
requirement: &23573700 !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: *23573700
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rspec
|
49
|
-
requirement: &
|
49
|
+
requirement: &23573376 !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: *23573376
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: simplecov
|
60
|
-
requirement: &
|
60
|
+
requirement: &23573076 !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: *23573076
|
69
69
|
description: Utilities
|
70
70
|
email:
|
71
71
|
- tbpgr@tbpgr.jp
|
@@ -90,6 +90,7 @@ files:
|
|
90
90
|
- lib/eval_helper/if_code_after.rb
|
91
91
|
- lib/eval_helper/require_code.rb
|
92
92
|
- lib/eval_helper/require_relative_code.rb
|
93
|
+
- lib/eval_helper/set_variable_code.rb
|
93
94
|
- lib/eval_helper/ternary_operator.rb
|
94
95
|
- lib/eval_helper/times_code.rb
|
95
96
|
- lib/eval_helper/unless_code.rb
|
@@ -160,6 +161,7 @@ files:
|
|
160
161
|
- spec/eval_helper/if_code_spec.rb
|
161
162
|
- spec/eval_helper/require_code_spec.rb
|
162
163
|
- spec/eval_helper/require_relative_code_spec.rb
|
164
|
+
- spec/eval_helper/set_variable_code_spec.rb
|
163
165
|
- spec/eval_helper/ternary_operator_spec.rb
|
164
166
|
- spec/eval_helper/times_code_spec.rb
|
165
167
|
- spec/eval_helper/unless_code_after_spec.rb
|
@@ -249,6 +251,7 @@ test_files:
|
|
249
251
|
- spec/eval_helper/if_code_spec.rb
|
250
252
|
- spec/eval_helper/require_code_spec.rb
|
251
253
|
- spec/eval_helper/require_relative_code_spec.rb
|
254
|
+
- spec/eval_helper/set_variable_code_spec.rb
|
252
255
|
- spec/eval_helper/ternary_operator_spec.rb
|
253
256
|
- spec/eval_helper/times_code_spec.rb
|
254
257
|
- spec/eval_helper/unless_code_after_spec.rb
|