samantha 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +35 -0
- data/Rakefile +1 -0
- data/bin/samantha +7 -0
- data/lib/samantha/version.rb +3 -0
- data/lib/samantha.rb +79 -0
- data/samantha.gemspec +25 -0
- metadata +97 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b9ad3e4c91268821796cfa57788c75a1d380c6d0
|
4
|
+
data.tar.gz: ce84ecde8b2d9830b1d970f9a7e60ef8ef46e1c8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8c32db4e18978e2f8b1c03b5b1f5359c460365a0eb65e0362552909e530e835ee6d7637d5f3982fb097eadf0003876aa610e733d86985984f9fd6604768aa65e
|
7
|
+
data.tar.gz: 9aa8dff391644e88315013f7bd6502384fa58a2c2b3b3d0ad79f9604048cbb4187cd5e8859208d482f32995b3fd6b7fd0e6e87135b9f01272da4f6585b9b53a1
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 flipstewart
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# Samantha :sparkles:
|
2
|
+
|
3
|
+
![Samantha Screenshot](http://f.cl.ly/items/003L2b3y0S2j2i3X3u04/samantha.png)
|
4
|
+
|
5
|
+
Samantha finds all the hex color codes in a directory and displays them along with the number of times they occur
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'samantha'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install samantha
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Samantha takes one command,
|
24
|
+
|
25
|
+
`$ samantha <dir>`
|
26
|
+
|
27
|
+
where <dir> is the directory you'd like to find hex color codes in.
|
28
|
+
|
29
|
+
## Contributing
|
30
|
+
|
31
|
+
1. Fork it
|
32
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
33
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
34
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
35
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/samantha
ADDED
data/lib/samantha.rb
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
require "samantha/version"
|
2
|
+
require "paint"
|
3
|
+
|
4
|
+
module Samantha
|
5
|
+
|
6
|
+
class Palette
|
7
|
+
attr_accessor :colors
|
8
|
+
|
9
|
+
def initialize()
|
10
|
+
@colors = []
|
11
|
+
end
|
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
|
+
def find_colors(dir)
|
39
|
+
Dir["#{dir}/*"].each do |f|
|
40
|
+
File.open(f) do |f|
|
41
|
+
f.each_line do |l|
|
42
|
+
l.scan(/\B#[0-9a-fA-f]{3,6}\b/).each do |hex|
|
43
|
+
hex = hex.downcase
|
44
|
+
@palette.add_color(Color.new(hex, 1))
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
@palette.colors.sort_by! { |c| c.count }
|
51
|
+
|
52
|
+
color_block = " "
|
53
|
+
|
54
|
+
puts Paint['', nil, nil]
|
55
|
+
|
56
|
+
puts "#{(" Hexes in /" + dir.to_s)}"
|
57
|
+
|
58
|
+
puts
|
59
|
+
|
60
|
+
puts "╭──────────────┬────────┬────────╮"
|
61
|
+
puts "│ │ Hex │ Uses │"
|
62
|
+
puts "├──────────────┼────────┼────────┤"
|
63
|
+
|
64
|
+
@palette.colors.each do |c|
|
65
|
+
puts "│ #{Paint[color_block, nil, c.hex]} │ #{c.hex.ljust(6)} │ #{c.count.to_s.ljust(6)} │"
|
66
|
+
puts "├──────────────┼────────┼────────┤"
|
67
|
+
end
|
68
|
+
|
69
|
+
puts "│ Total │ │ #{@palette.colors.length.to_s.ljust(6)} │"
|
70
|
+
puts "╰──────────────┴────────┴────────╯"
|
71
|
+
|
72
|
+
puts
|
73
|
+
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
data/samantha.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'samantha/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "samantha"
|
8
|
+
spec.version = Samantha::VERSION
|
9
|
+
spec.authors = ["Flip Stewart"]
|
10
|
+
spec.email = ["flipstewart@me.com"]
|
11
|
+
spec.description = %q{Hex code counter}
|
12
|
+
spec.summary = %q{Samantha finds all the hex color codes in a directory and displays them along with the number of times they occur}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = ["samantha"]
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
|
24
|
+
spec.add_runtime_dependency('paint', '0.8.6')
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: samantha
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Flip Stewart
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-07-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: paint
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.8.6
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.8.6
|
55
|
+
description: Hex code counter
|
56
|
+
email:
|
57
|
+
- flipstewart@me.com
|
58
|
+
executables:
|
59
|
+
- samantha
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- .gitignore
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE.txt
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- lib/samantha.rb
|
69
|
+
- lib/samantha/version.rb
|
70
|
+
- samantha.gemspec
|
71
|
+
- bin/samantha
|
72
|
+
homepage: ''
|
73
|
+
licenses:
|
74
|
+
- MIT
|
75
|
+
metadata: {}
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options: []
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - '>='
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
requirements: []
|
91
|
+
rubyforge_project:
|
92
|
+
rubygems_version: 2.0.3
|
93
|
+
signing_key:
|
94
|
+
specification_version: 4
|
95
|
+
summary: Samantha finds all the hex color codes in a directory and displays them along
|
96
|
+
with the number of times they occur
|
97
|
+
test_files: []
|