pyradise 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/lib/pyradise/cli.rb +8 -5
  3. data/pyradise.gemspec +1 -1
  4. metadata +1 -1
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
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
- # puts "_" * w
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
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{pyradise}
8
- s.version = "0.3.0"
8
+ s.version = "0.3.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Marcos Piccinini"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pyradise
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcos Piccinini