colorname 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f3b66ad5dd2f4d26871db471555587311d2cbfcb
4
+ data.tar.gz: afc2efc310b7acd0468ab64fb5b4b0bb7b75dae7
5
+ SHA512:
6
+ metadata.gz: 430198c977481ee5b0d671a203036010b0be8efd9bcff27d15e425a1e215a331a88a4733e395ce71e9bebd90415f17836e731c2b51570ac96dad82248293cf0e
7
+ data.tar.gz: 2a753faabcc0d98c87be29da1e3932a91be1bd3b0c03fd46f953a7f59fe5ae88f7402730a22cd2edd2086c181142b2f05b18053508f23b1611ba1c99988b85d9
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.0
5
+ before_install:
6
+ gem install bundler -v 1.14.6
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at celil.ileri@bil.omu.edu.tr. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in colorname.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 celilileri
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # Colorname
2
+
3
+ [![Build Status](https://travis-ci.com/celilileri/colorname.svg?token=qSHr3MpL5P1vaDoy2yPE&branch=master)](https://travis-ci.com/celilileri/colorname)
4
+
5
+ Ruby Gem for decide name of a given color.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'colorname'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install colorname
22
+
23
+ ## Usage
24
+
25
+ ```ruby
26
+ color_code = Color::RGB.new(30, 140, 30)
27
+ color_name = Colorname::Dominant.find(color_code))
28
+ puts color_name # Green
29
+ ```
30
+
31
+ ## Contributing
32
+
33
+ Bug reports and pull requests are welcome on GitHub at https://github.com/celilileri/colorname. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
34
+
35
+
36
+ ## License
37
+
38
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
39
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'colorname'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require 'irb'
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/colorname.gemspec ADDED
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'colorname/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'colorname'
8
+ spec.version = Colorname::VERSION
9
+ spec.authors = ['celilileri']
10
+ spec.email = ['celil.ileri@bil.omu.edu.tr']
11
+
12
+ spec.summary = ' A Color Categorizator and Namer Ruby Gem Project '
13
+ spec.homepage = 'https://github.com/celilileri/colorname'
14
+ spec.license = 'MIT'
15
+
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = 'exe'
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ['lib']
23
+
24
+ spec.add_development_dependency 'bundler', '~> 1.14'
25
+ spec.add_development_dependency 'rake', '~> 10.0'
26
+ spec.add_development_dependency 'rspec', '~> 3.0'
27
+ spec.add_development_dependency 'color', '~> 1.8'
28
+ end
@@ -0,0 +1,31 @@
1
+ # Color Name Finder method
2
+ module Colorname
3
+ class << self
4
+ def base_color(cc)
5
+ if cc.red == cc.green && cc.green == cc.blue
6
+ # XXX Should add grey?
7
+ cc.red < 127 ? :Black : :White
8
+ elsif cc.red == cc.green && cc.red > cc.blue
9
+ [:Red, :Green]
10
+ elsif cc.red == cc.blue && cc.red > cc.green
11
+ [:Red, :Blue]
12
+ elsif cc.green == cc.blue && cc.green > cc.red
13
+ [:Green, :Blue]
14
+ else
15
+ case [cc.red, cc.green, cc.blue].each_with_index.max[1]
16
+ when 0
17
+ :Red
18
+ when 1
19
+ :Green
20
+ when 2
21
+ :Blue
22
+ end
23
+ end
24
+ end
25
+
26
+ def base(cc, sign = ', ')
27
+ base = base_color(cc)
28
+ base.is_a?(Array) ? base.join(sign) : base
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,8 @@
1
+ # Color Name Finder method
2
+ module Colorname
3
+ class << self
4
+ def find(cc)
5
+ VALUES.select{|_, val| val == [cc.red, cc.green, cc.blue]}.keys
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,152 @@
1
+ module Colorname
2
+ VALUES = {
3
+ aliceblue: [240, 248, 255],
4
+ antiquewhite: [250, 235, 215],
5
+ aqua: [0, 255, 255],
6
+ aquamarine: [127, 255, 212],
7
+ azure: [240, 255, 255],
8
+ beige: [245, 245, 220],
9
+ bisque: [255, 228, 196],
10
+ black: [0, 0, 0],
11
+ blanchedalmond: [255, 235, 205],
12
+ blue: [0, 0, 255],
13
+ blueviolet: [138, 43, 226],
14
+ brown: [165, 42, 42],
15
+ burlywood: [222, 184, 135],
16
+ cadetblue: [95, 158, 160],
17
+ chartreuse: [127, 255, 0],
18
+ chocolate: [210, 105, 30],
19
+ coral: [255, 127, 80],
20
+ cornflowerblue: [100, 149, 237],
21
+ cornsilk: [255, 248, 220],
22
+ crimson: [220, 20, 60],
23
+ cyan: [0, 255, 255],
24
+ darkblue: [0, 0, 139],
25
+ darkcyan: [0, 139, 139],
26
+ darkgoldenrod: [184, 134, 11],
27
+ darkgray: [169, 169, 169],
28
+ darkgreen: [0, 100, 0],
29
+ darkgrey: [169, 169, 169],
30
+ darkkhaki: [189, 183, 107],
31
+ darkmagenta: [139, 0, 139],
32
+ darkolivegreen: [85, 107, 47],
33
+ darkorange: [255, 140, 0],
34
+ darkorchid: [153, 50, 204],
35
+ darkred: [139, 0, 0],
36
+ darksalmon: [233, 150, 122],
37
+ darkseagreen: [143, 188, 143],
38
+ darkslateblue: [72, 61, 139],
39
+ darkslategray: [47, 79, 79],
40
+ darkslategrey: [47, 79, 79],
41
+ darkturquoise: [0, 206, 209],
42
+ darkviolet: [148, 0, 211],
43
+ deeppink: [255, 20, 147],
44
+ deepskyblue: [0, 191, 255],
45
+ dimgray: [105, 105, 105],
46
+ dimgrey: [105, 105, 105],
47
+ dodgerblue: [30, 144, 255],
48
+ firebrick: [178, 34, 34],
49
+ floralwhite: [255, 250, 240],
50
+ forestgreen: [34, 139, 34],
51
+ fuchsia: [255, 0, 255],
52
+ gainsboro: [220, 220, 220],
53
+ ghostwhite: [248, 248, 255],
54
+ gold: [255, 215, 0],
55
+ goldenrod: [218, 165, 32],
56
+ gray: [128, 128, 128],
57
+ green: [0, 128, 0],
58
+ greenyellow: [173, 255, 47],
59
+ grey: [128, 128, 128],
60
+ honeydew: [240, 255, 240],
61
+ hotpink: [255, 105, 180],
62
+ indianred: [205, 92, 92],
63
+ indigo: [75, 0, 130],
64
+ ivory: [255, 255, 240],
65
+ khaki: [240, 230, 140],
66
+ lavender: [230, 230, 250],
67
+ lavenderblush: [255, 240, 245],
68
+ lawngreen: [124, 252, 0],
69
+ lemonchiffon: [255, 250, 205],
70
+ lightblue: [173, 216, 230],
71
+ lightcoral: [240, 128, 128],
72
+ lightcyan: [224, 255, 255],
73
+ lightgoldenrodyellow: [250, 250, 210],
74
+ lightgray: [211, 211, 211],
75
+ lightgreen: [144, 238, 144],
76
+ lightgrey: [211, 211, 211],
77
+ lightpink: [255, 182, 193],
78
+ lightsalmon: [255, 160, 122],
79
+ lightseagreen: [32, 178, 170],
80
+ lightskyblue: [135, 206, 250],
81
+ lightslategray: [119, 136, 153],
82
+ lightslategrey: [119, 136, 153],
83
+ lightsteelblue: [176, 196, 222],
84
+ lightyellow: [255, 255, 224],
85
+ lime: [0, 255, 0],
86
+ limegreen: [50, 205, 50],
87
+ linen: [250, 240, 230],
88
+ magenta: [255, 0, 255],
89
+ maroon: [128, 0, 0],
90
+ mediumaquamarine: [102, 205, 170],
91
+ mediumblue: [0, 0, 205],
92
+ mediumorchid: [186, 85, 211],
93
+ mediumpurple: [147, 112, 219],
94
+ mediumseagreen: [60, 179, 113],
95
+ mediumslateblue: [123, 104, 238],
96
+ mediumspringgreen: [0, 250, 154],
97
+ mediumturquoise: [72, 209, 204],
98
+ mediumvioletred: [199, 21, 133],
99
+ midnightblue: [25, 25, 112],
100
+ mintcream: [245, 255, 250],
101
+ mistyrose: [255, 228, 225],
102
+ moccasin: [255, 228, 181],
103
+ navajowhite: [255, 222, 173],
104
+ navy: [0, 0, 128],
105
+ oldlace: [253, 245, 230],
106
+ olive: [128, 128, 0],
107
+ olivedrab: [107, 142, 35],
108
+ orange: [255, 165, 0],
109
+ orangered: [255, 69, 0],
110
+ orchid: [218, 112, 214],
111
+ palegoldenrod: [238, 232, 170],
112
+ palegreen: [152, 251, 152],
113
+ paleturquoise: [175, 238, 238],
114
+ palevioletred: [219, 112, 147],
115
+ papayawhip: [255, 239, 213],
116
+ peachpuff: [255, 218, 185],
117
+ peru: [205, 133, 63],
118
+ pink: [255, 192, 203],
119
+ plum: [221, 160, 221],
120
+ powderblue: [176, 224, 230],
121
+ purple: [128, 0, 128],
122
+ rebeccapurple: [102, 51, 153],
123
+ red: [255, 0, 0],
124
+ rosybrown: [188, 143, 143],
125
+ royalblue: [65, 105, 225],
126
+ saddlebrown: [139, 69, 19],
127
+ salmon: [250, 128, 114],
128
+ sandybrown: [244, 164, 96],
129
+ seagreen: [46, 139, 87],
130
+ seashell: [255, 245, 238],
131
+ sienna: [160, 82, 45],
132
+ silver: [192, 192, 192],
133
+ skyblue: [135, 206, 235],
134
+ slateblue: [106, 90, 205],
135
+ slategray: [112, 128, 144],
136
+ slategrey: [112, 128, 144],
137
+ snow: [255, 250, 250],
138
+ springgreen: [0, 255, 127],
139
+ steelblue: [70, 130, 180],
140
+ tan: [210, 180, 140],
141
+ teal: [0, 128, 128],
142
+ thistle: [216, 191, 216],
143
+ tomato: [255, 99, 71],
144
+ turquoise: [64, 224, 208],
145
+ violet: [238, 130, 238],
146
+ wheat: [245, 222, 179],
147
+ white: [255, 255, 255],
148
+ whitesmoke: [245, 245, 245],
149
+ yellow: [255, 255, 0],
150
+ yellowgreen: [154, 205, 50]
151
+ }
152
+ end
@@ -0,0 +1,3 @@
1
+ module Colorname
2
+ VERSION = '0.1.0'.freeze
3
+ end
data/lib/colorname.rb ADDED
@@ -0,0 +1,9 @@
1
+ require 'color'
2
+ require 'colorname/version'
3
+ require 'colorname/base'
4
+ require 'colorname/find'
5
+ require 'colorname/list'
6
+
7
+ # Colorname Module
8
+ module Colorname
9
+ end
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: colorname
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - celilileri
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-05-05 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.14'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.14'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: color
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.8'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.8'
69
+ description:
70
+ email:
71
+ - celil.ileri@bil.omu.edu.tr
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - ".travis.yml"
79
+ - CODE_OF_CONDUCT.md
80
+ - Gemfile
81
+ - LICENSE.txt
82
+ - README.md
83
+ - Rakefile
84
+ - bin/console
85
+ - bin/setup
86
+ - colorname.gemspec
87
+ - lib/colorname.rb
88
+ - lib/colorname/base.rb
89
+ - lib/colorname/find.rb
90
+ - lib/colorname/list.rb
91
+ - lib/colorname/version.rb
92
+ homepage: https://github.com/celilileri/colorname
93
+ licenses:
94
+ - MIT
95
+ metadata: {}
96
+ post_install_message:
97
+ rdoc_options: []
98
+ require_paths:
99
+ - lib
100
+ required_ruby_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ required_rubygems_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ requirements: []
111
+ rubyforge_project:
112
+ rubygems_version: 2.6.8
113
+ signing_key:
114
+ specification_version: 4
115
+ summary: A Color Categorizator and Namer Ruby Gem Project
116
+ test_files: []