color_picker 0.0.3 → 0.0.5

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: dffd37982d997c26d03ee396de464fff385ac85b
4
- data.tar.gz: 18e40b3e3b4c34e5e83e1a53529b40c91e4ce099
3
+ metadata.gz: 3375f03aa1f80f6778494d1dd85994153d331e38
4
+ data.tar.gz: c26e50dfa7751458d7e3dbf1c90a17862d161b55
5
5
  SHA512:
6
- metadata.gz: 374bb9e5bd5adbb10c7467d82963befe9411c1aaa669dc26a42cca6bf22e415c9c4b65bfb2d8aca0cc2e57a235f064a9ed8de9954a4de148577afe085a79685b
7
- data.tar.gz: c07345d4b20acd6ec23382bd49a33394402533c955c0947d36503b04c93ee986d1f2887d23b21022bb35919af9bb485a136ece194ba6f384a68a6d3a271d51d3
6
+ metadata.gz: 977d7b86e719ff4abb12c9a68e5aaab72b9753964dfc346442c733178c86133215e81c7b3e342d0b8bc8bf017c62d5303910e76c28ccc5ed8a098181fff09d21
7
+ data.tar.gz: f83ff755d9fc0e1551cf788adc517924a9fd9433f230b518db4cf76bb16d9af8ed0df9501b7d04ad8b07e34e760556733ba1c23ef95fa601684241ee595c3563
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .rvmrc
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.0
data/CHANGELOG.md ADDED
@@ -0,0 +1,16 @@
1
+ # CHANGELOG
2
+
3
+ ### VERSION 0.0.1
4
+ * First Version
5
+
6
+ ### VERSION 0.0.2
7
+ * ruby required version since 1.9.3 up to the edge version
8
+
9
+ ### VERSION 0.0.3
10
+ * fixed gem dependency
11
+
12
+ ### VERSION 0.0.4
13
+ * add files to gem spec, rake dependecy and version file
14
+
15
+ ### VERSION 0.0.5
16
+ * fix gem dependencies and add travis to test every build
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+ gem "minitest", "~> 5.3.5"
3
+ gem "rake"
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Bernardo Galindo
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,4 @@
1
+ color_picker
2
+ ============
3
+
4
+ a tool to get a color based on color palette, also have a method to export to html all the color palette
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require 'rake/testtask'
2
+
3
+ Rake::TestTask.new do |t|
4
+ t.libs << 'test'
5
+ t.pattern = "test/**/*_test.rb"
6
+ end
7
+
8
+ task default: :test
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'color_picker/version'
5
+ Gem::Specification.new do |s|
6
+ s.name = "color_picker"
7
+ s.version = ColorPicker::VERSION
8
+ s.date = "2014-07-13"
9
+ s.summary = "A gem to genenerate a random color"
10
+ s.description = "a tool to get a color based on color palette, also have a method to export to html all the color palette"
11
+ s.authors = ["Bernardo Galindo"]
12
+ s.email = "bernardo466@gmail.com"
13
+ s.homepage = "http://github.com/bernardogalindo/color_picker"
14
+ s.license = "MIT"
15
+
16
+ s.files = `git ls-files -z`.split("\x0")
17
+ s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
19
+ s.require_paths = ['lib']
20
+ s.required_ruby_version = '>= 1.9.3'
21
+
22
+ s.add_development_dependency "minitest"
23
+ s.add_development_dependency "rake"
24
+ end
@@ -0,0 +1,30 @@
1
+ module ColorPicker
2
+ class Color
3
+ attr_accessor :palette
4
+ attr_reader :code
5
+
6
+ def initialize
7
+ @palette = Palette.new
8
+ @code = ""
9
+ generate
10
+ end
11
+
12
+ def code
13
+ @code ||= generate
14
+ end
15
+
16
+ def generate
17
+ @code = ""
18
+ @palette.range.each_with_index do |range, index|
19
+ @code += range.to_a[rand(range.size)].to_s(16)
20
+ end
21
+ @code
22
+ end
23
+
24
+ def palette_type(type)
25
+ palette.type = type
26
+ end
27
+
28
+
29
+ end
30
+ end
@@ -0,0 +1,60 @@
1
+ module ColorPicker
2
+ class Palette
3
+ attr_reader :range, :range_html
4
+ attr_accessor :blue_color_range, :green_color_range, :red_color_range
5
+ def initialize(palette_type="complete_palette")
6
+ @range, @blue_color_range, @green_color_range, @red_color_range = []
7
+ @range_html = ""
8
+ eval "#{palette_type}"
9
+ end
10
+
11
+ def type=(type)
12
+ eval "#{type}"
13
+ end
14
+
15
+ def complete_palette
16
+ @blue_color_range = 0 .. 255
17
+ @green_color_range = 0 .. 255
18
+ @red_color_range = 0 .. 255
19
+ generate_palette
20
+ end
21
+
22
+ def strong_colors
23
+ @green_color_range = 0 .. 9
24
+ @red_color_range = 0 .. 7
25
+ @blue_color_range = 0 .. 159
26
+ generate_palette
27
+ end
28
+
29
+ def to_html
30
+ @range_html = "<div style='width='600px'; height='auto'; float='left'; clear='both'>"
31
+
32
+ max_number = (@red_color_range.end+1) * (@green_color_range.end+1) * (@blue_color_range.end+1)
33
+
34
+ (0 .. max_number-1).each do |color_code|
35
+ color_container = "<div style='background= #{color_code.to_s(16)}; border= 1px solid #000;'>&nbps;</div><div style='float= left'>#{color_code.to_s(16)}</div>"
36
+ @range_html += color_container
37
+ end
38
+ @range_html += "</div>"
39
+ end
40
+
41
+ def method_missing(m, *args, &block)
42
+ puts "There's no color palette type #{m} here -- please select strong colors color palette"
43
+ end
44
+
45
+ private
46
+ def generate_palette
47
+ %w(red green blue).each do |color|
48
+ eval "#{color}_color_range= #{color}_color_range.to_s(16)" unless color.is_a?(String)
49
+ end
50
+ @range = [@red_color_range,@green_color_range,@blue_color_range]
51
+ end
52
+
53
+ def get_pair
54
+ (@blue_color_range.begin.to_i(16) ..@blue_color_range.end.to_i(16)).map do |n|
55
+ n.to_s(16)
56
+ end
57
+ end
58
+
59
+ end
60
+ end
@@ -0,0 +1,3 @@
1
+ module ColorPicker
2
+ VERSION = "0.0.5"
3
+ end
data/lib/color_picker.rb CHANGED
@@ -1,3 +1,3 @@
1
- require 'color_picker'
2
1
  require 'color_picker/color'
