vv 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/vv.rb +2 -0
- data/lib/vv/array_methods.rb +0 -8
- data/lib/vv/object_methods.rb +11 -0
- data/lib/vv/random_methods.rb +8 -6
- data/lib/vv/string_methods.rb +43 -4
- data/lib/vv/style/bold.rb +15 -0
- data/lib/vv/style/color.rb +218 -0
- data/lib/vv/style/format.rb +7 -0
- data/lib/vv/style/italic.rb +15 -0
- data/lib/vv/style/underline.rb +16 -0
- data/lib/vv/utility/automate.rb +75 -0
- data/lib/vv/version.rb +1 -1
- metadata +9 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d58f40f0cc4161bee4e7e096e6979dbe03efcc9680f9f3505130d56c741bdf98
|
4
|
+
data.tar.gz: f5bd9113ecc56aff96f6afe29f61e50a48b0264c104d5a3910eee57d8dfa8efc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f7461ddd243c9e4d19ee0833ae0aa365b95f6fb98d471c62304a1848a53b22a9685bdd2172794ceead2c464c0846ef150afde0798de5c0dd4b8a65127a1acae9
|
7
|
+
data.tar.gz: 007b014236517943ddc6954edf83daeb3e0f782c88238080be57f246baf5ab09191ab5e9778024784b16b4d9e55668400032d2c1682bea676b0fa09c9930bfe6
|
data/lib/vv.rb
CHANGED
data/lib/vv/array_methods.rb
CHANGED
data/lib/vv/random_methods.rb
CHANGED
@@ -24,17 +24,19 @@ module VV
|
|
24
24
|
36
|
25
25
|
end
|
26
26
|
|
27
|
-
def identifier length=nil,
|
27
|
+
def identifier length=nil, charset_radix: nil
|
28
28
|
length ||= self.random_identifier_default_length
|
29
29
|
|
30
|
-
|
31
|
-
largest_digit = (
|
30
|
+
charset_radix ||= self.default_charset
|
31
|
+
largest_digit = (charset_radix - 1).to_s charset_radix
|
32
32
|
|
33
|
-
start = ( largest_digit * ( length - 1 ) ).to_i
|
34
|
-
|
33
|
+
start = ( largest_digit * ( length - 1 ) ).to_i charset_radix
|
34
|
+
start += 1
|
35
|
+
|
36
|
+
finish = ( largest_digit * ( length ) ).to_i charset_radix
|
35
37
|
range = start..finish
|
36
38
|
|
37
|
-
SecureRandom.random_number(range).to_s
|
39
|
+
SecureRandom.random_number(range).to_s charset_radix
|
38
40
|
end
|
39
41
|
|
40
42
|
def character *args, capitals: false
|
data/lib/vv/string_methods.rb
CHANGED
@@ -75,10 +75,6 @@ module VV
|
|
75
75
|
|
76
76
|
end
|
77
77
|
|
78
|
-
def blank?
|
79
|
-
self == ""
|
80
|
-
end
|
81
|
-
|
82
78
|
def starts_with? *args
|
83
79
|
self.start_with?(*args)
|
84
80
|
end
|
@@ -229,6 +225,49 @@ module VV
|
|
229
225
|
t: 1000_000_000_000 }.stringify_keys
|
230
226
|
end
|
231
227
|
|
228
|
+
def style *args
|
229
|
+
color = bold = underline = italic = nil
|
230
|
+
|
231
|
+
args.flatten!
|
232
|
+
args.map! { |arg| arg.to_sym }
|
233
|
+
|
234
|
+
args.each do |arg|
|
235
|
+
if Color.known_color? arg
|
236
|
+
if color.present?
|
237
|
+
raise "Color already set"
|
238
|
+
else
|
239
|
+
color = Color.new arg
|
240
|
+
end
|
241
|
+
elsif arg == :bold
|
242
|
+
bold = Bold.new
|
243
|
+
elsif arg == :underline
|
244
|
+
underline = Underline.new
|
245
|
+
elsif ( arg == :italic ) or ( arg == :italics )
|
246
|
+
italic = Italic.new
|
247
|
+
else
|
248
|
+
raise NotImplemented
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
252
|
+
reset = Format.reset_code
|
253
|
+
response = self.chomp(reset) + reset
|
254
|
+
|
255
|
+
response.prepend italic.code if italic
|
256
|
+
response.prepend underline.code if underline
|
257
|
+
response.prepend bold.code if bold
|
258
|
+
|
259
|
+
if color
|
260
|
+
start = response.index color.start_code
|
261
|
+
if start
|
262
|
+
finish = response[start..-1].index("m") + start
|
263
|
+
response.slice! start..finish
|
264
|
+
end
|
265
|
+
response.prepend color.code
|
266
|
+
end
|
267
|
+
|
268
|
+
response
|
269
|
+
end
|
270
|
+
|
232
271
|
def insta
|
233
272
|
return self if self.starts_with?("@")
|
234
273
|
"@#{self}"
|
@@ -0,0 +1,218 @@
|
|
1
|
+
# Some code retrieved from rainbow gem, license followed:
|
2
|
+
# https://github.com/sickill/rainbow
|
3
|
+
# At commit: 0425bb46a408e406501c842d97233f13d93701e3
|
4
|
+
class Color
|
5
|
+
NAMES = {
|
6
|
+
aqua: [0, 255, 255],
|
7
|
+
aquamarine: [127, 255, 212],
|
8
|
+
mediumaquamarine: [102, 205, 170],
|
9
|
+
azure: [240, 255, 255],
|
10
|
+
beige: [245, 245, 220],
|
11
|
+
bisque: [255, 228, 196],
|
12
|
+
black: [0, 0, 0],
|
13
|
+
blanchedalmond: [255, 235, 205],
|
14
|
+
blue: [0, 0, 255],
|
15
|
+
darkblue: [0, 0, 139],
|
16
|
+
lightblue: [173, 216, 230],
|
17
|
+
mediumblue: [0, 0, 205],
|
18
|
+
aliceblue: [240, 248, 255],
|
19
|
+
cadetblue: [95, 158, 160],
|
20
|
+
dodgerblue: [30, 144, 255],
|
21
|
+
midnightblue: [25, 25, 112],
|
22
|
+
navyblue: [0, 0, 128],
|
23
|
+
powderblue: [176, 224, 230],
|
24
|
+
royalblue: [65, 105, 225],
|
25
|
+
skyblue: [135, 206, 235],
|
26
|
+
deepskyblue: [0, 191, 255],
|
27
|
+
lightskyblue: [135, 206, 250],
|
28
|
+
slateblue: [106, 90, 205],
|
29
|
+
darkslateblue: [72, 61, 139],
|
30
|
+
mediumslateblue: [123, 104, 238],
|
31
|
+
steelblue: [70, 130, 180],
|
32
|
+
lightsteelblue: [176, 196, 222],
|
33
|
+
brown: [165, 42, 42],
|
34
|
+
rosybrown: [188, 143, 143],
|
35
|
+
saddlebrown: [139, 69, 19],
|
36
|
+
sandybrown: [244, 164, 96],
|
37
|
+
burlywood: [222, 184, 135],
|
38
|
+
chartreuse: [127, 255, 0],
|
39
|
+
chocolate: [210, 105, 30],
|
40
|
+
coral: [255, 127, 80],
|
41
|
+
lightcoral: [240, 128, 128],
|
42
|
+
cornflower: [100, 149, 237],
|
43
|
+
cornsilk: [255, 248, 220],
|
44
|
+
crimson: [220, 20, 60],
|
45
|
+
cyan: [0, 255, 255],
|
46
|
+
darkcyan: [0, 139, 139],
|
47
|
+
lightcyan: [224, 255, 255],
|
48
|
+
firebrick: [178, 34, 34],
|
49
|
+
fuchsia: [255, 0, 255],
|
50
|
+
gainsboro: [220, 220, 220],
|
51
|
+
gold: [255, 215, 0],
|
52
|
+
goldenrod: [218, 165, 32],
|
53
|
+
darkgoldenrod: [184, 134, 11],
|
54
|
+
lightgoldenrod: [250, 250, 210],
|
55
|
+
palegoldenrod: [238, 232, 170],
|
56
|
+
gray: [190, 190, 190],
|
57
|
+
darkgray: [169, 169, 169],
|
58
|
+
dimgray: [105, 105, 105],
|
59
|
+
lightgray: [211, 211, 211],
|
60
|
+
slategray: [112, 128, 144],
|
61
|
+
lightslategray: [119, 136, 153],
|
62
|
+
webgray: [128, 128, 128],
|
63
|
+
green: [0, 255, 0],
|
64
|
+
darkgreen: [0, 100, 0],
|
65
|
+
lightgreen: [144, 238, 144],
|
66
|
+
palegreen: [152, 251, 152],
|
67
|
+
darkolivegreen: [85, 107, 47],
|
68
|
+
yellowgreen: [154, 205, 50],
|
69
|
+
forestgreen: [34, 139, 34],
|
70
|
+
lawngreen: [124, 252, 0],
|
71
|
+
limegreen: [50, 205, 50],
|
72
|
+
seagreen: [46, 139, 87],
|
73
|
+
darkseagreen: [143, 188, 143],
|
74
|
+
lightseagreen: [32, 178, 170],
|
75
|
+
mediumseagreen: [60, 179, 113],
|
76
|
+
springgreen: [0, 255, 127],
|
77
|
+
mediumspringgreen: [0, 250, 154],
|
78
|
+
webgreen: [0, 128, 0],
|
79
|
+
honeydew: [240, 255, 240],
|
80
|
+
indianred: [205, 92, 92],
|
81
|
+
indigo: [75, 0, 130],
|
82
|
+
ivory: [255, 255, 240],
|
83
|
+
khaki: [240, 230, 140],
|
84
|
+
darkkhaki: [189, 183, 107],
|
85
|
+
lavender: [230, 230, 250],
|
86
|
+
lavenderblush: [255, 240, 245],
|
87
|
+
lemonchiffon: [255, 250, 205],
|
88
|
+
lime: [0, 255, 0],
|
89
|
+
linen: [250, 240, 230],
|
90
|
+
magenta: [255, 0, 255],
|
91
|
+
darkmagenta: [139, 0, 139],
|
92
|
+
maroon: [176, 48, 96],
|
93
|
+
webmaroon: [127, 0, 0],
|
94
|
+
mintcream: [245, 255, 250],
|
95
|
+
mistyrose: [255, 228, 225],
|
96
|
+
moccasin: [255, 228, 181],
|
97
|
+
oldlace: [253, 245, 230],
|
98
|
+
olive: [128, 128, 0],
|
99
|
+
olivedrab: [107, 142, 35],
|
100
|
+
orange: [255, 165, 0],
|
101
|
+
darkorange: [255, 140, 0],
|
102
|
+
orchid: [218, 112, 214],
|
103
|
+
darkorchid: [153, 50, 204],
|
104
|
+
mediumorchid: [186, 85, 211],
|
105
|
+
papayawhip: [255, 239, 213],
|
106
|
+
peachpuff: [255, 218, 185],
|
107
|
+
peru: [205, 133, 63],
|
108
|
+
pink: [255, 192, 203],
|
109
|
+
deeppink: [255, 20, 147],
|
110
|
+
lightpink: [255, 182, 193],
|
111
|
+
hotpink: [255, 105, 180],
|
112
|
+
plum: [221, 160, 221],
|
113
|
+
purple: [160, 32, 240],
|
114
|
+
mediumpurple: [147, 112, 219],
|
115
|
+
rebeccapurple: [102, 51, 153],
|
116
|
+
webpurple: [127, 0, 127],
|
117
|
+
red: [255, 0, 0],
|
118
|
+
darkred: [139, 0, 0],
|
119
|
+
orangered: [255, 69, 0],
|
120
|
+
mediumvioletred: [199, 21, 133],
|
121
|
+
palevioletred: [219, 112, 147],
|
122
|
+
salmon: [250, 128, 114],
|
123
|
+
darksalmon: [233, 150, 122],
|
124
|
+
lightsalmon: [255, 160, 122],
|
125
|
+
seashell: [255, 245, 238],
|
126
|
+
sienna: [160, 82, 45],
|
127
|
+
silver: [192, 192, 192],
|
128
|
+
darkslategray: [47, 79, 79],
|
129
|
+
snow: [255, 250, 250],
|
130
|
+
tan: [210, 180, 140],
|
131
|
+
teal: [0, 128, 128],
|
132
|
+
thistle: [216, 191, 216],
|
133
|
+
tomato: [255, 99, 71],
|
134
|
+
turquoise: [64, 224, 208],
|
135
|
+
darkturquoise: [0, 206, 209],
|
136
|
+
mediumturquoise: [72, 209, 204],
|
137
|
+
paleturquoise: [175, 238, 238],
|
138
|
+
violet: [238, 130, 238],
|
139
|
+
darkviolet: [148, 0, 211],
|
140
|
+
blueviolet: [138, 43, 226],
|
141
|
+
wheat: [245, 222, 179],
|
142
|
+
white: [255, 255, 255],
|
143
|
+
antiquewhite: [250, 235, 215],
|
144
|
+
floralwhite: [255, 250, 240],
|
145
|
+
ghostwhite: [248, 248, 255],
|
146
|
+
navajowhite: [255, 222, 173],
|
147
|
+
whitesmoke: [245, 245, 245],
|
148
|
+
yellow: [255, 255, 0],
|
149
|
+
lightyellow: [255, 255, 224],
|
150
|
+
greenyellow: [173, 255, 47]
|
151
|
+
}.freeze
|
152
|
+
|
153
|
+
attr_accessor :r, :g, :b
|
154
|
+
|
155
|
+
def self.names
|
156
|
+
NAMES.each do | name, _ |
|
157
|
+
styled_name = name.to_s.style name
|
158
|
+
styled_name += " (black)" if name == :black
|
159
|
+
puts styled_name
|
160
|
+
end
|
161
|
+
nil
|
162
|
+
end
|
163
|
+
|
164
|
+
def self.lookup_color name
|
165
|
+
name = name.to_s
|
166
|
+
name.gsub! "_", ""
|
167
|
+
name.gsub! "-", ""
|
168
|
+
name = name.to_sym
|
169
|
+
|
170
|
+
NAMES[name]
|
171
|
+
end
|
172
|
+
|
173
|
+
def self.known_color? name
|
174
|
+
self.lookup_color(name).present?
|
175
|
+
end
|
176
|
+
|
177
|
+
def initialize name=nil, hex: nil, rgb: nil
|
178
|
+
raise NotImplemented if name.nil?
|
179
|
+
raise NotImplemented if hex.present?
|
180
|
+
raise NotImplemented if rgb.present?
|
181
|
+
|
182
|
+
color ||= self.class.lookup_color name
|
183
|
+
|
184
|
+
raise NotImplemented unless color.present?
|
185
|
+
|
186
|
+
@r, @g, @b = color
|
187
|
+
end
|
188
|
+
|
189
|
+
def red
|
190
|
+
@r
|
191
|
+
end
|
192
|
+
|
193
|
+
def green
|
194
|
+
@g
|
195
|
+
end
|
196
|
+
|
197
|
+
def blue
|
198
|
+
@b
|
199
|
+
end
|
200
|
+
|
201
|
+
def rgb
|
202
|
+
[@r, @g, @b]
|
203
|
+
end
|
204
|
+
|
205
|
+
def code
|
206
|
+
"#{start_code}#{@r};#{@g};#{@b}m"
|
207
|
+
end
|
208
|
+
|
209
|
+
def html
|
210
|
+
"##{@r.to_s(16)}#{@g.to_s(16)}#{@b.to_s(16)}"
|
211
|
+
end
|
212
|
+
alias_method :hex, :html
|
213
|
+
|
214
|
+
def start_code
|
215
|
+
"\x1b[38;2;"
|
216
|
+
end
|
217
|
+
|
218
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
module VV
|
2
|
+
module Automate
|
3
|
+
|
4
|
+
def version path:
|
5
|
+
args = ARGV.to_a
|
6
|
+
lines = File.read(path).split("\n")
|
7
|
+
|
8
|
+
raise "Unknown number of arguments" if args.size > 1
|
9
|
+
version = lines[1].split(" = ")[-1].gsub("'","")
|
10
|
+
if args.size < 1
|
11
|
+
puts version
|
12
|
+
exit
|
13
|
+
end
|
14
|
+
|
15
|
+
command = args[0]
|
16
|
+
weird = version.split(".").size != 3
|
17
|
+
raise "Only handles basic versions" if weird
|
18
|
+
|
19
|
+
major, minor, point = version.split(".").map(&:to_i)
|
20
|
+
|
21
|
+
if command == "+"
|
22
|
+
point += 1
|
23
|
+
elsif command == "++"
|
24
|
+
point = 0
|
25
|
+
minor += 1
|
26
|
+
elsif command == "+++"
|
27
|
+
point = 0
|
28
|
+
minor = 0
|
29
|
+
major += 1
|
30
|
+
elsif command.split(".").size == 3
|
31
|
+
major, minor, point = command.split(".")
|
32
|
+
elsif command == "reset"
|
33
|
+
system("git checkout -- #{path}")
|
34
|
+
exit
|
35
|
+
elsif %w[ help --help h -h ].include? command
|
36
|
+
puts
|
37
|
+
puts "Available commands are:"
|
38
|
+
puts
|
39
|
+
puts "+ - point increment"
|
40
|
+
puts "++ - minor increment"
|
41
|
+
puts "+++ - major increment"
|
42
|
+
puts
|
43
|
+
puts "x.y.z - to set version explicitly"
|
44
|
+
puts "reset - to revert to version in git"
|
45
|
+
puts
|
46
|
+
exit
|
47
|
+
end
|
48
|
+
|
49
|
+
new_version = [major, minor, point].join(".")
|
50
|
+
lines[1] = " VERSION = '#{new_version}'"
|
51
|
+
lines << ""
|
52
|
+
|
53
|
+
File.write(path, lines.join("\n"))
|
54
|
+
|
55
|
+
end
|
56
|
+
module_function :version
|
57
|
+
|
58
|
+
def build( name: )
|
59
|
+
puts %x{ find lib/ | \\
|
60
|
+
xargs git ls-files --error-unmatch > /dev/null 2>&1 \\
|
61
|
+
|| ( echo && \\
|
62
|
+
echo "Warning: A file in lib/ is not tracked by git" && \\
|
63
|
+
echo )
|
64
|
+
|
65
|
+
rm #{name}-*.gem
|
66
|
+
gem uninstall --ignore-dependencies #{name} > /dev/null
|
67
|
+
bundle
|
68
|
+
gem build #{name}.gemspec
|
69
|
+
gem install $(readlink -f #{name}-*.gem | sort | tail -n 1 ) --pre
|
70
|
+
}
|
71
|
+
end
|
72
|
+
module_function :build
|
73
|
+
|
74
|
+
end
|
75
|
+
end
|
data/lib/vv/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zach Aysan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -68,10 +68,17 @@ files:
|
|
68
68
|
- lib/vv/gem_methods.rb
|
69
69
|
- lib/vv/hash_methods.rb
|
70
70
|
- lib/vv/nil_methods.rb
|
71
|
+
- lib/vv/object_methods.rb
|
71
72
|
- lib/vv/random_methods.rb
|
72
73
|
- lib/vv/readline_methods.rb
|
73
74
|
- lib/vv/string_methods.rb
|
75
|
+
- lib/vv/style/bold.rb
|
76
|
+
- lib/vv/style/color.rb
|
77
|
+
- lib/vv/style/format.rb
|
78
|
+
- lib/vv/style/italic.rb
|
79
|
+
- lib/vv/style/underline.rb
|
74
80
|
- lib/vv/true_methods.rb
|
81
|
+
- lib/vv/utility/automate.rb
|
75
82
|
- lib/vv/version.rb
|
76
83
|
homepage: https://github.com/zachaysan/vv
|
77
84
|
licenses:
|