samantha 0.0.2 → 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/bin/samantha +2 -2
- data/lib/samantha/version.rb +1 -1
- data/lib/samantha.rb +26 -32
- 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: 6392430cb7ccc85c8ae39a4078df65cb688a720f
|
4
|
+
data.tar.gz: 9d48e0aef594e8ebfacbf8389c5bdf1fc9033515
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c32a4972cc24fa6149afb46072d177daf389507fb411a44015f7a5642829ebc8fc51d5746007f0e8068b8613a38276bdcdda65b0a1591b40272318db53c16ab3
|
7
|
+
data.tar.gz: f2b8f7e32285fef5ead1e0c9c5863443e5956687b13408a88698cea2db7343d6cb1070b371dbe8cab64e68b138d4db1469956954f998104351e06a6b5e1bd608
|
data/bin/samantha
CHANGED
data/lib/samantha/version.rb
CHANGED
data/lib/samantha.rb
CHANGED
@@ -10,56 +10,50 @@ module Samantha
|
|
10
10
|
@colors = []
|
11
11
|
end
|
12
12
|
|
13
|
-
def add_color(color)
|
14
|
-
a = @colors.detect { |c| c.hex == color.hex }
|
15
|
-
if a == nil
|
16
|
-
@colors.push(color)
|
17
|
-
else
|
18
|
-
a.count += 1
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
class Color
|
24
|
-
attr_accessor :hex, :count
|
25
|
-
|
26
|
-
def initialize(hex, count)
|
27
|
-
@hex = hex
|
28
|
-
@count = count
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
class Base
|
33
|
-
|
34
|
-
def initialize()
|
35
|
-
@palette = Palette.new
|
36
|
-
end
|
37
|
-
|
38
13
|
def find_colors(dir)
|
39
14
|
Dir["#{dir}/*"].each do |f|
|
40
15
|
File.open(f) do |f|
|
41
16
|
f.each_line do |l|
|
42
17
|
l.scan(/\B#[0-9a-fA-f]{3,6}\b/).each do |hex|
|
43
18
|
hex = hex.downcase
|
44
|
-
|
19
|
+
add_color(Color.new(hex, 1))
|
45
20
|
end
|
46
21
|
end
|
47
22
|
end
|
48
23
|
end
|
24
|
+
end
|
49
25
|
|
50
|
-
|
26
|
+
def add_color(color)
|
27
|
+
a = @colors.detect { |c| c.hex == color.hex }
|
28
|
+
if a == nil
|
29
|
+
@colors.push(color)
|
30
|
+
else
|
31
|
+
a.count += 1
|
32
|
+
end
|
33
|
+
end
|
51
34
|
|
52
|
-
|
35
|
+
def print_colors(dir)
|
36
|
+
find_colors(dir)
|
53
37
|
|
54
|
-
@
|
55
|
-
|
56
|
-
end
|
38
|
+
@colors.sort_by! { |c| c.count }
|
39
|
+
@colors.reverse!
|
57
40
|
|
41
|
+
puts Paint['', nil, nil]
|
42
|
+
@colors.each do |c|
|
43
|
+
puts "#{Paint['●', c.hex, nil]} ##{c.hex.ljust(6)} #{c.count.to_s.ljust(6)}"
|
44
|
+
end
|
58
45
|
puts
|
46
|
+
end
|
47
|
+
end
|
59
48
|
|
49
|
+
class Color
|
50
|
+
attr_accessor :hex, :count
|
60
51
|
|
52
|
+
def initialize(hex, count)
|
53
|
+
@hex = hex
|
54
|
+
@count = count
|
61
55
|
end
|
62
|
-
|
63
56
|
end
|
64
57
|
|
65
58
|
end
|
59
|
+
|