ruboty-variable 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/lib/ruboty/handlers/variable.rb +53 -0
- data/lib/ruboty/variable/actions/variable.rb +1 -1
- data/lib/ruboty/variable/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb8e5f840f7ccaebfce105e659c9ea6beda3971c
|
4
|
+
data.tar.gz: 65edd0653a07a661bdeb26bac79910e9248b6edf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f23b3bee227208142e4d9b3086effadc1fbbaf7a30f061b2d80fa748b99ff28cf83c1df3e55505cff44abcaeefbed044c77cc4d690c9eafe2cafca2634276ff5
|
7
|
+
data.tar.gz: bf4d81183ba16c8c706bd14fbf4ed3a3ea770694b861487e8963e04f190475c99de806a3c01e50ecc2f741c5c952da4e85f11dc724daa8e348e9fcb27aa0cf66
|
data/README.md
CHANGED
@@ -66,7 +66,7 @@ Set 3 to hoge
|
|
66
66
|
> ruboty var set piyo piyo_value
|
67
67
|
Set piyo_value to piyo
|
68
68
|
> ruboty var list
|
69
|
-
key
|
69
|
+
key type value
|
70
70
|
hoge - string - 3
|
71
71
|
piyo - string - piyo_value
|
72
72
|
~~~
|
@@ -78,7 +78,7 @@ piyo - string - piyo_value
|
|
78
78
|
> ruboty var array init ary
|
79
79
|
Created ary empty array
|
80
80
|
> ruboty var list
|
81
|
-
key
|
81
|
+
key type value
|
82
82
|
ary - array - []
|
83
83
|
~~~
|
84
84
|
|
@@ -94,7 +94,7 @@ Push one to ary
|
|
94
94
|
Push two to ary
|
95
95
|
Push three to ary
|
96
96
|
> ruboty var list
|
97
|
-
key
|
97
|
+
key type value
|
98
98
|
ary - array - ["one", "two", "three"]
|
99
99
|
~~~
|
100
100
|
|
@@ -114,7 +114,7 @@ Push three to ary
|
|
114
114
|
ary already included one
|
115
115
|
ary already included two
|
116
116
|
> ruboty var list
|
117
|
-
key
|
117
|
+
key type value
|
118
118
|
ary - array - ["one", "two", "three"]
|
119
119
|
~~~
|
120
120
|
|
@@ -38,6 +38,59 @@ module Ruboty
|
|
38
38
|
def array_remove(message)
|
39
39
|
Ruboty::Variable::Actions::Variable.new(message).array_push(message[:key], message[:values])
|
40
40
|
end
|
41
|
+
|
42
|
+
on /var test\z/, name: 'test_values', hide: true
|
43
|
+
|
44
|
+
def test_values(message)
|
45
|
+
var = Ruboty::Variable::Actions::Variable.new(message)
|
46
|
+
puts '# set'
|
47
|
+
var.set("hoge", "hoge_value")
|
48
|
+
var.set("123457", "999")
|
49
|
+
var.set("aohef23", "awef8a23a3a32")
|
50
|
+
var.set("string", "string_value")
|
51
|
+
|
52
|
+
puts "\n# get"
|
53
|
+
var.get("hoge")
|
54
|
+
var.get("piyo")
|
55
|
+
|
56
|
+
puts "\n# list"
|
57
|
+
var.list
|
58
|
+
|
59
|
+
puts "\n# delete"
|
60
|
+
var.delete("hoge")
|
61
|
+
var.delete("hoge")
|
62
|
+
var.list
|
63
|
+
|
64
|
+
puts "\n# init array"
|
65
|
+
var.array_init("ary")
|
66
|
+
var.array_init("string")
|
67
|
+
var.array_init("string")
|
68
|
+
var.list
|
69
|
+
|
70
|
+
puts "\n# push array"
|
71
|
+
var.array_push("ary", "one")
|
72
|
+
var.array_push("ary", "two")
|
73
|
+
var.array_push("ary", "two")
|
74
|
+
var.list
|
75
|
+
|
76
|
+
puts "\n# push array to empty array"
|
77
|
+
var.array_push("hoge", "kkkk")
|
78
|
+
var.array_push("zxcv", "pppp")
|
79
|
+
|
80
|
+
puts "\n# push values to array"
|
81
|
+
var.array_push("ary", "three four five")
|
82
|
+
var.list
|
83
|
+
|
84
|
+
puts "\n# remove values from array"
|
85
|
+
var.array_remove("ary", "one three")
|
86
|
+
var.list
|
87
|
+
|
88
|
+
puts "\n# remove error"
|
89
|
+
var.array_remove("ary", "one three")
|
90
|
+
var.array_remove("noary", "one")
|
91
|
+
var.array_remove("123457", "one")
|
92
|
+
var.list
|
93
|
+
end
|
41
94
|
end
|
42
95
|
end
|
43
96
|
end
|
@@ -91,7 +91,7 @@ module Ruboty
|
|
91
91
|
key_len = [max_key_length, 'key'.size].max
|
92
92
|
type_len = [max_type_length, 'type'.size].max
|
93
93
|
|
94
|
-
mes = "%-#{key_len}s %-#{type_len}s value\n" % %w(key
|
94
|
+
mes = "%-#{key_len}s %-#{type_len}s value\n" % %w(key type)
|
95
95
|
mes << @var.values.map do |k, v|
|
96
96
|
"%-#{key_len}s - %-#{type_len}s - #{v[:value]}" % [k, v[:type]]
|
97
97
|
end.join("\n")
|