pyradise 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/lib/pyradise/cli.rb +8 -5
- data/pyradise.gemspec +1 -1
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.1
|
data/lib/pyradise/cli.rb
CHANGED
@@ -18,16 +18,18 @@ module Pyradise
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def list(*query)
|
21
|
-
p query
|
22
21
|
t = Time.now
|
23
22
|
w = terminal_size[0]
|
24
23
|
s = w - 36
|
25
24
|
puts "\n#{t(:search)} #{'"' + green(query.join(" ")) + '"' if query[0]}... #{t(:order)}: #{green(Options[:order])}"
|
26
|
-
#
|
25
|
+
# puts "_" * w
|
27
26
|
puts
|
28
27
|
prods = Product.filter(:name.like("%#{query.join("%")}%")).order(Options[:order])
|
29
28
|
prods.each_with_index do |prod, i|
|
30
29
|
name = prod.name.length > s ? prod.name[0..s] + ".. " : prod.name + " "
|
30
|
+
#
|
31
|
+
# Replace each occurrence with color
|
32
|
+
# Need to ensure the length of the string for some reason.. =/
|
31
33
|
for q in query
|
32
34
|
b = i % 2 == 0 ? "\e[0m\e[2m" : "\e[0m\e[0m"
|
33
35
|
replaces = name.scan(/#{q}/i).length
|
@@ -35,8 +37,9 @@ module Pyradise
|
|
35
37
|
name += "." until name.length > w - 23
|
36
38
|
end
|
37
39
|
total_price = prod.price * Options[:rate] * Options[:tax]
|
40
|
+
#
|
41
|
+
# Format the output
|
38
42
|
out = sprintf("%-6s | %-6s | %-#{s}s %-3d | R$ %s", prod.store, prod.sid, name, prod.price, yellow(total_price.to_i))
|
39
|
-
|
40
43
|
puts i % 2 == 0 ? bold(out) : out
|
41
44
|
end
|
42
45
|
puts "_" * w
|
@@ -156,9 +159,9 @@ module Pyradise
|
|
156
159
|
def green(txt); "\e[32m#{txt}\e[0m"; end
|
157
160
|
def yellow(txt); "\e[33m#{txt}\e[0m"; end
|
158
161
|
def bold(txt); "\e[2m#{txt}\e[0m"; end
|
159
|
-
end
|
160
|
-
|
161
162
|
|
163
|
+
end
|
162
164
|
|
163
165
|
end
|
166
|
+
|
164
167
|
end
|
data/pyradise.gemspec
CHANGED