3
2
  require 'color_picker/palette'
3
+ require 'color_picker/version'
@@ -0,0 +1,31 @@
1
+ require "test_helper"
2
+ module ColorPicker
3
+ class ColorTest < Minitest::Test
4
+ def setup
5
+ @color = ColorPicker::Color.new
6
+ end
7
+
8
+ def test_generate
9
+ assert_match /[0..9]|[a-fA-F]{1,6}/, @color.generate
10
+ end
11
+
12
+ def test_code
13
+ pre_generate_code = @color.code
14
+ assert_equal pre_generate_code, @color.code
15
+ end
16
+
17
+ def test_complete_palette
18
+ @color.palette_type("complete_palette")
19
+ assert_equal [0..255, 0..255, 0..255], @color.palette.range
20
+ end
21
+
22
+ def test_strong_colors_palette
23
+ @color.palette_type("strong_colors")
24
+ assert_equal [0..7, 0..9, 0..159], @color.palette.range
25
+ end
26
+
27
+ def test_method_missing
28
+ assert_match "undefined_method", @color.palette_type("undefined_method")
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,16 @@
1
+ require "test_helper"
2
+ module ColorPicker
3
+ class PaletteTest < Minitest::Test
4
+ def setup
5
+ @palette = ColorPicker::Palette.new
6
+ end
7
+
8
+ def test_complete_palette
9
+ assert_equal [0..255, 0 .. 255, 0 .. 255], @palette.complete_palette
10
+ end
11
+
12
+ def test_strong_colors_palette
13
+ assert_equal [0..7, 0 .. 9, 0 .. 159], @palette.strong_colors
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,4 @@
1
+ require 'rake'
2
+ require 'color_picker'
3
+ require 'minitest/autorun'
4
+ require 'minitest/unit'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: color_picker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bernardo Galindo
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
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'
27
41
  description: a tool to get a color based on color palette, also have a method to export
28
42
  to html all the color palette
29
43
  email: bernardo466@gmail.com
@@ -31,7 +45,21 @@ executables: []
31
45
  extensions: []
32
46
  extra_rdoc_files: []
33
47
  files:
48
+ - ".gitignore"
49
+ - ".travis.yml"
50
+ - CHANGELOG.md
51
+ - Gemfile
52
+ - LICENSE.txt
53
+ - README.md
54
+ - Rakefile
55
+ - color_picker.gemspec
34
56
  - lib/color_picker.rb
57
+ - lib/color_picker/color.rb
58
+ - lib/color_picker/palette.rb
59
+ - lib/color_picker/version.rb
60
+ - test/color_test.rb
61
+ - test/palette_test.rb
62
+ - test/test_helper.rb
35
63
  homepage: http://github.com/bernardogalindo/color_picker
36
64
  licenses:
37
65
  - MIT
@@ -56,4 +84,7 @@ rubygems_version: 2.2.0.preview.1
56
84
  signing_key:
57
85
  specification_version: 4
58
86
  summary: A gem to genenerate a random color
59
- test_files: []
87
+ test_files:
88
+ - test/color_test.rb
89
+ - test/palette_test.rb
90
+ - test/test_helper.rb