samantha 0.0.2 → 0.0.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5bba903f9f30cab948b6fb38f05479b1ffa553ec
4
- data.tar.gz: 51ea88e965c81de1bb55dc0fa14c8486f76e0853
3
+ metadata.gz: 6392430cb7ccc85c8ae39a4078df65cb688a720f
4
+ data.tar.gz: 9d48e0aef594e8ebfacbf8389c5bdf1fc9033515
5
5
  SHA512:
6
- metadata.gz: 9429041c9eb60258b85a61ccd7fc7fefcc6f63dcbf80809eab2cebe8d8de86cddeb20dad5c62aa38dc10f272cdb7049f9ea95cf717fb4327e4ced2b869b89843
7
- data.tar.gz: 5d8ef26e6fb6312cf7ee6705a169554c845cdca5374f26cde45529b49cb4be5645ddf6a1e573e55a10d1b0113047a2341c1e502fe0fc081849e1e9a0d5576462
6
+ metadata.gz: c32a4972cc24fa6149afb46072d177daf389507fb411a44015f7a5642829ebc8fc51d5746007f0e8068b8613a38276bdcdda65b0a1591b40272318db53c16ab3
7
+ data.tar.gz: f2b8f7e32285fef5ead1e0c9c5863443e5956687b13408a88698cea2db7343d6cb1070b371dbe8cab64e68b138d4db1469956954f998104351e06a6b5e1bd608
data/bin/samantha CHANGED
@@ -2,6 +2,6 @@
2
2
 
3
3
  require 'samantha'
4
4
 
5
- samantha = Samantha::Base.new
5
+ samantha = Samantha::Palette.new
6
6
 
7
- samantha.find_colors(*ARGV)
7
+ samantha.print_colors(*ARGV)
@@ -1,3 +1,3 @@
1
1
  module Samantha
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.4"
3
3
  end
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
- @palette.add_color(Color.new(hex, 1))
19
+ add_color(Color.new(hex, 1))
45
20
  end
46
21
  end
47
22
  end
48
23
  end
24
+ end
49
25
 
50
- color_block = "●"
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
- puts Paint['', nil, nil]
35
+ def print_colors(dir)
36
+ find_colors(dir)
53
37
 
54
- @palette.colors.each do |c|
55
- puts "#{Paint[color_block, c.hex, nil]} ##{c.hex.ljust(6)} #{c.count.to_s.ljust(6)}"
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
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: samantha
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Flip Stewart